Skip to content

Commit

Permalink
Introduce a gradle PMD plugin (#241)
Browse files Browse the repository at this point in the history
  • Loading branch information
yutaro-sakamoto authored Oct 21, 2023
1 parent 59b8749 commit 08fb9c2
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 31 deletions.
5 changes: 2 additions & 3 deletions .github/workflows/cicd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,7 @@ jobs:
run: |
sudo apt-get update -y
sudo apt-get install -y clang-format cppcheck
curl -L -o pmd-bin-6.52.0.zip https://github.com/pmd/pmd/releases/download/pmd_releases%2F6.52.0/pmd-bin-6.52.0.zip
curl -L -o spotbugs-4.7.3.zip https://github.com/spotbugs/spotbugs/releases/download/4.7.3/spotbugs-4.7.3.zip
unzip pmd-bin-6.52.0.zip
unzip spotbugs-4.7.3.zip
- name: Install opensource COBOL 4J
Expand All @@ -118,7 +116,8 @@ jobs:
- name: Run PMD
run: |
pmd-bin-6.52.0/bin/run.sh pmd -d ${PWD}/libcobj/src -R ${PWD}/.github/ruleset.xml -f text
cd libcobj
./gradlew pmdMain
- name: Run cppcheck
run: |
Expand Down
16 changes: 2 additions & 14 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,8 @@ The below sections describe how to setup and run static code analysis.

## Setup static analysis tools

### clang-format

Run `sudo apt install clang-format` in Ubuntu to install `clang-format`.

### PMD

Run the following commands to install `PMD`:
```sh
curl -L -o pmd-bin-6.52.0.zip https://github.com/pmd/pmd/releases/download/pmd_releases%2F6.52.0/pmd-bin-6.52.0.zip
unzip pmd-bin-6.52.0.zip
mv pmd-bin-6.52 /usr/local/bin/
rm pmd-bin-6.52.0.zip
```

## Run static analysis

### check with clang-format and google-java-format
Expand All @@ -37,7 +25,7 @@ If you want to make sure all files are formatted, run `./check-format` in the to

### PMD

Run the following command in the top directory of opensource COBOL 4J:
Run the following command in libcobj/ directory:
```
/usr/local/bin/pmd-bin-6.52.0/bin/run.sh -d libcobj/src -R .github/ruleset.xml -f text
./gradlew pmdMain
```
16 changes: 2 additions & 14 deletions CONTRIBUTING_JP.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,8 @@ CIの静的解析はCとJavaのソースコードがそれぞれ[clang-format](h

## セットアップ

### clang-format

Ubuntuでは`sudo apt install clang-format`コマンドを実行すれば`clang-format`をインストールできます。

### PMD

下記のコマンドを実行して`PMD`をインストールしてください。
```sh
curl -L -o pmd-bin-6.52.0.zip https://github.com/pmd/pmd/releases/download/pmd_releases%2F6.52.0/pmd-bin-6.52.0.zip
unzip pmd-bin-6.52.0.zip
mv pmd-bin-6.52 /usr/local/bin/
rm pmd-bin-6.52.0.zip
```

## 静的解析の実行

### clang-formatとgoogle-java-format
Expand All @@ -37,7 +25,7 @@ opensource COBOL 4Jのトップディレクトリで`./format`を実行してく

### PMD

opensource COBOL 4Jのトップディレクトリで下記のコマンドを実行してください
opensource COBOL 4Jのlibcobj/ディレクトリで下記のコマンドを実行してください
```
/usr/local/bin/pmd-bin-6.52.0/bin/run.sh -d libcobj/src -R .github/ruleset.xml -f text
./gradlew pmdMain
```
7 changes: 7 additions & 0 deletions libcobj/app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ plugins {
id("java")
id("com.github.sherter.google-java-format") version "0.9"
id("maven-publish")
pmd
}

repositories {
Expand All @@ -24,6 +25,12 @@ java {
}
}

pmd {
isConsoleOutput = true
ruleSets = listOf()
ruleSetFiles = files("${rootDir}/config/pmdRuleSet.xml")
}

publishing {
repositories {
maven {
Expand Down
File renamed without changes.

0 comments on commit 08fb9c2

Please sign in to comment.