Skip to content

Commit

Permalink
Add goatse detection
Browse files Browse the repository at this point in the history
  • Loading branch information
lancew committed Jul 27, 2016
1 parent 562ae9f commit 2f9a74f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
10 changes: 8 additions & 2 deletions lib/Perl/Critic/Policy/Perlsecret.pm
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ sub violates {
'Inchworm' => \&_inchworm,
'Inchworm on a stick' => \&_inchworm_on_a_stick,
'Space Station' => \&_space_station,
# 'Goatse' => qr/=\(.*\)=/,
'Goatse' => \&_goatse,
# 'Flaming X-Wing' => qr/=<.*>=~/,
# 'Kite' => qr/~~<>/,
# 'Ornate Double Edged Sword' => qr/<<m=~m>>/,
Expand Down Expand Up @@ -136,6 +136,12 @@ sub _space_station {
}
}


sub _goatse {
for my $child ($_[0]->children)
{
next unless ref($child) eq 'PPI::Structure::List';
return 1 if $child->sprevious_sibling eq '=' && $child->snext_sibling eq '=';
}
}

1;
6 changes: 4 additions & 2 deletions t/20-policies.t
Original file line number Diff line number Diff line change
Expand Up @@ -63,15 +63,17 @@ print - + - '23a';
__CODE__
is pcritique( 'Perlsecret', \$code ), 2, '2 x Space station';

=pod
# Goatse
$code = <<'__CODE__';
$n =()= "abababab" =~ /a/;
#$n =()= "abababab" =~ /a/;
$n =($b)= "abababab" =~ /a/g;
$n = ( $b ) = "abababab" =~ /a/g;
# print "Dist($k,$k2)=($tri+1)/($min-1)=$Dist{$k}{$k2}\n";
__CODE__
is pcritique( 'Perlsecret', \$code ), 2;
is pcritique( 'Perlsecret', \$code ), 3, '3 x Goatse';

=pod
# Flaming X-Wing
$code = <<'__CODE__';
@data{@fields} =<>=~ $regexp;
Expand Down

0 comments on commit 2f9a74f

Please sign in to comment.