How to customise the severity of the google_checks.xml file modules

150 Views Asked by At

I wanted to change the severity of the modules and i don't want to go to every rule and add the property severity to error or something else, is their any way to treat some rule as a warning and some rule as a error in seperate files and if possible how i can run maven checkstyle using those files.

So for this i have tried with the 'import file="custom_checks.xml"' in the google_checks.xml file but this is not working along with this i have used the 'includes google_checks.xml,custom_check.xml' but this approaches are not working.

My case is that I don't want to treat every rule as a error and also i don't want to update every rules severity.

1

There are 1 best solutions below

0
rveach On

There is currently no way to change the severity based on the file being scanned. You can change the severity of all modules in the config, or change each one individually. You can use the same module more than once, each with a different severity to try and achieve what you want, but this depends too much on the module in question.

Example: https://checkstyle.org/config.html#Severity

<module name="Checker">
  <property name="severity" value="warning"/>
  <module name="Translation">
    <property name="severity" value="error"/>
  </module>
</module>

You can suppress violations based on file, so you may want to look into this and see if it can do what you want.

https://checkstyle.org/config_filters.html

import file="custom_checks.xml" includes google_checks.xml,custom_check.xml

I am not sure where this came from, but you cannot currently combine multiple configs into 1 checkstyle run. If you have multiple configurations, you must run them in separate CLI runs.