« blib/lib/Perl/Critic/PolicyParameter/Behavior/Enumeration.pm
↑ Summary
blib/lib/Perl/Critic/Utils/POD.pm »
| 1 | package Perl::Critic::Policy::ControlStructures::ProhibitYadaOperator; | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | 40 | ▶ | use 5.010001; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | 40 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | 40 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | 40 | ▶ | use Readonly; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||
| 8 | 40 | ▶ | use Perl::Critic::Utils qw{ :characters :severities }; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 9 | 40 | ▶ | use parent 'Perl::Critic::Policy'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||
| 11 | 40 | our $VERSION = '1.150'; | |||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||
| 13 | #----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||
| 15 | 40 | Readonly::Scalar my $DESC => q{yada operator (...) used}; | |||||||||||||||||||||||||||
| 16 | 40 | Readonly::Scalar my $EXPL => q{The yada operator is a placeholder for code you have not yet written.}; | |||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||
| 18 | #----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||
| 20 | 90 | ▶ | sub supported_parameters { return () } | ||||||||||||||||||||||||||
|
Subroutine
supported_parameters: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 21 | 75 | ▶ | sub default_severity { return $SEVERITY_HIGH } | ||||||||||||||||||||||||||
|
Subroutine
default_severity: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 22 | 86 | ▶ | sub default_themes { return qw( core pbp maintenance ) } | ||||||||||||||||||||||||||
|
Subroutine
default_themes: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 23 | 33 | ▶ | sub applies_to { return 'PPI::Token::Operator' } | ||||||||||||||||||||||||||
|
Subroutine
applies_to: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||
| 25 | #----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||
| 27 | sub violates { | ||||||||||||||||||||||||||||
| 28 | 140 | ▶ | my ( $self, $elem, undef ) = @_; | ||||||||||||||||||||||||||
|
Subroutine
violates: called CC=2 SCAR=7.6
Pod
documented
| |||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||
| 30 | 140 | ▶ | if ( _is_yada( $elem ) ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 31 | 0 | return $self->violation( $DESC, $EXPL, $elem ); | |||||||||||||||||||||||||||
| 32 | } | ||||||||||||||||||||||||||||
| 33 | 140 | return; #ok! | |||||||||||||||||||||||||||
| 34 | } | ||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||
| 36 | sub _is_yada { | ||||||||||||||||||||||||||||
| 37 | 140 | ▶ | my ( $elem ) = @_; | ||||||||||||||||||||||||||
|
Subroutine
_is_yada: called CC=4 SCAR=23.2
| |||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||
| 39 | 140 | ▶ | return if $elem ne '...'; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 40 | #return if not defined $elem->statement; | ||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||
| 42 | # if there is something significant on both sides of the element it's | ||||||||||||||||||||||||||||
| 43 | # probably the three dot range operator | ||||||||||||||||||||||||||||
| 44 | 0 | ▶ | return if ($elem->snext_sibling and $elem->sprevious_sibling); | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$elem->snext_sibling and $elem->sprevious_sibling
MC/DC0%0/2
$elem->snext_sibling and $elem->sprevious_sibling
$elem->snext_sibling
$elem->sprevious_sibling
Truth table0%0/3
A and B
A= $elem->snext_siblingB= $elem->sprevious_sibling
| |||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||
| 46 | 0 | return 1; | |||||||||||||||||||||||||||
| 47 | } | ||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||
| 49 | 40 | 1; | |||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||
| 51 | __END__ | ||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||
| 53 | #----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||
| 55 | =pod | ||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||
| 57 | =for stopwords yada Berndt | ||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||
| 59 | =head1 NAME | ||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||
| 61 | Perl::Critic::Policy::ControlStructures::ProhibitYadaOperator - Never use C<...> in production code. | ||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||
| 63 | =head1 AFFILIATION | ||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||
| 65 | This Policy is part of the core L<Perl::Critic|Perl::Critic> | ||||||||||||||||||||||||||||
| 66 | distribution. | ||||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||
| 69 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||
| 71 | The yada operator C<...> is not something you'd want in production | ||||||||||||||||||||||||||||
| 72 | code because it will throw an exception when executed. However, it is | ||||||||||||||||||||||||||||
| 73 | perfectly useful in less critical environments as a placeholder for code | ||||||||||||||||||||||||||||
| 74 | not yet implemented. | ||||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||
| 76 | =head1 CONFIGURATION | ||||||||||||||||||||||||||||
| 77 | |||||||||||||||||||||||||||||
| 78 | This Policy is not configurable except for the standard options. | ||||||||||||||||||||||||||||
| 79 | |||||||||||||||||||||||||||||
| 80 | =head1 AUTHOR | ||||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||
| 82 | Alan Berndt <alan@eatabrick.org> | ||||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||
| 84 | =head1 COPYRIGHT | ||||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||
| 86 | Copyright (c) 2015-2017 Alan Berndt. All rights reserved. | ||||||||||||||||||||||||||||
| 87 | |||||||||||||||||||||||||||||
| 88 | This program is free software; you can redistribute it and/or modify | ||||||||||||||||||||||||||||
| 89 | it under the same terms as Perl itself. The full text of this license | ||||||||||||||||||||||||||||
| 90 | can be found in the LICENSE file included with this module. | ||||||||||||||||||||||||||||
| 91 | |||||||||||||||||||||||||||||
| 92 | =cut | ||||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||
| 94 | # Local Variables: | ||||||||||||||||||||||||||||
| 95 | # mode: cperl | ||||||||||||||||||||||||||||
| 96 | # cperl-indent-level: 4 | ||||||||||||||||||||||||||||
| 97 | # fill-column: 78 | ||||||||||||||||||||||||||||
| 98 | # indent-tabs-mode: nil | ||||||||||||||||||||||||||||
| 99 | # c-indentation-style: bsd | ||||||||||||||||||||||||||||
| 100 | # End: | ||||||||||||||||||||||||||||
| 101 | # ex: set ts=8 sts=4 sw=4 tw=78 ft=perl expandtab shiftround : | ||||||||||||||||||||||||||||