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

[java] UseLocaleWithCaseConversions - false positive with a non-String class #4277

Closed
winhkey opened this issue Jan 1, 2023 · 1 comment
Closed
Labels
a:false-positive PMD flags a piece of code that is not problematic
Milestone

Comments

@winhkey
Copy link

winhkey commented Jan 1, 2023

Affects PMD Version: 6.53.0

Rule: UseLocaleWithCaseConversions

Description: The class Ulid has a toLowerCase() method, but no overloads take a locale. The class Ulid is not a string.

Code Sample demonstrating the issue:

public class Foo {
    public static String generateUlid(boolean uppercase) {
        Ulid ulid = Ulid.fast();
        return uppercase ? ulid.toString() : ulid.toLowerCase(); // here problem
    }
}

Expected outcome:

PMD reports a violation "UseLocaleWithCaseConversions: When doing a String.toLowerCase()/toUpperCase() call, use a Locale" at line 4, but that's wrong. That's a false positive.

Running PMD through: CLI

Additional info:

@winhkey winhkey added the a:bug PMD crashes or fails to analyse a file. label Jan 1, 2023
@adangel adangel added a:false-positive PMD flags a piece of code that is not problematic and removed a:bug PMD crashes or fails to analyse a file. labels Jan 16, 2023
@adangel adangel changed the title UseLocaleWithCaseConversions [java] UseLocaleWithCaseConversions - false positive with a non-String class Jan 16, 2023
@jsotuyod jsotuyod added needs:pmd7-revalidation The issue hasn't yet been retested vs PMD 7 and may be stale and removed needs:pmd7-revalidation The issue hasn't yet been retested vs PMD 7 and may be stale labels Mar 17, 2024
@jsotuyod
Copy link
Member

This is no longer reproducible under PMD 7.0.0

@oowekyala oowekyala added this to the 7.0.0 milestone Mar 17, 2024
jsotuyod added a commit that referenced this issue Mar 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
a:false-positive PMD flags a piece of code that is not problematic
Projects
None yet
Development

No branches or pull requests

4 participants