7

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-

4
  • use same of parent ? thats what it should be Commented Aug 22, 2013 at 8:12
  • 1
    Parent? okay consider the following example a rule for abstract class name or constant variable name is defined with severity as inherit who would be the parent here? Commented Aug 22, 2013 at 8:15
  • Please post the log or the stylesheet with the necessary information. As far as I know inherited is not a valid value for checkstyle severity. Commented Aug 22, 2013 at 8:33
  • @Thihara : actually it shows in the drop down of eclipse-cs integrator, which i guess is the checkstyle plugin for eclipse Commented Aug 22, 2013 at 8:51

2 Answers 2

6

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.

Sign up to request clarification or add additional context in comments.

Comments

0

Command line properties and ant Checkstyle task properties apply to the root Checker module. Also, properties are inherited in the module hierarchy.

See Checkstyle documentation for further details.

2 Comments

so does this mean that if I have a custom checkstyle configuration it would inherit from the default configuration i.e. sun checks? So if I understand correctly the severity for such a rule defined would be same as the one defined in "Sun Checks"?
"...Also, properties are inherited in the module hierarchy." Inherited from where is my question actually?

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.