Perl::Critic::Policy::Variables::RequireInitializationForLocalVars - Write local $foo = $bar; instead of just local $foo;. River stage three • 113 direct dependents • 455 total dependents

Most people don't realize that a localized copy of a variable does not retain its original value. Unless you initialize the variable when you "local"-ize it, it defaults to "undef". If you want the variable to retain its original value, just initiali...

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

Perl::Critic::Policy::Variables::ProhibitConditionalDeclarations - Do not write my $foo = $bar if $baz; . River stage three • 113 direct dependents • 455 total dependents

Declaring a variable with a postfix conditional is really confusing. If the conditional is false, its not clear if the variable will be false, undefined, undeclared, or what. It's much more straightforward to make variable declarations separately. my...

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

Perl::Critic::Policy::BuiltinFunctions::ProhibitReverseSortBlock - Forbid $b before $a in sort blocks. River stage three • 113 direct dependents • 455 total dependents

Conway says that it is much clearer to use "reverse" than to flip $a and $b around in a "sort" block. He also suggests that, in newer perls, "reverse" is specifically looked for and optimized, and in the case of a simple reversed string "sort", using...

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

Perl::Critic::Policy::ErrorHandling::RequireCheckingReturnValueOfEval - You can't depend upon the value of $@/$EVAL_ERROR to tell whether an eval failed. River stage three • 113 direct dependents • 455 total dependents

A common idiom in perl for dealing with possible errors is to use "eval" followed by a check of $@/$EVAL_ERROR: eval { ... }; if ($EVAL_ERROR) { ... } There's a problem with this: the value of $EVAL_ERROR can change between the end of the "eval" and ...

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

Perl::Critic::Policy::RegularExpressions::ProhibitFixedStringMatches - Use eq or hash instead of fixed-pattern regexps. River stage three • 113 direct dependents • 455 total dependents

A regular expression that matches just a fixed set of constant strings is wasteful of performance and is hard on maintainers. It is much more readable and often faster to use "eq" or a hash to match such strings. # Bad my $is_file_function = $token =...

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

Perl::Critic::Policy::RegularExpressions::RequireBracesForMultiline - Use { and } to delimit multi-line regexps. River stage three • 113 direct dependents • 455 total dependents

Long regular expressions are hard to read. A good practice is to use the "x" modifier and break the regex into multiple lines with comments explaining the parts. But, with the usual "//" delimiters, the beginning and end can be hard to match, especia...

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

Perl::Critic::Policy::ValuesAndExpressions::RequireNumberSeparators - Write 141_234_397.0145 instead of 141234397.0145 . River stage three • 113 direct dependents • 455 total dependents

Long numbers can be difficult to read. To improve legibility, Perl allows numbers to be split into groups of digits separated by underscores. This policy requires number sequences of more than three digits to be separated. $long_int = 123456789; #not...

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

Perl::Critic::Policy::RegularExpressions::ProhibitEnumeratedClasses - Use named character classes instead of explicit character lists. River stage three • 113 direct dependents • 455 total dependents

This policy is not for everyone! If you are working in pure ASCII, then disable it now or you may see some false violations. On the other hand many of us are working in a multilingual world with an extended character set, probably Unicode. In that wo...

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

Perl::Critic::Policy::InputOutput::RequireBracedFileHandleWithPrint - Write print {$FH} $foo, $bar; instead of print $FH $foo, $bar;. River stage three • 113 direct dependents • 455 total dependents

The "print" and "printf" functions have a unique syntax that supports an optional file handle argument. Conway suggests wrapping this argument in braces to make it visually stand out from the other arguments. When you put braces around any of the spe...

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

Perl::Critic::Policy::Subroutines::ProhibitSubroutinePrototypes - Don't write sub my_function (@@) {}. River stage three • 113 direct dependents • 455 total dependents

Contrary to common belief, subroutine prototypes do not enable compile-time checks for proper arguments. Don't use them....

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

Perl::Critic::Policy::ValuesAndExpressions::ProhibitImplicitNewlines - Use concatenation or HEREDOCs instead of literal line breaks in strings. River stage three • 113 direct dependents • 455 total dependents

Strings with embedded line breaks are hard to read. Use concatenation or HEREDOCs instead. my $foo = "Line one is quite long Line two"; # Bad my $foo = "Line one is quite long\nLine two"; # Better, but still hard to read my $foo = "Line one is quite ...

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

Perl::Critic::Policy::ValuesAndExpressions::ProhibitConstantPragma - Don't < use constant FOO = 15 >>. River stage three • 113 direct dependents • 455 total dependents

Named constants are a good thing. But don't use the "constant" pragma because barewords don't interpolate. Instead use the Readonly module. use constant FOOBAR => 42; #not ok use Readonly; Readonly my $FOOBAR => 42; #ok Readonly::Scalar my $FOOBAR =>...

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

Perl::Critic::Policy::RegularExpressions::ProhibitEscapedMetacharacters - Use character classes for literal meta-characters instead of escapes. River stage three • 113 direct dependents • 455 total dependents

Ever heard of leaning toothpick syndrome? That comes from writing regular expressions that match on characters that are significant in regular expressions. For example, the expression to match four forward slashes looks like: m/\/\/\/\//; Well, this ...

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

Perl::Critic::Policy::ControlStructures::ProhibitMutatingListFunctions - Don't modify $_ in list functions. River stage three • 113 direct dependents • 455 total dependents

"map", "grep" and other list operators are intended to transform arrays into other arrays by applying code to the array elements one by one. For speed, the elements are referenced via a $_ alias rather than copying them. As a consequence, if the code...

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

Perl::Critic::Policy::RegularExpressions::RequireLineBoundaryMatching - Always use the /m modifier with regular expressions. River stage three • 113 direct dependents • 455 total dependents

Folks coming from a "sed" or "awk" background tend to assume that '$' and '^' match the beginning and end of the line, rather than then beginning and end of the string. Adding the '/m' flag to your regex makes it behave as most people expect it shoul...

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

Perl::Critic::Policy::RegularExpressions::ProhibitUnusualDelimiters - Use only // or {} to delimit regexps. River stage three • 113 direct dependents • 455 total dependents

Perl lets you delimit regular expressions with almost any character, but most choices are illegible. Compare these equivalent expressions: s/foo/bar/; # good s{foo}{bar}; # good s#foo#bar#; # bad s;foo;bar;; # worse s|\|\||\||; # eye-gouging bad...

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

Perl::Critic::Policy::Documentation::RequirePackageMatchesPodName - The =head1 NAME section should match the package. River stage three • 113 direct dependents • 455 total dependents

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

Perl::Critic::Exception::Configuration::Option::Policy::ParameterValue - A problem with the value of a parameter for a policy. River stage three • 113 direct dependents • 455 total dependents

A representation of a problem found with the value of a parameter for a Perl::Critic::Policy, whether from a .perlcriticrc, another profile file, or command line....

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

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

A representation of the configuration attempting to specify a value for a parameter that a Perl::Critic::Policy doesn't have, 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::ProhibitMismatchedOperators - Don't mix numeric operators with string operands, or vice-versa. River stage three • 113 direct dependents • 455 total dependents

Using the wrong operator type for a value can obscure coding intent and possibly lead to subtle errors. An example of this is mixing a string equality operator with a numeric value, or vice-versa. if ($foo == 'bar') {} #not ok if ($foo eq 'bar') {} #...

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

197 results (0.077 seconds)