4

I am using IntelliJ IDEA version 2017.3, then I install plug-in CheckStyle-IDEA v 5.16.0 successful, I install Apache Maven Checkstyle Plugin to run myCheckFile.xml. At install phase, I received many check style error like:

Indentation: '.' has incorrect indentation level 6, expected level should be 8.
Indentation: 'new' has incorrect indentation level 6, expected level should be 8.

After importing CheckStyle settings, I expect when I hit Ctrl+Alt+L inside IntelliJ IDEA all check style error will die but that doesn't happen, is there's something i'm missing ?

3
  • 1
    checkstyle is not combined with the formatter. You need to tell the formatter explicitly what to do. Jan 13, 2018 at 1:30
  • Could you please share your checkstyle scheme? May be not all settings are supported by IDEA formatter.
    – y.bedrov
    Jan 15, 2018 at 8:06
  • If you install Save Actions plugin and configure it to reformat on save then it'll automatically format for you
    – Archmede
    Feb 27, 2020 at 19:11

1 Answer 1

0

You might have a .editorconfig file which is taking precedence. I ran into the same problem and my solution was to comment out the .editorconfig file. Our team is using JHipster, which automatically generates a .editorconfig file. This generally has just a few key settings, including indent_size=4. I was experimenting with Google's checkstyle xml settings and saw the same overall issue you were seeing, where the checkstyle plugin was indicating the indentation was wrong, but the code/reformat option wasn't fixing it.

TL;DR - see if you have a .editorconfig file and if so delete it or comment out the conflicting styles.

2
  • 1
    Where is this file located?
    – Archmede
    Feb 27, 2020 at 19:05
  • 1
    There is also a checkbox 'Enable EditorConfig support' under Preferences->Editor->Code Style that you can disable to prevent a .editorconfig file from overriding settings. Apr 14, 2022 at 17:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.