Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Turn off UnnecessaryLambda check in tests #1210

Merged
merged 5 commits into from
Feb 4, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions changelog/@unreleased/pr-1210.v2.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
type: fix
fix:
description: Turn off UnnecessaryLambda in tests where it doesn't provide value
because there is a ubiquitous use case that is painful to fix.
links:
- https://github.com/palantir/gradle-baseline/pull/1210
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,17 @@ private static void applyToJavaProject(Project project) {
}));
});

project.getTasks().withType(JavaCompile.class).configureEach(javaCompile -> {
((ExtensionAware) javaCompile.getOptions())
.getExtensions()
.configure(ErrorProneOptions.class, errorProneOptions -> {
// Relax some checks for test code
if (errorProneOptions.isCompilingTestOnlyCode()) {
errorProneOptions.check("UnnecessaryLambda", CheckSeverity.OFF);
}
});
});

// In case of java 8 we need to add errorprone javac compiler to bootstrap classpath of tasks that perform
// compilation or code analysis. ErrorProneJavacPluginPlugin handles JavaCompile cases via errorproneJavac
// configuration and we do similar thing for Test and Javadoc type tasks
Expand Down