Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: rewrite the implementation into Kotlin #924

Merged
merged 45 commits into from
Aug 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
08f0186
build: introduce Kotlin
KengoTODA Jul 31, 2023
107a781
chore: convert Effort class
KengoTODA Jul 31, 2023
a2db47a
chore: convert internal.SemanticVersion
KengoTODA Jul 31, 2023
50fbd4e
chore: convert SpotBugsExtension
KengoTODA Jul 31, 2023
5617e88
Merge remote-tracking branch 'origin/v6' into introduce-kotlin
KengoTODA Aug 1, 2023
d247057
chore: keep replacing Java code with Kotlin code
KengoTODA Aug 1, 2023
1c1c082
chore: translate report related file
KengoTODA Aug 1, 2023
376bd18
chore: add OutputScanner
KengoTODA Aug 2, 2023
12d4035
build: update build settings
KengoTODA Aug 2, 2023
1915063
chore: introduce changes from #930
KengoTODA Aug 2, 2023
af6b756
chore: rewrite SpotBugsRunner classes
KengoTODA Aug 5, 2023
55ab06a
chore: replace all Java/Groovy with Kotlin
KengoTODA Aug 5, 2023
bfb6218
ci: remove javadoc workflow
KengoTODA Aug 5, 2023
727c4af
Merge remote-tracking branch 'origin/master' into introduce-kotlin
KengoTODA Aug 5, 2023
d73b963
ci: run workflow even on release branch
KengoTODA Aug 5, 2023
8ec3bf3
test: resolve some known issues
KengoTODA Aug 6, 2023
9e6b483
test: resolve some known issues
KengoTODA Aug 6, 2023
8173a0a
test: fix known issues
KengoTODA Aug 6, 2023
3ed2167
Merge remote-tracking branch 'origin/v6' into introduce-kotlin
KengoTODA Aug 10, 2023
5db6b1e
build: remove needless spotless rules
KengoTODA Aug 10, 2023
78cdc3a
test: use canonicalPath to support Windows
KengoTODA Aug 10, 2023
b597026
chore: reflect changes from #929
KengoTODA Aug 10, 2023
d43acd3
chore: apply more kotlin-like coding style
KengoTODA Aug 10, 2023
52eac51
test: pass several tests
KengoTODA Aug 10, 2023
f961e41
test: fix all broken test cases
KengoTODA Aug 11, 2023
9de73d7
test: kotlin lazy assignment prop is enable by default from 8.2
KengoTODA Aug 11, 2023
a39266b
test: remove needless imports
KengoTODA Aug 11, 2023
4520495
test: skip tests if Gradle version is too old
KengoTODA Aug 11, 2023
f7a1d2c
docs: sync changes of interface to documentations
KengoTODA Aug 11, 2023
8c96471
test: add missing imports
KengoTODA Aug 11, 2023
0091772
test: fix test cases
KengoTODA Aug 11, 2023
8b7218b
chore: make SpotBugsTask configuration-cache safe
KengoTODA Aug 11, 2023
c378771
build: introduce Dokka
KengoTODA Aug 11, 2023
0a4db3f
ci: deploy prerelease from the v6 branch
KengoTODA Aug 11, 2023
71777be
test: skip cachability check if NamedDomainObjectContainer is not cac…
KengoTODA Aug 11, 2023
72f4464
chore: make the reports field public
KengoTODA Aug 11, 2023
3221337
chore: apply spotless
KengoTODA Aug 11, 2023
71385ea
ci: check bytecode version built by Kotlin compiler
KengoTODA Aug 11, 2023
3863ab0
chore: simplify path to import for prop-assign
KengoTODA Aug 11, 2023
699c54f
build: remove completed TODO comment
KengoTODA Aug 11, 2023
0d0b702
chore: format code by spotless
KengoTODA Aug 11, 2023
57bec82
build: replace SpotBugs with detekt
KengoTODA Aug 12, 2023
7381fd6
docs: explain the motivation to keep legacy APIs
KengoTODA Aug 12, 2023
9ccf193
ci: mark the beta branch
KengoTODA Aug 13, 2023
9c5bf2a
Merge branch 'v6' into introduce-kotlin
KengoTODA Aug 13, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@ on:
push:
branches:
- master
- v6
pull_request:
branches:
- master
- v6

jobs:
CodeQL-Build:
Expand All @@ -29,15 +31,14 @@ jobs:
with:
distribution: 'temurin'
java-version: 11
cache: gradle
- name: Gradle Wrapper Validation
uses: gradle/wrapper-validation-action@v1

- name: Build
run: |
./gradlew spotbugsMain
- name: Build with Gradle
uses: gradle/gradle-build-action@v2
with:
arguments: detekt --scan
- name: Upload SARIF file
uses: github/codeql-action/upload-sarif@v1
with:
# Path to SARIF file relative to the root of the repository
sarif_file: build/reports/spotbugs/main.sarif
sarif_file: build/reports/detekt/detekt.sarif
8 changes: 5 additions & 3 deletions .github/workflows/javadoc.yml → .github/workflows/dokka.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ on:
push:
branches:
- master

jobs:
javadoc:
runs-on: ubuntu-latest
Expand All @@ -16,14 +17,15 @@ jobs:
with:
distribution: 'temurin'
java-version: 11
cache: gradle
- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version-file: '.nvmrc'
cache: npm
- name: Generate Groovydoc
run: ./gradlew groovydoc
uses: gradle/gradle-build-action@v2
with:
arguments: dokkaHtml
- name: Prepare to Deploy
run: |
npm ci
Expand All @@ -33,4 +35,4 @@ jobs:
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
BRANCH: gh-pages
FOLDER: build/docs/groovydoc/
FOLDER: build/dokka/html/
4 changes: 2 additions & 2 deletions .github/workflows/gradle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
gradle: ['7.6.2', '8.0']
gradle: ['7.6.2', '8.1', '8.2']
steps:
- uses: actions/checkout@v3
with:
Expand All @@ -39,7 +39,7 @@ jobs:
arguments: build -Dsnom.test.functional.gradle=${{ matrix.gradle }} --scan
- run: |
echo Verifying the java version used in class files...
cd build/classes/groovy/main
cd build/classes/kotlin/main
javap -v com.github.spotbugs.snom.SpotBugsPlugin | grep -q 'major version: 52'
- name: Run Semantic Release
run: |
Expand Down
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,6 @@ $RECYCLE.BIN/
### Gradle ###
.gradle
build/
gradle.properties

# Ignore Gradle GUI config
gradle-app.setting
Expand Down
13 changes: 13 additions & 0 deletions .idea/codeStyles/Project.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions .idea/codeStyles/codeStyleConfig.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions .idea/jarRepositories.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/kotlinc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 0 additions & 10 deletions .idea/runConfigurations.xml

This file was deleted.

121 changes: 61 additions & 60 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,45 @@ Refer [the Gradle Plugin portal](https://plugins.gradle.org/plugin/com.github.sp

Configure `spotbugs` extension to configure the behaviour of tasks:

```kotlin
// require Gradle 8.2+
import com.github.spotbugs.snom.Confidence
import com.github.spotbugs.snom.Effort
spotbugs {
ignoreFailures = false
showStackTraces = true
showProgress = true
effort = Effort.DEFAULT
reportLevel = Confidence.DEFAULT
visitors = listOf("FindSqlInjection", "SwitchFallthrough")
omitVisitors = listOf("FindNonShortCircuit")
reportsDir = file("$buildDir/spotbugs")
includeFilter = file("include.xml")
excludeFilter = file("exclude.xml")
baselineFile = file("baseline.xml")
onlyAnalyze = listOf("com.foobar.MyClass", "com.foobar.mypkg.*")
maxHeapSize = "1g"
extraArgs = listOf("-nested:false")
jvmArgs = listOf("-Duser.language=ja")
}
```

<details>
<summary>with Groovy DSL</summary>

```groovy
import com.github.spotbugs.snom.Confidence
import com.github.spotbugs.snom.Effort
spotbugs {
ignoreFailures = false
showStackTraces = true
showProgress = true
effort = 'default'
reportLevel = 'default'

// https://discuss.kotlinlang.org/t/bug-cannot-use-kotlin-enum-from-groovy/1521
// https://touk.pl/blog/2018/05/28/testing-kotlin-with-spock-part-2-enum-with-instance-method/
effort = Effort.valueOf('DEFAULT')
reportLevel = Confidence.valueOf('DEFAULT')

visitors = [ 'FindSqlInjection', 'SwitchFallthrough' ]
omitVisitors = [ 'FindNonShortCircuit' ]
reportsDir = file("$buildDir/spotbugs")
Expand All @@ -48,63 +80,41 @@ spotbugs {
jvmArgs = [ '-Duser.language=ja' ]
}
```

<details>
<summary>with Kotlin DSL</summary>

```kotlin
spotbugs {
ignoreFailures.set(false)
showStackTraces.set(true)
showProgress.set(true)
effort.set(com.github.spotbugs.snom.Effort.DEFAULT)
reportLevel.set(com.github.spotbugs.snom.Confidence.DEFAULT)
visitors.set(listOf("FindSqlInjection", "SwitchFallthrough"))
omitVisitors.set(listOf("FindNonShortCircuit"))
reportsDir.set(file("$buildDir/spotbugs"))
includeFilter.set(file("include.xml"))
excludeFilter.set(file("exclude.xml"))
baselineFile.set(file("baseline.xml"))
onlyAnalyze.set(listOf("com.foobar.MyClass", "com.foobar.mypkg.*"))
maxHeapSize.set("1g")
extraArgs.set(listOf("-nested:false"))
jvmArgs.set(listOf("-Duser.language=ja"))
}
```
</details>

Configure `spotbugsPlugin` to apply any SpotBugs plugin:

```groovy
```kotlin
dependencies {
spotbugsPlugins 'com.h3xstream.findsecbugs:findsecbugs-plugin:1.12.0'
spotbugsPlugins("com.h3xstream.findsecbugs:findsecbugs-plugin:1.12.0")
}
```

<details>
<summary>with Kotlin DSL</summary>
<summary>with Groovy DSL</summary>

```kotlin
```groovy
dependencies {
spotbugsPlugins("com.h3xstream.findsecbugs:findsecbugs-plugin:1.12.0")
spotbugsPlugins 'com.h3xstream.findsecbugs:findsecbugs-plugin:1.12.0'
}
```
</details>

Configure `spotbugs` to choose your favorite SpotBugs version:

```groovy
```kotlin
dependencies {
spotbugs 'com.github.spotbugs:spotbugs:4.7.1'
spotbugs("com.github.spotbugs:spotbugs:4.7.1")
}
```


<details>
<summary>with Kotlin DSL</summary>
<summary>with Groovy DSL</summary>

```kotlin
```groovy
dependencies {
spotbugs("com.github.spotbugs:spotbugs:4.7.1")
spotbugs 'com.github.spotbugs:spotbugs:4.7.1'
}
```
</details>
Expand All @@ -125,6 +135,19 @@ TBU
Configure [`SpotBugsTask`](https://spotbugs-gradle-plugin.netlify.com/com/github/spotbugs/snom/spotbugstask) directly,
to set task-specific properties.

```kotlin
// require Gradle 8.2+
tasks.spotbugsMain {
reports.create("html") {
required = true
outputLocation = file("$buildDir/reports/spotbugs.html")
setStylesheet("fancy-hist.xsl")
}
}
```

<details>
<summary>with Groovy DSL</summary>
```groovy
// Example to configure HTML report
spotbugsMain {
Expand All @@ -137,47 +160,25 @@ spotbugsMain {
}
}
```

<details>
<summary>with Kotlin DSL</summary>

```kotlin
tasks.spotbugsMain {
reports.create("html") {
required.set(true)
outputLocation.set(file("$buildDir/reports/spotbugs.html"))
setStylesheet("fancy-hist.xsl")
}
}
```
</details>

## SpotBugs version mapping

By default, this Gradle Plugin uses the SpotBugs version listed in this table.
By default, this Gradle Plugin uses the SpotBugs version listed in the following table.

You can change SpotBugs version by [the `toolVersion` property of the spotbugs extension](https://spotbugs-gradle-plugin.netlify.com/com/github/spotbugs/snom/spotbugsextension#toolVersion) or the `spotbugs` configuration.

| Gradle Plugin | SpotBugs |
|--------------:|---------:|
| 6.0.0 | 4.7.3 |
| 5.1.x | 4.7.3 |
| 5.0.13 | 4.7.3 |
| 5.0.12 | 4.7.2 |
| 5.0.9 | 4.7.1 |
| 5.0.7 | 4.7.0 |
| 5.0.4 | 4.5.3 |
| 5.0.3 | 4.5.2 |
| 5.0.2 | 4.5.1 |
| 4.7.10 | 4.5.0 |
| 4.7.8 | 4.4.2 |
| 4.7.5 | 4.4.1 |
| 4.7.3 | 4.4.0 |
| 4.7.2 | 4.3.0 |
| 4.6.1 | 4.2.1 |
| 4.5.0 | 4.1.1 |
| 4.4.4 | 4.0.6 |
| 4.4.2 | 4.0.5 |
| 4.0.7 | 4.0.2 |
| 4.0.0 | 4.0.0 |

### Refer the version in the build script

Expand Down
Loading