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

Repeated annotations and broken formatting when adding suppressions #77

Closed
lazaroclapp opened this issue Sep 20, 2022 · 1 comment
Closed
Labels
bug Something isn't working

Comments

@lazaroclapp
Copy link
Collaborator

Describe the bug
When running the auto-annotator on suppression (and @NullUnmarked) adding mode, I am observing two issues on fields that otherwise already contain annotations:

  • Duplicated instances of @Nullable added
  • Lack of spaces between the last added annotation and the field's modifiers

For example, this is the initial code:

@JsonProperty
@JsonInclude(JsonInclude.Include.NON_NULL)
public String foo;

And this the auto-annotator's result (before Google Java Format, but that's irrelevant for now because this code won't build):

@JsonProperty @JsonInclude(JsonInclude.Include.NON_NULL) @Nullable @SuppressWarnings("NullAway.Init")
@Nullablepublic   String foo;

Note: a) @Nullable is repeated, despite it already having @SuppressWarnings("NullAway.Init") (which makes no sense combined with @Nullable); b) @Nullablepublic as opposed to @Nullable public

To Reproduce
See code-example above. Configuration includes --chain --activate-downstream-dependencies-analysis --force-resolve.

Expected behavior
I would expect that field to either be annotated:

@JsonProperty
@JsonInclude(JsonInclude.Include.NON_NULL)
@SuppressWarnings("NullAway.Init")
public String foo;

Or:

@JsonProperty
@JsonInclude(JsonInclude.Include.NON_NULL)
@Nullable
public String foo;

Stack trace
N/A

OS (please complete the following information):

@lazaroclapp lazaroclapp added the bug Something isn't working label Sep 20, 2022
nimakarimipour added a commit that referenced this issue Sep 21, 2022
…s. (#80)

This PR makes [LexicalPreservingPrinter](https://github.com/javaparser/javaparser/tree/master/javaparser-core/src/main/java/com/github/javaparser/printer/lexicalpreservation) the default printer in unit tests.

This required some unit tests output to be updated as a result of using a new printer.

This is in the hope of catching `LexicalPreserverPrinter` bugs in future, however even with our current set of unit tests still #77 is not detected yet.
@nimakarimipour
Copy link
Member

#90 is landed and resolves this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants