Kengo's blog

Technical articles about original projects, JVM, Static Analysis and TypeScript.

PMD ruleset for SLF4J

 I wanted to use ruleset to validate my codes so I asked to ML of SLF4J, but there is no tool to help. So I've created a PMD ruleset for SLF4J. It may help to code with unified valid logging.

How to use

 If you have already used PMD ruleset, you can use this package as it. Please type `mvn clean package` in the ruleset directory. The xml file is here.
 PMDの外部ルールセットを既に利用したことがある方は、ビルドの成果物をルールセットとしてご利用ください。rulesetディレクトリ`mvn clean package`と実行することでjarが作成されます。xmlファイルはここにあります。

 If you don't have, you can learn how to use at official site, but I recommend to use Sonar plugin which I'll explain. Original PMD ruleset is not easy to use I think.

Install Sonar plugin to your sonar

 My product has sonar-plugin module. To create plugin file, please type `mvn clean package` in this module. You can find jar file in target directory after building, so please copy it to ${sonar.home}/extensions/plugin. Your Sonar will read this jar and use it.
 sonar-pluginモジュールを用意していますので、こちらで`mvn clean package`してSonarプラグインを作成してください。targetディレクトリにできたjarファイルを${sonar.home}/extensions/pluginに突っ込んでやるだけで使えます。Sonarえらい。

Next step

 It has only 4 rules but I plan to enhance -- for example, joining String and avoid to use LoggerFactory in method. I think this is simple and effective tool to help coding. Please try to use and fork it!