You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Lately I've been working on cleaning up a lot of old code in RuboCop, and one of the most common patterns that has appeared is overly abstruse conditionals, which contain all the low level details and often mix several conditionals and concepts into a single expression.
These conditionals are usually completely unintelligible, even if you can wrap your head around the order of operations and identify the implicit grouping.
Refactoring these is simple, but not easy. Simple because the solution is just to extract one or more explaining variables, methods, or classes. Hard because reverse engineering the conditional requires substantial work.
It would be nice to have automatic linting for these kinds of conditions.
I'm open to collaborating on defining the rules governing such a linter, but it might not be as straightforward as setting a complexity threshold, as relatively simple conditions can often also benefit from having their concepts named.
The text was updated successfully, but these errors were encountered:
Hello! 🙂
Lately I've been working on cleaning up a lot of old code in RuboCop, and one of the most common patterns that has appeared is overly abstruse conditionals, which contain all the low level details and often mix several conditionals and concepts into a single expression.
Example:
These conditionals are usually completely unintelligible, even if you can wrap your head around the order of operations and identify the implicit grouping.
Refactoring these is simple, but not easy. Simple because the solution is just to extract one or more explaining variables, methods, or classes. Hard because reverse engineering the conditional requires substantial work.
It would be nice to have automatic linting for these kinds of conditions.
I'm open to collaborating on defining the rules governing such a linter, but it might not be as straightforward as setting a complexity threshold, as relatively simple conditions can often also benefit from having their concepts named.
The text was updated successfully, but these errors were encountered: