Perl::Critic::Policy::BuiltinFunctions::ProhibitStringySplit - Write split /-/, $string instead of split '-', $string. River stage three • 113 direct dependents • 455 total dependents

The "split" function always interprets the PATTERN argument as a regular expression, even if you specify it as a string. This causes much confusion if the string contains regex metacharacters. So for clarity, always express the PATTERN argument as a ...

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

Perl::Critic::Policy::RegularExpressions::ProhibitComplexRegexes - Split long regexps into smaller qr// chunks. River stage three • 113 direct dependents • 455 total dependents

Big regexps are hard to read, perhaps even the hardest part of Perl. A good practice to write digestible chunks of regexp and put them together. This policy flags any regexp that is longer than "N" characters, where "N" is a configurable value that d...

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

Perl::Critic::Policy::Miscellanea::ProhibitUnrestrictedNoCritic - Forbid a bare ## no critic River stage three • 113 direct dependents • 455 total dependents

A bare "## no critic" annotation will disable all the active Policies. This creates holes for other, unintended violations to appear in your code. It is better to disable only the particular Policies that you need to get around. By putting Policy nam...

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

Perl::Critic::Policy::RegularExpressions::ProhibitUnusedCapture - Only use a capturing group if you plan to use the captured value. River stage three • 113 direct dependents • 455 total dependents

Perl regular expressions have multiple types of grouping syntax. The basic parentheses (e.g. "m/(foo)/") captures into the magic variable $1. Non-capturing groups (e.g. "m/(?:foo)/" are useful because they have better runtime performance and do not c...

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

Perl::Critic::Policy::CodeLayout::RequireConsistentNewlines - Use the same newline through the source. River stage three • 113 direct dependents • 455 total dependents

Source code files are divided into lines with line endings of "\r", "\n" or "\r\n". Mixing these different line endings causes problems in many text editors and, notably, Module::Signature and GnuPG....

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

Perl::Critic::Policy::ClassHierarchies::ProhibitExplicitISA - Employ use base instead of @ISA. River stage three • 113 direct dependents • 455 total dependents

Conway recommends employing "use base qw(Foo)" instead of the usual "our @ISA = qw(Foo)" because the former happens at compile time and the latter at runtime. The base pragma also automatically loads "Foo" for you so you save a line of easily-forgott...

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

Perl::Critic::Policy::ClassHierarchies::ProhibitAutoloading - AUTOLOAD methods should be avoided. River stage three • 113 direct dependents • 455 total dependents

Declaring a subroutine with the name "AUTOLOAD" will violate this Policy. The "AUTOLOAD" mechanism is an easy way to generate methods for your classes, but unless they are carefully written, those classes are difficult to inherit from. And over time,...

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

Perl::Critic::Policy::BuiltinFunctions::RequireGlobFunction - Use glob q{*} instead of <*>. River stage three • 113 direct dependents • 455 total dependents

Conway discourages the use of the "<..>" construct for globbing, as it is easily confused with the angle bracket file input operator. Instead, he recommends the use of the "glob()" function as it makes it much more obvious what you're attempting to d...

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

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

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

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

Perl::Critic::Policy::InputOutput::ProhibitInteractiveTest - Use prompt() instead of -t. River stage three • 113 direct dependents • 455 total dependents

The "-t" operator is fragile and complicated. When you are testing whether "STDIN" is interactive, It's much more robust to use well-tested CPAN modules like IO::Interactive....

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

Perl::Critic::Policy::ControlStructures::ProhibitPostfixControls - Write if($condition){ do_something() } instead of do_something() if $condition. River stage three • 113 direct dependents • 455 total dependents

Conway discourages using postfix control structures ("if", "for", "unless", "until", "when", "while") because they hide control flow. The "unless" and "until" controls are particularly evil because they lead to double-negatives that are hard to compr...

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

Perl::Critic::Policy::Modules::ProhibitConditionalUseStatements - Avoid putting conditional logic around compile-time includes. River stage three • 113 direct dependents • 455 total dependents

Modules included via "use" are loaded at compile-time. Placing conditional logic around the "use" statement has no effect on whether the module will be loaded. Doing so can also serve to confuse the reader as to the author's original intent. If you n...

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

Perl::Critic::Policy::InputOutput::RequireEncodingWithUTF8Layer - Write < open $fh, q{<:encoding(UTF-8)}, $filename; > instead of < open $fh, q{<:utf8}, $filename; >. River stage three • 113 direct dependents • 455 total dependents

Use of the ":utf8" I/O layer (as opposed to ":encoding(UTF8)" or ":encoding(UTF-8)") was suggested in the Perl documentation up to version 5.8.8. This may be OK for output, but on input ":utf8" does not validate the input, leading to unexpected resul...

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

Perl::Critic::Policy::CodeLayout::ProhibitTrailingWhitespace - Don't use whitespace at the end of lines. River stage three • 113 direct dependents • 455 total dependents

Anything that is not readily visually detectable is a bad thing in general, and more specifically, as different people edit the same code, their editors may automatically strip out trailing whitespace, causing spurious differences between different v...

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

Perl::Critic::Policy::InputOutput::ProhibitReadlineInForLoop - Write < while( $line = < ){...} >> instead of < for(<){...} >>. River stage three • 113 direct dependents • 455 total dependents

Using the readline operator in a "for" or "foreach" loop is very slow. The iteration list of the loop creates a list context, which causes the readline operator to read the entire input stream before iteration even starts. Instead, just use a "while"...

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

Perl::Critic::Policy::ControlStructures::ProhibitUntilBlocks - Write while(! $condition) instead of until($condition). River stage three • 113 direct dependents • 455 total dependents

Conway discourages using "until" because it leads to double-negatives that are hard to understand. Instead, reverse the logic and use "while". until($condition) { do_something() } #not ok until(! $no_flag) { do_something() } #really bad while( ! $con...

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

Perl::Critic::Policy::BuiltinFunctions::ProhibitLvalueSubstr - Use 4-argument substr instead of writing substr($foo, 2, 6) = $bar. River stage three • 113 direct dependents • 455 total dependents

Conway discourages the use of "substr()" as an lvalue, instead recommending that the 4-argument version of "substr()" be used instead. substr($something, 1, 2) = $newvalue; # not ok substr($something, 1, 2, $newvalue); # ok The four-argument form of ...

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

Perl::Critic::Policy::InputOutput::ProhibitBarewordFileHandles - Write open my $fh, q{<}, $filename; instead of open FH, q{<}, $filename;. River stage three • 113 direct dependents • 455 total dependents

Using bareword symbols to refer to file handles is particularly evil because they are global, and you have no idea if that symbol already points to some other file handle. You can mitigate some of that risk by "local"izing the symbol first, but that'...

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

Perl::Critic::Policy::ClassHierarchies::ProhibitOneArgBless - Write bless {}, $class; instead of just bless {};. River stage three • 113 direct dependents • 455 total dependents

Always use the two-argument form of "bless" because it allows subclasses to inherit your constructor. sub new { my $class = shift; my $self = bless {}; # not ok my $self = bless {}, $class; # ok return $self; }...

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

Perl::Critic::Policy::Variables::RequireLocalizedPunctuationVars - Magic variables should be assigned as "local". River stage three • 113 direct dependents • 455 total dependents

Punctuation variables (and their English.pm equivalents) are global variables. Messing with globals is dangerous in a complex program as it can lead to very subtle and hard to fix bugs. If you must change a magic variable in a non-trivial program, do...

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

197 results (0.098 seconds)