GitGrepPerlStatement/StatementFinder.pm

filter: Statementstmt 45.0% 18 / 40 Branchbran 0.0% 0 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 46.1% 6 / 13 Podpod 0.0% 0 / 6 totaltotal 38.1% 24 / 63 CC 3 SCAR 9.8
CC
3
Cov
41%
search
6.0
highlight
6.0
new
2.0
CRAP 2.7
« GitGrepPerlStatement.pm ↑ Summary
1 package App::GitGrepPerlStatement::StatementFinder;
2 1 ▶use 5.008001;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 1 ▶use PPI;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 1 ▶use List::MoreUtils qw(any);
Subroutine BEGIN: called CC=1 SCAR=0.0
7 1 ▶use Term::ANSIColor qw(colored);
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 0 ▶sub new {
Subroutine new: not called CC=1 SCAR=6.9
Pod undocumented
10 0 my ($class, $word) = @_;
11 0 bless {
12 word => $word,
13 docs => [],
14 }, $class;
15 }
16  
17 0 ▶sub word {
Subroutine word: not called CC=1 SCAR=6.9
Pod undocumented
18 0 my ($self) = @_;
19 0 $self->{word};
20 }
21  
22 0 ▶sub search {
Subroutine search: not called CC=2 SCAR=17.9
Pod undocumented
23 0 my ($self, $file) = @_;
24  
25 0 my $doc = PPI::Document->new($file);
26 0 ▶ return unless $doc;
Branch: 1 branch
BranchTrueFalseTotal
unless $doc 0 0 0
27 0 push @{$self->{docs}}, $doc;
28  
29 0 my $statements = $doc->find('PPI::Statement');
30  
31 grep {
32 0 my $tokens = [ $_->children ];
33  
34 0 ▶ any {
Subroutine __ANON__: not called CC=1 SCAR=6.9
35 0 $_ eq $self->word;
36 0 } @$tokens;
37 } @$statements;
38 }
39  
40 0 ▶sub flush {
Subroutine flush: not called CC=1 SCAR=6.9
Pod undocumented
41 0 my ($self) = @_;
42 0 $self->{docs} = [];
43 }
44  
45 0 ▶sub highlight_style {
Subroutine highlight_style: not called CC=1 SCAR=6.9
Pod undocumented
46 0 ['red'];
47 }
48  
49 0 ▶sub highlight {
Subroutine highlight: not called CC=2 SCAR=17.9
Pod undocumented
50 0 my ($self, $statement) = @_;
51  
52 join '', map {
53 0 ▶ if ($_ eq $self->word) {
Branch: 1 branch
BranchTrueFalseTotal
if ($_ eq $self->word) { } 0 0 0
54 0 colored($self->highlight_style, $_);
55 } else {
56 0 $_;
57 }
58 } $statement->children;
59 }
60  
61 1 1;
« GitGrepPerlStatement.pm ↑ Summary