Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Checkstyle different severity for same module based on property

Is it possible to have different severity levels for the same module but with different properties?

This is what I am looking at:

<module name="IllegalThrows">
   <property name="illegalClassNames" value="NullPointerException,java.lang.RuntimeException,Exception"/>
</module>

<module name="IllegalThrows">
  <property name="illegalClassNames" value="Exception"/>
  <property name="severity" value="warning"/>
</module>
like image 422
user5383926 Avatar asked Sep 28 '15 08:09

user5383926


1 Answers

Yes, that's perfectly ok! There are some minor glitches in your example code; here's a slightly modified version:

<module name="IllegalThrows">
    <property name="severity" value="warning"/>
    <property name="illegalClassNames"
        value="java.lang.NullPointerException,java.lang.RuntimeException"/>
</module>

<module name="IllegalThrows">
    <property name="severity" value="error"/>
    <property name="illegalClassNames" value="java.lang.Exception"/>
</module>

I set a severity on both modules. One can be left out if it is the same as the configured default severity (usually warning). Also, I removed the redundancy where Exception was declared in both modules. This would have caused you to get two issues for the same line of code. It is sufficient to specify only the fully qualified class names.

like image 82
barfuin Avatar answered Oct 07 '22 04:10

barfuin