-
Notifications
You must be signed in to change notification settings - Fork 39
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
When variables are assigned then returned, instead directly return them #1
Conversation
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.
The build fails because tests are missing. See RefasterCheckTest#TEMPLATE_GROUPS
and the input/output files under src/test/resources/tech/picnic/errorprone/bugpatterns
.
Really cool :)
error-prone-contrib/src/main/java/tech/picnic/errorprone/refastertemplates/MethodTemplates.java
Outdated
Show resolved
Hide resolved
I created tests, not sure why build still fails:
|
Curious! Will have a look. |
Ah, I see. It tries to download the fork from open-source repos, but it doesn't exist there. (Well, it exists on Jitpack, but that repo isn't configured.) I'll try to fix that, though I suspect this is going to bite me in the butt once we want to release to Maven Central. A concern for later. Stay tuned :) |
Testing on branch |
cdd727b
to
ba99b76
Compare
The build now passes on |
Main build passed, PR build didn't. Restarting the later with cleared caches. Can't explain this yet. |
Success 🎉. Next up: review the PR 😄. Might do this tomorrow; will want to make some OCD changes for consistency with the existing code. But it looks good :) |
I was wondering: I included a few cases in which I expect the script not to change anything. Do these tests even work? Doesn't it only check for any change, not all cases? |
ba99b76
to
84cd332
Compare
Generally I don't include such test cases, but yes they do work, because in the output file they're unchanged, as required. I rebased and added a commit with some renaming and shuffling to better match the "style" used by the other tests. I have one concern about merging this PR, though: there are a small number of cases where we would not want to apply this rule. An example from diff --git a/atom/targetedcontent-service/targetedcontent-service-logic/src/main/java/com/picnic/targetedcontent/logic/repository/impl/TargetedContentRepositoryImpl.java b/atom/targetedcontent-service/targetedcontent-service-logic/src/main/java/com/picnic/targetedcontent/logic/repository/impl/TargetedContentRepositoryImpl.java
index 1d47d84d48..4375c89b9a 100644
--- a/atom/targetedcontent-service/targetedcontent-service-logic/src/main/java/com/picnic/targetedcontent/logic/repository/impl/TargetedContentRepositoryImpl.java
+++ b/atom/targetedcontent-service/targetedcontent-service-logic/src/main/java/com/picnic/targetedcontent/logic/repository/impl/TargetedContentRepositoryImpl.java
@@ -91,10 +91,7 @@ public final class TargetedContentRepositoryImpl implements TargetedContentRepos
.as(TargetedContent.class))
.map(
tc -> {
- @SuppressWarnings("unchecked")
- TargetedContent<TargetedContentPayload> content =
- (TargetedContent<TargetedContentPayload>) tc;
- return content;
+ return (TargetedContent<TargetedContentPayload>) tc;
});
}
} Here the I'll sit on this a bit longer. |
I'm quite surprised that it just drops such annotations. The stuff Error Prone can and cannot do is still a bit magic to me. It would indeed be interesting to look into implementing such logic ourselves. |
84cd332
to
9252e4a
Compare
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.
Rebased and resolved conflicts. @SimonBaars are you interested in proposing such a BugPattern
?
9252e4a
to
5dda918
Compare
5dda918
to
a5e226f
Compare
Decided to pick this one up myself ;). See #513. |
Was feeling adventurous ;-)