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

Rule 4.1.3 Try to use 'val' instead of 'var' for variable declaration #328

Merged
merged 10 commits into from
Sep 30, 2020

Conversation

orchestr7
Copy link
Member

Adding simple rule that prohibits usage of var

What's done:

  1. Adding rule and variable detection utility

### What's done:
### What's done:
1) Adding template for visitor of No val rule
2) Creating utilities for getting variable and usages
### What's done:
1) Scope logic that missing for class
### What's done:
1) Finished variables searching mechanism with 3 FixMe
2) Tests, some are correctly failing, that's why disables
### What's done:
1) Added SAY_NO_TO_VAR rule that prohibits usage of 'var' local properties (the only exception are accumulators)
2) Tests added
### What's done:
1) Adding rule to docs
@orchestr7 orchestr7 requested a review from petertrr September 28, 2020 00:42
@orchestr7 orchestr7 linked an issue Sep 28, 2020 that may be closed by this pull request
@orchestr7 orchestr7 added the enhancement New feature or request label Sep 28, 2020
### What's done:
1) Review notes
…no-val

# Conflicts:
#	build.gradle.kts
#	diktat-analysis.yml
#	diktat-rules/src/main/kotlin/generated/WarningNames.kt
#	diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/constants/Warnings.kt
#	info/available-rules.md
@codecov
Copy link

codecov bot commented Sep 30, 2020

Codecov Report

Merging #328 into master will increase coverage by 0.00%.
The diff coverage is 79.31%.

Impacted file tree graph

@@            Coverage Diff            @@
##             master     #328   +/-   ##
=========================================
  Coverage     82.82%   82.82%           
- Complexity     1127     1132    +5     
=========================================
  Files            54       56    +2     
  Lines          2800     2836   +36     
  Branches        893      908   +15     
=========================================
+ Hits           2319     2349   +30     
  Misses          162      162           
- Partials        319      325    +6     
Flag Coverage Δ Complexity Δ
#unittests 82.82% <79.31%> (+<0.01%) 1132.00 <5.00> (+5.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> (ø)
...n/kotlin/org/cqfn/diktat/ruleset/utils/PsiUtils.kt 41.93% <50.00%> (-12.24%) 0.00 <0.00> (ø)
...tlin/org/cqfn/diktat/ruleset/utils/AstNodeUtils.kt 82.65% <60.00%> (-0.60%) 0.00 <0.00> (ø)
...qfn/diktat/ruleset/utils/VariableSearchASTUtils.kt 81.25% <81.25%> (ø) 0.00 <0.00> (?)
...cqfn/diktat/ruleset/rules/ImmutableValNoVarRule.kt 85.71% <85.71%> (ø) 5.00 <5.00> (?)
...tlin/org/cqfn/diktat/ruleset/constants/Warnings.kt 96.87% <100.00%> (+0.03%) 9.00 <0.00> (ø)
...cqfn/diktat/ruleset/rules/DiktatRuleSetProvider.kt 97.82% <100.00%> (+0.04%) 3.00 <0.00> (ø)
...at/ruleset/rules/identifiers/LocalVariablesRule.kt 92.06% <100.00%> (ø) 32.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 7030f70...e0be996. Read the comment docs.

@orchestr7 orchestr7 merged commit 3a38311 into master Sep 30, 2020
@petertrr petertrr deleted the feature/no-val branch October 1, 2020 11:03
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.

Rule 4.1.3 Try to use 'val' instead of 'var' for variable declaration
2 participants