Perl::Critic::Policy::TooMuchCode::ProhibitDuplicateSub(3pm)

Perl::Critic::Policy::TooMuchCode::ProhibitDuplicateSub3pm

When 2 subroutines are defined with the same name, report the first one.

Overview

This policy checks if there are subroutine definitions with identical names under the same namespace. If they exists, all but the last one are marked as violation.

perl runtime allows a named subroutine to be redefined in the same source file and the latest definition wins. In the event that this is done by developers, preferably unintentionally, perl runtime warns about a subroutine is redefined with the position is for the one that wins. This policy does the opposite.

Although the last one is not marked as a violation, it's position is reported together. Making it easier for developer to locate the subroutine.

Should the developer decide to programmatically remove the duplicates, simply go through all the violations and remove those statements.

Releases

2 releases since Debian 12 (Bookworm); the text changed 1 time.

  1. 12
  2. 13

From libperl-critic-toomuchcode-perl 0.19-1 in Debian 13 (Trixie). Parsed by carta from the page's man source.