Perl::Critic::Policy::ControlStructures::ProhibitDeepNests - Don't write deeply nested loops and conditionals. River stage three • 113 direct dependents • 455 total dependents

Deeply nested code is often hard to understand and may be a sign that it needs to be refactored. There are several good books on how to refactor code. I like Martin Fowler's "Refactoring: Improving The Design of Existing Code"....

PETDANCE/Perl-Critic-1.134 - 23 May 2019 02:52:21 GMT

Perl::Critic::Policy::Subroutines::ProhibitBuiltinHomonyms - Don't declare your own open function. River stage three • 113 direct dependents • 455 total dependents

Common sense dictates that you shouldn't declare subroutines with the same name as one of Perl's built-in functions or keywords. See perlfunc for a list of built-in functions; see perlsyn for keywords. sub open {} #not ok sub exit {} #not ok sub prin...

PETDANCE/Perl-Critic-1.134 - 23 May 2019 02:52:21 GMT

Perl::Critic::Policy::BuiltinFunctions::ProhibitStringyEval - Write eval { my $foo; bar($foo) } instead of eval "my $foo; bar($foo);". River stage three • 113 direct dependents • 455 total dependents

The string form of "eval" is recompiled every time it is executed, whereas the block form is only compiled once. Also, the string form doesn't give compile-time warnings. eval "print $foo"; # not ok eval {print $foo}; # ok...

PETDANCE/Perl-Critic-1.134 - 23 May 2019 02:52:21 GMT

Perl::Critic::Policy::Subroutines::ProhibitExcessComplexity - Minimize complexity by factoring code into smaller subroutines. River stage three • 113 direct dependents • 455 total dependents

All else being equal, complicated code is more error-prone and more expensive to maintain than simpler code. The first step towards managing complexity is to establish formal complexity metrics. One such metric is the McCabe score, which describes th...

PETDANCE/Perl-Critic-1.134 - 23 May 2019 02:52:21 GMT

Perl::Critic::Exception::Configuration::NonExistentPolicy - The configuration referred to a non-existent policy. River stage three • 113 direct dependents • 455 total dependents

A representation of the configuration attempting to specify a Perl::Critic::Policy that is not known, whether from a .perlcriticrc, another profile file, or command line....

PETDANCE/Perl-Critic-1.134 - 23 May 2019 02:52:21 GMT

Perl::Critic::Policy::ValuesAndExpressions::ProhibitMagicNumbers - Don't use values that don't explain themselves. River stage three • 113 direct dependents • 455 total dependents

What is a "magic number"? A magic number is a number that appears in code without any explanation; e.g. "$bank_account_balance *= 57.492;". You look at that number and have to wonder where that number came from. Since you don't understand the signifi...

PETDANCE/Perl-Critic-1.134 - 23 May 2019 02:52:21 GMT

Perl::Critic::Policy::TestingAndDebugging::ProhibitNoStrict - Prohibit various flavors of no strict. River stage three • 113 direct dependents • 455 total dependents

There are good reasons for disabling certain kinds of strictures, But if you were wise enough to "use strict" in the first place, then it doesn't make sense to disable it completely. By default, any "no strict" statement will violate this policy. How...

PETDANCE/Perl-Critic-1.134 - 23 May 2019 02:52:21 GMT

Perl::Critic::Policy::Modules::ProhibitAutomaticExportation - Export symbols via @EXPORT_OK or %EXPORT_TAGS instead of @EXPORT. River stage three • 113 direct dependents • 455 total dependents

When using Exporter, symbols placed in the @EXPORT variable are automatically exported into the caller's namespace. Although convenient, this practice is not polite, and may cause serious problems if the caller declares the same symbols. The best pra...

PETDANCE/Perl-Critic-1.134 - 23 May 2019 02:52:21 GMT

Perl::Critic::Policy::TestingAndDebugging::RequireUseStrict - Always use strict. River stage three • 113 direct dependents • 455 total dependents

Using strictures is probably the single most effective way to improve the quality of your code. This policy requires that the "'use strict'" statement must come before any other statements except "package", "require", and other "use" statements. Thus...

PETDANCE/Perl-Critic-1.134 - 23 May 2019 02:52:21 GMT

Perl::Critic::Policy::BuiltinFunctions::ProhibitBooleanGrep - Use List::MoreUtils::any instead of grep in boolean context. River stage three • 113 direct dependents • 455 total dependents

Using "grep" in boolean context is a common idiom for checking if any elements in a list match a condition. This works because boolean context is a subset of scalar context, and grep returns the number of matches in scalar context. A non-zero number ...

PETDANCE/Perl-Critic-1.134 - 23 May 2019 02:52:21 GMT

Perl::Critic::Policy::CodeLayout::ProhibitParensWithBuiltins - Write open $handle, $path instead of open($handle, $path). River stage three • 113 direct dependents • 455 total dependents

Conway suggests that all built-in functions be called without parentheses around the argument list. This reduces visual clutter and disambiguates built-in functions from user functions. Exceptions are made for "my", "local", and "our" which require p...

PETDANCE/Perl-Critic-1.134 - 23 May 2019 02:52:21 GMT

Perl::Critic::Policy::Modules::RequireFilenameMatchesPackage - Package declaration must match filename. River stage three • 113 direct dependents • 455 total dependents

The package declaration should always match the name of the file that contains it. For example, "package Foo::Bar;" should be in a file called "Bar.pm". This makes it easier for developers to figure out which file a symbol comes from when they see it...

PETDANCE/Perl-Critic-1.134 - 23 May 2019 02:52:21 GMT

Perl::Critic::Policy::InputOutput::ProhibitBacktickOperators - Discourage stuff like @files = `ls $directory`. River stage three • 113 direct dependents • 455 total dependents

Backticks are super-convenient, especially for CGI programs, but I find that they make a lot of noise by filling up STDERR with messages when they fail. I think its better to use IPC::Open3 to trap all the output and let the application decide what t...

PETDANCE/Perl-Critic-1.134 - 23 May 2019 02:52:21 GMT

Perl::Critic::Policy::Variables::RequireLexicalLoopIterators - Write for my $element (@list) {...} instead of for $element (@list) {...}. River stage three • 113 direct dependents • 455 total dependents

This policy asks you to use "my"-style lexical loop iterator variables: foreach my $zed (...) { ... } Unless you use "my", "for"/"foreach" loops use a global variable with its value "local" to the block. In other words, foreach $zed (...) { ... } is ...

PETDANCE/Perl-Critic-1.134 - 23 May 2019 02:52:21 GMT

Perl::Critic::Policy::Subroutines::ProhibitAmpersandSigils - Don't call functions with a leading ampersand sigil. River stage three • 113 direct dependents • 455 total dependents

Since Perl 5, the ampersand sigil is completely optional when invoking subroutines. It also turns off checking of subroutine prototypes. It's easily confused with the bitwise 'and' operator. @result = &some_function(); # not ok @result = some_functio...

PETDANCE/Perl-Critic-1.134 - 23 May 2019 02:52:21 GMT

Perl::Critic::Policy::Subroutines::ProhibitExplicitReturnUndef - Return failure with bare return instead of return undef. River stage three • 113 direct dependents • 455 total dependents

Returning "undef" upon failure from a subroutine is pretty common. But if the subroutine is called in list context, an explicit "return undef;" statement will return a one-element list containing "(undef)". Now if that list is subsequently put in a b...

PETDANCE/Perl-Critic-1.134 - 23 May 2019 02:52:21 GMT

Perl::Critic::Policy::TestingAndDebugging::RequireUseWarnings - Always use warnings. River stage three • 113 direct dependents • 455 total dependents

Using warnings, and paying attention to what they say, is probably the single most effective way to improve the quality of your code. This policy requires that the 'use warnings' statement must come before any other statements except "package", "requ...

PETDANCE/Perl-Critic-1.134 - 23 May 2019 02:52:21 GMT

Perl::Critic::Policy::TestingAndDebugging::RequireTestLabels - Tests should all have labels. River stage three • 113 direct dependents • 455 total dependents

Most Perl modules with regression tests use Test::More as infrastructure for writing and running those tests. It has an easy, procedural syntax for writing comparisons of results to expectations. Most of the Test::More functions allow the programmer ...

PETDANCE/Perl-Critic-1.134 - 23 May 2019 02:52:21 GMT

Perl::Critic::Policy::BuiltinFunctions::ProhibitUniversalIsa - Write < eval { $foo-isa($pkg) } >> instead of UNIVERSAL::isa($foo, $pkg). River stage three • 113 direct dependents • 455 total dependents

print UNIVERSAL::isa($obj, 'Foo::Bar') ? 'yes' : 'no'; #not ok print eval { $obj->isa('Foo::Bar') } ? 'yes' : 'no'; #ok As of Perl 5.9.3, the use of "UNIVERSAL::isa" as a function has been deprecated and the method form is preferred instead. Formerly...

PETDANCE/Perl-Critic-1.134 - 23 May 2019 02:52:21 GMT

Perl::Critic::Policy::BuiltinFunctions::ProhibitUniversalCan - Write < eval { $foo-can($name) } >> instead of UNIVERSAL::can($foo, $name). River stage three • 113 direct dependents • 455 total dependents

print UNIVERSAL::can($obj, 'Foo::Bar') ? 'yes' : 'no'; #not ok print eval { $obj->can('Foo::Bar') } ? 'yes' : 'no'; #ok As of Perl 5.9.3, the use of UNIVERSAL::can as a function has been deprecated and the method form is preferred instead. Formerly, ...

PETDANCE/Perl-Critic-1.134 - 23 May 2019 02:52:21 GMT

197 results (0.087 seconds)