Perl.pm

filter: Statementstmt 57.6% 30 / 52 Branchbran 0.0% 0 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 50.0% 9 / 18 Podpod 0.0% 0 / 5 totaltotal 50.6% 39 / 77 CC 2 SCAR 6.4
CC
2
Cov
56%
_check_parser
6.0
__ANON__
2.0
new_from_file
2.0
CRAP 1.9
« CLI/Perl.pm ↑ Summary
1 package Spellunker::Perl;
2 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use utf8;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 1 ▶use 5.010_001;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 1 ▶use version; our $VERSION = version->declare("v0.3.2");
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 1 ▶use Spellunker;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 1 ▶use PPI;
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 1 ▶use Mouse;
Subroutine BEGIN: called CC=1 SCAR=0.0
13  
14 has spellunker => (
15 is => 'ro',
16 0 ▶ default => sub { Spellunker->new() },
Subroutine __ANON__: not called CC=1 SCAR=6.9
17 1 handles => [qw(add_stopwords load_dictionary)],
18 );
19  
20 1 has ppi => (
21 is => 'ro',
22 isa => 'PPI::Document',
23 required => 1,
24 );
25  
26 1 ▶no Mouse;
Subroutine BEGIN: called CC=1 SCAR=0.0
27  
28 0 ▶sub new_from_file {
Subroutine new_from_file: not called CC=1 SCAR=6.9
Pod undocumented
29 0 my ($class, $filename) = @_;
30  
31 0 my $ppi = PPI::Document->new($filename);
32 0 return $class->new(ppi => $ppi);
33 }
34  
35 0 ▶sub new_from_string {
Subroutine new_from_string: not called CC=1 SCAR=6.9
Pod undocumented
36 0 my ($class, $string) = @_;
37 0 my $ppi = PPI::Document->new(\$string);
38 0 return $class->new(ppi => $ppi);
39 }
40  
41 # TEST:
42 # the real defaults are dfined in the parser
43  
44 # tokens: [$line_number, $content]
45 0 ▶sub _check_parser {
Subroutine _check_parser: not called CC=2 SCAR=17.9
46 0 my ($self, $token, $method) = @_;
47  
48 0 my @err = $self->{spellunker}->check_line($token->$method);
49 0 ▶ if (@err) {
Branch: 1 branch
BranchTrueFalseTotal
if (@err) 0 0 0
50 0 return ([$token->line_number, $token->$method, \@err]);
51 }
52 0 return ();
53 }
54  
55 0 ▶sub check_comment {
Subroutine check_comment: not called CC=1 SCAR=6.9
Pod undocumented
56 0 my ($self) = @_;
57  
58 0 ▶ my $comments = $self->ppi->find( sub { $_[1]->isa('PPI::Token::Comment') } );
Subroutine __ANON__: not called CC=1 SCAR=6.9
59 0 return map { $self->_check_parser($_, 'content') } @$comments;
60 }
61  
62 0 ▶sub check_sub_name {
Subroutine check_sub_name: not called CC=1 SCAR=6.9
Pod undocumented
63 0 my ($self) = @_;
64  
65 0 ▶ my $comments = $self->ppi->find( sub { $_[1]->isa('PPI::Statement::Sub') } );
Subroutine __ANON__: not called CC=1 SCAR=6.9
66 0 return map { $self->_check_parser($_, 'name') } @$comments;
67 }
68  
69 # TEST:
70 0 ▶sub agument { }
Subroutine agument: not called CC=1 SCAR=0.0
Pod undocumented
71  
72 # TEST:
73 # template agument
74  
75 1 1;
76 __END__
« CLI/Perl.pm ↑ Summary