IntelliJ IDEA code format from checkstyle configuration

I've decided to contribute to android maven plugin.

They use quite specific code style format. It will take some time for me to modify IDEA code format rules to satisfy their requirements.

Fortunately there is checkstyle configuration. I've already installed check-style plugin for IDEA and immediately see where my current formatting is wrong.

Unfortunately I didn't find way to import checkstyle configuration into IDEA formatting rules.

I'm interested if it's possible.


UPDATE : supported since 4.24.0 plug-in version, see here for details.


Original answer from 2013:

Not possible yet, please star/vote to track the progress of the issue.


finally there is something:

checkstyle-IDEA since 4.24.0 features import of checkstyle config.

A solution is available now:

  • Please install CheckStyle-IDEA plugin (http://plugins.jetbrains.com/plugin/1065?pr=idea), it can be found via plug-in repository (Settings|Plugins|Browse repositories).

  • 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 message "CheckStyle configuration settings were imported to ... scheme".

    If you encounter any problems, you can create a new issue for the CheckStyle plug-in here: https://github.com/jshiell/checkstyle-idea/issues. This issue is actually a duplicate of https://github.com/jshiell/checkstyle-idea/issues/126.

    CheckStyle plug-in version where the feature is available is 4.24.0

    Copied from https://youtrack.jetbrains.com/issue/IDEA-61520#comment=27-1292600


    There is an ugly workaround that I have been able to live with:

    First import the Checkstyle format into Eclipse, as explained here: How to generate an Eclipse formatter configuration from a checkstyle configuration?

    Then export the format from Eclipse (via Windows --> Preferences --> Java --> Code Style --> Formatter -> Edit -> Export and import the resulting *.xml file into IntelliJ IDEA

    Of course this is kinda bonkers especially if you do not have someone around who has Eclipse running anyway, as you have to install it just to be able to "translate" the checkstyle format into something IntelliJ can read; but if it only has to be done once per project it might be somewhat better than manually adjust the format.

    链接地址: http://www.djcxy.com/p/96202.html

    上一篇: 如何看到Intellij Idea中的maven check style插件报告?

    下一篇: 来自checkstyle配置的IntelliJ IDEA代码格式