-
Notifications
You must be signed in to change notification settings - Fork 80
Setup CheckStyle to your IDE
If you use IntelliJ IDEA follow steps:
- Download Checkstyle plugin, version 8.22, for your IDE. Go to - Other Settings/Checkstyle. Click on add configuration File -> Browse -> and choose configuration file in root of project -
checkstyle.xml
-> OK. Also add a description for this Checkstyle file, e.g. "GreenCity".
Click to activate this Configuration File -> Apply.
-
Go to Editor -> Code Style -> Choose Scheme : Default-> Settings -> Restore Defaults -> Dublicate -> Set the name(e.g GreenCity) -> Settings -> Import Scheme -> CheckStyle Configuration -> and choose configuration file in root of project - checkstyle.xml -> OK -> Apply. If you did everything right you can use hotkeys as Ctrl + Alt + L - for Formatting code, and Ctrl + Alt + O - for Optimizing imports.
-
Set running checkstyle before building if for running project you use grafic interface of IDE(green RUN button on top of IDE)
Go to Edit Configurations... of running project -> GreenCityApplication -> Menu on bottom of settings("Before launch") -> Plus -> "Run Maven Goal" -> Comand line : checkstyle:check -> OK -> OK
Also if you just want to check the project you can use command: mvn checkstyle:check
IMPORTANT! Always before creating PR to dev check project with checkstyle by running project or executing command: mvn checkstyle:check
P.S If imports have wrong order after formatting, check in IDE Settings -> Editor -> Java -> Imports -> Import Layout, and check there order of imports, it should be like this:
- "import static all others imports",
- "blank line",
- "import all others imports"
If your comments symbols "//" plased at first column of line, and our checkstyle is not OK with that than go to: Settings -> Code Style -> Java -> Code Generation -> and remove mark at "Line comment at first column".