Skip to content

Commit

Permalink
[Fix rubocop#13557] Mark Lint/NumericOperationWithConstantResult as…
Browse files Browse the repository at this point in the history
… unsafe
  • Loading branch information
Earlopain committed Dec 12, 2024
1 parent 4618790 commit c186264
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 0 deletions.
1 change: 1 addition & 0 deletions changelog/change_mark_numeric_result_constant_unsafe.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* [#13557](https://github.com/rubocop/rubocop/issues/13557): Mark `Lint/NumericOperationWithConstantResult` as unsafe. ([@earlopain][])
2 changes: 2 additions & 0 deletions config/default.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2155,7 +2155,9 @@ Lint/NumberedParameterAssignment:
Lint/NumericOperationWithConstantResult:
Description: 'Checks for numeric operations with constant results.'
Enabled: pending
Safe: false
VersionAdded: '1.69'
VersionChanged: <<next>>

Lint/OrAssignmentToConstant:
Description: 'Checks unintended or-assignment to constant.'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,12 @@ module Lint
# Other numeric operations that are similarly leftover from debugging or mistakes
# are handled by Lint/UselessNumericOperation.
#
# @safety
# This cop is unsafe in cases like `x -= x` where `x` is an Array. `x` would be
# `[]` after the operation (not `0`) but the cop can't distinquish such cases.
# Additionally, for `x % 1` when `x` is a String, it is a format call and doesn't
# result in a numerical result.
#
# @example
#
# # bad
Expand Down

0 comments on commit c186264

Please sign in to comment.