Policy/Bangs/ProhibitBitwiseOperators.pm

filter: Statementstmt 96.7% 30 / 31 Branchbran 100% 2 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 90.9% 10 / 11 Podpod 80.0% 4 / 5 totaltotal 93.8% 46 / 49 CC 2 SCAR 2.2
CC
2
Cov
97%
default_themes
2.0
violates
2.0
BEGIN
1.0
CRAP 1.2
« Policy/Bangs/ProhibitCommentedOutCode.pm ↑ Summary
1 package Perl::Critic::Policy::Bangs::ProhibitBitwiseOperators;
2  
3 5 ▶use 5.006001;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 5 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 5 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 5 ▶use Readonly;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 5 ▶use Perl::Critic::Utils qw{ :severities :classification :data_conversion };
Subroutine BEGIN: called CC=1 SCAR=0.0
9 5 ▶use base 'Perl::Critic::Policy';
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 5 our $VERSION = '1.14';
12  
13 #-----------------------------------------------------------------------------
14  
15 5 Readonly::Scalar my $DESC => q{Use of bitwise operator};
16 5 Readonly::Scalar my $EXPL => q{Use of bitwise operator};
17  
18 #-----------------------------------------------------------------------------
19  
20 13 ▶sub supported_parameters { return () }
Subroutine supported_parameters: called CC=1 SCAR=0.0
Pod undocumented
21 7 ▶sub default_severity { return $SEVERITY_HIGHEST }
Subroutine default_severity: called CC=1 SCAR=0.0
Pod documented
22 0 ▶sub default_themes { return qw( bangs bugs ) }
Subroutine default_themes: not called CC=1 SCAR=6.9
Pod documented
23 10 ▶sub applies_to { return 'PPI::Token::Operator' }
Subroutine applies_to: called CC=1 SCAR=0.0
Pod documented
24  
25 #-----------------------------------------------------------------------------
26  
27 5 my %bitwise_operators = hashify( qw( & | ^ ~ &= |= ^= ) );
28  
29 72 ▶sub violates {
Subroutine violates: called CC=2 SCAR=6.9
Pod documented
30 72 my ( $self, $elem, undef ) = @_;
31  
32 72 my $content = $elem->content();
33 72 ▶ if ( $bitwise_operators{$content} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($bitwise_operators{$content}) 7 65 72
34 7 return $self->violation( $DESC, qq{$EXPL "$content"}, $elem );
35 }
36 65 return; #ok!
37 }
38  
39 5 1;
40  
41 __END__
« Policy/Bangs/ProhibitCommentedOutCode.pm ↑ Summary