26 Apr 2022 03:43:51 UTC
- Distribution: Perl-Critic-StricterSubs
- Module version: 0.06
- Source (raw)
- Browse (raw)
- How to Contribute
- Testers (419 / 7 / 0)
- KwaliteeBus factor: 2
- 87.90% Coverage
- License: perl_5
- Perl: v5.6.1
- Download (37.93KB)
- MetaCPAN Explorer
- Subscribe to distribution
- This version
- Latest version
- INCLUDED POLICIES
Perl::Critic::StricterSubs - Perl::Critic plugin for stricter subroutine checks
This module has no functionality, but instead contains documentation for this distribution and acts as a means of pulling other modules into a bundle. All of the Policy modules contained herein will have an "AFFILIATION" section announcing their participation in this grouping.
As a dynamic language, Perl doesn't require you to define subroutines until run-time. Although this is a powerful feature, it can also be a major source of bugs. For example, you might mistype the name of a subroutine, or call a subroutine from another module without including that module or importing that subroutine. And unless you have very good test coverage, you might not know about these bugs until you have already launched your code.
The Perl::Critic::Policy modules in this distribution are aimed at reducing errors caused by invoking subroutines that are not defined. Each Policy can be used separately. But when applied together, they enforce a specific and deliberate coding style that minimizes the chance of writing code that makes calls to undefined subroutines.
This coding style will not appeal to everyone. Some folks will surely find this coding style to be too verbose or too restrictive. In particular, importing via Exporter tags and pattern matching is purposely not supported. But hopefully, these Policies will encourage you to consciously consider the inherent trade-offs of your current coding style.
Perl::Critic is a static analyzer, so the Policies in this distro only pertain to static subroutines. That is, subroutine calls that typically look like one of these:
foo(); Bar::baz( $string ); Quux->new( @args );
At present, Perl::Critic cannot not know the class ancestry of any particular object reference. Thus, the Policies in this distro do not cover object methods, such as these:
Still, it is difficult for Perl::Critic to know precisely which static subroutines will be defined at run time. Therefore, these Policies are expected to report some false violations. So you probably don't want to use these Policies with Test::Perl::Critic or other frameworks that expect 100% violation-free code. Instead, I suggest using these Policies with the perlcritic command to perform ad hoc analysis of your code.
The following Policy modules are shipped in this distribution. See the documentation within each module for details on its specific behavior.
If you refer to symbols in another package, you must explicitly include that module. [Severity: 4]
Unqualified subroutines must always be declared or explicitly imported within the file. [Severity: 4]
Only allow calls to external subroutines that are named in
@EXPORT_OK. [Severity: 4]
All subroutines named for
@EXPORT_OKmust be defined in the file. [Severity: 4]
Do not declare subroutines with fully-qualified names [Severity: 3]
After installing the
Perl-Critic-StricterSubsdistro, all the included Policies available to the Perl::Critic engine. The Policies in this distro all belong to the "strictersubs" theme, so you can disable all of them at once using either of these methods:
# In your .perlcriticrc file... theme = not strictersubs # With the perlcritic command-line... $> perlcritic --theme='not stricter_subs' MyModule.pm
Each Policy in this distro may support additional configuration settings that can be accessed through your .perlcriticrc file. See the perldoc in each Policy for more details.
DEVELOPMENT of the
Perl-Critic-StricterSubsdistribution was financed by a grant from The Mathworks (http://mathworks.com). The Perl::Critic team sincerely thanks The Mathworks for their generous support of the Perl community and open-source software.
Jeffrey Ryan Thalhammer <firstname.lastname@example.org>
Copyright (c) 2007-2022 Jeffrey Ryan Thalhammer.
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.
Module Install Instructions
To install Perl::Critic::StricterSubs, copy and paste the appropriate command in to your terminal.
perl -MCPAN -e shell install Perl::Critic::StricterSubs
For more information on module installation, please visit the detailed CPAN module installation guide.
|s||Focus search bar|
|?||Bring up this help dialog|
|g p||Go to pull requests|
|g i||go to github issues (only if github is preferred repository)|
|g a||Go to author|
|g c||Go to changes|
|g i||Go to issues|
|g d||Go to dist|
|g r||Go to repository/SCM|
|g s||Go to source|
|g b||Go to file browse|