このセクションの内容

前提条件

Jtest は、Checkstyle 5.5、5.6、5.7、6.5、および 7.6 での静的解析をサポートしています。

Checkstyle ルールを有効にし、このフォルダーにドロップしたプラグインを使用するには、次の操作を行います。

  1. INSTALL_DIR/etc に移動し、framework.properties 設定ファイルを開きます。
  2. felix.auto.start.4 セットを探し、最初のエントリとして 次の .jar ファイルを追加します: org.apache.felix.fileinstall-3.4.0.jar

Checkstyle のダウンロードとインストール

  1. 次のウェブ サイトから Checkstyle をダウンロードします。
    http://sourceforge.net/projects/checkstyle/files
  2. Checkstyle を展開し、インストールします。
  3. [INSTALL_DIR]/integration/checkstyle  ディレクトリにある configs、plugins、rules フォルダーをインストール ディレクトリにコピーします。
  4. jtestcli.properties ファイルを編集して次のプロパティを追加します。
    jtest.analyzer.checkstyle.enabled=true
    jtest.analyzer.checkstyle.dir=CHECKSTYLE/INSTALLATION/DIRECTORY
    rules.provider_cs.analyzer=com.puppycrawl.tools.checkstyle
    rules.provider_cs.data=${jtest.home}/rules/csrules.xml

Checkstyle を使用したコードの解析

Checkstyle ユーザー定義テスト コンフィギュレーションを指定して Checkstyle での解析を実行します。

  • user://Checkstyle - すべてのルールが有効
  • user://Checkstyle Recommended - Checkstyles 推奨ルールが有効

オプションのカスタマイズ

以下のプロパティを構成して Checkstyle との統合をカスタマイズできます。 

# Custom limit for number of files to be tested in a single executed Checkstyle process. Default is 50.
# However, if subsequent files are placed in the same directory, they will be still scheduled to that
# process unless the "hard" limit is reached (twice the "regular" limit).
jtest.analyzer.checkstyle.files.limit=50

# Custom timeout (seconds) for the Checkstyle process to start. Default is 5 seconds.
jtest.analyzer.checkstyle.launch.timeout=5

# Custom timeout (seconds) for the Checkstyle process to complete. Default is 60 seconds.
jtest.analyzer.checkstyle.timeout=60

# Custom launch file for Checkstyle process. Default is taken from the Checkstyle analyzer jar file. 
# If one cannot be found, attempts to use file 'checkstyle.ini' from current working directory.
jtest.analyzer.checkstyle.launch.file=CUSTOM/LAUNCH/FILE

[INSTALL_DIR]/integration/checkstyle ディレクトリにある rulemap.txt ファイルには、テスト コンフィギュレーションで使用されるルール ID が、どのように Checkstyle のルール タイプにマッピングされるかに関する情報が記載されています。

  • No labels