Login
Offering a new Perl::Critic::Annotation class for review.
The idea here is to define an object that represents the
"## no critic" markers that appear in the file. Policies
can then interact with these objects via P::C::Document.
For example, ProhibitUnrestrictedNoCritic would look something
like this:
sub violates {
my ( $self, $doc, undef ) = @_;
# If for some reason $doc is not a P::C::Document, then all bets are off
return if not $doc->isa('Perl::Critic::Document');
my @violations = ();
for my $annotation ($doc->annotations()) {
if ($annotation->disables_all_policies()) {
my $token = $annotation->token();
push @violations, $self->violation($DESC, $EXPL, $token);
}
}
return @violations;
}
I've completed most of the work to integrate this with the existing
code. But I won't commit it until everyone has reviewed this idea.
Comments wanted!