Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Recommendation 4.3.2 generic types explicit declaration #314

Merged

Conversation

aktsay6
Copy link
Collaborator

@aktsay6 aktsay6 commented Sep 22, 2020

Which rule and warnings did you add?

Recommendation 4.3.2 was added: Variables of generic types should have explicit type declaration. Closes #295

Actions checklist

  • Implemented Rule, added Warnings
  • Added tests on checks
  • Added tests on fixers
  • Updated diktat-analysis.yml
  • Updated available-rules.md

### What's done:
  * Added rule logic
  * Added warn tests
### What's done:
  * Added fix test
  * Remade logic of rule
@aktsay6 aktsay6 added the enhancement New feature or request label Sep 22, 2020
@codecov
Copy link

codecov bot commented Sep 22, 2020

Codecov Report

Merging #314 into master will decrease coverage by 0.01%.
The diff coverage is 78.94%.

Impacted file tree graph

@@             Coverage Diff              @@
##             master     #314      +/-   ##
============================================
- Coverage     81.78%   81.76%   -0.02%     
- Complexity     1075     1093      +18     
============================================
  Files            53       54       +1     
  Lines          2767     2786      +19     
  Branches        876      884       +8     
============================================
+ Hits           2263     2278      +15     
  Misses          183      183              
- Partials        321      325       +4     
Flag Coverage Δ Complexity Δ
#unittests 81.76% <78.94%> (-0.02%) 1093.00 <18.00> (+18.00) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ Complexity Δ
...at-rules/src/main/kotlin/generated/WarningNames.kt 0.00% <ø> (ø) 0.00 <0.00> (ø)
...uleset/rules/VariableGenericTypeDeclarationRule.kt 76.47% <76.47%> (ø) 18.00 <18.00> (?)
...tlin/org/cqfn/diktat/ruleset/constants/Warnings.kt 96.84% <100.00%> (+0.03%) 9.00 <0.00> (ø)
...cqfn/diktat/ruleset/rules/DiktatRuleSetProvider.kt 97.77% <100.00%> (+0.05%) 3.00 <0.00> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update f8c2c4f...8428852. Read the comment docs.

@aktsay6 aktsay6 requested review from petertrr and kentr0w September 25, 2020 07:55
…-explicit-declaration

# Conflicts:
#	diktat-analysis.yml
#	diktat-rules/src/main/kotlin/generated/WarningNames.kt
#	diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/constants/Warnings.kt
#	diktat-rules/src/main/resources/diktat-analysis-huawei.yml
#	diktat-rules/src/main/resources/diktat-analysis.yml
#	info/available-rules.md
@aktsay6 aktsay6 requested a review from petertrr September 28, 2020 13:11
Copy link
Member

@petertrr petertrr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[INFO] [ktlint] /home/runner/work/diKTat/diKTat/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/VariableGenericTypeDeclarationRule.kt:60:9: [GENERIC_VARIABLE_WRONG_DECLARATION] variable should have explicit type declaration: val sideRegex = Regex("<([a-zA-Z, <>?]*)>") (cannot be auto-corrected)
something went wrong here...

@aktsay6 aktsay6 marked this pull request as draft September 28, 2020 15:35
@aktsay6 aktsay6 marked this pull request as ready for review September 28, 2020 15:47
@aktsay6 aktsay6 requested a review from petertrr September 28, 2020 15:47
…eric-types-explicit-declaration' into feature/recommendation-4.3.2-generic-types-explicit-declaration
val callExpr = node.findChildByType(CALL_EXPRESSION)
?: node.findChildByType(DOT_QUALIFIED_EXPRESSION)?.getAllChildrenWithType(CALL_EXPRESSION)?.lastOrNull()

val rightSide = sideRegex.find(callExpr?.text ?: "")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe it will be more reliable to use something like (callExpr.psi as KtCallExpression).typeArgumentList? To explicitly retrieve type parameters and compare them instead of text.

…laration' of https://github.com/cqfn/diKTat into feature/recommendation-4.3.2-generic-types-explicit-declaration
Copy link
Member

@petertrr petertrr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Collaborator

@kentr0w kentr0w left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@aktsay6 aktsay6 merged commit 8738dd1 into master Sep 29, 2020
@aktsay6 aktsay6 deleted the feature/recommendation-4.3.2-generic-types-explicit-declaration branch September 29, 2020 12:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Recommendation 4.3.2: Variables of generic types should have explicit type declaration
3 participants