27 May 2021 06:45:59 UTC
- Distribution: Perl-Critic-Community
- Module version: v1.0.0
- Source (raw)
- Browse (raw)
- How to Contribute
- Repository (git clone)
- Issues (6)
- KwaliteeBus factor: 1
- 89.34% Coverage
- License: artistic_2
- Perl: v5.10.1
- Activity24 month
- Download (45.29KB)
- MetaCPAN Explorer
- Subscribe to distribution
- This version
- Latest version++ed by:2 non-PAUSE usersDBOOK Dan Book
- Reverse dependencies
- CPAN Testers List
- Dependency graph
Perl::Critic::Policy::Community::IndirectObjectNotation - Don't call methods indirectly
Perl allows a form of method call where the method name is first, followed by the invocant (class or object to call the method on), then the argument list. This is an unfortunate legacy syntax that should no longer be used. See "Indirect Object Syntax" in perlobj and "REFERENCES" in indirect for more information.
my $obj = new My::Class @args; # not ok my $obj = My::Class->new(@args); # ok
It is difficult to detect indirect object notation by static analysis, so this policy only forbids the
newmethod call by default, as it is highly unlikely to be the name of a standard subroutine call. Consider using the indirect pragma to cause the code to warn or die when indirect object notation is used.
This policy is a subclass of the Perl::Critic core policy Perl::Critic::Policy::Objects::ProhibitIndirectSyntax, and performs the same function but in the
This policy is part of Perl::Critic::Community.
This policy can be configured, in the same way as its parent policy Perl::Critic::Policy::Objects::ProhibitIndirectSyntax, to attempt to forbid additional method names from being called indirectly. Be aware this may lead to false positives as it is difficult to detect indirect object notation by static analysis. The
newsubroutine is always forbidden in addition to these.
[Community::IndirectObjectNotation] forbid = create destroy
Copyright 2015, Dan Book.
This library is free software; you may redistribute it and/or modify it under the terms of the Artistic License version 2.0.
Module Install Instructions
To install Perl::Critic::Community, copy and paste the appropriate command in to your terminal.
perl -MCPAN -e shell install Perl::Critic::Community
For more information on module installation, please visit the detailed CPAN module installation guide.