Skip to content

[java] AssertJ SimplifyStartsWith false-positive #2712

@pnsantos

Description

@pnsantos

Affects PMD Version: 6.26

Rule: SimplifyStartsWith

Description:

When using assertJ like so:

assertThat(someStringValue).startsWith("a");

PMD is flagging this with:

Rule:SimplifyStartsWith Priority:3 This call to String.startsWith can be rewritten using String.charAt(0).

This feels like it's a false-positive, even though one could make it be:

assertThat(someStringValue.charAt(0)).isEqualTo("a");

it feels much less idiomatic use of the library's API

Metadata

Metadata

Assignees

No one assigned

    Labels

    a:false-positivePMD flags a piece of code that is not problematic

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions