Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.
On the other hand, constants can be referenced from many places, but only need to be updated in a single place.
Noncompliant Code Example
With the default threshold of 3:
C MOVEL 'CLEAR' W1CLR Noncompliant
C MOVEL '*DECOD' W1DCDE
C MOVEL '*ERROR' W1ERR
C MOVEL '*EXIT ' W1EXIT
C MOVEL 'CLEAR' W1FIRT
C MOVEL 'CLEAR' W1HELP
/free
W1CLR = 'CLEAR'; // Noncompliant
W1FIRT = 'CLEAR';
W1HELP = 'CLEAR';
/end-free
Compliant Solution
D W0Clr C CONST('CLEAR')
C MOVEL W0Clr W1CLR
C MOVEL '*DECOD' W1DCDE
C MOVEL '*ERROR' W1ERR
C MOVEL '*EXIT ' W1EXIT
C MOVEL W0Clr W1FIRT
C MOVEL W0Clr W1HELP
D W0Clr C CONST('CLEAR')
/free
W1CLR = W0Clr;
W1FIRT = W0Clr;
W1HELP = W0Clr;
/end-free
Exceptions
To prevent generating some false-positives, literals having less than 5 characters are excluded.