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

New cop that detects operations with constant results #11191

Closed
fatkodima opened this issue Nov 19, 2022 · 0 comments · Fixed by #13186
Closed

New cop that detects operations with constant results #11191

fatkodima opened this issue Nov 19, 2022 · 0 comments · Fixed by #13186

Comments

@fatkodima
Copy link
Contributor

fatkodima commented Nov 19, 2022

Inspired by https://hexdocs.pm/credo/Credo.Check.Warning.OperationWithConstantResult.html

It should check for the code like

x * 1
x * 0
x / 1
x ** 0
x ** 1
x % 1

This is almost always a mistake (or just left after debugging, probably) or just redundant code.

Zopolis4 added a commit to Zopolis4/rubocop that referenced this issue Jul 29, 2024
Makes progress on rubocop#11191.

Certain numeric operations have no impact, being:
Adding or subtracting 0, multiplying or dividing by 1 or raising to the power of 1.

These are probably mistakes or leftover from debugging, so flag and optionally remove them.
Zopolis4 added a commit to Zopolis4/rubocop that referenced this issue Jul 29, 2024
Makes progress on rubocop#11191.

Certain numeric operations have no impact, being:
Adding or subtracting 0, multiplying or dividing by 1 or raising to the power of 1.

These are probably mistakes or leftover from debugging, so flag and optionally remove them.
Zopolis4 added a commit to Zopolis4/rubocop that referenced this issue Aug 27, 2024
Makes progress on rubocop#11191.

Certain numeric operations have no impact, being:
Adding or subtracting 0, multiplying or dividing by 1 or raising to the power of 1.

These are probably mistakes or leftover from debugging, so flag and optionally remove them.
bbatsov pushed a commit that referenced this issue Aug 31, 2024
Makes progress on #11191.

Certain numeric operations have no impact, being:
Adding or subtracting 0, multiplying or dividing by 1 or raising to the power of 1.

These are probably mistakes or leftover from debugging, so flag and optionally remove them.
Zopolis4 added a commit to Zopolis4/rubocop that referenced this issue Sep 3, 2024
Zopolis4 added a commit to Zopolis4/rubocop that referenced this issue Sep 3, 2024
Zopolis4 added a commit to Zopolis4/rubocop that referenced this issue Sep 9, 2024
Zopolis4 added a commit to Zopolis4/rubocop that referenced this issue Sep 17, 2024
Zopolis4 added a commit to Zopolis4/rubocop that referenced this issue Nov 1, 2024
Zopolis4 added a commit to Zopolis4/rubocop that referenced this issue Nov 7, 2024
Zopolis4 added a commit to Zopolis4/rubocop that referenced this issue Nov 7, 2024
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 a pull request may close this issue.

1 participant