Closed
Description
We should align with Spring Framework (see spring-projects/spring-framework#33708). We should also add a checkstyle rule (spring-projects/spring-framework@0a64591)
Metadata
Metadata
Assignees
Labels
Type
Projects
Relationships
Development
No branches or pull requests
Activity
bclozel commentedon Oct 16, 2024
I've had a look at creating a custom check for spring-javaformat - in the end, it's not really far from a "single line regexp check" because the AST doesn't give any type information about the instance nor arguments. Checking for the method name and argument count and heuristics is the best we can do.
wilkinsona commentedon Oct 16, 2024
We might be able to check more precisely using ArchUnit.
nosan commentedon Oct 16, 2024
I tried ArchUnit in my branch and it works fine.
[-] Use Locale.ROOT for locale neutral, case insensitive comparisons[/-][+]Case-insensitive comparisons may be adversely affected by the user's locale[/+]Call String.toLowerCase and .toUppercase with explicit locale
rickie commentedon Oct 25, 2024
Another tool that could've helped with flagging this issue is Error Prone. It's a compiler plugin that, in addition to pointing out problems, can also automatically apply the fixes (patch mode), so no manual change is required.
For this particular case, there is the
StringCaseLocaleUsage
check that flags such cases. To see the full list of checks you can go to the docs: https://errorprone.info/bugpatterns.Is using Error Prone something the Spring team would find interesting to consider and explore?
philwebb commentedon Oct 25, 2024
Thanks @rickie, error prone has been on the radar for a while, but we haven't yet found the time to integrate it. We'll need it when we tackle #10712 and at that point will probably evaluate more checks.