use Perl::Critic::Violation;
use Perl::Critic::Document;
use Perl::Critic::Statistics;
-use Perl::Critic::Utils qw{ :characters };
+use Perl::Critic::Utils qw{ :characters hashify };
#-----------------------------------------------------------------------------
return if not $policy->prepare_to_scan_document($doc);
my $maximum_violations = $policy->get_maximum_violations_per_document();
+ my %policies_that_cannot_be_disabled = hashify(_policies_that_cannot_be_disabled());
if (defined $maximum_violations && $maximum_violations == 0) {
return;
my $line = $violation->location()->[0];
if (exists $is_line_disabled->{$line}) {
next VIOLATION if $is_line_disabled->{$line}->{$policy_name}
- && $policy->can_be_disabled();
+ && not exists $policies_that_cannot_be_disabled{$policy_name};
next VIOLATION if $is_line_disabled->{$line}->{ALL}
- && $policy->can_be_disabled();
+ && not exists $policies_that_cannot_be_disabled{$policy_name};
}
push @violations, $violation;
#-----------------------------------------------------------------------------
-1;
+sub _policies_that_cannot_be_disabled {
+ # This is a special list of policies that cannot
+ # be disabled by the "no critic" pseudo-pragma.
+
+ return qw(
+ Perl::Critic::Policy::Miscellanea::ProhibitUnrestrictedNoCritic
+ );
+}
#-----------------------------------------------------------------------------
+1;
+
+
+
__END__
=pod
#-----------------------------------------------------------------------------
-sub can_be_disabled {
- return $TRUE;
-}
-
-#-----------------------------------------------------------------------------
-
sub _validate_config_keys {
my ( $self, $errors, $config ) = @_;
Appends additional themes to this Policy. Any existing themes are
preserved. Duplicate themes will be removed.
-=item C< can_be_disabled() >
-
-Returns a true value if this Policy can be disabled by a C<"## no critic">
-marker. The default method returns true. Most Policies should never need
-to override this. But If you want to write a policy that cannot be disabled,
-override this method to return false. Note that this only affects the
-C<"## no critic"> markers -- the Policy can still be disabled via the
-F<.perlcriticrc> file.
=item C< get_abstract() >