-
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
Emit website link along with Refaster refactor suggestions #255
Conversation
// specify an optional URL pattern.) | ||
// XXX: Replace only the first `$`. | ||
// XXX: Review URL format. Currently produced format: | ||
// https://error-prone.picnic.tech/refastertemplates/OptionalTemplates#OptionalOrElseThrow |
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.
This URL looks great 😍 FYI @oxkitsune for the appropriate anchors to use.
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.
Added a commit with some early thoughts about supporting custom annotations on Refaster template. Code is very rough, but I can see in a debugger that this works at least in principle.
@rickie We could also use this annotations for more fine-grained filtering, e.g. based on whether a property is behavior preserving.
@oxkitsune these annotations could be used for documentation generation :)
@@ -0,0 +1,12 @@ | |||
package tech.picnic.errorprone.refaster.annotation; |
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.
We might want to give the package tech.picnic.errorprone.refaster.util
a better name. Maybe .matchers
.
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'm not sure I agree with that. We can introduce a .matchers
but not all things would go in there. The SourceCode
and JavaKeywords
are really just utils IMO.
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.
Ah, I see I was looking in the wrong place. I was confused because of the name TemplateCollection
. Yes you are absolutely right, we should rename this. Can be part of this PR right? I'll do it anyway, if you think it should be separate we can move the commit out anyways.
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.
Filed: #267
...ter-support/src/main/java/tech/picnic/errorprone/refaster/annotation/TemplateCollection.java
Outdated
Show resolved
Hide resolved
b5d73cb
to
3e47909
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.
A few open points remain, but I don't expect the over-all structure of the PR to change much. So reviews are welcome.
|
||
/** Refaster templates related to expressions dealing with {@link Optional}s. */ | ||
@OnlineDocumentation |
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 idea is that we add this annotation to each Refaster template collection in this repository.
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.
But let's do that in a follow-up PR right?
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.
Either-or. (As in: we drop it here, or add it to the others. I'm fine with deferring in order to keep the PR smaller. Ideally we automate the task, perhaps reusing some of the code I'm writing in this context. TBD.)
@@ -63,7 +66,7 @@ boolean after(Optional<T> optional) { | |||
} | |||
} | |||
|
|||
/** Prefer {@link Optional#orElseThrow()} over the less explicit {@link Optional#get()}. */ | |||
@Description("Prefer `Optional#orElseThrow()` over the less explicit `Optional#get()`") |
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.
@oxkitsune (once applied more widely) these annotations can be used for the website generation.
/** A simple template for testing purposes, having several custom annotations. */ | ||
@Description("A custom description about matching single-char strings") | ||
@OnlineDocumentation | ||
@Severity(WARNING) |
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 default severity is SUGGESTION
. @oxkitsune this @Severity
annotation can also be used for website generation. (Not yet sure whether we have (m)any Refaster templates that deserve a severity override, but still.)
ac2b91e
to
73c5cb3
Compare
Rebased; PR now targets #267. |
73c5cb3
to
3f3cf3c
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.
Added a commit with a proposal to solve the XXXs related to -XepAllSuggestionsAsWarnings
, PTAL. I think we can mark this as ready for review because most XXXs are now picked up.
The XXX about testing AnnotatedCompositeCodeTransformer
I want to propose to defer. Especially because we need this logic for the other PRs. We can later add the test for sure.
/** | ||
* Describes the severity of a Refaster template or group of Refaster templates. | ||
* | ||
* <p>The default severity is {@link SeverityLevel#SUGGESTION}. Annotations on nested classes |
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.
It's a bit unnatural that we say the default is SeverityLevel#SUGGESTION
but below we do not specify that.
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.
Although, looking at the other code, I can see why it is. That wasn't my point :).
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.
Yeah, there are some delicate things going on here. I'll push a proposal.
private static String extractRefasterTemplateName(Description description) { | ||
String message = description.getRawMessage(); | ||
int index = message.indexOf(':'); | ||
checkState(index >= 0, "String '%s' does not contain character '%s'", message, ':'); |
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.
checkState(index >= 0, "String '%s' does not contain character '%s'", message, ':'); | |
checkState(index >= 0, "String '%s' does not contain character ':', message); |
Can't we simplify this? Will push the proposal.
// XXX: Can we find a better name for thi class? | ||
// XXX: Use `@AutoValue`? | ||
// XXX: Test this class directly. (Right now it's only indirectly tested through `RefasterTest`.) | ||
final class AnnotatedCompositeCodeTransformer implements CodeTransformer, Serializable { |
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.
Hmm, will throw in one other idea for now: AugmentedCompositeCodeTransformer
. We use augment
in this context a few times. It's hard to come up with a better name I'd say. So will probably remove that XXX as I like the current name.
Description description, Optional<SeverityLevel> severityOverride) { | ||
return Description.builder( | ||
description.position, | ||
"Refaster Rule", |
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.
"Refaster Rule", | |
"RefasterRule", |
👀 All checks are without space, so would propose to do the same here TBH.
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.
That space is there very much on purpose:
The replacement check name ("Refaster Template") is chosen such that it is guaranteed not to match any canonical bug checker name (as that could cause {@link VisitorState#reportMatch(Description)}} to override the reported severity).
I'll make it more explicit.
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.
Currently the value (Refaster Rule) does not match the documentation (Refaster Template). Changed the documentation to the former.
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.
We use both Refaster Rule
and Refaster Template
a lot. Not really sure if we need to settle on using one of the two.
Now it depends a bit on the situation, I feel.
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.
We use both Refaster Rule
and Refaster Template
a lot. Not really sure if we need to settle on using one of the two.
Now it depends a bit on the situation, I feel.
To be honest, I try to only use the word "template" to avoid confusing and make people use the same words. I'd be okay with switching everything to template. WDYT?
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't find a clear distinction between a rule and a template in the original documentation either. I'm happy with both (slightly prefer template, given the annotations), as long as we are consistent 👍
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.
Yeah, this has bugged me for a while as well. I suspect it's more correct to call "the whole thing" a Refaster rule, since (a) it's represented by the RefasterRule
type and (b) the individual methods are called before/after templates.
So that would make "Refaster Rule" correct for this code.
That still leaves many incorrect usages elsewhere in the code base... maybe something for a separate PR?
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.
Yea let's defer to another PR.
I'm also in camp let's be consistent as @Badbond is haha. I bet you are as well.
It makes slightly more sense to say "lets add a rule for that" instead of "lets add a template for that".
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.
Not done reviewing, flushing what I have so far.
.expectErrorMessage( | ||
"StringOfSizeZeroTemplate", | ||
containsPattern( | ||
"\\[Refaster Rule\\] FooTemplates\\.StringOfSizeZeroTemplate: Refactoring opportunity\\s+.+\\s+null")) |
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.
Did you perhaps see where the null
is coming from? We can look into that later :).
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.
Yeah, it's due to this code calling this method. Could be fixed by unconditionally calling linkTextForDiagnostic
, and then discarding the result if null
. Wanna open a PR upstream? :)
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.
According to the Description.Builder
, link
is Nullable
. We could instead of an empty string pass in null
at AnnotatedCompositeCodeTransformer#augmentDescription
if we don't have a url
, causing this to not appear at all (verified this). This might be nice to do in this transition period until all checks and templates have a link. Got a commit ready if we wish to do this.
Edit: pushed after having it discussed offline with @Stephan202. PTAL and feel free to tweak.
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.
Wanna open a PR upstream? :)
Yes that sounds good. Would be a nice improvement.
Will write it down and do after the EPS OSS-ing journey 😛.
/** | ||
* Describes the severity of a Refaster template or group of Refaster templates. | ||
* | ||
* <p>The default severity is {@link SeverityLevel#SUGGESTION}. Annotations on nested classes |
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.
Although, looking at the other code, I can see why it is. That wasn't my point :).
refaster-support/src/main/java/tech/picnic/errorprone/refaster/annotation/package-info.java
Outdated
Show resolved
Hide resolved
.../src/main/java/tech/picnic/errorprone/refaster/plugin/AnnotatedCompositeCodeTransformer.java
Outdated
Show resolved
Hide resolved
790638e
to
1f4275a
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 added a commit.
import tech.picnic.errorprone.refaster.annotation.OnlineDocumentation; | ||
import tech.picnic.errorprone.refaster.annotation.Severity; | ||
|
||
// XXX: Test this class directly. (Right now it's only indirectly tested through `RefasterTest`.) |
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 see the comment was dropped, but the naming question is still open for me (I don't quite like the current name).
int index = message.indexOf(':'); | ||
checkState(index >= 0, "String '%s' does not contain character ':'", message); |
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.
Maybe we don't even need to mention :
.
Optional<Method> isSuggestionsAsWarningsMethod = | ||
Arrays.stream(errorProneOptions.getClass().getDeclaredMethods()) | ||
.filter(m -> Modifier.isPublic(m.getModifiers())) | ||
.filter(m -> m.getName().equals("isSuggestionsAsWarnings")) | ||
.findFirst(); | ||
return isSuggestionsAsWarningsMethod.isPresent() |
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.
This is classpath-invariant, so we should execute this code only once.
refaster-runner/pom.xml
Outdated
<!-- XXX: This `runtime` scope declaration ensures that | ||
`AnnotatedCompositeCodeTransformer` instances can be deserialized. | ||
It also makes our custom Refaster annotations available. The issue | ||
with this setup is that `refaster-compiler` has *non*-`provided` | ||
dependency declarations on Error Prone, as it should be able to | ||
function independently. This could cause classpath issues for users | ||
of *this* module. Consider moving | ||
`AnnotatedCompositeCodeTransformer` back to `refaster-support`. --> | ||
<scope>runtime</scope> |
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.
Note to self: fix this before merging the PR.
/* { arguments, expectedSeverities } */ | ||
|
||
Stream<Arguments> forkTestCases = | ||
isBuiltWithErrorProneFork() |
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.
"Built" is past tense, while this is about the current classpath :)
private static boolean isBuiltWithErrorProneFork() { | ||
Class<?> clazz; | ||
try { | ||
clazz = | ||
Class.forName( | ||
"com.google.errorprone.ErrorProneOptions", | ||
/* initialize= */ false, | ||
Thread.currentThread().getContextClassLoader()); | ||
} catch (ClassNotFoundException e) { | ||
throw new IllegalStateException("Can't load `ErrorProneOptions` class", e); | ||
} | ||
return Arrays.stream(clazz.getDeclaredMethods()) | ||
.filter(m -> Modifier.isPublic(m.getModifiers())) | ||
.anyMatch(m -> m.getName().equals("isSuggestionsAsWarnings")); | ||
} |
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.
Let's reuse the other code; will push a proposal.
refaster-support/src/main/java/tech/picnic/errorprone/refaster/annotation/package-info.java
Outdated
Show resolved
Hide resolved
|
||
/** Refaster templates related to expressions dealing with {@link Optional}s. */ | ||
@OnlineDocumentation |
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.
Here and below: don't forget to revert the changes in this file, assuming we introduce the annotations separately.
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.
Added a commit.
/** | ||
* Describes the severity of a Refaster template or group of Refaster templates. | ||
* | ||
* <p>The default severity is {@link SeverityLevel#SUGGESTION}. Annotations on nested classes |
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.
Yeah, there are some delicate things going on here. I'll push a proposal.
Description description, Optional<SeverityLevel> severityOverride) { | ||
return Description.builder( | ||
description.position, | ||
"Refaster Rule", |
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.
That space is there very much on purpose:
The replacement check name ("Refaster Template") is chosen such that it is guaranteed not to match any canonical bug checker name (as that could cause {@link VisitorState#reportMatch(Description)}} to override the reported severity).
I'll make it more explicit.
.expectErrorMessage( | ||
"StringOfSizeZeroTemplate", | ||
containsPattern( | ||
"\\[Refaster Rule\\] FooTemplates\\.StringOfSizeZeroTemplate: Refactoring opportunity\\s+.+\\s+null")) |
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.
Yeah, it's due to this code calling this method. Could be fixed by unconditionally calling linkTextForDiagnostic
, and then discarding the result if null
. Wanna open a PR upstream? :)
import tech.picnic.errorprone.refaster.annotation.OnlineDocumentation; | ||
import tech.picnic.errorprone.refaster.annotation.Severity; | ||
|
||
// XXX: Can we find a better name for this class? `CompositeAnnotatedCodeTransformer`, ...? |
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 missed this comment. I think I did at some point also ponder AugmentedCompositeCodeTransformer
. Might still be the way to go; will add it to the list.
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.
Flushing first part of review and added a commit.
Description description, Optional<SeverityLevel> severityOverride) { | ||
return Description.builder( | ||
description.position, | ||
"Refaster Rule", |
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.
Currently the value (Refaster Rule) does not match the documentation (Refaster Template). Changed the documentation to the former.
* VisitorState#reportMatch(Description)} will override the reported severity only if this bug | ||
* checker's severity was explicitly configured. |
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.
For my understanding (and for future readers), we currently do not support overriding the severity level of a set of Refaster templates, right? This would require the parsing of a new flag.
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.
Indeed, one can only override the default for all templates. I do see now that this sentence is no longer correct (it reflects an earlier understanding I had of the situation), so will push a tweak.
.expectErrorMessage( | ||
"StringOfSizeZeroTemplate", | ||
containsPattern( | ||
"\\[Refaster Rule\\] FooTemplates\\.StringOfSizeZeroTemplate: Refactoring opportunity\\s+.+\\s+null")) |
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.
According to the Description.Builder
, link
is Nullable
. We could instead of an empty string pass in null
at AnnotatedCompositeCodeTransformer#augmentDescription
if we don't have a url
, causing this to not appear at all (verified this). This might be nice to do in this transition period until all checks and templates have a link. Got a commit ready if we wish to do this.
Edit: pushed after having it discussed offline with @Stephan202. PTAL and feel free to tweak.
* | ||
* @param options The currently active Error Prone options. | ||
* @return {@code true} iff {@link #isErrorProneForkAvailable() the Error Prone fork is available} | ||
* and the aforementioned flag is configured. |
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.
* and the aforementioned flag is configured. | |
* and the aforementioned flag is set. |
In line with the subject, otherwise it is a bit ambigious as this could also indicate one can configure the flag.
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.
Tnx for the review so far @Badbond! Added a small commit :)
.map( | ||
urlPattern -> | ||
urlPattern.replace(TOP_LEVEL_CLASS_URL_PLACEHOLDER, nameComponents.next())) | ||
.map( | ||
urlPattern -> | ||
urlPattern.replace( | ||
NESTED_CLASS_URL_PLACEHOLDER, Iterators.getNext(nameComponents, ""))); |
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.
Since the variables have a small scope anyway: let's rename to url
and avoid the line wrapping.
* VisitorState#reportMatch(Description)} will override the reported severity only if this bug | ||
* checker's severity was explicitly configured. |
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.
Indeed, one can only override the default for all templates. I do see now that this sentence is no longer correct (it reflects an earlier understanding I had of the situation), so will push a tweak.
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.
Sooo, the open points for now (that are a MUST before merging) are:
- Settle on a name for the
AnnotatedCompositeCodeTransformer
. - Revert the changes in
OptionalTemplates
. - Fixing the
runtime
scope declaration ofrefaster-compiler
.
For me a review of the latest commits and RefasterRuleCompilerTaskListener
left.
Description description, Optional<SeverityLevel> severityOverride) { | ||
return Description.builder( | ||
description.position, | ||
"Refaster Rule", |
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.
We use both Refaster Rule
and Refaster Template
a lot. Not really sure if we need to settle on using one of the two.
Now it depends a bit on the situation, I feel.
Description description, Optional<SeverityLevel> severityOverride) { | ||
return Description.builder( | ||
description.position, | ||
"Refaster Rule", |
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.
We use both Refaster Rule
and Refaster Template
a lot. Not really sure if we need to settle on using one of the two.
Now it depends a bit on the situation, I feel.
To be honest, I try to only use the word "template" to avoid confusing and make people use the same words. I'd be okay with switching everything to template. WDYT?
424d772
to
49f1d00
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.
Another intermittent review for posting the following suggested commit message. Feel free to tweak/suggest an alternative. Slightly different than from 0561c37 given that we have changed more here.
Suggested commit message:
Augment `Description`s of Refaster rule matches (#255)
By emitting a website link, if available, and reporting the matching Refaster
rule in the description's message rather than its check name. Additionally, it
is now possible to assign a custom severity to Refaster rules and to override
the severity of matches for all Refaster rules by passing
`-Xep:Refaster:[SEVERITY]`.
* A {@link CompositeCodeTransformer} that can be augmented with annotations. | ||
* | ||
* <p>The content of the annotations can be used for enriched compilation warnings or errors, and | ||
* documentation purposes. |
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.
Thanks for the Javadocs @rickie! I jotted something down in a private note when I had a sudden brainpulse a while ago:
A composite code transformer that enhances the description of matches from Refaster rules based on optionally available annotations.
Placing it here to see if (part of it) might be nice to still adopt. Note, ^ is more focused around current functionality and Refaster rules specifically. Feel free to consider s/enhances/augments/
and s/rules/templates/
.
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.
It's a good one, augmenting the description of matches is indeed the two examples explained in one go. Will push a change :).
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.
While debugging, I got a better understanding of how the annotations are retrieved and passed down. As such, I understood that the annotations available inside this AnnotatedCompositeCodeTransformer
are (per annotation type) of the first available parent class (i.e. of one of the encompassing parent template collections) of the RefasterRule
CodeTransformer
s herein. Here, we augment descriptions on matches per respective CodeTransformer
based on annotations available on said CodeTransformer
and otherwise use the encompassing annotations mentioned above (not that this class knows, it just has been given a list of fallback annotations to rely upon).
As such, I'm wondering whether we should clarify this Javadoc accordingly as 'the annotations' is currently a bit ambigious over which annotations in the context of (Composite
) CodeTransformer
s we are talking about. Committed a suggestion, PTAL. Not entirely happy with 'as a fallback' but was less happy with words such as 'otherwise' or 'default'.
Also not sure if we should mention the annotations in the summary given the class' name, but left it for now. I did change the summary line as semantically it was saying that the annotations could augment this CompositeCodeTransformer
. Also removed the XXX for lack of a better alternative on my side too.
Feel free to revert or change if I did not get the design of this class correctly 😅
2837464
to
ea33a0b
Compare
Rebased; PR targets default branch again. |
Tweaked suggested commit message (CC @Badbond):
|
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.
Thanks @rickie for the rebasing and renaming efforts! 👍
I am considering not applying @OnlineDocumentation
on two Refaster rule collections. WDYT?
@@ -72,6 +73,7 @@ | |||
// XXX: As-is these rules do not result in a complete migration: | |||
// - Expressions containing comments are skipped due to a limitation of Refaster. | |||
// - Assertions inside lambda expressions are also skipped. Unclear why. | |||
@OnlineDocumentation |
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.
Assuming these are migration rules, do we wish to keep these enabled by default in the future? Otherwise it might be nice not to add @OnlineDocumentation
now where we can filter this one out when we start extracting these classes in docgen.
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.
Hmm, this one is likely to trigger if not explicitly disabled, so perhaps having the link would be nice? (I'm not too worried about breaking the URL later on, TBH.)
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.
Alright. Let's revisit this then when we probably have the functionality to exclude certain collections/specific rules 👍.
|
||
/** Refaster rule collection to validate reporting of a match occurring in an unexpected place. */ | ||
@OnlineDocumentation |
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.
Are we expecting this to be documented on the website? Otherwise we should remove this annotation, I think.
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.
Nice catch! Will drop.
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.
That said, the script should anyway restrict itself to */main/*
, since refaster-runner/src/test/java/tech/picnic/errorprone/refaster/runner/FooRules.java
does need the documentation, but should be ignored regardless :)
Slightly tweaked suggested commit message. |
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.
Added a commit. Commit tweak LGTM; reflowed it.
@@ -12,6 +12,11 @@ final class CodeTransformersTest { | |||
@Test |
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.
☝️ likely got lost during conflict resolution, but there was also a small tweak here.
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.
Odd; this comment should have been flushed during the previous review round.
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.
Ah yeah there was something there. I think I got it wrong during rebasing haha.
|
||
/** Refaster rule collection to validate reporting of a match occurring in an unexpected place. */ | ||
@OnlineDocumentation |
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.
Nice catch! Will drop.
|
||
/** Refaster rule collection to validate reporting of a match occurring in an unexpected place. */ | ||
@OnlineDocumentation |
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.
That said, the script should anyway restrict itself to */main/*
, since refaster-runner/src/test/java/tech/picnic/errorprone/refaster/runner/FooRules.java
does need the documentation, but should be ignored regardless :)
@@ -72,6 +73,7 @@ | |||
// XXX: As-is these rules do not result in a complete migration: | |||
// - Expressions containing comments are skipped due to a limitation of Refaster. | |||
// - Assertions inside lambda expressions are also skipped. Unclear why. | |||
@OnlineDocumentation |
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.
Hmm, this one is likely to trigger if not explicitly disabled, so perhaps having the link would be nice? (I'm not too worried about breaking the URL later on, TBH.)
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.
Nothing more from my side! Let's go! 🚀
I've got one more thing to consider. I think it could be smart to drop the |
Due to connection in the metro I think my previous comment didn't get through; Latest changes LGTM! Tweaked the suggested commit message as there was some duplication in there 👀. WDYT? |
Works for me 👍
Ah, so it was not just me. Connectivity was worse today than generally.
Tnx; looks like that was my fault. |
Added a commit to drop it. |
❗
This PR is on top of #286❗Work in progress; see this thread for context.