LoginSignup
0
0

More than 5 years have passed since last update.

checkstyle の設定ファイルに関する Tips

Last updated at Posted at 2017-01-01

checkstyle を実行する際、-cオプションでチェック項目のフィルタリングなどを定義した設定ファイルを指定できる。

$ java com.puppycrawl.tools.checkstyle.Main   
Must specify a config XML file.
usage: java com.puppycrawl.tools.checkstyle.Main [options] -c <config.xml>
            file...
 -c <arg>   The check configuration file to use.
 (以下略)

実は、-cオプションには URL も指定できる。
http://checkstyle.sourceforge.net/cmdline.html#Command_line_usage

-c configurationFile - specifies the location of the file that defines the configuration modules. The location can either be a filesystem location, or a name passed to the ClassLoader.getResource() method.

そのため、設定ファイルを Github などのリモートリポジトリに置いておくと、
複数のプロジェクトで同じ設定を共有することができる上に、
設定の更新を自動的に反映させることができる。

例えば、Github 上に置いた設定ファイルを読み込む場合は、以下のようなコマンドになる。

$ java com.puppycrawl.tools.checkstyle.Main \
  -c https://raw.githubusercontent.com/[user_name]/[repo_name]/[branch_name]/[path_to_file]/checkstyle.xml
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0