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

Introduce UnqualifiedSuggestedFixImport check #880

Merged
merged 4 commits into from
Dec 18, 2023

Conversation

Stephan202
Copy link
Member

@Stephan202 Stephan202 commented Nov 12, 2023

Suggested commit message:

Introduce `UnqualifiedSuggestedFixImport` check (#880)

Usage of `SuggestedFix.Builder#add{,Static}Import` does not always yield
valid code, so this check suggests alternatives instead.

@Stephan202 Stephan202 added this to the 0.15.0 milestone Nov 12, 2023
Copy link

Looks good. All 20 mutations in this change were killed.

class surviving killed
🎉tech.picnic.errorprone.bugpatterns.JUnitValueSource 0 3
🎉tech.picnic.errorprone.bugpatterns.PrimitiveComparison 0 2
🎉tech.picnic.errorprone.bugpatterns.CollectorMutability 0 1
🎉tech.picnic.errorprone.bugpatterns.ImportSuggestion 0 11
🎉tech.picnic.errorprone.bugpatterns.SpringMvcAnnotation 0 3

Mutation testing report by Pitest. Review any surviving mutants by inspecting the line comments under Files changed.

@Stephan202 Stephan202 force-pushed the sschroevers/import-suggestion-check branch from c6ecb82 to b752e72 Compare November 13, 2023 05:26
@Stephan202
Copy link
Member Author

Added one more commit with some cleanup that is enabled by this check; that code will be further improved by #882 once it lands.

Copy link

sonarcloud bot commented Nov 13, 2023

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 1 Code Smell

100.0% 100.0% Coverage
0.0% 0.0% Duplication

Copy link

Looks good. All 21 mutations in this change were killed.

class surviving killed
🎉tech.picnic.errorprone.bugpatterns.JUnitValueSource 0 3
🎉tech.picnic.errorprone.bugpatterns.PrimitiveComparison 0 2
🎉tech.picnic.errorprone.bugpatterns.CollectorMutability 0 2
🎉tech.picnic.errorprone.bugpatterns.ImportSuggestion 0 11
🎉tech.picnic.errorprone.bugpatterns.SpringMvcAnnotation 0 3

Mutation testing report by Pitest. Review any surviving mutants by inspecting the line comments under Files changed.

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 two considerations :). Approving nonetheless.

return Description.NO_MATCH;
}

switch (ASTHelpers.getSymbol(tree).name.toString()) {
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
switch (ASTHelpers.getSymbol(tree).name.toString()) {
switch (ASTHelpers.getSymbol(tree).getSimpleName().toString()) {

What do we prefer in these cases?

Copy link
Member Author

Choose a reason for hiding this comment

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

We should use the method name indeed 👍

linkType = CUSTOM,
severity = WARNING,
tags = FRAGILE_CODE)
public final class ImportSuggestion extends BugChecker implements MethodInvocationTreeMatcher {
Copy link
Member

Choose a reason for hiding this comment

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

I'm thinking that ImportSuggestion sounds a bit "generic" for its goal. Maybe one doesn't directly link Suggestion to the SuggestedFix part. Perhaps the word SuggestedFix should be in there as it is specific to that.

Copy link
Member Author

Choose a reason for hiding this comment

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

Hmm, hard to come up with another name. Perhaps UnqualifiedSuggestedFixImport?

Copy link
Member

Choose a reason for hiding this comment

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

Sounds good IMO, I'll commit the change.

Copy link
Contributor

@mohamedsamehsalah mohamedsamehsalah left a comment

Choose a reason for hiding this comment

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

LGTM 👍

@Stephan202 Stephan202 force-pushed the sschroevers/import-suggestion-check branch from b752e72 to 30777b3 Compare December 16, 2023 16:32
Copy link
Member Author

@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.

Tnx for the reviews! Added a small commit.

return Description.NO_MATCH;
}

switch (ASTHelpers.getSymbol(tree).name.toString()) {
Copy link
Member Author

Choose a reason for hiding this comment

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

We should use the method name indeed 👍

linkType = CUSTOM,
severity = WARNING,
tags = FRAGILE_CODE)
public final class ImportSuggestion extends BugChecker implements MethodInvocationTreeMatcher {
Copy link
Member Author

Choose a reason for hiding this comment

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

Hmm, hard to come up with another name. Perhaps UnqualifiedSuggestedFixImport?

Copy link

Looks good. All 21 mutations in this change were killed.

class surviving killed
🎉tech.picnic.errorprone.bugpatterns.JUnitValueSource 0 3
🎉tech.picnic.errorprone.bugpatterns.PrimitiveComparison 0 2
🎉tech.picnic.errorprone.bugpatterns.CollectorMutability 0 2
🎉tech.picnic.errorprone.bugpatterns.ImportSuggestion 0 11
🎉tech.picnic.errorprone.bugpatterns.SpringMvcAnnotation 0 3

Mutation testing report by Pitest. Review any surviving mutants by inspecting the line comments under Files changed.

@Stephan202 Stephan202 changed the title Introduce ImportSuggestion check Introduce UnqualifiedSuggestedFixImport check Dec 18, 2023
Stephan202 and others added 4 commits December 18, 2023 12:39
Usage of `SuggestedFix.Builder#add{,Static}Import` does not always yield
valid code, so this check suggests alternatives instead.
@Stephan202
Copy link
Member Author

Rename LGTM. I updated the PR title and suggested commit message. Now resolving conflict.

@Stephan202 Stephan202 force-pushed the sschroevers/import-suggestion-check branch from 5a2b276 to 6ccd2a0 Compare December 18, 2023 11:41
Copy link

sonarcloud bot commented Dec 18, 2023

Quality Gate Passed Quality Gate passed

The SonarCloud Quality Gate passed, but some issues were introduced.

1 New issue
0 Security Hotspots
100.0% Coverage on New Code
0.0% Duplication on New Code

See analysis details on SonarCloud

Copy link

Looks good. All 21 mutations in this change were killed.

class surviving killed
🎉tech.picnic.errorprone.bugpatterns.JUnitValueSource 0 3
🎉tech.picnic.errorprone.bugpatterns.PrimitiveComparison 0 2
🎉tech.picnic.errorprone.bugpatterns.CollectorMutability 0 2
🎉tech.picnic.errorprone.bugpatterns.UnqualifiedSuggestedFixImport 0 11
🎉tech.picnic.errorprone.bugpatterns.SpringMvcAnnotation 0 3

Mutation testing report by Pitest. Review any surviving mutants by inspecting the line comments under Files changed.

@rickie
Copy link
Member

rickie commented Dec 18, 2023

Now resolving conflict.

Oh I missed something? 🤔

@Stephan202
Copy link
Member Author

Stephan202 commented Dec 18, 2023

Nope, unrelated conflict. Will merge :)

@rickie rickie merged commit a0b1f70 into master Dec 18, 2023
16 checks passed
@rickie rickie deleted the sschroevers/import-suggestion-check branch December 18, 2023 11:51
@rickie
Copy link
Member

rickie commented Dec 18, 2023

Haha just did it 😄.

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.

None yet

3 participants