error-prone

Configurable Lint and Error-Prone checker alternatives for @CheckReturnValue

License

License

Categories

Categories

Error Prone Application Testing & Monitoring Code Analysis config Application Layer Libs Configuration
GroupId

GroupId

io.sweers.configurablecheckreturnvalue
ArtifactId

ArtifactId

error-prone
Last Version

Last Version

0.1.1
Release Date

Release Date

Type

Type

jar
Description

Description

error-prone
Configurable Lint and Error-Prone checker alternatives for @CheckReturnValue
Project URL

Project URL

https://github.com/ZacSweers/configurable-checkreturnvalue/
Source Code Management

Source Code Management

https://github.com/ZacSweers/configurable-checkreturnvalue/

Download error-prone

How to add to project

<!-- https://jarcasting.com/artifacts/io.sweers.configurablecheckreturnvalue/error-prone/ -->
<dependency>
    <groupId>io.sweers.configurablecheckreturnvalue</groupId>
    <artifactId>error-prone</artifactId>
    <version>0.1.1</version>
</dependency>
// https://jarcasting.com/artifacts/io.sweers.configurablecheckreturnvalue/error-prone/
implementation 'io.sweers.configurablecheckreturnvalue:error-prone:0.1.1'
// https://jarcasting.com/artifacts/io.sweers.configurablecheckreturnvalue/error-prone/
implementation ("io.sweers.configurablecheckreturnvalue:error-prone:0.1.1")
'io.sweers.configurablecheckreturnvalue:error-prone:jar:0.1.1'
<dependency org="io.sweers.configurablecheckreturnvalue" name="error-prone" rev="0.1.1">
  <artifact name="error-prone" type="jar" />
</dependency>
@Grapes(
@Grab(group='io.sweers.configurablecheckreturnvalue', module='error-prone', version='0.1.1')
)
libraryDependencies += "io.sweers.configurablecheckreturnvalue" % "error-prone" % "0.1.1"
[io.sweers.configurablecheckreturnvalue/error-prone "0.1.1"]

Dependencies

test (6)

Group / Artifact Type Version
com.google.guava : guava jar 27.0.1-jre
com.google.errorprone : error_prone_test_helpers jar 2.3.2
com.google.truth : truth jar 0.42
junit : junit jar 4.13-beta-2
org.mockito : mockito-core jar 1.9.5
org.assertj : assertj-core jar 3.11.1

Project Modules

There are no modules declared in this project.

Configurable CheckReturnValue

Build Status

Configurable Lint and Error-Prone alternative checkers for @CheckReturnValue.

Integration

Lint

(For Gradle)

For Android Java/Kotlin projects, the lint should automatically be included just by using the lintChecks configuration For plain Java/Kotlin projects, you'll need to apply the com.android.lint plugin first

Maven Central

// Only if not an Android project
apply plugin: 'com.android.lint'

dependencies {
  lintChecks 'io.sweers.configurablecheckreturnvalue:lint:x.y.z'
}

By default, a common set of known CheckReturnValue-esque annotations will be used to match the standard Lint CheckReturn detector. To configure a custom set, you can define them with a :-delimited string of fully qualified class names or simple names via configurableCheckReturnValue.customAnnotations property in the root gradle.properties file. These override the default set.

If you want to use the standard set but just exclude some, you can define them as a :-delimited string of fully qualified class names via configurableCheckReturnValue.excludeAnnotations.

# gradle.properties
configurableCheckReturnValue.customAnnotations=my.custom.annotation.CheckReturn:another.annotation.CheckReturnTwo
configurableCheckReturnValue.excludeAnnotations=some.excluded.CheckReturnAnnotation

Error Prone

Gradle, using net.ltgt.errorprone plugin:

Maven Central

dependencies {
  errorprone 'io.sweers.configurablecheckreturnvalue:error-prone:x.y.z'
}

By default, a common set of known CheckReturnValue-esque annotations will be used to match the standard Error-Prone CheckReturnValue checker, as well as fuzzy matching on any annotation with simple name CheckReturnValue. To configure a custom set, you can define them with a :-delimited string of fully qualified class names or simple names via CustomAnnotations. These override the default set.

If you want to use the standard set but just exclude some, you can define them as a :-delimited string of fully qualified class names or simple names via ExcludeAnnotations.

For Java projects:

import net.ltgt.gradle.errorprone.CheckSeverity

def customAnnotations = [
    "my.custom.annotation.CheckReturn"
]
def excludeAnnotations = [
    "some.excluded.CheckReturnAnnotation"
]
tasks.withType(JavaCompile).configure {
  check("ConfigurableCheckReturnValue", CheckSeverity.ERROR)
  options.errorprone.option("ConfigurableCheckReturnValue:CustomAnnotations", customAnnotations.join(":"))
  options.errorprone.option("ConfigurableCheckReturnValue:ExcludeAnnotations", excludeAnnotations.join(":"))
}

For Android projects:

import net.ltgt.gradle.errorprone.CheckSeverity

def customAnnotations = [
  "my.custom.annotation.CheckReturn"
]
def excludeAnnotations = [
  "some.excluded.CheckReturnAnnotation"
]
// Use `libraryVariants` for com.android.library, `applicationVariants` for com.android.application
android.(libraryVariants|applicationVariants).all { variant ->
  variant.javaCompileProvider.configure {
    options.errorprone {
      check("ConfigurableCheckReturnValue", CheckSeverity.ERROR)
      options.errorprone.option("ConfigurableCheckReturnValue:CustomAnnotations", customAnnotations.join(":"))
      options.errorprone.option("ConfigurableCheckReturnValue:ExcludeAnnotations", excludeAnnotations.join(":"))
    }
  }
}

Snapshots of the development version are available in Sonatype's snapshots repository.

License

Copyright (C) 2018 Zac Sweers

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

Versions

Version
0.1.1
0.1.0