« Policy/Reneeb/Capitalization.pm
↑ Summary
Policy/RegularExpressions/RequireExtendedFormattingExceptForSplit.pm »
| 1 | package Perl::Critic::Policy::Reneeb::RequirePostderef; | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | # ABSTRACT: Require Postdereferencing which became stable in Perl 5.24 | ||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||
| 5 | 5 | ▶ | use 5.006001; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | 5 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | 5 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 8 | 5 | ▶ | use Readonly; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 9 | 5 | ▶ | use List::Util qw(first); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||
| 11 | 5 | ▶ | use Perl::Critic::Utils qw{ :severities }; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||
| 13 | 5 | ▶ | use base 'Perl::Critic::Policy'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||
| 15 | 5 | our $VERSION = '2.05'; | |||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||
| 17 | #----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||
| 19 | 5 | Readonly::Scalar my $DESC => q{Use postderef (e.g. $ref->@*) instead of the "old" dereferencing (e.g. @{$ref})}; | |||||||||||||||||||||||||||
| 20 | 5 | Readonly::Scalar my $EXPL => [ ]; | |||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||
| 22 | #----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||
| 24 | 22 | ▶ | sub default_severity { return $SEVERITY_MEDIUM } | ||||||||||||||||||||||||||
|
Subroutine
default_severity: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 25 | 1 | ▶ | sub default_themes { return qw<reneeb> } | ||||||||||||||||||||||||||
|
Subroutine
default_themes: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 26 | 23 | ▶ | sub applies_to { | ||||||||||||||||||||||||||
|
Subroutine
applies_to: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 27 | 23 | return qw< | |||||||||||||||||||||||||||
| 28 | PPI::Token::Cast | ||||||||||||||||||||||||||||
| 29 | >; | ||||||||||||||||||||||||||||
| 30 | } | ||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||
| 32 | #----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||
| 34 | 20 | ▶ | sub violates { | ||||||||||||||||||||||||||
|
Subroutine
violates: called CC=5 SCAR=16.1
Pod
documented
| |||||||||||||||||||||||||||||
| 35 | 20 | my ( $self, $elem, $doc ) = @_; | |||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||
| 37 | # postderence syntax do also have a PPI::Token::Cast object, | ||||||||||||||||||||||||||||
| 38 | # but that looks different | ||||||||||||||||||||||||||||
| 39 | 20 | ▶ | return if !first{ $elem->content ne $_ }qw($ @ * % &),'$#'; | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.2
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||
| 41 | 20 | my $sibling = $elem->snext_sibling; | |||||||||||||||||||||||||||
| 42 | 20 | ▶ | return if !$sibling; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||
| 44 | # grep in boolean or void context isn't checked | ||||||||||||||||||||||||||||
| 45 | 17 | ▶ | return if !$sibling->isa('PPI::Structure::Block') && !$sibling->isa('PPI::Token::Symbol'); | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$sibling->isa("PPI::Structure::Block") or $sibling->isa("PPI::Token::Symbol")
MC/DC100%2/2
$sibling->isa("PPI::Structure::Block") or $sibling->isa("PPI::Token::Symbol")
$sibling->isa("PPI::Structure::Block")
$sibling->isa("PPI::Token::Symbol")
Truth table100%3/3
A or B
A= $sibling->isa("PPI::Structure::Block")B= $sibling->isa("PPI::Token::Symbol")
| |||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||
| 47 | 13 | return $self->violation( $DESC, $EXPL, $elem ); | |||||||||||||||||||||||||||
| 48 | } | ||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||
| 50 | 5 | 1; | |||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||
| 52 | =pod | ||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||
| 54 | =encoding UTF-8 | ||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||
| 56 | =head1 NAME | ||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||
| 58 | Perl::Critic::Policy::Reneeb::RequirePostderef - Require Postdereferencing which became stable in Perl 5.24 | ||||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||
| 60 | =head1 VERSION | ||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||
| 62 | version 2.05 | ||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||
| 64 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||
| 66 | Use postderef (e.g. $ref->@*) instead of the "old" dereferencing (e.g. @{$ref}) | ||||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||
| 68 | =head1 AUTHOR | ||||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||
| 70 | Renee Baecker <reneeb@cpan.org> | ||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||
| 72 | =head1 COPYRIGHT AND LICENSE | ||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||
| 74 | This software is Copyright (c) 2015 by Renee Baecker. | ||||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||
| 76 | This is free software, licensed under: | ||||||||||||||||||||||||||||
| 77 | |||||||||||||||||||||||||||||
| 78 | The Artistic License 2.0 (GPL Compatible) | ||||||||||||||||||||||||||||
| 79 | |||||||||||||||||||||||||||||
| 80 | =cut | ||||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||
| 82 | __END__ | ||||||||||||||||||||||||||||