-
Notifications
You must be signed in to change notification settings - Fork 88
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
Forbid code that would reformat poorly #389
Forbid code that would reformat poorly #389
Conversation
943e840
to
a95f1d1
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a readable and concise way to format the code, so we shouldn't prevent it:
Runnable r = () -> { throw new RuntimeException(); }
I'm not experiencing the issues with whitespace re-formatting that you mention, so I would suggest diagnosing that first.
a95f1d1
to
ebb63fe
Compare
I experience this in all recent Intellij versions. |
Look at the codestyle options and try to see which one is causing that? Maybe they introduced a new option that's defaulting to some other setting... |
FWIW, I'm running IntelliJ 2023.3.2 and I don't experience the problem there. |
i already tried that, but didn't find an option for this. |
Current checkstyle rules somehow allow things like void run() { throw new UnsupportedOperationException(); } Runnable r = () -> { throw new RuntimeException(); } Runnable asRunnable() { a_field++; } void update() { throw new RuntimeException(); } however, when such code is then auto-formatted by IntelliJ with Airbase codestyle, some whitespace is removed, resulting in a code that violates checkstyle rules. This state is undesired: sometimes a person working on a class file may need to undo auto-formatting so pass checkstyle checks. The new rules aim to reduce such situation by recognizing some common would-format-incorrectly patterns.
ebb63fe
to
3f85bb6
Compare
switching to 2023.3.2 and importing https://github.com/airlift/codestyle/blob/master/IntelliJIdea2019/Airlift.xml anew did not make intellij retain code as is upon auto-formatting Runnable r = () -> { throw new RuntimeException(); } is there any additional configuration i should set to make it work? |
Do you have Spaces->Within->Code Braces turned on? |
this indeed helps! |
Current checkstyle rules somehow allow things like
however, when such code is then auto-formatted by IntelliJ with Airbase codestyle, some whitespace is removed, resulting in a code that violates checkstyle rules. This state is undesired: sometimes a person working on a class file may need to undo auto-formatting so pass checkstyle checks.
The new rules aim to reduce such situation by recognizing some common would-format-incorrectly patterns.