How fix all check style issues with Intellij Idea?

前端 未结 2 1690
日久生厌
日久生厌 2021-02-13 10:30

I have an xml configuration file for maven checkstyle plugin. I have installed Intellij Idea plugin and see all checkstyle violation. Is there a way to fix most of them automati

相关标签:
2条回答
  • 2021-02-13 10:39

    There is an option now.

    checkstyle-IDEA since 4.24.0 features import of checkstyle config.

    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 on the gear, then 'import scheme', 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. Copied the answer from here

    Edit: Quote has been changed for clarity and to meet the current UI design.

    0 讨论(0)
  • 2021-02-13 10:48

    I have the same problem. As far as I know, the rules used for reformatting cannot be imported from Checkstyle config. You can configure your Checkstyle rules in the Idea's Code Style config (File -> Settings -> Code Style) and then reformat the code (Code -> Reformat Code [Ctrl+Alt+L]) according to the rules (you can apply it to the whole code base at once).

    0 讨论(0)
提交回复
热议问题