How to import checkstyle rules into Intellij IDEA code format rules
While i was working on different open source projects, i was facing with one issue - every project would have their own code style rules. Most of them are described with codestyle.xml file. That's good, because you can run something like ./gradle clean check
and it will output you every code style issue you made. But it means that you have to run this check every time on every new change to ensure that code style is not broken. IDEA has a shortcut for formatting code and for me it was different from checkstyle.xml
rules. By default Intellij IDEA doesn't allow you to import checkstyle rules into code formatting settings. But, thanks to the latest version of Checkstyle plugin you can now do that. In order to do that you need to follow this steps :
- Install Checkstyle plugin
- Go to Settings|Editor|Code Style, choose a code style you want to import CheckStyle configuration to.
- Click Manage...|Import.., choose "CheckStyle Configuration" and select a corresponding CheckStyle configuration file. Click OK
At the end you will see a "CheckStyle configuration settings were imported to ... scheme"
message.