A check for multiple identical string literals is a
special case of the check for duplicated code.
It's main advantages are that it identifies a fairly
common problem - and can be implemented relatively
easily - and executed quickly (compared to other
checks for replicated code).
There should be a configurable length limit - below
which the problem is not reported - defaulting to
The implementation should ideally report the problem
on /every/ line involved (including the first one) -
though I'm not sure how easy this is to do in
Similar checks for other multiple identical literals
could also be done relatively inexpensively -
int, long, float, double - but they might be a
bit less useful.
Log in to post a comment.