| 1 | package Code::TidyAll::Plugin::Perl::IgnoreMethodSignaturesSimple; | ||||||||||
| 2 | 1 | $Code::TidyAll::Plugin::Perl::IgnoreMethodSignaturesSimple::VERSION = '0.03'; | |||||||||
| 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 base qw(Code::TidyAll::Plugin); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 6 | |||||||||||
| 7 | 0 | ▶ | sub preprocess_source { | ||||||||
|
Subroutine
preprocess_source: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 8 | 0 | my ( $self, $source ) = @_; | |||||||||
| 9 | |||||||||||
| 10 | 0 | $source =~ | |||||||||
| 11 | 0 | s/^\h*(method|func)\s+(\w+)([^\{]+)\{/$self->_munged_sub($1, $2, $3)/gme; | |||||||||
| 12 | |||||||||||
| 13 | 0 | return $source; | |||||||||
| 14 | } | ||||||||||
| 15 | |||||||||||
| 16 | 0 | ▶ | sub postprocess_source { | ||||||||
|
Subroutine
postprocess_source: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||
| 17 | 0 | my ( $self, $source ) = @_; | |||||||||
| 18 | |||||||||||
| 19 | 0 | foreach my $id ( keys( %{ $self->{saves} } ) ) { | |||||||||
| 20 | 0 | my ( $keyword, $name, $rest ) = @{ $self->{saves}->{$id} }; | |||||||||
| 21 | 0 | for ( $name, $rest ) { s/^\s+//; s/\s+$// } | |||||||||
| 22 | |||||||||||
| 23 | # Blank parens if no params list | ||||||||||
| 24 | # | ||||||||||
| 25 | 0 | ▶ | $rest = '()' if $rest !~ /\S/; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 26 | |||||||||||
| 27 | # No space inside parens | ||||||||||
| 28 | # | ||||||||||
| 29 | 0 | $rest =~ s/\(\s+/\(/; | |||||||||
| 30 | 0 | $rest =~ s/\s+\)/\)/; | |||||||||
| 31 | |||||||||||
| 32 | 0 | $source =~ s/sub MUNGED_${id}_/$keyword $name $rest/; | |||||||||
| 33 | } | ||||||||||
| 34 | |||||||||||
| 35 | 0 | return $source; | |||||||||
| 36 | } | ||||||||||
| 37 | |||||||||||
| 38 | 0 | ▶ | sub _munged_sub { | ||||||||
|
Subroutine
_munged_sub: not called CC=1 SCAR=6.9
| |||||||||||
| 39 | 0 | my ( $self, $keyword, $name, $rest ) = @_; | |||||||||
| 40 | |||||||||||
| 41 | 0 | my $id = $self->_unique_id; | |||||||||
| 42 | 0 | $self->{saves}->{$id} = [ $keyword, $name, $rest ]; | |||||||||
| 43 | 0 | return "sub MUNGED_${id}_ {"; | |||||||||
| 44 | } | ||||||||||
| 45 | |||||||||||
| 46 | 1 | my $unique_id = 0; | |||||||||
| 47 | |||||||||||
| 48 | 0 | ▶ | sub _unique_id { | ||||||||
|
Subroutine
_unique_id: not called CC=1 SCAR=6.9
| |||||||||||
| 49 | 0 | return join( '_', time, $unique_id++ ); | |||||||||
| 50 | } | ||||||||||
| 51 | |||||||||||
| 52 | 1 | 1; | |||||||||
| 53 | |||||||||||
| 54 | __END__ | ||||||||||