Skip to content

Allow else when {...} in MandatoryBracesIfStatements rule#3905

Merged
schalkms merged 2 commits into
detekt:mainfrom
schalkms:#3708-fix_MandatoryBracesIfStatements
Jun 25, 2021
Merged

Allow else when {...} in MandatoryBracesIfStatements rule#3905
schalkms merged 2 commits into
detekt:mainfrom
schalkms:#3708-fix_MandatoryBracesIfStatements

Conversation

@schalkms

Copy link
Copy Markdown
Member

This allows multi-line when statements following an else without requiring braces.

Fixes #3708

This allows multi-line when statements following an else without requiring braces.

Fixes #3708
@schalkms schalkms added this to the 1.18.0 milestone Jun 25, 2021
@codecov

codecov Bot commented Jun 25, 2021

Copy link
Copy Markdown

Codecov Report

Merging #3905 (9bec25a) into main (66f20e7) will decrease coverage by 0.01%.
The diff coverage is 100.00%.

Impacted file tree graph

@@             Coverage Diff              @@
##               main    #3905      +/-   ##
============================================
- Coverage     83.55%   83.53%   -0.02%     
- Complexity     3118     3120       +2     
============================================
  Files           456      456              
  Lines          8973     8996      +23     
  Branches       1746     1753       +7     
============================================
+ Hits           7497     7515      +18     
- Misses          564      565       +1     
- Partials        912      916       +4     
Impacted Files Coverage Δ
...ules/style/optional/MandatoryBracesIfStatements.kt 68.75% <100.00%> (+2.08%) ⬆️
...ls/src/main/kotlin/io/github/detekt/psi/KtFiles.kt 73.52% <0.00%> (-4.25%) ⬇️
...rturbosch/detekt/rules/style/UnusedPrivateClass.kt 73.33% <0.00%> (+3.33%) ⬆️

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 66f20e7...9bec25a. Read the comment docs.

@@ -56,5 +57,6 @@ class MandatoryBracesIfStatements(config: Config = Config.empty) : Rule(config)
private fun KtIfExpression.isNotBlockOrIfExpression(): Boolean =

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The names of both extension functions seem wrong to me. The change has not exactly made it any better ;)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Thanks! Those names should really be improved.
I'll change it in a separate PR.

@schalkms schalkms merged commit 54a42d5 into detekt:main Jun 25, 2021
@schalkms schalkms deleted the #3708-fix_MandatoryBracesIfStatements branch June 25, 2021 19:59
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.

Allow multi-line when statement following an else without requiring braces

3 participants