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

Impsort duplicates comments above first import if there is no space separation #35

Closed
bruce-y opened this issue Oct 1, 2020 · 1 comment · Fixed by #36
Closed

Impsort duplicates comments above first import if there is no space separation #35

bruce-y opened this issue Oct 1, 2020 · 1 comment · Fixed by #36
Labels
Milestone

Comments

@bruce-y
Copy link
Contributor

bruce-y commented Oct 1, 2020

Describe the bug
When there is a comment before the first import and there is not a space between the comment and the import line.
When running impsort, this comment is duplicated.

Versions (OS, Maven, Java, and others, as appropriate):

  • Affected version(s) of this project: 1.4.1
  • OS: MacOS

To Reproduce
Steps to reproduce the behavior (or a link to an example repository that reproduces the problem):

  1. Write any Java file with any imports .
  2. Write a comment above the first import.
// some comment
import foo.bar;
import bar.baz;

class Foo(){
}
  1. Run impsort on the file.
  2. See duplicated comment.
// some comment

// some comment
import foo.bar;
import bar.baz;

class Foo(){
}

Expected behavior
This comment is moved around with the import but not duplicated.

Additional context
This also is an issue with block comments, where the entire block comment is duplicated. In the Maven Debug logs, we see the log that it Found imports: with the comment included above the import line.

@bruce-y bruce-y added the bug label Oct 1, 2020
@bruce-y bruce-y changed the title Impsort duplicates comments above import Impsort duplicates comments above import if there is not a package declaration Oct 1, 2020
@bruce-y bruce-y changed the title Impsort duplicates comments above import if there is not a package declaration Impsort duplicates comments above first import if there is no space separation Oct 1, 2020
@bruce-y
Copy link
Contributor Author

bruce-y commented Oct 1, 2020

Addressed in PR #36

@ctubbsii ctubbsii linked a pull request Oct 1, 2020 that will close this issue
@ctubbsii ctubbsii added this to the 1.5.0 milestone Oct 1, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants