Skip to content

enable more potential-bugs rules for detekt code base #3997

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

Merged

Conversation

marschwar
Copy link
Contributor

This relates to #3993 and enables checks from the potential-bugs rule set

override fun shutdown() = Unit
override fun shutdown(): Unit = Unit
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fun fact:

override fun shutdown() = Unit // -> violates ImplicitUnitReturnType 

override fun shutdown(): Unit = Unit // -> violates OptionalUnit

override fun shutdown() {} // -> violates EmptyFunctionBlock

Copy link
Member

Choose a reason for hiding this comment

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

override fun shutdown() = Unit // -> violates ImplicitUnitReturnType 

This feels like a false positive, right?

It's not "Implicit".

Anyway I like this way to implement it:

override fun shutdown() {
  // no-op
}

Copy link
Member

Choose a reason for hiding this comment

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

I'd vote to revert this change (and the one in LicenceHeaderLoaderExtensionSpec.kt). Add them to our baseline and open an issue to fix the false-positive. Those changes doesn't improve the code so they should not be made just to make detekt happy.

Copy link
Member

Choose a reason for hiding this comment

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

Those changes doesn't improve the code so they should not be made just to make detekt happy.

Agree +1. I also prefer the //no-op approach but the status quo ( = Unit) should also be accepted.

Copy link
Contributor Author

@marschwar marschwar Aug 5, 2021

Choose a reason for hiding this comment

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

I added @Suppress to those 2 occurrences and raised #4004

Copy link
Member

Choose a reason for hiding this comment

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

Is it good to add the suppress? For false postives the suppress have the problem that generates debt because we will need to remove it. If we use the baseline instead we can just regenerate it in the next version.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Agreed and changed. Unfortunately gradlew detektBaselineTest will be run for each module and output the baseline to config/detekt/baseline-test.xml. So each module overwrites the baseline from the previous module making it a rather manual process to create a combined version.

@codecov
Copy link

codecov bot commented Aug 1, 2021

Codecov Report

Merging #3997 (2fbf34c) into main (3710da1) will decrease coverage by 0.01%.
The diff coverage is 0.00%.

Impacted file tree graph

@@             Coverage Diff              @@
##               main    #3997      +/-   ##
============================================
- Coverage     83.55%   83.53%   -0.02%     
  Complexity     3179     3179              
============================================
  Files           459      459              
  Lines          9085     9082       -3     
  Branches       1765     1772       +7     
============================================
- Hits           7591     7587       -4     
+ Misses          564      561       -3     
- Partials        930      934       +4     
Impacted Files Coverage Δ
...gitlab/arturbosch/detekt/generator/out/Markdown.kt 21.42% <0.00%> (ø)
.../io/gitlab/arturbosch/detekt/generator/out/Yaml.kt 68.57% <0.00%> (ø)
.../detekt/metrics/processors/ProjectSLOCProcessor.kt 92.30% <0.00%> (-7.70%) ⬇️
...o/gitlab/arturbosch/detekt/rules/KtModifierList.kt 84.61% <0.00%> (-7.06%) ⬇️
...itlab/arturbosch/detekt/rules/style/ReturnCount.kt 92.68% <0.00%> (-2.56%) ⬇️
...bosch/detekt/rules/complexity/LongParameterList.kt 87.75% <0.00%> (-2.05%) ⬇️
...rbosch/detekt/rules/complexity/TooManyFunctions.kt 97.40% <0.00%> (-1.32%) ⬇️
...gitlab/arturbosch/detekt/api/AnnotationExcluder.kt 66.66% <0.00%> (ø)
...b/arturbosch/detekt/core/reporting/OutputFacade.kt 84.21% <0.00%> (ø)
...turbosch/detekt/rules/style/UnusedPrivateMember.kt 91.36% <0.00%> (ø)
... and 5 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 3710da1...2fbf34c. Read the comment docs.

@marschwar marschwar added the housekeeping Marker for housekeeping tasks and refactorings label Aug 2, 2021
@BraisGabin BraisGabin merged commit d1d15fa into detekt:main Aug 7, 2021
@marschwar marschwar deleted the boyscout/enable-potental-bugs-rules branch August 7, 2021 12:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
housekeeping Marker for housekeeping tasks and refactorings
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants