Skip to content

Commit

Permalink
Upgrade gradle-errorprone (#1371)
Browse files Browse the repository at this point in the history
Upgrade gradle-errorprone
  • Loading branch information
ferozco authored Jun 1, 2020
1 parent b012683 commit a63a0ad
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 24 deletions.
6 changes: 1 addition & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -124,11 +124,7 @@ Rules can be suppressed at the project level, or have their severity modified, b

```gradle
tasks.withType(JavaCompile).configureEach {
options.errorprone.errorproneArgs += ['-Xep:Slf4jLogsafeArgs:OFF']
// alternatively, using the DSL:
options.errorprone {
check('Slf4jLogsafeArgs', CheckSeverity.OFF)
}
options.errorprone.disable 'Slf4jLogsafeArgs'
}
```

Expand Down
5 changes: 5 additions & 0 deletions changelog/@unreleased/pr-1371.v2.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
type: improvement
improvement:
description: Upgrade gradle-errorprone
links:
- https://github.com/palantir/gradle-baseline/pull/1371
Original file line number Diff line number Diff line change
Expand Up @@ -197,16 +197,19 @@ private static void configureErrorProneOptions(

if (project.hasProperty(DISABLE_PROPERY)) {
log.info("Disabling baseline-error-prone for {} due to {}", project, DISABLE_PROPERY);
errorProneOptions.setEnabled(false);
errorProneOptions.getEnabled().set(false);
} else {
errorProneOptions.setEnabled(true);
errorProneOptions.getEnabled().set(true);
}

errorProneOptions.setDisableWarningsInGeneratedCode(true);
errorProneOptions.getDisableWarningsInGeneratedCode().set(true);
String projectPath = project.getProjectDir().getPath();
String separator = Pattern.quote(Paths.get(projectPath).getFileSystem().getSeparator());
errorProneOptions.setExcludedPaths(String.format(
"%s%s(build|src%sgenerated.*)%s.*", Pattern.quote(projectPath), separator, separator, separator));
errorProneOptions
.getExcludedPaths()
.set(String.format(
"%s%s(build|src%sgenerated.*)%s.*",
Pattern.quote(projectPath), separator, separator, separator));
errorProneOptions.check("CatchSpecificity", CheckSeverity.OFF);
errorProneOptions.check("UnusedVariable", CheckSeverity.OFF);
errorProneOptions.check("EqualsHashCode", CheckSeverity.ERROR);
Expand All @@ -217,7 +220,7 @@ private static void configureErrorProneOptions(
errorProneOptions.check("URLEqualsHashCode", CheckSeverity.ERROR);

// Relax some checks for test code
if (errorProneOptions.isCompilingTestOnlyCode()) {
if (errorProneOptions.getCompilingTestOnlyCode().get()) {
errorProneOptions.check("UnnecessaryLambda", CheckSeverity.OFF);
}

Expand Down Expand Up @@ -357,9 +360,9 @@ private static boolean isErrorProneRefactoring(Project project) {
}

private static boolean checkExplicitlyDisabled(ErrorProneOptions errorProneOptions, String check) {
Map<String, CheckSeverity> checks = errorProneOptions.getChecks();
Map<String, CheckSeverity> checks = errorProneOptions.getChecks().get();
return checks.get(check) == CheckSeverity.OFF
|| errorProneOptions.getErrorproneArgs().contains(String.format("-Xep:%s:OFF", check));
|| errorProneOptions.getErrorproneArgs().get().contains(String.format("-Xep:%s:OFF", check));
}

private static final class LazyConfigurationList extends AbstractList<File> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ class BaselineErrorProneIntegrationTest extends AbstractPluginTest {
buildFile << standardBuildFile
buildFile << """
tasks.withType(JavaCompile) {
options.errorprone.errorproneArgs += ['-Xep:OptionalOrElseMethodInvocation:OFF']
options.errorprone.disable 'OptionalOrElseMethodInvocation'
}
dependencies {
implementation 'org.slf4j:slf4j-api:1.7.25'
Expand Down Expand Up @@ -203,7 +203,7 @@ class BaselineErrorProneIntegrationTest extends AbstractPluginTest {
def 'compileJava does not apply patches for error-prone checks that were turned OFF via #checkConfigurationMethod'() {
def checkName = "Slf4jLogsafeArgs"
def turnOffCheck = [
(CheckConfigurationMethod.ARG): "options.errorprone.errorproneArgs += ['-Xep:$checkName:OFF']",
(CheckConfigurationMethod.ARG): "options.errorprone.disable '$checkName'",
(CheckConfigurationMethod.DSL): """
options.errorprone {
check '$checkName', net.ltgt.gradle.errorprone.CheckSeverity.OFF
Expand Down
2 changes: 1 addition & 1 deletion versions.lock
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ io.dropwizard.metrics:metrics-core:3.2.6 (1 constraints: 95108ba5)
junit:junit:4.13 (8 constraints: 88716f64)
net.bytebuddy:byte-buddy:1.10.5 (1 constraints: 410b37de)
net.bytebuddy:byte-buddy-agent:1.10.5 (1 constraints: 410b37de)
net.ltgt.gradle:gradle-errorprone-plugin:0.7.1 (1 constraints: 0a050136)
net.ltgt.gradle:gradle-errorprone-plugin:1.2.1 (1 constraints: 0605f735)
org.apache.commons:commons-lang3:3.9 (1 constraints: b004292c)
org.apache.maven:maven-artifact:2.0.5 (3 constraints: 5032579f)
org.apache.maven:maven-artifact-manager:2.0.5 (1 constraints: 310dcb20)
Expand Down
14 changes: 6 additions & 8 deletions versions.props
Original file line number Diff line number Diff line change
Expand Up @@ -15,24 +15,22 @@ org.immutables:* = 2.8.8
org.ow2.asm:asm = 7.3.1

# test deps
com.fasterxml.jackson.*:* = 2.11.0
com.github.stefanbirkner:system-rules = 1.19.0
com.netflix.nebula:nebula-test = 7.8.6
com.palantir.tokens:auth-tokens = 3.6.1
com.palantir.tritium:tritium-registry = 0.16.10
commons-lang:commons-lang = 2.6
junit:junit = 4.13
net.lingala.zip4j:zip4j = 1.3.2
com.github.stefanbirkner:system-rules = 1.19.0
net.ltgt.gradle:gradle-errorprone-plugin = 1.2.1
org.apache.commons:commons-lang3 = 3.9
commons-lang:commons-lang = 2.6
org.assertj:assertj-core = 3.16.1
org.hamcrest:hamcrest-core = 2.2
org.junit.jupiter:* = 5.6.2
org.mockito:* = 3.3.3
com.fasterxml.jackson.*:* = 2.11.0
com.palantir.tokens:auth-tokens = 3.6.1
com.palantir.tritium:tritium-registry = 0.16.10

# dependency-upgrader:OFF
# Updating to 0.8 would raise our minimum compatible version to 5.2
net.ltgt.gradle:gradle-errorprone-plugin = 0.7.1

# Don't upgrade, we will remove this in a future release.
# Users should depend on this plugin directly such that it will get updated by excavator.
com.palantir.javaformat:gradle-palantir-java-format = 0.3.9

0 comments on commit a63a0ad

Please sign in to comment.