5

以下はチェックスタイルに関する私のコードですが、抑制コメント行の間の監査を抑制していないようです。/* */ の代わりにインラインコメント // も試しました

助けてください。私は多くの方法を試しました-これを修正するための順列/組み合わせ。ありがとうございました。さらに情報が必要な場合はお知らせください。

/* 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 の読み取り:

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

SuppressionCommentFilter をチェッカーの下に移動した後:

<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">
..
..
..
4

1 に答える 1

2

インデントチェックは と呼ばれIndentationます。checkFormatプロパティを次のように変更すると機能し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>

または、より一般的には、checkFormatプロパティをまったく設定しないことをお勧めします。これにより、抑制コメントにより、そのコード ブロックのすべての警告が抑制されます。

于 2012-11-12T19:52:36.143 に答える