-
Notifications
You must be signed in to change notification settings - Fork 39
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
Recommendation 4.3.2 generic types explicit declaration #314
Conversation
### What's done: * Added rule logic * Added warn tests
### What's done: * Added fix test * Remade logic of rule
…-explicit-declaration
### What's done: * Fixed bugs
Codecov Report
@@ 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
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
…-explicit-declaration
…-explicit-declaration
...at-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/VariableGenericTypeDeclarationRule.kt
Outdated
Show resolved
Hide resolved
...at-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/VariableGenericTypeDeclarationRule.kt
Outdated
Show resolved
Hide resolved
...at-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/VariableGenericTypeDeclarationRule.kt
Show resolved
Hide resolved
...at-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/VariableGenericTypeDeclarationRule.kt
Show resolved
Hide resolved
...at-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/VariableGenericTypeDeclarationRule.kt
Outdated
Show resolved
Hide resolved
### What's done: * Fixed bugs
### What's done: * Fixed bugs * Added fixme
…-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
### What's done: * Fixed bugs
### What's done: * Fixed bugs
diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/constants/Warnings.kt
Outdated
Show resolved
Hide resolved
...at-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/VariableGenericTypeDeclarationRule.kt
Outdated
Show resolved
Hide resolved
...c/test/kotlin/org/cqfn/diktat/ruleset/chapter4/VariableGenericTypeDeclarationRuleWarnTest.kt
Show resolved
Hide resolved
…-explicit-declaration
### What's done: * Fixed bugs
### What's done: * Fixed bugs
…-explicit-declaration
There was a problem hiding this 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...
...at-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/VariableGenericTypeDeclarationRule.kt
Outdated
Show resolved
Hide resolved
### What's done: * Fixed bugs
### What's done: * Fixed bugs
…-explicit-declaration
### What's done: * Fixed bugs
…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 ?: "") |
There was a problem hiding this comment.
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
### What's done: * Logic remade
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
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