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
Do not complain about -1 overusage #2364
Conversation
Negative constants are already handled by "Found magic number".
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.
Thank you!
@@ -101,13 +101,9 @@ def is_unary_minus(node: ast.AST) -> bool: | |||
|
|||
We use this predicate to allow values | |||
like ``-some_value`` to be overused. | |||
|
|||
Although negative constants like ``-1`` |
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.
-1
is fine. But, things like -5
and -37
should be reported.
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.
But they are already reported by "Found magic number" – should they be really reported again here?
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.
Yes, complexity rules are different from "Found magic number"
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 am looking at this:
MAGIC_NUMBERS_WHITELIST: Final = frozenset(( |
Should all negatives of those be excluded or only -1?
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.
@sobolevn what do you think?
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.
Only -1
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.
@sobolevn done :)
Codecov Report
@@ Coverage Diff @@
## master #2364 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 120 120
Lines 6394 6392 -2
Branches 1442 1441 -1
=========================================
- Hits 6394 6392 -2
Continue to review full report at Codecov.
|
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.
Thank you! Please, add a test case for this.
Negative constants are already handled by "Found magic number".
Checklist
CHANGELOG.md
Related issues
Closes #2362