Scroll to navigation

Perl::Critic::Policy::TooMuchCode::ProhibitDuplicateLiteral(3pm) User Contributed Perl Documentation Perl::Critic::Policy::TooMuchCode::ProhibitDuplicateLiteral(3pm)

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.

CONFIGURATION

Some strings/numbers may be allowed to have duplicates by listing them in the "allowlist" parameter in the configs:

    [TooMuchCode::ProhibitDuplicateLiteral]
    allowlist = 'present' "forty two" 42

The values is a space-separated list of numbers or quoted string.

The default values in the allowlist are: "0 1". These two numbers are always part of allowlist and cannot be removed.

Please be aware that, a string literal and its numerical literal counterpart (1 vs "1") are considered to be the same. Adding "42" to the allowlist is the same as adding 42.

2023-10-05 perl v5.36.0