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

Commit

Permalink
Merge pull request #205 from novoda/master
Browse files Browse the repository at this point in the history
Merge master back into develop
  • Loading branch information
mr-archano authored Oct 24, 2019
2 parents db201b7 + 26d042c commit b616a86
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 10 deletions.
15 changes: 7 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Gradle static analysis plugin
[![](https://ci.novoda.com/buildStatus/icon?job=gradle-static-analysis-plugin)](https://ci.novoda.com/job/gradle-static-analysis-plugin/lastSuccessfulBuild) [![](https://img.shields.io/badge/License-Apache%202.0-lightgrey.svg)](LICENSE.txt) [![Bintray](https://api.bintray.com/packages/novoda/maven/gradle-static-analysis-plugin/images/download.svg)](https://bintray.com/novoda-oss/maven/gradle-static-analysis-plugin/_latestVersion)
[![](https://ci.novoda.com/buildStatus/icon?job=gradle-static-analysis-plugin)](https://ci.novoda.com/job/gradle-static-analysis-plugin/lastSuccessfulBuild) [![](https://img.shields.io/badge/License-Apache%202.0-lightgrey.svg)](LICENSE.txt) [![Bintray](https://api.bintray.com/packages/novoda-oss/maven/gradle-static-analysis-plugin/images/download.svg)](https://bintray.com/novoda-oss/maven/gradle-static-analysis-plugin/_latestVersion)

A Gradle plugin to easily apply the same setup of static analysis tools across different Android, Java or Kotlin projects.

Expand Down Expand Up @@ -32,7 +32,7 @@ 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/iss (Duplicate Code Detection) ues/150)
* `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:0.8'
classpath 'com.novoda:gradle-static-analysis-plugin:1.0'
}
}
Expand All @@ -63,7 +63,7 @@ or from the [Gradle Plugins Repository](https://plugins.gradle.org/):

```gradle
plugins {
id 'com.novoda.static-analysis' version '0.8'
id 'com.novoda.static-analysis' version '1.0'
}
```
Expand All @@ -85,7 +85,7 @@ staticAnalysis {
}
```

This will enable all the tools with their default settings. For more advanced configurations, please refer to the
This will enable all the tools with their default settings and create `evaluateViolations` task. Running `./gradlew evaluateViolations` task will run all configured tools and print the reports to console. For more advanced configurations, please refer to the
[advanced usage](docs/advanced-usage.md) and to the [supported tools](docs/supported-tools.md) pages.

## Sample app
Expand All @@ -107,9 +107,8 @@ repositories {
You can find the latest snapshot version following this [link](https://bintray.com/novoda-oss/snapshots/gradle-static-analysis-plugin/_latestVersion).

## Roadmap
The plugin is under active development and to be considered in **beta stage**. It is routinely used by many Novoda projects and
by other external projects with no known critical issues. The API is supposed to be relatively stable, but there still may be
breaking changes as we move towards version 1.0.
The plugin is under active development. It is routinely used by many Novoda projects and
by other external projects with no known critical issues.

Future improvements can be found on the repository's
[issue tracker](https://github.com/novoda/gradle-static-analysis-plugin/issues?q=is%3Aopen+is%3Aissue+label%3Aenhancement).
23 changes: 21 additions & 2 deletions docs/incubating/custom-evaluator.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ can be provided as a closure as well:

```gradle
staticAnalysis {
evaluator { Set<Violations> allViolations ->
evaluator { Set allViolations ->
// add your evaluation logic here
}
//...
Expand All @@ -61,10 +61,29 @@ Anything that respect such contract is valid. For example, a custom evaluator mi
* Only break the build if there are errors or warnings in one specific report
* Or anything else that you can think of

For example, this custom evaluator fails the build if PMD errors are greater than five:

```gradle
evaluator { Set allViolations ->
allViolations.each { violation ->
if (violation.name == "PMD" && violation.errors > 5) {
throw new GradleException("PMD Violations exceeded")
}
}
}
```
The properties you can read from a [`Violation`][violationscode] result are:

* `name`: Possible values are: `"PMD"`, `"Checkstyle"`, `"Findbugs"`, `"KTlint"`, `"Detekt"` and `"Lint"`.
* `errors`: Represents the number of errors found during the analysis.
* `warnings`: Represents the number of warnings found during the analysis.
* `reports`: Contains a list of the generated report files.

---
Please note that the presence of an `evaluator` property will make the plugin ignore the `penalty` closure and its thresholds. If you
want to provide behaviour on top of the default [`DefaultViolationsEvaluator`][defaultviolationsevaluatorcode], you can have your own
evaluator run its logic and then delegate the thresholds counting to an instance of `DefaultViolationsEvaluator` you create.

[violationsevaluatorcode]: https://github.com/novoda/gradle-static-analysis-plugin/blob/master/plugin/src/main/groovy/com/novoda/staticanalysis/ViolationsEvaluator.groovy
[defaultviolationsevaluatorcode]: https://github.com/novoda/gradle-static-analysis-plugin/blob/master/plugin/src/main/groovy/com/novoda/staticanalysis/DefaultViolationsEvaluator.groovy
[violationscode]: https://github.com/novoda/gradle-static-analysis-plugin/blob/master/plugin/src/main/groovy/com/novoda/staticanalysis/internal/Violations.groovy
[violationscode]: https://github.com/novoda/gradle-static-analysis-plugin/blob/master/plugin/src/main/groovy/com/novoda/staticanalysis/Violations.groovy

0 comments on commit b616a86

Please sign in to comment.