| 1 | package Code::TidyAll::Plugin::Flake8; | ||||||||||||||||||||||||||||
| 2 | 1 | $Code::TidyAll::Plugin::Flake8::VERSION = '0.4.0'; | |||||||||||||||||||||||||||
| 3 | 1 | ▶ | use Moo; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | 1 | ▶ | use String::ShellQuote qw/ shell_quote /; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||
| 6 | 1 | ▶ | use vars qw/ $_check /; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||
| 8 | BEGIN | ||||||||||||||||||||||||||||
| 9 | 1 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=3 SCAR=16.0
| |||||||||||||||||||||||||||||
| 10 | 1 | my $code = <<'EOF'; | |||||||||||||||||||||||||||
| 11 | from flake8.main import application | ||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||
| 13 | def _py_check(fn): | ||||||||||||||||||||||||||||
| 14 | app = application.Application() | ||||||||||||||||||||||||||||
| 15 | app.run([fn]) | ||||||||||||||||||||||||||||
| 16 | return ((app.result_count > 0) or app.catastrophic_failure) | ||||||||||||||||||||||||||||
| 17 | EOF | ||||||||||||||||||||||||||||
| 18 | ## no critic | ||||||||||||||||||||||||||||
| 19 | 0 | ▶ | if ( ( eval "use Inline Python => \$code" ) and !$@ ) | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=1.6
Branch: 1 branch
Condition33%1/3
eval "use Inline Python => \$code" and not $@
MC/DC0%0/2
eval "use Inline Python => \$code" and not $@
eval "use Inline Python => \$code"
not $@
Truth table33%1/3
A and not(B)
A= eval "use Inline Python => \$code"B= not $@
| |||||||||||||||||||||||||||||
| 20 | { | ||||||||||||||||||||||||||||
| 21 | ## use critic | ||||||||||||||||||||||||||||
| 22 | 0 | ▶ | $_check = sub { return _py_check(shift); }; | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 23 | } | ||||||||||||||||||||||||||||
| 24 | else | ||||||||||||||||||||||||||||
| 25 | { | ||||||||||||||||||||||||||||
| 26 | 0 | ▶ | $_check = sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 27 | 0 | my $cmd = shell_quote( 'flake8', shift ); | |||||||||||||||||||||||||||
| 28 | 0 | return scalar `$cmd`; | |||||||||||||||||||||||||||
| 29 | 1 | }; | |||||||||||||||||||||||||||
| 30 | } | ||||||||||||||||||||||||||||
| 31 | } | ||||||||||||||||||||||||||||
| 32 | 1 | extends 'Code::TidyAll::Plugin'; | |||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||
| 34 | sub validate_file | ||||||||||||||||||||||||||||
| 35 | 0 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
validate_file: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||
| 36 | 0 | my ( $self, $fn ) = @_; | |||||||||||||||||||||||||||
| 37 | 0 | ▶ | if ( my $error = $_check->($fn) ) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 38 | { | ||||||||||||||||||||||||||||
| 39 | 0 | die qq#flake8 validation failed for the file "$fn" ; error="$error"#; | |||||||||||||||||||||||||||
| 40 | } | ||||||||||||||||||||||||||||
| 41 | 0 | return; | |||||||||||||||||||||||||||
| 42 | } | ||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||
| 44 | 1 | 1; | |||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||
| 46 | __END__ | ||||||||||||||||||||||||||||