| 1 | package Test::TrailingSpace; | ||||||||||||||||||||||||||||||||||
| 2 | 3 | $Test::TrailingSpace::VERSION = '0.0601'; | |||||||||||||||||||||||||||||||||
| 3 | 3 | ▶ | use 5.014; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 4 | 3 | ▶ | use strict; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 5 | 3 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 6 | 3 | ▶ | use autodie; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||||||||
| 8 | 3 | ▶ | use Test::More; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||||||||
| 10 | 3 | ▶ | use File::Find::Object::Rule 0.0301; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||||||||
| 12 | sub new | ||||||||||||||||||||||||||||||||||
| 13 | 11 | ▶ | { | ||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||
| 14 | 11 | my $class = shift; | |||||||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||||||||
| 16 | 11 | my $self = bless {}, $class; | |||||||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||||||||
| 18 | 11 | $self->_init(@_); | |||||||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||||||||
| 20 | 11 | return $self; | |||||||||||||||||||||||||||||||||
| 21 | } | ||||||||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||||||||
| 23 | sub _filename_regex | ||||||||||||||||||||||||||||||||||
| 24 | 22 | ▶ | { | ||||||||||||||||||||||||||||||||
|
Subroutine
_filename_regex: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||
| 25 | 22 | my $self = shift; | |||||||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||||||||
| 27 | 22 | ▶ | if (@_) | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 28 | { | ||||||||||||||||||||||||||||||||||
| 29 | 11 | $self->{_filename_regex} = shift; | |||||||||||||||||||||||||||||||||
| 30 | } | ||||||||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||||||||
| 32 | 22 | return $self->{_filename_regex}; | |||||||||||||||||||||||||||||||||
| 33 | } | ||||||||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||||||||
| 35 | sub _root_path | ||||||||||||||||||||||||||||||||||
| 36 | 22 | ▶ | { | ||||||||||||||||||||||||||||||||
|
Subroutine
_root_path: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||
| 37 | 22 | my $self = shift; | |||||||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||||||||
| 39 | 22 | ▶ | if (@_) | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 40 | { | ||||||||||||||||||||||||||||||||||
| 41 | 11 | $self->{_root_path} = shift; | |||||||||||||||||||||||||||||||||
| 42 | } | ||||||||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||||||||
| 44 | 22 | return $self->{_root_path}; | |||||||||||||||||||||||||||||||||
| 45 | } | ||||||||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||||||||
| 47 | sub _abs_path_prune_re | ||||||||||||||||||||||||||||||||||
| 48 | 22 | ▶ | { | ||||||||||||||||||||||||||||||||
|
Subroutine
_abs_path_prune_re: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||
| 49 | 22 | my $self = shift; | |||||||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||||||||
| 51 | 22 | ▶ | if (@_) | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 52 | { | ||||||||||||||||||||||||||||||||||
| 53 | 11 | $self->{_abs_path_prune_re} = shift; | |||||||||||||||||||||||||||||||||
| 54 | } | ||||||||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||||||||
| 56 | 22 | return $self->{_abs_path_prune_re}; | |||||||||||||||||||||||||||||||||
| 57 | } | ||||||||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||||||||
| 59 | sub _path_cb | ||||||||||||||||||||||||||||||||||
| 60 | 22 | ▶ | { | ||||||||||||||||||||||||||||||||
|
Subroutine
_path_cb: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||
| 61 | 22 | my $self = shift; | |||||||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||||||||
| 63 | 22 | ▶ | if (@_) | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 64 | { | ||||||||||||||||||||||||||||||||||
| 65 | 11 | $self->{_path_cb} = shift; | |||||||||||||||||||||||||||||||||
| 66 | } | ||||||||||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||||||||
| 68 | 22 | return $self->{_path_cb}; | |||||||||||||||||||||||||||||||||
| 69 | } | ||||||||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||||||||
| 71 | sub _init | ||||||||||||||||||||||||||||||||||
| 72 | 11 | ▶ | { | ||||||||||||||||||||||||||||||||
|
Subroutine
_init: called CC=5 SCAR=16.1
| |||||||||||||||||||||||||||||||||||
| 73 | 11 | my ( $self, $args ) = @_; | |||||||||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||||||||
| 75 | 11 | ▶ | $self->_root_path( exists( $args->{root} ) ? $args->{root} : '.' ); | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 76 | 11 | $self->_filename_regex( $args->{filename_regex} ); | |||||||||||||||||||||||||||||||||
| 77 | 11 | $self->_abs_path_prune_re( $args->{abs_path_prune_re} ); | |||||||||||||||||||||||||||||||||
| 78 | 11 | my $find_cr = $args->{find_cr}; | |||||||||||||||||||||||||||||||||
| 79 | |||||||||||||||||||||||||||||||||||
| 80 | 11 | ▶ | my $OPEN_MODE = $find_cr ? '<:raw' : '<'; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 81 | 11 | my $cb = | |||||||||||||||||||||||||||||||||
| 82 | "sub { my (\$r) = \@_; my \$nf = 0; while (my \$p = \$r->match()) { open( my \$fh, '$OPEN_MODE', \$p ); L: while ( my \$l = <\$fh> ){chomp(\$l);"; | ||||||||||||||||||||||||||||||||||
| 83 | 11 | $cb .= | |||||||||||||||||||||||||||||||||
| 84 | q#if ( $l =~ /[ \\t]+\\r?\\z/ ){diag("Found trailing space in file '$p'");++$nf; last L;}#; | ||||||||||||||||||||||||||||||||||
| 85 | 11 | ▶ | if ( $args->{find_tabs} ) | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 86 | { | ||||||||||||||||||||||||||||||||||
| 87 | 3 | $cb .= | |||||||||||||||||||||||||||||||||
| 88 | q#if ( $l =~ /\\t/ ) { diag("Found hard tabs in file '$p'"); ++$nf; last L;}#; | ||||||||||||||||||||||||||||||||||
| 89 | } | ||||||||||||||||||||||||||||||||||
| 90 | |||||||||||||||||||||||||||||||||||
| 91 | 11 | ▶ | if ($find_cr) | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 92 | { | ||||||||||||||||||||||||||||||||||
| 93 | 2 | $cb .= | |||||||||||||||||||||||||||||||||
| 94 | q# if ( $l =~ /\\r\\z/ ) { diag("Found Carriage Returns line endings in file '$p'"); ++$nf; last L; }#; | ||||||||||||||||||||||||||||||||||
| 95 | } | ||||||||||||||||||||||||||||||||||
| 96 | 11 | $cb .= "} } return \$nf;}"; | |||||||||||||||||||||||||||||||||
| 97 | |||||||||||||||||||||||||||||||||||
| 98 | ## no critic | ||||||||||||||||||||||||||||||||||
| 99 | 11 | $self->_path_cb( eval($cb) ); | |||||||||||||||||||||||||||||||||
| 100 | ## use critic | ||||||||||||||||||||||||||||||||||
| 101 | 11 | return; | |||||||||||||||||||||||||||||||||
| 102 | } | ||||||||||||||||||||||||||||||||||
| 103 | |||||||||||||||||||||||||||||||||||
| 104 | sub no_trailing_space | ||||||||||||||||||||||||||||||||||
| 105 | 11 | ▶ | { | ||||||||||||||||||||||||||||||||
|
Subroutine
no_trailing_space: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||
| 106 | 11 | local $Test::Builder::Level = $Test::Builder::Level + 1; | |||||||||||||||||||||||||||||||||
| 107 | |||||||||||||||||||||||||||||||||||
| 108 | 11 | my ( $self, $blurb ) = @_; | |||||||||||||||||||||||||||||||||
| 109 | |||||||||||||||||||||||||||||||||||
| 110 | 11 | my $subrule = File::Find::Object::Rule->new; | |||||||||||||||||||||||||||||||||
| 111 | |||||||||||||||||||||||||||||||||||
| 112 | 11 | my $abs_path_prune_re = $self->_abs_path_prune_re(); | |||||||||||||||||||||||||||||||||
| 113 | |||||||||||||||||||||||||||||||||||
| 114 | my $rule = $subrule->or( | ||||||||||||||||||||||||||||||||||
| 115 | $subrule->new->exec( | ||||||||||||||||||||||||||||||||||
| 116 | 132 | ▶ | sub { | ||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||
| 117 | 132 | my ( $shortname, undef, $path ) = @_; | |||||||||||||||||||||||||||||||||
| 118 | return ( | ||||||||||||||||||||||||||||||||||
| 119 | ( | ||||||||||||||||||||||||||||||||||
| 120 | 132 | ▶ | $shortname =~ | ||||||||||||||||||||||||||||||||
|
Condition100%6/6
$shortname =~ /\A(?:blib|_build|CVS|\.svn|\.bzr|\.hg|\.git)\z/u || defined $abs_path_prune_re && $path =~ /$abs_path_prune_re/u
defined $abs_path_prune_re and $path =~ /$abs_path_prune_re/u
MC/DC100%3/3
$shortname =~ /\A(?:blib|_build|CVS|\.svn|\.bzr|\.hg|\.git)\z/u || defined $abs_path_prune_re && $path =~ /$abs_path_prune_re/u
$shortname =~ /\A(?:blib|_build|CVS|\.svn|\.bzr|\.hg|\.git)\z/u
defined $abs_path_prune_re
$path =~ /$abs_path_prune_re/u
Truth table100%4/4
A || B and C
A= $shortname =~ /\A(?:blib|_build|CVS|\.svn|\.bzr|\.hg|\.git)\z/uB= defined $abs_path_prune_reC= $path =~ /$abs_path_prune_re/u
| |||||||||||||||||||||||||||||||||||
| 121 | /\A(?:blib|_build|CVS|\.svn|\.bzr|\.hg|\.git)\z/ | ||||||||||||||||||||||||||||||||||
| 122 | ) | ||||||||||||||||||||||||||||||||||
| 123 | or ( defined($abs_path_prune_re) | ||||||||||||||||||||||||||||||||||
| 124 | && ( $path =~ m/$abs_path_prune_re/ ) ) | ||||||||||||||||||||||||||||||||||
| 125 | ); | ||||||||||||||||||||||||||||||||||
| 126 | } | ||||||||||||||||||||||||||||||||||
| 127 | 11 | )->prune->discard, | |||||||||||||||||||||||||||||||||
| 128 | $subrule->new->file() | ||||||||||||||||||||||||||||||||||
| 129 | |||||||||||||||||||||||||||||||||||
| 130 | # ->exec(sub { print STDERR join(",", "Foo==", @_), "\n"; return 1; }) | ||||||||||||||||||||||||||||||||||
| 131 | ->name( $self->_filename_regex() ), | ||||||||||||||||||||||||||||||||||
| 132 | )->start( $self->_root_path() ); | ||||||||||||||||||||||||||||||||||
| 133 | 11 | my $num_found = $self->_path_cb()->($rule); | |||||||||||||||||||||||||||||||||
| 134 | |||||||||||||||||||||||||||||||||||
| 135 | 11 | return is( $num_found, 0, $blurb ); | |||||||||||||||||||||||||||||||||
| 136 | } | ||||||||||||||||||||||||||||||||||
| 137 | |||||||||||||||||||||||||||||||||||
| 138 | 3 | 1; | |||||||||||||||||||||||||||||||||
| 139 | |||||||||||||||||||||||||||||||||||
| 140 | __END__ | ||||||||||||||||||||||||||||||||||