Skip to content

#1337: match .java extension case-insensitively in PmdValidator#1574

Closed
bibonix wants to merge 2 commits intoyegor256:masterfrom
bibonix:fix-1337-case-insensitive-java-files
Closed

#1337: match .java extension case-insensitively in PmdValidator#1574
bibonix wants to merge 2 commits intoyegor256:masterfrom
bibonix:fix-1337-case-insensitive-java-files

Conversation

@bibonix
Copy link
Copy Markdown
Contributor

@bibonix bibonix commented Apr 27, 2026

Fixes #1337.

Summary

  • PmdValidator#getNonExcludedFiles skipped files whose .java extension was not all lowercase, because it filtered with the case-sensitive regex ^.*\.java$. On case-insensitive file systems (Windows / default macOS) javac happily compiles Foo.JAVA, but qulice never asked PMD to look at it.
  • Replaced the regex with name.toLowerCase(Locale.ROOT).endsWith(".java"), which is both case-insensitive and simpler than the regex it replaces.

Test plan

  • Added acceptsJavaFilesWithUppercaseExtension and acceptsJavaFilesWithMixedCaseExtension in PmdValidatorTest that fail on the old regex and pass with the fix.
  • Added skipsFilesThatAreNotJava to guard against the obvious regression (non-Java files must still be skipped).
  • Verified the failing tests reproduce the bug before the fix (2 failures), and that the full module test suite (mvn -B test) passes after the fix (318 tests, 0 failures).

bibonix added 2 commits April 27, 2026 20:24
Reproduces the bug in PmdValidator#getNonExcludedFiles where files
with uppercase or mixed-case .java extensions (e.g. .JAVA, .Java)
are silently dropped from validation because the regex used to
detect Java files is case-sensitive.
PmdValidator#getNonExcludedFiles previously used the case-sensitive
regex '^.*\\.java$' to decide whether a file should be passed to
PMD. Files with uppercase or mixed-case .java extensions (.JAVA,
.Java) were therefore silently skipped on case-insensitive file
systems where javac would still happily compile them.

Switched to a case-insensitive endsWith check, which is also
simpler than the regex it replaces.
@yegor256 yegor256 closed this Apr 30, 2026
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

Successfully merging this pull request may close these issues.

File Filtering Logic (Possible Logic Issue)

2 participants