Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Checkstyle doesn't work with SuppressionCommentFilter

Tags:

checkstyle

Below is my code around check style - but it doesnt seem to suppress the audits between the suppression comment lines. I also tried with inline comment // instead of /* */

Please help. I have trying a lot of ways - permutation/combinations of those to get this fixed. Thank you. Please let me know if you need more info.

/* CHECKSTYLE:OFF */
private abc createTimerChart(String title, String yAxisLabel, XYDataset dataset) {
    final abc chart = ChartFactory.createXYLineChart(title, // chart title
            "Time Elapsed (" + pollUnit.toString() + ")", // x axis label
            yAxisLabel, // y axis label
            dataset, // data
            PlotOrientation.VERTICAL, true, // include legend
            true, // tooltips
            false // urls
            );
/* CHECKSTYLE:ON */

CONFIG.XML reads:

    <module name="FileContentsHolder">
        <module name="SuppressionCommentFilter">
            <property name="checkFormat" value="IndentationCheck"/>
        </module>
    </module>

AFTER MOVING SuppressionCommentFilter UNDER CHECKER:

<module name="Checker">

<!-- setting the default severity to warning -->
<property name="severity" value="warning" />

<module name="SuppressionCommentFilter">
    <property name="checkFormat" value="Indentation"/>
</module>

<!-- No TAB characters in the source code -->
<module name="FileTabCharacter" />

<!-- List of files to ignore . -->
<!-- TODO Add all auto-generated files to this file -->
<module name="SuppressionFilter">
    <property name="file" value="checkstyle/kepler-checkstyle-suppressions.xml"/>
</module>
<module name="TreeWalker">
..
..
..
like image 357
user1304121 Avatar asked Nov 04 '22 11:11

user1304121


1 Answers

The indentation check is called Indentation. It shold work if you change the checkFormat property to just Indentation:

<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE module PUBLIC "-//Puppy Crawl//DTD Check Configuration 1.3//EN"
    "http://www.puppycrawl.com/dtds/configuration_1_3.dtd">
<module name="Checker">
    <property name="severity" value="warning" />
    <module name="TreeWalker">
        <module name="JavadocType" />
        <module name="Indentation" />
        <module name="FileContentsHolder"/>
    </module>
    <module name="SuppressionCommentFilter">
        <property name="checkFormat" value="Indentation" />
    </module>
</module>

Or, more generally, I would recommend not setting the checkFormat property at all, which will make the suppression comment suppress all warnings for that block of code.

like image 142
barfuin Avatar answered Nov 13 '22 05:11

barfuin