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 ErrorProneRuntimeClasspath check #882

Merged
merged 8 commits into from
Dec 20, 2023

Conversation

Stephan202
Copy link
Member

@Stephan202 Stephan202 commented Nov 13, 2023

❗ This PR is on top of #881. ❗

Suggested commit message:

Introduce `ErrorProneRuntimeClasspath` check (#882)

Prefer "type-safe" type references were possible, but use string
literals if the references type may not be available at runtime.

The PR is split into three commits that can best be reviewed one-by-one: the check, its automated suggestions, and manual tweaks.

@Stephan202 Stephan202 added this to the 0.15.0 milestone Nov 13, 2023
@Stephan202 Stephan202 requested a review from rickie November 13, 2023 05:19
Copy link

  • Surviving mutants in this change: 1
  • Killed mutants in this change: 43
class surviving killed
🧟tech.picnic.errorprone.bugpatterns.ErrorProneRuntimeClasspath 1 42
🎉tech.picnic.errorprone.bugpatterns.CollectorMutability 0 1

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

Copy link

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

class surviving killed
🎉tech.picnic.errorprone.bugpatterns.CollectorMutability 0 1
🎉tech.picnic.errorprone.bugpatterns.ErrorProneRuntimeClasspath 0 43

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

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

98.7% 98.7% Coverage
0.0% 0.0% Duplication

Copy link

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

class surviving killed
🎉tech.picnic.errorprone.bugpatterns.CollectorMutability 0 1
🎉tech.picnic.errorprone.bugpatterns.ErrorProneRuntimeClasspath 0 43

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

@rickie rickie force-pushed the sschroevers/canonical-class-name-usage branch from 2e67804 to 1fa3951 Compare December 5, 2023 12:55
@Stephan202 Stephan202 force-pushed the sschroevers/canonical-class-name-usage branch from 1fa3951 to 2695c4d Compare December 16, 2023 16:21
@rickie rickie force-pushed the sschroevers/canonical-class-name-usage branch from 2695c4d to 9307a2e Compare December 18, 2023 08:06
Base automatically changed from sschroevers/canonical-class-name-usage to master December 18, 2023 08:19
@Stephan202
Copy link
Member Author

I've started to resolve the conflicts here. Almost done; will finalize after some meetings.

@Stephan202 Stephan202 force-pushed the sschroevers/error-prone-runtile-classpath branch 2 times, most recently from 90f58c2 to ec1ce7e Compare December 18, 2023 14:25
@Stephan202
Copy link
Member Author

Rebased; the PR now targets master and is ready for review.

Copy link

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

class surviving killed
🎉tech.picnic.errorprone.bugpatterns.ErrorProneRuntimeClasspath 0 43

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

1 similar comment
Copy link

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

class surviving killed
🎉tech.picnic.errorprone.bugpatterns.ErrorProneRuntimeClasspath 0 43

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

@Stephan202 Stephan202 force-pushed the sschroevers/error-prone-runtile-classpath branch from ec1ce7e to 748b70f Compare December 18, 2023 17:08
@Stephan202
Copy link
Member Author

Once again rebased and resolved a conflict. @rickie and @mohamedsamehsalah I suspect this'll start happening more ;)

Copy link

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

class surviving killed
🎉tech.picnic.errorprone.bugpatterns.ErrorProneRuntimeClasspath 0 43

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

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.

Nothing stands out for me :octocat:

Is there a general rule to follow when determining if a class is available on run-time or not ?

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.

I added one more commit, in which I resorted a few things. The only place I didn't reorder is the listing in JUnitValueSource, as there the existing order seems more intuitive.

Is there a general rule to follow when determining if a class is available on run-time or not ?

Thanks for reviewing @mohamedsamehsalah! I'm not sure about a "general rule", but we use this code to check whether a given class is "currently" on the classpath. That of course doesn't mean that a class will also be on the classpath when the code is executed at a later point in time. For example, we have a bunch of provided dependencies that may not actually be "provided" by downstream users. That's why the ErrorProneRuntimeClasspath check restricts itself to types that match the CLASSPATH_TYPES regex: those are known to be dependencies of Error Prone, and thus ~guaranteed to be present. I've also added a comment making this more explicit :)

Copy link

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

class surviving killed
🎉tech.picnic.errorprone.bugpatterns.ErrorProneRuntimeClasspath 0 43

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.

Cool PR, sorry for delay in review :). 🚀

}

@Override
public Description matchMethodInvocation(MethodInvocationTree tree, VisitorState state) {
Copy link
Member

Choose a reason for hiding this comment

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

Interesting, AFAIKT we always start with the two overrides, right?

Copy link
Member Author

Choose a reason for hiding this comment

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

Indeed. Here I think the idea was to have two "groups" methods, one for each "direction", but I see now that this is not how it turned out. Will move 👍

*/
private static final Pattern CLASSPATH_TYPES =
Pattern.compile(
"com\\.google\\.common\\..*|com\\.google\\.errorprone\\.([^\\.]+(?<!TestHelper)(\\..*)?)|java\\..*");
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
"com\\.google\\.common\\..*|com\\.google\\.errorprone\\.([^\\.]+(?<!TestHelper)(\\..*)?)|java\\..*");
"com\\.google\\.common\\..*|com\\.google\\.errorprone\\.([^.]+(?<!TestHelper)(\\..*)?)|java\\..*");

Test passes without these 👀. Seems redundant.

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.

Added the commit as it can probably be improved. Other issue is not a blocker for me so already approving.

Copy link

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

class surviving killed
🎉tech.picnic.errorprone.bugpatterns.ErrorProneRuntimeClasspath 0 43

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

Prefer "type-safe" type references were possible, but use string
literals if the references type may not be available at runtime.
@Stephan202 Stephan202 force-pushed the sschroevers/error-prone-runtile-classpath branch from 59bb665 to 1ce6800 Compare December 20, 2023 13:47
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.

Rebased and added a commit.

Ideally we move this check, and some like it, to a separate Maven module, so that downstream users won't have to disable it. But that's something we can/should pick up separately.

}

@Override
public Description matchMethodInvocation(MethodInvocationTree tree, VisitorState state) {
Copy link
Member Author

Choose a reason for hiding this comment

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

Indeed. Here I think the idea was to have two "groups" methods, one for each "direction", but I see now that this is not how it turned out. Will move 👍

Copy link

sonarcloud bot commented Dec 20, 2023

Quality Gate Passed Quality Gate passed

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

2 New issues
0 Security Hotspots
98.7% Coverage on New Code
0.0% Duplication on New Code

See analysis details on SonarCloud

Copy link

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

class surviving killed
🎉tech.picnic.errorprone.bugpatterns.ErrorProneRuntimeClasspath 0 43

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

@rickie rickie merged commit d569156 into master Dec 20, 2023
16 checks passed
@rickie rickie deleted the sschroevers/error-prone-runtile-classpath branch December 20, 2023 21:14
@Stephan202 Stephan202 changed the title Introduce ErrorProneRuntimeClasspath check Introduce ErrorProneRuntimeClasspath check Feb 11, 2024
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