Checkstyle / Module / Headers



ヘッダのチェック。

Header

親モジュールTreeWalker
実装クラスcom.puppycrawl.tools.checkstyle.checks.HeaderCheck

ソースファイルが、指定されたヘッダから始まっていることをチェックします。

プロパティ名デフォルト概要
headerFileStringnullヘッダの定義が入っているファイルの名前
ignoreLinesInteger Setなしチェックをとばす行番号のセット

記述サンプル

  • Standard Checkstyle
    <module name = "Header">
       <property name = "headerFile" value = "java.header" />
       <property name = "ignoreLines" value = "2, 5" />
    </module>
  • Plug-in Checkstyle
    <rule-configuration
        classname = "com.puppycrawl.tools.checkstyle.checks.HeaderCheck"
        severity = "warning">
        <config-properties>
            <config-property name = "headerFile" value = "java.header" />
            <config-property name = "ignoreLines" value = "2, 5" />
        </config-properties>
    </rule-configuration>

RegexpHeader

親モジュールTreeWalker
実装クラスcom.puppycrawl.tools.checkstyle.checks.RegexpHeaderCheck

Header では固定パターンのファイルでしたが、この Check では、指定したファイル内の正規表現を認識します。これにより、もっと複雑なチェックが可能になります。

ここで使われる正規表現エンジンは、Jakarta Regexp です。どのようなパターンが利用できるかは、http://jakarta.apache.org/regexp/apidocs/org/apache/regexp/RE.html を見てください。

プロパティ名デフォルト概要
headerFileStringnullヘッダの定義が入っているファイルの名前
ignoreLinesInteger Setなしチェックをとばす行番号のセット

記述サンプル

  • Standard Checkstyle
    <module name = "Header">
       <property name = "headerFile" value = "java.re.header" />
       <property name = "ignoreLines" value = "2, 5" />
    </module>
  • Plug-in Checkstyle
    <rule-configuration
        classname = "com.puppycrawl.tools.checkstyle.checks.HeaderCheck"
        severity = "warning">
        <config-properties>
            <config-property name = "headerFile" value = "java.re.header" />
            <config-property name = "ignoreLines" value = "2, 5" />
        </config-properties>
    </rule-configuration>