Skip to content

Files

Latest commit

 

History

History
21 lines (13 loc) · 537 Bytes

UnnecessaryCallToSubstring.md

File metadata and controls

21 lines (13 loc) · 537 Bytes

Pattern: Unnecessary String.substring(0)

Issue: -

Description

Calling String.substring(0) always returns the original string. This code is meaningless.

Examples:

string.substring(0)         // violation
method().substring(0)       // violation

prop.substring(1)           // OK, not constant 0
prop.substring(0, 1)        // OK, end is specified

Further Reading