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