24 Mar 2021 03:09:35 UTC
- Distribution: Perl-Critic
- Module version: 1.140
- Source (raw)
- Browse (raw)
- How to Contribute
- Testers (2886 / 5 / 1)
- KwaliteeBus factor: 2
- 90.11% Coverage
- License: perl_5
- Perl: v5.6.1
- Activity24 month
- Download (635.2KB)
- MetaCPAN Explorer
- Subscribe to distribution
- This version
- Latest version++ed by:58 non-PAUSE usersPETDANCE Andy Lesterand 1 contributors
- Jeffrey Thalhammer
- and possibly others
- Reverse dependencies
- CPAN Testers List
- Dependency graph
Perl::Critic::Policy::Objects::ProhibitIndirectSyntax - Prohibit indirect object call syntax.
This Policy is part of the core Perl::Critic distribution.
Indirect object syntax is commonly used in other object-oriented languages for instantiating objects. Perl allows this, but to say that it supports it may be going too far. Instead of writing
my $foo = new Foo;
it is preferable to write
my $foo = Foo->new;
The problem is that Perl needs to make a number of assumptions at compile time to disambiguate the first form, so it tends to be fragile and to produce hard-to-track-down bugs.
Indirect object syntax is also hard for Perl::Critic to disambiguate, so this policy only checks certain subroutine calls. The names of the subroutines can be configured using the
[Objects::ProhibitIndirectSyntax] forbid = create destroy
newsubroutine is configured by default; any additional
forbidvalues are in addition to
The general situation can not be handled via static analysis.
Thomas R. Wyant, III wyant at cpan dot org
Copyright (c) 2009-2011 Tom Wyant.
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.