Skip to content
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

Merged
merged 8 commits into from
Apr 28, 2022

Conversation

Cheshiriks
Copy link
Member

What's done:

### 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
### 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")
Copy link
Member

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

Copy link
Member Author

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
Copy link

codecov bot commented Apr 28, 2022

Codecov Report

Merging #1276 (5540d83) into master (d8c4cea) will decrease coverage by 0.02%.
The diff coverage is 25.00%.

@@             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     
Flag Coverage Δ
unittests 82.37% <25.00%> (-0.03%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
...qfn/diktat/ruleset/rules/chapter1/PackageNaming.kt 89.83% <ø> (ø)
...leset/rules/chapter2/comments/HeaderCommentRule.kt 88.00% <ø> (ø)
.../ruleset/rules/chapter2/kdoc/CommentsFormatting.kt 72.10% <ø> (ø)
...n/diktat/ruleset/rules/chapter3/MagicNumberRule.kt 79.24% <25.00%> (-3.11%) ⬇️

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 d8c4cea...5540d83. Read the comment docs.

@Cheshiriks Cheshiriks merged commit d575c3f into master Apr 28, 2022
@Cheshiriks Cheshiriks deleted the bugfix/magig-number-ignore branch April 28, 2022 14:57
@@ -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())
Copy link
Member

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 😐

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Unsigned integer literal is perhaps incorrectly marked as a MAGIC_NUMBER
4 participants