Lint can be extended by registering plugins.
-The C<B::Lint->register_plugin( MyPlugin => \ @new_checks ) method
+The C<< B::Lint->register_plugin( MyPlugin => \@new_checks ) >> method
adds the class C<MyPlugin> to the list of plugins. It also adds the
list of C<@new_checks> to the list of valid checks.
-You must create a C<match( \ %checks )> method in your plugin class or
-one of its inheritence parents. It will be called on every op as a
-regular method call with a hash ref of checks as its parameter.
+You must create a C<match( \%checks )> method in your plugin class or one
+of its parents. It will be called on every op as a regular method call
+with a hash ref of checks as its parameter.
-You may not alter the check hash reference.
+You may not alter the %checks hash reference.
-The class methods C<B::Lint->file> and C<B::Lint->line> contain the
-current filename and line number.
+The class methods C<< B::Lint->file >> and C<< B::Lint->line >> contain
+the current filename and line number.
- package Sample;
- use B::Lint;
- B::Lint->register_plugin( Sample => [ 'good_taste' ] );
-
- sub match {
- my ( $op, $checks_href ) = shift;
-
- if ( $checks_href->{good_taste} ) {
- ...
- }
- }
+ package Sample;
+ use B::Lint;
+ B::Lint->register_plugin( Sample => [ 'good_taste' ] );
+
+ sub match {
+ my ( $op, $checks_href ) = shift;
+ if ( $checks_href->{good_taste} ) {
+ ...
+ }
+ }
=head1 BUGS
$m = $_->can('match'), $op->$m( \ %check ) for @plugins;
return;
}
+
*$_ = *B::OP::lint
for \ ( *B::PADOP::lint,
*B::LOGOP::lint,
}
}
# Remaining arguments are things to check
-
+
return \&do_lint;
}
sub register_plugin {
my ( undef, $plugin, $new_checks ) = @_;
-
+
# Register the plugin
for my $check ( @$new_checks ) {
defined $check
or warn "$check is already registered as a B::Lint feature.";
not $plugin_valid_check{ $check }
or warn "$check is already registered as a $plugin_valid_check{$check} feature.";
-
+
$plugin_valid_check{$check} = $plugin;
}
-
+
push @plugins, $plugin;
-
+
return;
}