-
Notifications
You must be signed in to change notification settings - Fork 39
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
Unsigned integer literal is perhaps incorrectly marked as a MAGIC_NUMBER #1276
Conversation
### What's done: * fixed ignore number in MAGIC_NUMBER rule Closes #1224
### What's done: * fixed ignore number in MAGIC_NUMBER rule Closes #1224
### What's done: * fixed ignore number in MAGIC_NUMBER rule Closes #1224
### What's done: * fixed ignore number in MAGIC_NUMBER rule Closes #1224
### What's done: * fixed ignore number in MAGIC_NUMBER rule Closes #1224
@@ -108,7 +108,7 @@ class MagicNumberRule(configRules: List<RulesConfig>) : DiktatRule( | |||
companion object { | |||
const val IGNORE_TEST = true | |||
const val NAME_ID = "aca-magic-number" | |||
val ignoreNumbersList = listOf("-1", "1", "0", "2") | |||
val ignoreNumbersList = listOf("-1", "1", "0", "2", "0U", "1U", "2U", "-1L", "0L", "1L", "2L", "0UL", "1UL", "2UL") |
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.
hope that we really compare strings in the logic
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 had to change the logic a bit
### What's done: * fixed ignore number in MAGIC_NUMBER rule Closes #1224
Codecov Report
@@ Coverage Diff @@
## master #1276 +/- ##
============================================
- Coverage 82.40% 82.37% -0.03%
Complexity 2550 2550
============================================
Files 105 105
Lines 7205 7207 +2
Branches 2018 2020 +2
============================================
Hits 5937 5937
Misses 351 351
- Partials 917 919 +2
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
@@ -102,13 +102,20 @@ class MagicNumberRule(configRules: List<RulesConfig>) : DiktatRule( | |||
/** | |||
* Check if string is number | |||
*/ | |||
// || ((this.last().uppercase() == "L" || this.last().uppercase() == "U") && this.substring(0, this.lastIndex-1).isNumber()) |
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.
Probably we can finally improve our commented_out_code
rule, to ignore leading whitespaces and make trigger on such cases 😐
What's done:
Closes Unsigned integer literal is perhaps incorrectly marked as a MAGIC_NUMBER #1224