Perl::Critic::Policy::CodeLayout::RequireTrailingCommas - Put a comma at the end of every multi-line list declaration, including the last one. River stage three • 113 direct dependents • 455 total dependents

Conway suggests that all elements in a multi-line list should be separated by commas, including the last element. This makes it a little easier to re-order the list by cutting and pasting. my @list = ($foo, $bar, $baz); #not ok my @list = ($foo, $bar...

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

Perl::Critic::Policy::Variables::RequireNegativeIndices - Negative array index should be used. River stage three • 113 direct dependents • 455 total dependents

Perl treats a negative array subscript as an offset from the end. Given this, the preferred way to get the last element is $x[-1], not $x[$#x] or $x[@x-1], and the preferred way to get the next-to-last is $x[-2], not "$x[$#x-1" or $x[@x-2]. The bigge...

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

Perl::Critic::Policy::InputOutput::ProhibitExplicitStdin - Use "<>" or "<ARGV>" or a prompting module instead of "<STDIN>". River stage three • 113 direct dependents • 455 total dependents

Perl has a useful magic filehandle called *ARGV that checks the command line and if there are any arguments, opens and reads those as files. If there are no arguments, *ARGV behaves like *STDIN instead. This behavior is almost always what you want if...

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

Perl::Critic::Policy::CodeLayout::ProhibitQuotedWordLists - Write qw(foo bar baz) instead of ('foo', 'bar', 'baz'). River stage three • 113 direct dependents • 455 total dependents

Conway doesn't mention this, but I think "qw()" is an underused feature of Perl. Whenever you need to declare a list of one-word literals, the "qw()" operator is wonderfully concise, and makes it easy to add to the list in the future. @list = ('foo',...

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

Perl::Critic::Policy::InputOutput::RequireCheckedSyscalls - Return value of flagged function ignored. River stage three • 113 direct dependents • 455 total dependents

This performs identically to InputOutput::RequireCheckedOpen/Close except that this is configurable to apply to any function, whether core or user-defined. If your module uses Fatal, Fatal::Exception, or autodie then any functions wrapped by those mo...

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

Perl::Critic::Exception::Configuration::Option::Global - A problem with Perl::Critic global configuration. River stage three • 113 direct dependents • 455 total dependents

A representation of a problem found with the global configuration of Perl::Critic, whether from a .perlcriticrc, another profile file, or command line. This is an abstract class. It should never be instantiated....

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

Perl::Critic::Policy::References::ProhibitDoubleSigils - Write @{ $array_ref } instead of @$array_ref. River stage three • 113 direct dependents • 455 total dependents

When dereferencing a reference, put braces around the reference to separate the sigils. Especially for newbies, the braces eliminate any potential confusion about the relative precedence of the sigils. push @$array_ref, 'foo', 'bar', 'baz'; #not ok p...

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

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

A representation of a problem found with the configuration of a Perl::Critic::Policy, whether from a .perlcriticrc, another profile file, or command line. This is an abstract class. It should never be instantiated....

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

Perl::Critic::Policy::Subroutines::ProhibitNestedSubs - sub never { sub correct {} }. River stage three • 113 direct dependents • 455 total dependents

Attention would-be clever Perl writers (including Younger RJBS): This does not do what you think: sub do_something { ... sub do_subprocess { ... } ... } "do_subprocess()" is global, despite where it is declared. Either write your subs without nesting...

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

Perl::Critic::Policy::Variables::ProhibitUnusedVariables - Don't ask for storage you don't need. River stage three • 113 direct dependents • 455 total dependents

Unused variables clutter code and require the reader to do mental bookkeeping to figure out if the variable is actually used or not. At present, this Policy is very limited in order to ensure that there aren't any false positives. Hopefully, this wil...

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

Perl::Critic::Policy::Miscellanea::ProhibitUselessNoCritic - Remove ineffective "## no critic" annotations. River stage three • 113 direct dependents • 455 total dependents

Sometimes, you may need to use a "## no critic" annotation to work around a false-positive bug in Perl::Critic. But eventually, that bug might get fixed, leaving your code with extra "## no critic" annotations lying about. Or you may use them to loca...

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

Perl::Critic::Policy::Modules::ProhibitMultiplePackages - Put packages (especially subclasses) in separate files. River stage three • 113 direct dependents • 455 total dependents

Conway doesn't specifically mention this, but I find it annoying when there are multiple packages in the same file. When searching for methods or keywords in your editor, it makes it hard to find the right chunk of code, especially if each package is...

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

Perl::Critic::Policy::BuiltinFunctions::RequireBlockMap - Write map { /$pattern/ } @list instead of map /$pattern/, @list. River stage three • 113 direct dependents • 455 total dependents

The expression forms of "grep" and "map" are awkward and hard to read. Use the block forms instead. @matches = grep /pattern/, @list; #not ok @matches = grep { /pattern/ } @list; #ok @mapped = map transform($_), @list; #not ok @mapped = map { transfo...

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

Perl::Critic::Policy::InputOutput::ProhibitOneArgSelect - Never write select($fh). River stage three • 113 direct dependents • 455 total dependents

Conway discourages the use of a raw "select()" when setting autoflushes. We'll extend that further by simply prohibiting the one-argument form of "select()" entirely; if you really need it you should know when/where/why that is. For performing autofl...

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

Perl::Critic::Policy::BuiltinFunctions::ProhibitVoidMap - Don't use map in void contexts. River stage three • 113 direct dependents • 455 total dependents

"map" and "grep" are intended to be pure functions, not mutators. If you want to iterate with side-effects, then you should use a proper "for" or "foreach" loop. grep{ print frobulate($_) } @list; #not ok print map{ frobulate($_) } @list; #ok grep{ $...

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

Perl::Critic::Policy::InputOutput::ProhibitJoinedReadline - Use local $/ = undef or Path::Tiny instead of joined readline. River stage three • 113 direct dependents • 455 total dependents

It's really easy to slurp a whole filehandle in at once with "join q{}, <$fh">, but that's inefficient -- Perl goes to the trouble of splitting the file into lines only to have that work thrown away. To save performance, either slurp the filehandle w...

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

Perl::Critic::Policy::Modules::ProhibitExcessMainComplexity - Minimize complexity in code that is outside of 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::Policy::BuiltinFunctions::RequireBlockGrep - Write grep { /$pattern/ } @list instead of grep /$pattern/, @list. River stage three • 113 direct dependents • 455 total dependents

The expression forms of "grep" and "map" are awkward and hard to read. Use the block forms instead. @matches = grep /pattern/, @list; #not ok @matches = grep { /pattern/ } @list; #ok @mapped = map transform($_), @list; #not ok @mapped = map { transfo...

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

Perl::Critic::Policy::BuiltinFunctions::ProhibitVoidGrep - Don't use grep in void contexts. River stage three • 113 direct dependents • 455 total dependents

"map" and "grep" are intended to be pure functions, not mutators. If you want to iterate with side-effects, then you should use a proper "for" or "foreach" loop. grep{ print frobulate($_) } @list; #not ok print map{ frobulate($_) } @list; #ok grep{ $...

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

Perl::Critic::Policy::Variables::ProhibitPerl4PackageNames - Use double colon (::) to separate package name components instead of single quotes ('). River stage three • 113 direct dependents • 455 total dependents

Perl 5 kept single quotes ("'") as package component separators in order to remain backward compatible with prior "perl"s, but advocated using double colon ("::") instead. In the more than a decade since Perl 5, double colons have been overwhelmingly...

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

197 results (0.086 seconds)