File Coverage

blib/lib/Perl/Critic/Policy/ControlStructures/ProhibitYadaOperator.pm
Criterion Covered Total %
statement 29 29 100.0
branch 6 6 100.0
condition 2 3 66.6
subroutine 12 12 100.0
pod 4 5 80.0
total 53 55 96.3


line stmt bran cond sub pod time code
1             package Perl::Critic::Policy::ControlStructures::ProhibitYadaOperator;
2              
3 40     40   26472 use 5.010001;
  40         170  
4 40     40   248 use strict;
  40         107  
  40         848  
5 40     40   214 use warnings;
  40         123  
  40         1007  
6 40     40   261 use Readonly;
  40         129  
  40         2098  
7              
8 40     40   328 use Perl::Critic::Utils qw{ :characters :severities };
  40         144  
  40         2206  
9 40     40   11723 use parent 'Perl::Critic::Policy';
  40         121  
  40         287  
10              
11             our $VERSION = '1.148';
12              
13             #-----------------------------------------------------------------------------
14              
15             Readonly::Scalar my $DESC => q{yada operator (...) used};
16             Readonly::Scalar my $EXPL => q{The yada operator is a placeholder for code you have not yet written.};
17              
18             #-----------------------------------------------------------------------------
19              
20 92     92 0 1680 sub supported_parameters { return () }
21 76     76 1 381 sub default_severity { return $SEVERITY_HIGH }
22 86     86 1 377 sub default_themes { return qw( core pbp maintenance ) }
23 35     35 1 111 sub applies_to { return 'PPI::Token::Operator' }
24              
25             #-----------------------------------------------------------------------------
26              
27             sub violates {
28 146     146 1 361 my ( $self, $elem, undef ) = @_;
29              
30 146 100       382 if ( _is_yada( $elem ) ) {
31 2         14 return $self->violation( $DESC, $EXPL, $elem );
32             }
33 144         2436 return; #ok!
34             }
35              
36             sub _is_yada {
37 146     146   298 my ( $elem ) = @_;
38              
39 146 100       334 return if $elem ne '...';
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 7 100 66     125 return if ($elem->snext_sibling and $elem->sprevious_sibling);
45              
46 2         95 return 1;
47             }
48              
49             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 :