-
-
Notifications
You must be signed in to change notification settings - Fork 767
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 false positive of UnnecessaryInnerClass #4509
Conversation
Codecov Report
@@ Coverage Diff @@
## main #4509 +/- ##
=========================================
Coverage 84.14% 84.15%
+ Complexity 3315 3314 -1
=========================================
Files 476 476
Lines 10882 10875 -7
Branches 2015 2011 -4
=========================================
- Hits 9157 9152 -5
Misses 692 692
+ Partials 1033 1031 -2
Continue to review full report at Codecov.
|
…ass to be inner
@@ -233,6 +233,7 @@ style: | |||
active: true | |||
UnnecessaryInnerClass: | |||
active: true | |||
ignoreAnnotated: ['Nested'] |
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.
I like this, because I may not necessarily reference anything in the outer class but still will be able to use inner classes to structure tests.
val fizz = foo | ||
inner class C { | ||
fun printFoo() { | ||
println(foo) |
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.
Did you mean to write println(fizz)
here? At least that is what the test description suggests.
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.
That's a great catch.
Main branch is failing because
/home/runner/work/detekt/detekt/custom-checks/src/test/kotlin/io/github/detekt/custom/SpekTestDiscoverySpec.kt:16:5: Class 'VariableDeclarationsInSpekGroupsShouldOnlyBeSimple' does not require
innerkeyword. [UnnecessaryInnerClass]
is a false positive.@Nested
tests require the class to be inner. IDE prompts **Only non-static nested classes can serve as '@nested' test classes. **