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

(WIP) Collapse if statements rule (#801) #814

Merged
merged 18 commits into from
Apr 5, 2021

Conversation

kgevorkyan
Copy link
Member

What's done:

  • Add rule description to the avaliable-rules, DiktatRuleSetProvider.kt and to the Warnings.kt
  • Detect nested if statements (level 2)
  • Add test for nested if statements

### What's done:
* Add rule description to the avaliable-rules, DiktatRuleSetProvider.kt and to the Warnings.kt
* Detect nested if statements (level 2)
* Add test for nested if statements
Copy link
Member

@orchestr7 orchestr7 left a comment

Choose a reason for hiding this comment

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

and extend tests please

@codecov
Copy link

codecov bot commented Mar 29, 2021

Codecov Report

Merging #814 (a9c2040) into master (9b75ec5) will decrease coverage by 0.03%.
The diff coverage is 79.76%.

Impacted file tree graph

@@             Coverage Diff              @@
##             master     #814      +/-   ##
============================================
- Coverage     80.95%   80.91%   -0.04%     
- Complexity     2248     2272      +24     
============================================
  Files            99      100       +1     
  Lines          5738     5801      +63     
  Branches       1783     1798      +15     
============================================
+ Hits           4645     4694      +49     
  Misses          286      286              
- Partials        807      821      +14     
Flag Coverage Δ Complexity Δ
unittests 80.91% <79.76%> (-0.04%) 0.00 <33.00> (ø)

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

Impacted Files Coverage Δ Complexity Δ
.../diktat/ruleset/rules/chapter1/IdentifierNaming.kt 81.52% <ø> (ø) 88.00 <0.00> (ø)
.../ruleset/rules/chapter3/StringConcatenationRule.kt 71.73% <ø> (ø) 53.00 <0.00> (ø)
...fn/diktat/ruleset/rules/chapter4/NullChecksRule.kt 75.00% <ø> (ø) 37.00 <0.00> (ø)
...qfn/diktat/ruleset/rules/chapter4/TypeAliasRule.kt 85.71% <ø> (ø) 11.00 <0.00> (ø)
...diktat/ruleset/rules/chapter6/AvoidUtilityClass.kt 77.27% <ø> (ø) 16.00 <0.00> (ø)
.../ruleset/rules/chapter2/kdoc/CommentsFormatting.kt 69.37% <62.50%> (-0.20%) 76.00 <4.00> (ø)
...ruleset/rules/chapter3/CollapseIfStatementsRule.kt 78.12% <78.12%> (ø) 24.00 <24.00> (?)
...tlin/org/cqfn/diktat/ruleset/constants/Chapters.kt 68.00% <100.00%> (+1.33%) 3.00 <1.00> (ø)
...tlin/org/cqfn/diktat/ruleset/constants/Warnings.kt 97.91% <100.00%> (+0.01%) 12.00 <0.00> (ø)
...cqfn/diktat/ruleset/rules/DiktatRuleSetProvider.kt 92.24% <100.00%> (+0.06%) 11.00 <0.00> (ø)
... and 3 more

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 9b75ec5...a9c2040. Read the comment docs.

### What's done:
* Change the way of the detection of nested if statements
* Provide logic for collapsing nested if statements, for now catched nested level is 2
* Add few tests
### What's done:
* Add configuration arg
* Upload WarningNames and diktat-analysis
* (WIP) Work on bug in collapsing of THEN parts
### What's done:
* Fix collapsing of THEN blocks
### What's done:
* Split functionality to several functions
* Fix the way of merging the nested conditions
* First support of nested if statements with nested level more than 2
@orchestr7 orchestr7 linked an issue Apr 1, 2021 that may be closed by this pull request
### What's done:
* Polish logic method
* Improve warn tests and add fix tests
* Add rule to guide
@kgevorkyan kgevorkyan force-pushed the feature/collapse_if_statements branch from c3eef47 to a1a3ac4 Compare April 1, 2021 12:45
### What's done:
* Add functionality of merging for compound conditions
* Add corresponding tests
### What's done:
* Add collapse if rule to other diktat-analysis files
### What's done:
* Add new check: don't collapse statements, if nested if have else node
* Separate collapse funtion to two ones
* Add more tests
@kgevorkyan kgevorkyan force-pushed the feature/collapse_if_statements branch from b8d80c8 to 355c426 Compare April 1, 2021 15:49
### What's done:
* Now nested if statements are collected in structure in aim to change ugly loops
* Appy review comments
@kgevorkyan kgevorkyan force-pushed the feature/collapse_if_statements branch from 489a09d to 758cc3e Compare April 2, 2021 13:35
### What's done:
* Fix incorrect behaviour, when parent IF have multiple IF child
* Add more tests for these cases
* Refactoring
@kgevorkyan kgevorkyan force-pushed the feature/collapse_if_statements branch from 395fa3e to e839c30 Compare April 2, 2021 15:26
### What's done:
* Improve logic of searching nested if, avoid npe
* Add tests
@kgevorkyan kgevorkyan force-pushed the feature/collapse_if_statements branch 4 times, most recently from ebd606c to 3a82929 Compare April 5, 2021 11:04
### What's done:
* Update existing files according new rule
@kgevorkyan kgevorkyan force-pushed the feature/collapse_if_statements branch from 3a82929 to ee917c1 Compare April 5, 2021 11:15
### What's done:
* Add new check in logic: we won't collapse statements, if parent  have else node
* Fix tests
@kgevorkyan kgevorkyan force-pushed the feature/collapse_if_statements branch from 59aa551 to fa81c09 Compare April 5, 2021 12:36
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

### What's done:
* Fix remarks according review
@kgevorkyan kgevorkyan marked this pull request as ready for review April 5, 2021 14:09
Copy link
Member

@orchestr7 orchestr7 left a comment

Choose a reason for hiding this comment

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

lgtm

@kgevorkyan kgevorkyan merged commit 199dd99 into master Apr 5, 2021
@kgevorkyan kgevorkyan deleted the feature/collapse_if_statements branch April 7, 2021 12:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Rule for collapsing IF-statements
3 participants