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

UnnecessarilyFullyQualified still applies to package-info.java on Windows #2164

Closed
PhilippWendler opened this issue Feb 3, 2021 · 1 comment

Comments

@PhilippWendler
Copy link

Description of the problem:

The same bug as #1652 still occurs when compiling on Windows: Error Prone warns about unnecessary fully qualified imports in package-info.java and recommends imports instead.

Output:

[javac] C:\projects\java-common-lib\src\org\sosy_lab\common\annotations\package-info.java:10: warning: [UnnecessarilyFullyQualified] This fully qualified name is unambiguous to the compiler if imported.
[javac] @com.google.errorprone.annotations.CheckReturnValue
[javac]                                   ^
[javac]     (see https://errorprone.info/bugpattern/UnnecessarilyFullyQualified)
[javac]   Did you mean '@CheckReturnValue'?
[javac] C:\projects\java-common-lib\src\org\sosy_lab\common\annotations\package-info.java:11: warning: [UnnecessarilyFullyQualified] This fully qualified name is unambiguous to the compiler if imported.
[javac] @javax.annotation.ParametersAreNonnullByDefault
[javac]                  ^
[javac]     (see https://errorprone.info/bugpattern/UnnecessarilyFullyQualified)
[javac]   Did you mean '@ParametersAreNonnullByDefault'?

(full log)

When looking at ea312c9 (the fix for #1652) the problem seems clear: the code in UnnecessarilyFullyQualified.isPackageInfo() of this commit only works if / is used as file-name separator, but in my build \ is used as can be seen from the error message. The code should probably either use File.separatorChar, or allow both / and \, or even better use proper file-name handling methods. Something like name.endsWith("package-info.java") might also be good enough in practice.

Bugs: what's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.

Should be possible to reproduce by just using Windows and the same reproducer as in #1652.

What version of Error Prone are you using?

2.5.1

@PhilippWendler
Copy link
Author

Was fixed by #2404, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant