-
Notifications
You must be signed in to change notification settings - Fork 133
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
create GradleTaskConfigurationAvoidance error prone check #2373
base: develop
Are you sure you want to change the base?
Conversation
Do not use gradle apis that eagerly create tasks.
Generate changelog in
|
|
||
@AutoService(BugChecker.class) | ||
@BugPattern( | ||
link = "https://github.com/palantir/gradle-baseline#baseline-error-prone-checks", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
drive-by: unless i'm missing something the README also needs to be updated with the addition of this check
link = "https://github.com/palantir/gradle-baseline#baseline-error-prone-checks", | ||
linkType = BugPattern.LinkType.CUSTOM, | ||
severity = SeverityLevel.ERROR, | ||
summary = "Forbid gradle apis that eagerly create tasks.") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can this have more detail here on what the user should do instead?
@BugPattern( | ||
link = "https://github.com/palantir/gradle-baseline#baseline-error-prone-checks", | ||
linkType = BugPattern.LinkType.CUSTOM, | ||
severity = SeverityLevel.ERROR, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we start this at a lower severity level that shows just warnings before making this fail builds? We have to give projects some time between getting a new baseline version that shows warnings and making those warnings fail the build.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure. Does anyone look at warnings though? Most projects that are affected are gradle plugins, which are probably not actively developed.
linkType = BugPattern.LinkType.CUSTOM, | ||
severity = SeverityLevel.ERROR, | ||
summary = "Forbid gradle apis that eagerly create tasks. Learn more at" | ||
+ " https://docs.gradle.org/current/userguide/task_configuration_avoidance.html") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is there more specific guidance devs should follow how to fix any of these warnings that will be thrown? Is https://docs.gradle.org/current/userguide/task_configuration_avoidance.html#sec:task_configuration_avoidance_pitfalls the best guidance that's out there and changing from eager task creation to lazy task creation?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As someone who doesn't really work on gradle plugins, I don't know the answer to this.
+ " https://docs.gradle.org/current/userguide/task_configuration_avoidance.html") | ||
@SuppressWarnings("deprecation") | ||
public final class GradleTaskConfigurationAvoidance extends BugChecker | ||
implements BugChecker.MethodInvocationTreeMatcher { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
does this also work on .gradle
files written in Groovy? The tests are only in Java, so I'm not sure if this would run on .gradle
files. Or is this only meant to run on gradle plugins written in Java?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe it does not because error prone only runs on java.
Before this PR
There is no error prone check to prevent usages of these gradle apis which can make gradle commands unnecessarily slow. Some of the apis are also very likely to be mistakenly used.
After this PR
==COMMIT_MSG==
Create GradleTaskConfigurationAvoidance error prone check to prevent
eager task creation.
==COMMIT_MSG==
Possible downsides?
None.