Skip to content

Commit

Permalink
Comments
Browse files Browse the repository at this point in the history
  • Loading branch information
pkoenig10 committed Jan 14, 2022
1 parent 9c19d27 commit df3539d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ public final class BaselineErrorProne implements Plugin<Project> {
private static final String PROP_ERROR_PRONE_APPLY = "errorProneApply";
private static final String PROP_REFASTER_APPLY = "refasterApply";
private static final String DISABLE_PROPERTY = "com.palantir.baseline-error-prone.disable";
private static final String ENABLE_PROPERTY = "com.palantir.baseline-error-prone.enable";

@Override
public void apply(Project project) {
Expand Down Expand Up @@ -209,11 +208,7 @@ private static void configureErrorProneOptions(
BaselineErrorProneExtension errorProneExtension,
JavaCompile javaCompile,
ErrorProneOptions errorProneOptions) {

if (project.hasProperty(ENABLE_PROPERTY)) {
errorProneOptions.getEnabled().set(true);
} else if (project.hasProperty(DISABLE_PROPERTY) || IntellijSupport.isRunningInIntellij()) {
log.info("Disabling baseline-error-prone for {}", project);
if (isDisabled(project)) {
errorProneOptions.getEnabled().set(false);
}

Expand Down Expand Up @@ -395,6 +390,15 @@ private static boolean isErrorProneRefactoring(Project project) {
return project.hasProperty(PROP_ERROR_PRONE_APPLY);
}

private static boolean isDisabled(Project project) {
Object disable = project.findProperty(DISABLE_PROPERTY);
if (disable == null) {
return IntellijSupport.isRunningInIntellij();
} else {
return !disable.equals("false");
}
}

private static boolean checkExplicitlyDisabled(ErrorProneOptions errorProneOptions, String check) {
Map<String, CheckSeverity> checks = errorProneOptions.getChecks().get();
return checks.get(check) == CheckSeverity.OFF
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ class BaselineErrorProneIntegrationTest extends AbstractPluginTest {
file('src/main/java/test/Test.java') << invalidJavaFile

then:
BuildResult result = with('compileJava', '-Pcom.palantir.baseline-error-prone.disable', '-Didea.active=true', '-Pcom.palantir.baseline-error-prone.enable').buildAndFail()
BuildResult result = with('compileJava', '-Pcom.palantir.baseline-error-prone.disable=false', '-Didea.active=true').buildAndFail()
result.task(":compileJava").outcome == TaskOutcome.FAILED
result.output.contains("[ArrayEquals] Reference equality used to compare arrays")
}
Expand Down

0 comments on commit df3539d

Please sign in to comment.