finally there is something:

checkstyle-IDEA since 4.24.0 features import of checkstyle config.

A solution is available now:

  1. 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).

  2. Go to Settings|Editor|Code Style|Java, choose a code style you want to import CheckStyle configuration to.

  3. While still in the Editor > Code Style > Java setting, click on the 🛞 wheel icon, choose "Import Scheme > Checkstyle Configuration*",* and select a corresponding checkstyle.xml 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

Answer from helt on Stack Overflow
🌐
JetBrains
youtrack.jetbrains.com › issue › IDEA-280417 › Intellij-using-checkstyle-xml-file-as-code-style-formatter
Intellij - using checkstyle .xml file as code style formatter
Our website uses some cookies and records your IP address for the purposes of accessibility, security, and managing your access to the telecommunication network. You can disable data collection and cookies by changing your browser settings, but it may affect how this website functions.
Discussions

Codestyle and formatters
Spotless? It can use the eclipse formatter which is pretty configurable, or the Google formatter, or others. More on reddit.com
🌐 r/java
27
18
October 21, 2024
Checkstyle is the worst tool ever. Would you agree?
You really want a formatting war being fought in each of your commits? Your ide doing one thing, the next person's reverts it, your ide does it again, etc.etc. Agree on a code style. Automate it. Adhere to it religiously (in your company/team). More on reddit.com
🌐 r/java
97
0
January 21, 2024
Add support for default IntelliJ IDEA formatting
In particular, I have to change java import order performed by IDEA by default to overcome Checkstyle's error Wrong order for . See the issue #525 closed without addressing. More on github.com
🌐 github.com
3
November 11, 2021
Use IntelliJ code style in Checkstyle - Stack Overflow
Those exported settings are in ... to CheckStyle. Finally, note that there is an open request for Intellij to do exactly what you want. See IDEA-149529: Current export functionality for Code Styles is lacking. Only useful for other users of IntelliJ or as a backup. Only exports the diff between user defined settings and the built-in default. This makes it very difficult to produce a matching style for other formatting/beautification ... More on stackoverflow.com
🌐 stackoverflow.com
April 1, 2020
🌐
Andrew Zakordonets
biercoff.com › how-to-import-checkstyle-rules-into-intellij-idea-code-format-rules
How to import checkstyle rules into Intellij IDEA code format rules
May 7, 2017 - 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.
🌐
Checkstyle
checkstyle.sourceforge.io › idea.html
Importing and debugging in IntelliJ IDE – checkstyle
2 weeks ago - To change formatter settings please go to File->Settings in menu. Then in the tree go to: Editor->Code Style->Java, open Import tab (follow numbers on a picture) and apply settings highlighted: Checkstyle has its own very strict set of inspections. To import and enable them go to Settings -> ...
🌐
Reddit
reddit.com › r/java › codestyle and formatters
r/java on Reddit: Codestyle and formatters
October 21, 2024 -

Hi y'all,

My team would like to standardise code formatting and enforce it in CI. We've tried google-java-formatter but it doesn't look nearly as good as inteliJ's default settings.

Ideally, we'd like to export inteliJs defaults (to have the benefits of built in formatter) and use something that would enforce it on CI build. Has anyone done it? What are your pipelines like? Any tips and tricks?

🌐
JetBrains
youtrack.jetbrains.com › issue › IDEA-61520 › Codestyle-from-Checkstyle
Codestyle from Checkstyle : IDEA-61520 - YouTrack - JetBrains
May 12, 2023 - Our website uses some cookies and records your IP address for the purposes of accessibility, security, and managing your access to the telecommunication network. You can disable data collection and cookies by changing your browser settings, but it may affect how this website functions.
🌐
Apache
doris.apache.org › java code formatting specification
Java Code Formatting Specification - Apache Doris
Complete the configuration by following the instructions and animations in the Java Linting official documentation. The auto-formatting feature of IDEA is recommended: Go to Preferences -> Editor -> Code Style -> Java. Click the configuration icon's Import Scheme and select IntelliJ ...
🌐
JetBrains
jetbrains.com › help › idea › reformat-and-rearrange-code.html
Reformat code | IntelliJ IDEA Documentation
1 month ago - Clear the checkboxes for the formatting that you want the IDE to apply according to the current code style. Reformat your code (Ctrl+Alt+L). IntelliJ IDEA will reformat your code in accordance with the current style settings, keeping existing formatting for the rules which you've selected.
Find elsewhere
🌐
GitHub
github.com › spring-io › spring-javaformat
GitHub - spring-io/spring-javaformat · GitHub
You can download the latest version from Maven Central. The plugin is automatically enabled when one or more of the following conditions match: ... The CheckStyle-IDEA plugin provides Checkstyle integration for IntelliJ IDEA.
Author: spring-io
🌐
Jabref
devdocs.jabref.org › getting-into-the-code › guidelines-for-setting-up-a-local-workspace › intellij-13-code-style.html
Step 3: Set up JabRef’s code style | Developer Documentation
Contributions to JabRef’s source code need to have a code formatting that is consistent with existing source code. For that purpose, JabRef provides code-style and check-style definitions. Install the CheckStyle-IDEA plugin, it can be found via the plug-in repository: Navigate to File > Settings… > Plugins”. On the top, click on “Marketplace”. Then, search for “Checkstyle”. Click on “Install” choose “CheckStyle-IDEA”. Note: In some MacBooks, Settings can be found at the “IntelliJ” button of the app menu instead of at “File”.
🌐
JetBrains
intellij-support.jetbrains.com › hc › en-us › community › posts › 206938295-Codestyle-from-Checkstyle
Codestyle from Checkstyle – IDEs Support (IntelliJ Platform) | JetBrains
November 19, 2010 - It takes quite a while (and is error-prone) to manually re-generate am IDEA Codestyle from a Checkstyle.xml definition. Thus, I would like this autogeneration feature. Fair? DS. // Best regards, // Lennart Jörelid ... Hello Lennart, There is no such feature in IntelliJ IDEA at the moment.
🌐
Checkstyle
checkstyle.org
Checkstyle 13.11.0 – checkstyle
Checkstyle analyzes Java source code against configurable rules for naming, imports, formatting, Javadoc, class design, and more.
🌐
Medium
datamify.medium.com › java-checkstyle-how-to-format-your-java-code-with-checkstyle-929565ce39a3
Java CheckStyle. How To Format Your Java Code With CheckStyle | by Oleksii Dushenin | Medium
July 24, 2021 - To begin with, we should install the Intellij IDEA plugin for checkstyle. It is done in settings. It is called CheckStyle-IDEA.
🌐
JetBrains
jetbrains.com › help › idea › configuring-code-style.html
Code style schemes | IntelliJ IDEA Documentation
1 month ago - Learn how to configure XML code style schemes, import code style schemes, and apply code standards from other languages.
🌐
Reddit
reddit.com › r/java › checkstyle is the worst tool ever. would you agree?
r/java on Reddit: Checkstyle is the worst tool ever. Would you agree?
January 21, 2024 -

I really do not understand the need for checkstyle. Imagine your build fails because you have an extra white space that you can't even see through naked eye. Java allows mulitple blank lines and as much white space as you want for a reason to have flexibility. I know it is possible for somoene to add accidently add 100s of blank new line but that is something no developer would ever do intentionally

🌐
GitHub
github.com › checkstyle › checkstyle › issues › 10941
Add support for default IntelliJ IDEA formatting · Issue #10941 · checkstyle/checkstyle
November 11, 2021 - In particular, I have to change java import order performed by IDEA by default to overcome Checkstyle's error Wrong order for . See the issue #525 closed without addressing.
Author: checkstyle
Top answer
1 of 2
13

Unfortunately it is not possible to do what you want for (at least) three reasons, the first two of which you have already raised:

  1. While is possible to export a code style file from Intellij IDEA using File->Settings->Code Style->Java->{Click the Settings icon}->Select Export... from the popup menu, that exported XML file only contains the changes you have made from the default settings.

  2. Those exported settings are in a format that is only meaningful to Intellij, so even if you could export every single Java code style setting to an XML file, you would then have to massively edit that file to make it meaningful to CheckStyle.

  3. Finally, note that there is an open request for Intellij to do exactly what you want. See IDEA-149529:

Current export functionality for Code Styles is lacking. Only useful for other users of IntelliJ or as a backup. Only exports the diff between user defined settings and the built-in default. This makes it very difficult to produce a matching style for other formatting/beautification tools.

It would be helpful if the export had the option of exports ALL the settings IDEA uses.

However, there is an alternative approach. Instead of providing an Intellij IDEA file to Checkstyle, provide a Checkstyle file to Intellij IDEA...

  1. Install the Checkstyle plugin, and then open two sets of one or more duplicated files in Intellij IDEA, one set configured to use IDEA's formatting and one set configured to Checkstyle's formatting.

  2. Repeatedly tweak the Checkstyle settings until its opened file(s) are formatted to conform to the corresponding files formatted by IDEA. When the sets of files match create a Checkstyle XML rules file. Tedious, but only a one time activity.

  3. Finally, you can then import your customized CheckStyle XML rules file into Intellij Idea, using Import Scheme -> CheckStyle Configuration as as shown in the screen shot below (if, and only if, you have installed the CheckStyle-IDEA plugin). This functionality did not exist when the OP was created. For more details see the following bug report: IDEA-61520 Codestyle from Checkstyle and in particular the response from JetBrains dated 2/8/16.

See also:

  • Intellij IDEA bug Configure code style from checkstyle #126

  • SO post IntelliJ IDEA code format from checkstyle configuration

2 of 2
0

I was looking for an answer to this too. I suppose you want to add it to your build process like I do. Since I saw no value in enforcing something that can't be automated, I settled on (haven't implemented yet) executing the style formatter as a pre-commit hook (I use git) https://www.jetbrains.com/help/idea/command-line-formatter.html against all files in the changelist. I use the defaults too, and this would be enough.

Since I don't have any customizations, I would not know if an exported code style xml would run the default in addition to the diff in the xml. Either way, there's no point in enforcing code style rules that can't be automated.

🌐
JetBrains
youtrack.jetbrains.com › issue › IDEA-280417
Jetbrains
December 27, 2021 - Our website uses some cookies and records your IP address for the purposes of accessibility, security, and managing your access to the telecommunication network. You can disable data collection and cookies by changing your browser settings, but it may affect how this website functions.
🌐
JetBrains
youtrack.jetbrains.com › issue › IDEA-61520
Codestyle from Checkstyle : IJPL-39182 - YouTrack - JetBrains
January 17, 2022 - Our website uses some cookies and records your IP address for the purposes of accessibility, security, and managing your access to the telecommunication network. You can disable data collection and cookies by changing your browser settings, but it may affect how this website functions.
🌐
Oracle
docs.oracle.com › en › graalvm › enterprise › 20 › docs › reference-manual › native-image › CodeStyle
Native Image Code Style
January 16, 2025 - Eclipse Checkstyle Plugin: reports Checkstyle violations in Eclipse, making it unnecessary to run mx checkstyle manually. https://checkstyle.github.io/eclipse-cs/ IntelliJ Eclipse Code Formatter: formats source files in IntelliJ according to Eclipse IntelliJ rules.