Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Java Checkstyle severity level inherit meaning?

What actuallly does severity level set as "inherit" mean in a checkstyle rule?

tried googling a lot couldn't find an actual definition for this-

like image 355
pranky64 Avatar asked Aug 22 '13 08:08

pranky64


People also ask

How do I check my Checkstyle violations?

To view to violation report, go to Window -> Show View -> Other, and search for Checkstyle. Options for Violations and Violations Chart should be displayed.

What does Checkstyle mean in Java?

Checkstyle is a development tool to help programmers to write Java code that sticks to a coding standard. It automates the process of checking Java code. It is an open-source tool that checks code against a configurable set of rules. It allows you to define your own set of rules and check your code against it.

How do I fix STS Checkstyle error?

Right click on the java file in Package Explorer or whatever, and select 'Apply Checkstyle Corrections'. Click on the error in the problems view, and select 'Quick fix'. This corrects the problem.


1 Answers

The Checkstyle rules are configured in a small, but important hierarchy. Checker is at the top, one of its "children" is Treewalker, and so on. Properties can be defined for individual checks, but also for these "parent checks". Thus, your run-of-the-mill Checkstyle configuration file looks like this:

<module name="Checker">
    <property name="severity" value="warning"/>  <!-- NOTE THIS -->
    <module name="TreeWalker">
        <property name="tabWidth" value="4"/>
        <module name="JavadocMethod">
            <property name="scope" value="public"/>
        </module>
    <!-- and so on -->
    </module>
    <!-- and so on -->
</module>

As you can see, there is the severity property of Checker, the topmost module. If a check somewhere lower in the hierarchy has its severity set to inherit (which is the same as not setting anything), then its severity will be, in this example, warning.

like image 98
barfuin Avatar answered Oct 03 '22 19:10

barfuin