Skip to content
This repository has been archived by the owner on Feb 11, 2022. It is now read-only.

Commit

Permalink
Merge develop into master for release (#215)
Browse files Browse the repository at this point in the history
Merge develop into master for release
  • Loading branch information
zegnus authored Nov 21, 2019
2 parents a6a33d8 + 72e4c77 commit 59e7605
Show file tree
Hide file tree
Showing 26 changed files with 681 additions and 64 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
Change Log
==========

[Version 1.2](https://github.com/novoda/gradle-static-analysis-plugin/releases/tag/v1.2)
--------------------------

- Add support for SpotBugs [PR#209](https://github.com/novoda/gradle-static-analysis-plugin/pull/209)
- Fixed an issue caused by combination of Gradle 5.6 and kotlin-kapt [#199](https://github.com/novoda/gradle-static-analysis-plugin/issues/199)
- Fix: Removed usage of deprecated Android APIs [PR#212](https://github.com/novoda/gradle-static-analysis-plugin/pull/212)
- Findbugs support is deprecated [PR#216](https://github.com/novoda/gradle-static-analysis-plugin/pull/216)

[Version 1.1](https://github.com/novoda/gradle-static-analysis-plugin/releases/tag/v1.1)
--------------------------

Expand Down
11 changes: 6 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ The plugin supports various static analysis tools for Java, Kotlin and Android p

* [`Checkstyle`](docs/tools/checkstyle.md)
* [`PMD`](docs/tools/pmd.md)
* [`FindBugs`](docs/tools/findbugs.md)
* [`FindBugs`](docs/tools/findbugs.md) [DEPRECATED] [Removed in Gradle 6.0]
* [`SpotBugs`](docs/tools/spotbugs.md)
* [`Detekt`](docs/tools/detekt.md)
* [`Android Lint`](docs/tools/android_lint.md)
* [`KtLint`](docs/tools/ktlint.md)
Expand All @@ -31,7 +32,6 @@ Please note that the tools availability depends on the project the plugin is app

### Tools in-consideration
* `Spotbugs` [#142](https://github.com/novoda/gradle-static-analysis-plugin/issues/142)
* `CPD (Duplicate Code Detection) ` [#150](https://github.com/novoda/gradle-static-analysis-plugin/issues/150)
* `error-prone` [#151](https://github.com/novoda/gradle-static-analysis-plugin/issues/151)
* `Jetbrains IDEA Inspections` [#152](https://github.com/novoda/gradle-static-analysis-plugin/issues/152)
Expand All @@ -52,7 +52,7 @@ buildscript {
jcenter()
}
dependencies {
classpath 'com.novoda:gradle-static-analysis-plugin:1.1'
classpath 'com.novoda:gradle-static-analysis-plugin:1.2'
}
}
Expand All @@ -63,7 +63,7 @@ or from the [Gradle Plugins Repository](https://plugins.gradle.org/):

```gradle
plugins {
id 'com.novoda.static-analysis' version '1.1'
id 'com.novoda.static-analysis' version '1.2'
}
```
Expand All @@ -80,6 +80,7 @@ staticAnalysis {
checkstyle { }
pmd { }
findbugs { }
spotbugs { }
detekt { }
lintOptions { }
}
Expand All @@ -89,7 +90,7 @@ This will enable all the tools with their default settings and create `evaluateV
[advanced usage](docs/advanced-usage.md) and to the [supported tools](docs/supported-tools.md) pages.

## Sample app
There are two sample Android projects available, one consisting of a regular app - available [here](https://github.com/novoda/gradle-static-analysis-plugin/tree/master/sample) - and the other comprising a multi-module setup available [here](https://github.com/novoda/gradle-static-analysis-plugin/tree/master/sample-multi-module). Both sample projects showcase a setup featuring Checkstyle, FindBugs, PMD, Lint and Detekt.
There are two sample Android projects available, one consisting of a regular app - available [here](https://github.com/novoda/gradle-static-analysis-plugin/tree/master/sample) - and the other comprising a multi-module setup available [here](https://github.com/novoda/gradle-static-analysis-plugin/tree/master/sample-multi-module). Both sample projects showcase a setup featuring Checkstyle, FindBugs, SpotBugs, PMD, Lint, Ktlint and Detekt.

## Snapshots
[![CI status](https://ci.novoda.com/buildStatus/icon?job=gradle-static-analysis-plugin-snapshot)](https://ci.novoda.com/job/gradle-static-analysis-plugin-snapshot/lastBuild/console) [![Download from Bintray](https://api.bintray.com/packages/novoda-oss/snapshots/gradle-static-analysis-plugin/images/download.svg)](https://bintray.com/novoda-oss/snapshots/gradle-static-analysis-plugin/_latestVersion)
Expand Down
3 changes: 3 additions & 0 deletions docs/supported-tools.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ Tool | Java | Android<br/>(Java) | Kotlin | Android<br/>(Kotlin)
[`Checkstyle`](https://checkstyle.sourceforge.net) | :white_check_mark: | :white_check_mark: | — | —
[`PMD`](https://pmd.github.io) | :white_check_mark: | :white_check_mark: | — | —
[`FindBugs`](http://findbugs.sourceforge.net/) | :white_check_mark: | :white_check_mark: | — | —
[`SpotBugs`](https://spotbugs.github.io/) | :white_check_mark: | :white_check_mark: | — | —
[`Detekt`](https://github.com/arturbosch/detekt) | — | — | :white_check_mark: | :white_check_mark:
[`Android Lint`](https://developer.android.com/studio/write/lint.html) | — | :white_check_mark:️ | — | :white_check_mark:
[`KtLint`](https://github.com/shyiko/ktlint) | — | — | :white_check_mark:️ | :white_check_mark:
Expand All @@ -22,6 +23,7 @@ For additional informations and tips on how to obtain advanced behaviours with t
* [Checkstyle](tools/checkstyle.md)
* [PMD](tools/pmd.md)
* [Findbugs](tools/findbugs.md)
* [SpotBugs](tools/spotbugs.md)
* [Android Lint](tools/android_lint.md)
* [KtLint](tools/ktlint.md)
* [Example configurations](#example-configurations)
Expand All @@ -40,6 +42,7 @@ staticAnalysis {
checkstyle {}
pmd {}
findbugs {}
spotbugs {}
lintOptions {}
detekt {}
ktlint {}
Expand Down
5 changes: 4 additions & 1 deletion docs/tools/findbugs.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
# Findbugs
# Findbugs [DEPRECATED]

**Disclaimer:** FindBugs is completely removed as of Gradle 6.0 and replaced by [`SpotBugs`](/docs/tools/spotbugs.md). FindBugs support in Static Analysis Plugin is now deprecated and will be removed in the next major version.

[Findbugs](http://findbugs.sourceforge.net/) is a static analysis tool that looks for potential bugs in Java code. It does not support Kotlin.
It can be used in both pure Java, and Android Java projects. It then only makes sense to have Findbugs enabled if you have Java code in your project.
The plugin only runs Findbugs on projects that contain the Java or the Android plugin.
Expand Down
29 changes: 29 additions & 0 deletions docs/tools/spotbugs.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# SpotBugs
[SpotBugs](https://spotbugs.github.io/) is a static analysis tool that looks for potential bugs in Java code. It does not support Kotlin.
It can be used in both pure Java, and Android Java projects. It then only makes sense to have SpotBugs enabled if you have Java code in your project.
The plugin only runs SpotBugs on projects that contain the Java or the Android plugin.

## Table of contents
* [Configure SpotBugs](#configure-spotbugs)
* [SpotBugs in mixed-language projects](#spotbugs-in-mixed-language-projects)

---

## Configure SpotBugs
Enabling and configuring SpotBugs for a project is done through the `spotbugs` closure:

```gradle
spotbugs {
toolVersion // Optional string, the latest SpotBugs release (currently 4.0.0-beta4)
excludeFilter // A file containing the SpotBugs exclusions, e.g., teamPropsFile('static-analysis/spotbugs-excludes.xml')
htmlReportEnabled true // Control whether html report generation should be enabled. `true` by default.
includeVariants { variant -> ... } // A closure to determine which variants (only for Android) to include
}
```

(assuming you're using the Novoda scaffolding system, see [Example configurations](#example-configurations) for more details)

For more information about SpotBugs rules, refer to the [official website](https://spotbugs.readthedocs.io/en/latest/bugDescriptions.html).

## SpotBugs in mixed-language projects
If your project mixes Java and Kotlin code, you will need to exclude your Kotlin files by using `excludeFilter`
2 changes: 1 addition & 1 deletion gradle/publish.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ ext {
websiteUrl = 'https://github.com/novoda/gradle-static-analysis-plugin'
}

version = '1.1'
version = '1.2'
groovydoc.docTitle = 'Static Analysis Plugin'

apply plugin: 'com.novoda.build-properties'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import com.novoda.staticanalysis.internal.findbugs.FindbugsConfigurator
import com.novoda.staticanalysis.internal.ktlint.KtlintConfigurator
import com.novoda.staticanalysis.internal.lint.LintConfigurator
import com.novoda.staticanalysis.internal.pmd.PmdConfigurator
import com.novoda.staticanalysis.internal.spotbugs.SpotBugsConfigurator
import org.gradle.api.NamedDomainObjectContainer
import org.gradle.api.Plugin
import org.gradle.api.Project
Expand Down Expand Up @@ -42,6 +43,7 @@ class StaticAnalysisPlugin implements Plugin<Project> {
CheckstyleConfigurator.create(project, violationsContainer, evaluateViolations),
PmdConfigurator.create(project, violationsContainer, evaluateViolations),
FindbugsConfigurator.create(project, violationsContainer, evaluateViolations),
SpotBugsConfigurator.create(project, violationsContainer, evaluateViolations),
DetektConfigurator.create(project, violationsContainer, evaluateViolations),
KtlintConfigurator.create(project, violationsContainer, evaluateViolations),
LintConfigurator.create(project, violationsContainer, evaluateViolations)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,29 @@ package com.novoda.staticanalysis.internal.findbugs

import com.novoda.staticanalysis.Violations
import com.novoda.staticanalysis.internal.CodeQualityConfigurator
import com.novoda.staticanalysis.internal.CollectViolationsTask
import org.gradle.api.Action
import org.gradle.api.DomainObjectSet
import org.gradle.api.NamedDomainObjectContainer
import org.gradle.api.Project
import org.gradle.api.Task
import org.gradle.api.file.ConfigurableFileTree
import org.gradle.api.file.FileCollection
import org.gradle.api.file.FileTree
import org.gradle.api.plugins.quality.FindBugs
import org.gradle.api.plugins.quality.FindBugsExtension
import org.gradle.api.tasks.SourceSet
import org.gradle.util.DeprecationLogger

import java.nio.file.Path

import static com.novoda.staticanalysis.internal.TasksCompat.configureNamed
import static com.novoda.staticanalysis.internal.TasksCompat.createTask

@Deprecated
class FindbugsConfigurator extends CodeQualityConfigurator<FindBugs, FindBugsExtension> {

protected boolean htmlReportEnabled = true

@Deprecated
static FindbugsConfigurator create(Project project,
NamedDomainObjectContainer<Violations> violationsContainer,
Task evaluateViolations) {
Expand Down Expand Up @@ -67,6 +69,7 @@ class FindbugsConfigurator extends CodeQualityConfigurator<FindBugs, FindBugsExt
@Override
protected void configureAndroidWithVariants(DomainObjectSet variants) {
if (configured) return
logDeprecatedMessage()

variants.all { configureVariant(it) }
variantFilter.filteredTestVariants.all { configureVariant(it) }
Expand All @@ -87,7 +90,7 @@ class FindbugsConfigurator extends CodeQualityConfigurator<FindBugs, FindBugsExt
List<File> androidSourceDirs = variant.sourceSets.collect { it.javaDirectories }.flatten()
task.description = "Run FindBugs analysis for ${variant.name} classes"
task.source = androidSourceDirs
task.classpath = variant.javaCompile.classpath
task.classpath = javaCompile(variant).classpath
task.extraArgs '-auxclasspath', androidJar
task.conventionMapping.map("classes") {
List<String> includes = createIncludePatterns(task.source, androidSourceDirs)
Expand All @@ -99,11 +102,14 @@ class FindbugsConfigurator extends CodeQualityConfigurator<FindBugs, FindBugsExt
}

private FileCollection getAndroidClasses(javaCompile, List<String> includes) {
includes.isEmpty() ? project.files() : project.fileTree(javaCompile.destinationDir).include(includes) as ConfigurableFileTree
includes.isEmpty() ? project.files() : project.fileTree(javaCompile.destinationDir).include(includes) as FileCollection
}

@Override
protected void configureJavaProject() {
if (!configured) {
logDeprecatedMessage()
}
super.configureJavaProject()
project.afterEvaluate {
project.sourceSets.each { SourceSet sourceSet ->
Expand Down Expand Up @@ -140,10 +146,10 @@ class FindbugsConfigurator extends CodeQualityConfigurator<FindBugs, FindBugsExt
}

private FileCollection createClassesTreeFrom(SourceSet sourceSet, List<String> includes) {
return sourceSet.output.classesDirs.inject(null) { ConfigurableFileTree cumulativeTree, File classesDir ->
return sourceSet.output.classesDirs.inject(null) { FileTree cumulativeTree, File classesDir ->
def tree = project.fileTree(classesDir)
.builtBy(sourceSet.output)
.include(includes) as ConfigurableFileTree
.include(includes) as FileCollection
cumulativeTree?.plus(tree) ?: tree
}
}
Expand Down Expand Up @@ -173,7 +179,6 @@ class FindbugsConfigurator extends CodeQualityConfigurator<FindBugs, FindBugsExt
}
}


private void createHtmlReportTask(String taskName) {
createTask(project, "generate${taskName.capitalize()}HtmlReport", GenerateFindBugsHtmlReport) { GenerateFindBugsHtmlReport task ->
def findbugs = project.tasks[taskName] as FindBugs
Expand All @@ -187,4 +192,13 @@ class FindbugsConfigurator extends CodeQualityConfigurator<FindBugs, FindBugsExt
private def getAndroidJar() {
"${project.android.sdkDirectory}/platforms/${project.android.compileSdkVersion}/android.jar"
}

private def logDeprecatedMessage() {
DeprecationLogger.nagUserWith(
"Novoda Static Analysis Plugin Findbugs support is deprecated.",
"This is scheduled to be removed in version 2.0",
"Please use SpotBugs instead. https://github.com/novoda/gradle-static-analysis-plugin/blob/master/docs/tools/spotbugs.md",
null
)
}
}
Loading

0 comments on commit 59e7605

Please sign in to comment.