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

Fix issues with Elvis operator in UnconditionalJumpStatementInLoop #4150

Merged
merged 1 commit into from
Oct 4, 2021
Merged

Fix issues with Elvis operator in UnconditionalJumpStatementInLoop #4150

merged 1 commit into from
Oct 4, 2021

Conversation

MiSikora
Copy link
Contributor

@MiSikora MiSikora commented Oct 2, 2021

It was hard to determine which features I could break during development, so I split the tests into more granular ones.

I tried my best to cover the rule. Still, suppose anyone has ideas for adding more tests for false-positive or false-negative checks. In that case, I'll gladly add them as this rule is quite tricky, in my opinion: especially given nesting and such.

Closes #4134.

- Do not report break statements
- Do not report conditional assignments
- Don ot report conditional expressions
@MiSikora MiSikora changed the title Fix issues in UnconditionalJumpStatementInLoop Fix issues with Elvis operator in UnconditionalJumpStatementInLoop Oct 2, 2021
@codecov
Copy link

codecov bot commented Oct 2, 2021

Codecov Report

Merging #4150 (e5ec18e) into main (4e265df) will increase coverage by 0.00%.
The diff coverage is 83.33%.

Impacted file tree graph

@@            Coverage Diff            @@
##               main    #4150   +/-   ##
=========================================
  Coverage     83.45%   83.45%           
+ Complexity     3185     3181    -4     
=========================================
  Files           463      465    +2     
  Lines          9095     9104    +9     
  Branches       1768     1774    +6     
=========================================
+ Hits           7590     7598    +8     
- Misses          571      572    +1     
  Partials        934      934           
Impacted Files Coverage Δ
...ekt/rules/bugs/UnconditionalJumpStatementInLoop.kt 95.00% <83.33%> (+5.00%) ⬆️
.../arturbosch/detekt/rules/style/UseIsNullOrEmpty.kt 54.66% <0.00%> (-2.67%) ⬇️
...bosch/detekt/rules/complexity/LongParameterList.kt 83.33% <0.00%> (-1.12%) ⬇️
...otlin/io/gitlab/arturbosch/detekt/core/Analyzer.kt 80.95% <0.00%> (-0.30%) ⬇️
...ab/arturbosch/detekt/core/config/ValidateConfig.kt 100.00% <0.00%> (ø)
...tlab/arturbosch/detekt/rules/style/UseDataClass.kt 77.94% <0.00%> (ø)
...b/arturbosch/detekt/rules/naming/FunctionNaming.kt 100.00% <0.00%> (ø)
...tlab/arturbosch/detekt/rules/bugs/LateinitUsage.kt 90.00% <0.00%> (ø)
...sch/detekt/rules/style/UnnecessaryAbstractClass.kt 82.92% <0.00%> (ø)
...etekt/rules/style/FunctionOnlyReturningConstant.kt 94.87% <0.00%> (ø)
... and 4 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 4e265df...e5ec18e. Read the comment docs.

@chao2zhang chao2zhang added this to the 1.19.0 milestone Oct 3, 2021
Copy link
Member

@chao2zhang chao2zhang left a comment

Choose a reason for hiding this comment

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

Thank you for fixing two bugs (The originally reported one for isConditionalJumpStatement() and the additional one for isFollowedByElvisJump())!

Copy link
Member

@BraisGabin BraisGabin left a comment

Choose a reason for hiding this comment

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

👏👏👏 great refactor in the tests. It's way easier now. Great first contribution 👍.

@BraisGabin BraisGabin merged commit 0a36aa9 into detekt:main Oct 4, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

False positive: UnconditionalJumpStatementInLoop with Elvis operator
4 participants