-
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
Introduce BugCheckerRules
Refaster rule collection
#526
Conversation
|
||
/** Refaster rules related to BugChecker classes. */ | ||
@OnlineDocumentation | ||
final class BugCheckerRules { |
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.
Honestly not sure about the reach of this class 🤔
I could also limit it to BugCheckerRefactoringTestHelper
, but then it's also quite closed.
That would also impact docs and all.
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, good question. In the past we have dodged questions such as this one by locating single rules in AssortedRules
. I'll add an extra rule so that the new rule isn't feeling lonely ;)
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.
Hahaha, yeah I saw this class and hesitated, but felt like doing this was cleaner ;)
Thanks for the added rule 💪
Looks good. No mutations were possible for these changes. |
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. Suggested commit message:
Introduce `BugCheckerRules` Refaster rule collection (#526)
@@ -37,7 +37,6 @@ | |||
<dependency> | |||
<groupId>${groupId.error-prone}</groupId> | |||
<artifactId>error_prone_test_helpers</artifactId> | |||
<scope>test</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.
We don't want to pull in test dependencies at runtime; this should become provided
.
* Drop {@link BugCheckerRefactoringTestHelper#setFixChooser(FixChooser)} when set to the default | ||
* {@link FixChoosers#FIRST}. | ||
*/ | ||
static final class SetFixChooserDefault { |
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 guess that with our upcoming automated Refaster rule naming scheme this class would be named BugCheckerRefactoringTestHelperIdentity
. (Due to side-effects this isn't fully accurate, but alas.) We can extend this rule to cover .setImportOrder("static-first")
.
} | ||
|
||
BugCheckerRefactoringTestHelper testSetFixChooserDefault() { | ||
return BugCheckerRefactoringTestHelper.newInstance(StringCaseLocaleUsage.class, getClass()) |
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.
return BugCheckerRefactoringTestHelper.newInstance(StringCaseLocaleUsage.class, getClass()) | |
return BugCheckerRefactoringTestHelper.newInstance(BugChecker.class, getClass()) |
|
||
/** Refaster rules related to BugChecker classes. */ | ||
@OnlineDocumentation | ||
final class BugCheckerRules { |
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, good question. In the past we have dodged questions such as this one by locating single rules in AssortedRules
. I'll add an extra rule so that the new rule isn't feeling lonely ;)
Looks good. No mutations were possible for these changes. |
// XXX: This rule assumes that the full source code is specified as a single string, e.g. using a | ||
// text block. Support for multi-line source code input would require a `BugChecker` | ||
// implementation instead. |
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.
Right now this rule won't match, but after #198 it'll be relevant.
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 @Stephan202 💪
74a3a4d
to
68fac51
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 Javadoc tweak and rebased.
Maybe we can consider adding something for BugCheckerRefactoringTestHelper#setArgs
for the case where we pass an ImmutableList
and have only one string. Could be nicer to drop immutableList
in that case. If the setArgs
is called with multiple strings we can opt for the ImmutableList
variant. WDYT? (out of scope in any case though)
Apart from that, it looks really good 👍🏻, nice to see that it drops a few of these occurrences 😄.
Thanks for picking up @Ptijohn 🚀 !
private BugCheckerRules() {} | ||
|
||
/** | ||
* Avoid calling {@link BugCheckerRefactoringTestHelper#setFixChooser(FixChooser)} with the |
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 should update this to also account for setImportOrder
. Will propose something :).
Looks good. No mutations were possible for these changes. |
Changes LGTM 👍 W.r.t. |
68fac51
to
7e05c73
Compare
Nice, sounds like a good idea 👍🏻 . Rebased, will merge once 🟢. |
Looks good. No mutations were possible for these changes. |
BugCheckerRule
refaster rulesBugCheckerRules
Refaster rule collection
Suggested commit message: