Skip to content

Files

Latest commit

 

History

History
17 lines (10 loc) · 591 Bytes

UnnecessaryStringInstantiation.md

File metadata and controls

17 lines (10 loc) · 591 Bytes

Pattern: Unnecessary string instantiation

Issue: -

Description

Checks for direct call to the String constructor that accepts a String literal. In almost all cases, this is unnecessary. Use a String literal (e.g., "...") instead of calling the corresponding String constructor (new String("..")) directly.

Here is an example of code that produces a violation:

def s = new String('abc')

Further Reading