-
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
(WIP) Collapse if statements rule (#801) #814
Conversation
### 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
diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter3/CollapseIfStatementsRule.kt
Outdated
Show resolved
Hide resolved
diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter3/CollapseIfStatementsRule.kt
Outdated
Show resolved
Hide resolved
diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/constants/Warnings.kt
Show resolved
Hide resolved
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.
and extend tests please
Codecov Report
@@ 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
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter3/CollapseIfStatementsRule.kt
Show resolved
Hide resolved
### 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
### What's done: * Polish logic method * Improve warn tests and add fix tests * Add rule to guide
c3eef47
to
a1a3ac4
Compare
### 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
b8d80c8
to
355c426
Compare
diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter3/CollapseIfStatementsRule.kt
Outdated
Show resolved
Hide resolved
diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter3/CollapseIfStatementsRule.kt
Outdated
Show resolved
Hide resolved
diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter3/CollapseIfStatementsRule.kt
Outdated
Show resolved
Hide resolved
diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter3/CollapseIfStatementsRule.kt
Outdated
Show resolved
Hide resolved
### What's done: * Now nested if statements are collected in structure in aim to change ugly loops * Appy review comments
489a09d
to
758cc3e
Compare
diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter3/CollapseIfStatementsRule.kt
Outdated
Show resolved
Hide resolved
...t-rules/src/test/kotlin/org/cqfn/diktat/ruleset/chapter3/CollapseIfStatementsRuleWarnTest.kt
Outdated
Show resolved
Hide resolved
diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter3/CollapseIfStatementsRule.kt
Show resolved
Hide resolved
### What's done: * Fix incorrect behaviour, when parent IF have multiple IF child * Add more tests for these cases * Refactoring
395fa3e
to
e839c30
Compare
diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter3/CollapseIfStatementsRule.kt
Outdated
Show resolved
Hide resolved
diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter3/CollapseIfStatementsRule.kt
Show resolved
Hide resolved
### What's done: * Improve logic of searching nested if, avoid npe * Add tests
ebd606c
to
3a82929
Compare
### What's done: * Update existing files according new rule
3a82929
to
ee917c1
Compare
### What's done: * Add new check in logic: we won't collapse statements, if parent have else node * Fix tests
59aa551
to
fa81c09
Compare
diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter1/IdentifierNaming.kt
Show resolved
Hide resolved
diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter3/CollapseIfStatementsRule.kt
Outdated
Show resolved
Hide resolved
diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter4/NullChecksRule.kt
Show resolved
Hide resolved
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
### What's done: * Fix remarks according review
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
What's done: