line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Code::TidyAll::Plugin::Spellunker; |
2
|
3
|
|
|
3
|
|
80921
|
use 5.008001; |
|
3
|
|
|
|
|
13
|
|
3
|
3
|
|
|
3
|
|
19
|
use strict; |
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
45
|
|
4
|
3
|
|
|
3
|
|
11
|
use warnings; |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
116
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
our $VERSION = "0.01"; |
7
|
|
|
|
|
|
|
|
8
|
3
|
|
|
3
|
|
805
|
use Moo; |
|
3
|
|
|
|
|
17517
|
|
|
3
|
|
|
|
|
20
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
extends 'Code::TidyAll::Plugin'; |
11
|
|
|
|
|
|
|
|
12
|
3
|
|
|
3
|
|
3403
|
use Spellunker; |
|
3
|
|
|
|
|
90184
|
|
|
3
|
|
|
|
|
110
|
|
13
|
|
|
|
|
|
|
|
14
|
3
|
|
|
3
|
|
1164
|
use Specio::Declare; |
|
3
|
|
|
|
|
161439
|
|
|
3
|
|
|
|
|
18
|
|
15
|
3
|
|
|
3
|
|
1607
|
use Specio::Library::Builtins; |
|
3
|
|
|
|
|
59429
|
|
|
3
|
|
|
|
|
28
|
|
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
has stopwords => ( |
18
|
|
|
|
|
|
|
is => 'ro', |
19
|
|
|
|
|
|
|
isa => anon( |
20
|
|
|
|
|
|
|
parent => t('Str'), |
21
|
|
|
|
|
|
|
where => sub { $_[0] =~ /^ \s* [^,]+ (?: \s* ,[^,]+ )* \s* $/xo }, |
22
|
|
|
|
|
|
|
), |
23
|
|
|
|
|
|
|
default => q{}, |
24
|
|
|
|
|
|
|
); |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
has parsed_stopwords => ( |
27
|
|
|
|
|
|
|
is => 'lazy', |
28
|
|
|
|
|
|
|
isa => t('ArrayRef'), |
29
|
|
|
|
|
|
|
); |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
## no critic (ProhibitUnusedPrivateSubroutines) |
32
|
|
|
|
|
|
|
sub _build_parsed_stopwords { |
33
|
4
|
|
|
4
|
|
60
|
my $self = shift; |
34
|
4
|
|
|
|
|
96
|
return [split /\s*,\s*/x, $self->stopwords]; |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
## use critic (ProhibitUnusedPrivateSubroutines) |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
sub validate_source { |
39
|
4
|
|
|
4
|
1
|
582
|
my ($self, $source) = @_; |
40
|
|
|
|
|
|
|
|
41
|
4
|
|
|
|
|
21
|
my @errors = $self->_check_source($source); |
42
|
4
|
100
|
|
|
|
153744
|
return unless @errors; |
43
|
|
|
|
|
|
|
|
44
|
2
|
|
|
|
|
41
|
my $msg = _stringify_errors(@errors); |
45
|
2
|
|
|
|
|
48
|
die $msg; ## no critic (RequireCarping) |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
sub _check_source { |
49
|
2
|
|
|
2
|
|
4
|
my ($self, $source) = @_; |
50
|
|
|
|
|
|
|
|
51
|
2
|
|
|
|
|
21
|
my $engine = Spellunker->new(); |
52
|
2
|
|
|
|
|
781452
|
$engine->add_stopwords(@{ $self->parsed_stopwords }); |
|
2
|
|
|
|
|
109
|
|
53
|
|
|
|
|
|
|
|
54
|
2
|
|
|
|
|
113
|
my @errors; |
55
|
|
|
|
|
|
|
|
56
|
2
|
|
|
|
|
4
|
my $lineno = 0; |
57
|
2
|
|
|
|
|
50
|
for my $line (split quotemeta $/, $source) { |
58
|
2
|
|
|
|
|
6
|
$lineno++; |
59
|
|
|
|
|
|
|
|
60
|
2
|
|
|
|
|
12
|
my @line_errors = $engine->check_line($line); |
61
|
2
|
100
|
|
|
|
1246
|
next unless @line_errors; |
62
|
|
|
|
|
|
|
|
63
|
1
|
|
|
|
|
5
|
push @errors => [ |
64
|
|
|
|
|
|
|
$lineno, |
65
|
|
|
|
|
|
|
$line, |
66
|
|
|
|
|
|
|
\@line_errors, |
67
|
|
|
|
|
|
|
]; |
68
|
|
|
|
|
|
|
} |
69
|
|
|
|
|
|
|
|
70
|
2
|
|
|
|
|
130661
|
return @errors; |
71
|
|
|
|
|
|
|
} |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
sub _stringify_errors { |
74
|
2
|
|
|
2
|
|
11
|
my @errors = @_; |
75
|
|
|
|
|
|
|
|
76
|
2
|
|
|
|
|
170
|
my $msg = "Errors:\n"; |
77
|
2
|
|
|
|
|
11
|
for (@errors) { |
78
|
2
|
|
|
|
|
9
|
my ($lineno, $line, $errs) = @$_; |
79
|
2
|
|
|
|
|
167
|
for my $err (@$errs) { |
80
|
2
|
|
|
|
|
23
|
$msg .= " $lineno: $err\n"; |
81
|
|
|
|
|
|
|
} |
82
|
|
|
|
|
|
|
} |
83
|
2
|
|
|
|
|
8
|
return $msg; |
84
|
|
|
|
|
|
|
} |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
1; |
87
|
|
|
|
|
|
|
__END__ |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
=encoding utf-8 |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
=head1 NAME |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
Code::TidyAll::Plugin::Spellunker - Code::TydyAll plugin for Spellunker |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
=head1 SYNOPSIS |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
[Spellunker] |
98
|
|
|
|
|
|
|
select = doc/**/*.txt |
99
|
|
|
|
|
|
|
stopwords = karupanerura |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
[Spellunker::Pod] |
102
|
|
|
|
|
|
|
select = lib/**/*.{pm,pod} |
103
|
|
|
|
|
|
|
stopwords = karupanerura |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
=head1 DESCRIPTION |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
Code::TidyAll::Plugin::Spellunker is Code::TydyAll plugin for Spellunker. |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
=head1 OPTIONS |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
=head2 stopwords |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
Add stopwords to the on memory dictionary. Separate it by ",". |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
SEE ALSO: https://metacpan.org/pod/Spellunker#$spellunker-%3Eadd_stopwords(@stopwords) |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
=head1 LICENSE |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
Copyright (C) karupanerura. |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or modify |
122
|
|
|
|
|
|
|
it under the same terms as Perl itself. |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
=head1 AUTHOR |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
karupanerura E<lt>karupa@cpan.orgE<gt> |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
=cut |
129
|
|
|
|
|
|
|
|