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 rule: Operation on Same Values #287

Open
elbrujohalcon opened this issue Mar 1, 2023 · 0 comments
Open

New rule: Operation on Same Values #287

elbrujohalcon opened this issue Mar 1, 2023 · 0 comments
Labels
Milestone

Comments

@elbrujohalcon
Copy link
Member

Operation on Same Values

Brief Description

The idea is to emit a warning in situations where an infix operation is applied to the same value on both sides of it, like the ones below...

X = X
X == X
{A, B, C} /= {A, B, C}
A -- A

Should be on by default?

YES

Options

  • operations :: [atom()] (default: ['=', '==', '/=', '=:=', '=/=', 'and', 'andalso', 'or', 'orelse', …])

For the default, you need to find all Erlang infix operators and figure out which ones make sense in this context and which ones doesn't. For instance, the result of X -- X is obvious ([]), but the result of X ++ X is not.

Reasoning

Paraphrasing Credo documentation:

In practice they are likely the result of a debugging session or were made by mistake.

Origin (#281)

Inspired by the Warning.OperationOnSameValues rule from Credo.
Also inspired by the Warning.BoolOperationOnSameValues rule from Credo.

@elbrujohalcon elbrujohalcon added this to the 3.0.0 milestone Mar 1, 2023
@paulo-ferraz-oliveira paulo-ferraz-oliveira changed the title Operation on Same Values New rule: Operation on Same Values Mar 1, 2023
@elbrujohalcon elbrujohalcon modified the milestones: 3.0.0, 3.1.0 Mar 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant