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
Feature request: Remove unnecessary parenthesis #105
Comments
Hi Jan, from "thumbs up" response, definitely our most popular proposal so far! :-) I completely agree with your example, but I wonder whether in other cases, parentheses might actually be intended to improve readability, e.g. by grouping subexpressions that semantically belong together … IF lv_is_valid = abap_true AND ( lv_year = 2023 AND lv_month < 10 ).
ENDIF. … or because not everyone may be so familiar with operator precedence rules: IF ( lv_year = 2022 AND lv_month > 8 ) OR ( lv_year = 2023 AND lv_month < 10 ).
ENDIF. But that could of course be solved with options, e.g. "Remove parentheses around subexpressions…":
Kind regards, |
Good thinking. I think I'd choose "Never" for the option "Remove parentheses around subexpressions". I'd only be interested in removing the parentheses if the entire condition is wrapped in parentheses. |
Please don't remove those, I cannot for the life of me remember the precedence rules especially if the condition is broken up into multiple lines.... I tend to just always add the brackets if AND and OR are combined, necessary or not. |
I think in that case you could simply not enable this rule or select the "Never" option. |
… so you could say, as long as you well-structured logical expression appears in OrANGe 🍊 order… CHECK a = b
AND NOT c GE d
OR a = c
AND NOT c GE b. you're fine without any parentheses :-) |
Thanks for the programming lesson @jmgrassau , shouldn't be too difficult to remember, coincidentally orange is part of the name of my current employer... 🍊 |
Hi Jan, thanks again for opening this issue! The new cleanup rule "Remove needless parentheses" is now available in version 1.11.0 which was just released! Kind regards, |
Hello,
Would it be possible to create a rule, that removes unnecessary parenthesis as described in the abaplint rule: https://rules.abaplint.org/many_parentheses/
Example:
Expected:
The text was updated successfully, but these errors were encountered: