NAME

TooMuchCode::ProhibitDuplicateLiteral - Don't repeat yourself with identical literals

DESCRIPTION

This policy checks if there are string/number literals with identical value in the same piece of perl code. Usually that's a small signal of repeating and perhaps a small chance of refactoring.

Certain numbers are whitelisted and not being checked in this policy because they are conventionally used everywhere.

The default whitelist is 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, -1, -2, -3, -4, -5, -6, -7, -8, -9

To opt-out more, add whitelist_numbers like this in .perlcriticrc

[TooMuchCode:ProhibitDuplicateLiteral]
whitelist_numbers = 42, 10

This configurable parameter appends to the default whitelist and there are no way to remove the default whitelist.

A string literal with its numerical literal counterpart with same value (1 vs "1") are considered to be two distinct values. Since it's a bit rare to explicitly hard-code number as string literals, it shouldn't make much difference otherwise. However this is just an arbitrary choice and might be adjusted in future versions.