Perl::Critic::Policy::Subroutines::ProhibitCallsToUndeclaredSubs(3pm)

NAME
Perl::Critic::Policy::Subroutines::ProhibitCallsToUndeclaredSubs

AFFILIATION
This policy is part of Perl::Critic::StricterSubs.

DESCRIPTION
This Policy checks that every unqualified subroutine call has a matching subroutine declaration in the current file, or that it explicitly appears in the import list for one of the included modules.

Some modules do not use the Exporter interface, and rely on other mechanisms to export symbols into your code. In those cases, this Policy will report a false violation. However, you can instruct this policy to ignore a particular subroutine name, as long as the appropriate package has been included in your file. See "CONFIGURATION" for more details.

CONFIGURATION
A list of exempt subroutines for this Policy can defined by specifying 'exempt_subs' as a string of space-delimited, fully-qualified subroutine names. For example, putting this in your .perlcriticrc file would allow you to call the "ok" and "is" functions without explicitly importing or declaring those functions, as long as the "Test::More" package has been included in the file somewhere.

    [Subroutines::ProhibitCallsToUndeclaredSubs]
    exempt_subs = Test::More::ok Test::More::is

By default, there are no exempt subroutines, but we're working on compiling a list of the most common ones.

LIMITATIONS
This Policy assumes that the file has no more than one "package" declaration and that all subs declared within the file are, in fact, declared into that same package. In most cases, violating either of these assumptions means you're probably doing something that you shouldn't do. Think twice about what you're doing.

Also, if you "require" a module and subsequently call the "import" method on that module, this Policy will not detect the symbols that might have been imported. In which case, you'll probably get bogus violations.

AUTHOR
Jeffrey Ryan Thalhammer <thaljef@cpan.org>

COPYRIGHT
Copyright 2007-2024 Jeffrey Ryan Thalhammer and Andy Lester

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. The full text of this license can be found in the LICENSE file included with this module.