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

Add @SuppressWarnings("all") to stop scanning tool complaints #52

Merged
merged 2 commits into from
Dec 18, 2023

Conversation

timtebeek
Copy link
Contributor

@timtebeek timtebeek self-assigned this Dec 18, 2023
@timtebeek timtebeek added the enhancement New feature or request label Dec 18, 2023
@timtebeek
Copy link
Contributor Author

@Stephan202 When running this branch against error-prone-support I do see a rather curious error

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.10.1:testCompile (default-testCompile) on project refaster-runner: Compilation failure: Compilation failure: 
[ERROR] /home/tim/Documents/workspace/timtebeek/error-prone-support/refaster-runner/target/generated-test-sources/test-annotations/tech/picnic/errorprone/refaster/runner/FooRulesRecipes.java:[25,18] cannot find symbol
[ERROR]   symbol:   class Generated
[ERROR]   location: package javax.annotation
  1. somehow the RefasterTemplateProcessor configured in error-prone-contrib is active on refaster-runner
  2. the javax.annotation.Generated annotation can not be found there; should we use a different one?

Any ideas there? Wouldn't want to release a version that breaks things on error-prone-support, or requires undesired changes there.

@Stephan202
Copy link
Contributor

somehow the RefasterTemplateProcessor configured in error-prone-contrib is active on refaster-runner

Yeah, that's because I moved the annotation processor declaration :)

the javax.annotation.Generated annotation can not be found there; should we use a different one?

Indeed, javax.annotation.Generated is no longer present on newer JDKs, where it's replaced with javax.annotation.processing.Generated (since JDK 9). IIRC this had something to do with splitting up the javax.annotation package to comply with the module system. Since you also target JDK 8, this can get a bit messy. Two other options:

  1. Define a custom @Generated annotation. Tools such as Error Prone support this, and there's precedent set by e.g. Lombok.
  2. Instead add @SuppressWarnings("all"). That matches what Lombok and Immutables do, and since google/error-prone@47f0c72 this is also supported by Error Prone.

@timtebeek
Copy link
Contributor Author

Helpful context once again, thanks! Switched to @SuppressWarnings("all") as that seemed easiest: no additional API surface or dependency. Thanks!

@timtebeek timtebeek changed the title Add generated annotations to stop scanning tools Add @SuppressWarnings("all") annotation to stop scanning tool complaints Dec 18, 2023
@timtebeek timtebeek changed the title Add @SuppressWarnings("all") annotation to stop scanning tool complaints Add @SuppressWarnings("all") to stop scanning tool complaints Dec 18, 2023
@timtebeek
Copy link
Contributor Author

Does that also mean I can drop the empty constructors and Javadoc again? 😇

Copy link
Contributor

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

Great question! I suspect that Doclint doesn't respect @SuppressWarnings("all"), but you could try 😄

@timtebeek timtebeek merged commit 41ec9fd into main Dec 18, 2023
1 check passed
@timtebeek timtebeek deleted the add-generated-annotations branch December 18, 2023 17:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

2 participants