-
-
Notifications
You must be signed in to change notification settings - Fork 770
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
False-positive MagicNumber issue reported when using negative numbers #530
Comments
This is probably hitting a corner case in the companion object/constants detection... It should work (and negative numbers are covered by the logic). Will maybe take a look at some point if I have some spare time over the next few days. |
Just checked fast, but could not reproduce it. Not in a test case not by running the cli. given("false positive negative constant number") {
it("test") {
val code = """
package com.foo.bar
class Test {
companion object {
private const val FALSE_POSITIVE = -180
private const val THIS_IS_FINE = 180
}
}
"""
assertThat(MagicNumber().lint(code)).isEmpty()
}
} |
Feel free to reopen this if the issue still happening for you from a master build. |
sorry I've been AFK for a few days, will have a look again and reopen if the issue is still there, thanks! |
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related topics. |
It seems that detekt is reporting a false-positive
MagicNumber
issue when defining a negative number as a constant.Code to reproduce:
Running
./gradlew detektCheck
reports the following issue:Using the annotation as expected (without raising the issue):
Currently using version
1.0.0.RC4-3
but I also tried with the latest1.0.0.RC5-3
and got the same results.Relevant configuration:
I also tried adding extra options:
But it didn't make a difference
The text was updated successfully, but these errors were encountered: