How to check code style in the whole project or some part of it in IDEA? Let me make an accent here on a word "check". I don't need to fix code style I just want to see how big is the problem of not following code style in the project. So I want to see list of lines or cases where code formatting is not inline with what I have set in the File -> Settings -> Code Style -> Java. I thought that Code Inspection does this but when I checked File -> Settings -> Inspections -> Code style issues it seemed to me that these issues are not about code style formatting.
What I would like to use is: I start some inspection on some part of code or the whole project and as a result of inspection I want to see list of issues/lines where code formatting is broken. I know I might just reformat the whole project and then run source control diff but I don't think that this is really good. I would like to see some categorization of code style issues with statistics, etc... Is there any way to get this in IDEA?
You should consider CheckStyle . It analyses the code and shows summary similar to error or warning message in the IDE. In addition you could customize the check style or use existing one. There should be a plugin for IDEA as well.
Try out maven-checkstyle-plugin . It's based on the Checkstyle . You can create configuration to run it under IntelliJ IDEA.
The output looks like:
C:\src\ClassPathTldsLoader.java:8:8: Unused import - java.util.Collections.
C:\src\model\Class1.java:64: 'if' construct must use '{}'s.
C:\src\model\Class2.java:55: 'if' construct must use '{}'s.
C:\src\Class3.java:4:1: Redundant import from the same package - java.util.Collections
...
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.