Skip to content

False negatives on IO_INEFFICIENT_INDEX_OF #1927

@gloNelson

Description

@gloNelson

Hi,
I thought it should be false negatives on IO_INEFFICIENT_INDEX_OF when using SpotBugs to analyze my project.

IO_INEFFICIENT_INDEX_OF: This code passes a constant string of length 1 to String.indexOf(). It is more efficient to use the integer implementations of String.indexOf(). f. e. call myString.indexOf('.') instead of myString.indexOf(".")

void testIIO_INEFFICIENT_INDEX_OF(int index){
    StringBuilder sb = new StringBuilder();
    int lastIndex = sb.indexOf(">", index);
}

It seems that SpotBugs does not do the same analysis on the StringBuilder class. Is it more efficient to use StringBuilder indexOf('.') than StringBuilder indexOf(".")?
Similar to #1928

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions