jdneo / vscode-checkstyle

Checkstyle extension for VS Code
https://marketplace.visualstudio.com/items?itemName=shengchen.vscode-checkstyle
GNU Lesser General Public License v3.0
69 stars 16 forks source link

Auto formatting #358

Open jdneo opened 11 months ago

jdneo commented 11 months ago

Discussed in https://github.com/jdneo/vscode-checkstyle/discussions/357

Originally posted by **SSmale** December 4, 2023 I am looking for a way to get my VSCode setup to auto fix the check style issues (as best as it can) so that there can be a check on build and I can be confident that I will have met the standard, Is there a guide to do this?
Maze-fr commented 9 months ago

The only way I found is to use an Eclipse style / format configuration file, like this one : https://github.com/google/styleguide/blob/gh-pages/eclipse-java-google-style.xml

Or download Eclipse, make your configuration and export it.

MRDGH2821 commented 7 months ago

Would be great to have an option like this:

image

Maze-fr commented 7 months ago

The recent update of VSCode brought great things to the Java language support, but unfortunately, there is still no way to deal with formatting. It looks like it's not an important feature for Java.

The most bothering thing is that I didn't find the list of possible properties, neither the available values for those properties.

MRDGH2821 commented 7 months ago

The recent update of VSCode brought great things to the Java language support, but unfortunately, there is still no way to deal with formatting. It looks like it's not an important feature for Java.

The most bothering thing is that I didn't find the list of possible properties, neither the available values for those properties.

The closest thing I found for formatting Java files is this - https://marketplace.visualstudio.com/items?itemName=JoseVSeb.google-java-format-for-vs-code

If you are using a different set of rules, then you are probably out of luck.

And yes, there is indeed a lack of proper configuration provisions.

Maze-fr commented 7 months ago

Exactly... almost everything I found is "use Google Java format without any flexibility or leave it". The only one I found that allows to modify / set your own rules is the one I mentioned before.

Actually, there is also a plugin using JS prettier with rules for Java, but you need NodeJS installed, but if I do only Java, I don't want NodeJS around.