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

Require static import of com.google.errorprone.matchers.Matchers methods #201

Merged
merged 2 commits into from
Aug 18, 2022

Conversation

oxkitsune
Copy link
Contributor

Add com.google.errorprone.matchers.Matchers to the StaticImport check, as methods from this class should always be statically imported.

Example:

- Matcher<ExpressionTree> DELEGATE = Matchers.isArrayType();
+ Matcher<ExpressionTree> DELEGATE = isArrayType();

Suggested commit message:

`StaticImport`: Add `com.google.errorprone.matchers.Matchers` candidates (#201)

Copy link
Member

@Stephan202 Stephan202 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice one!

Comment on lines 63 to 65
" // BUG: Diagnostic contains:",
" private static final Matcher<AnnotationTree> FOO = Matchers.isType(\"org.junit.jupiter.api.Test\");",
"",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I propose that we just add Matchers.isType(\"org.junit.jupiter.api.Test\") to the method m() below. (The usage doesn't need to be "realistic"; see e.g. the collector definitions.)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In fact: right now most entries aren't tested, so propose that we just drop this. (If/when we have a Pitest mutator that mutates varargs entries we should reconsider there.)

@rickie
Copy link
Member

rickie commented Aug 18, 2022

Suggested commit message:

Require static import of `com.google.errorprone.matchers.Matchers` methods (#201)

Copy link
Member

@Stephan202 Stephan202 left a 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 :)

Comment on lines 63 to 65
" // BUG: Diagnostic contains:",
" private static final Matcher<AnnotationTree> FOO = Matchers.isType(\"org.junit.jupiter.api.Test\");",
"",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In fact: right now most entries aren't tested, so propose that we just drop this. (If/when we have a Pitest mutator that mutates varargs entries we should reconsider there.)

@Stephan202 Stephan202 added this to the 0.1.1 milestone Aug 18, 2022
Copy link
Member

@rickie rickie left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only one violation in the codebase, lovely 😍.

@rickie rickie changed the title StaticImport: Add com.google.errorprone.matchers.Matchers candidates Require static import of com.google.errorprone.matchers.Matchers methods Aug 18, 2022
@rickie rickie merged commit 9ab5bbe into master Aug 18, 2022
@rickie rickie deleted the gdejong/PSM-1563 branch August 18, 2022 13:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

3 participants