NAME
Perl::Critic::Violation - Represents policy violations
SYNOPSIS
use PPI;
use Perl::Critic::Violation;
my $loc = $node->location(); #$node is a PPI::Node object
my $desc = 'Offending code'; #Describe the violation
my $expl = [1,45,67]; #Page numbers from PBB
my $vio = Perl::Critic::Violation->new($desc, $expl, $loc);
DESCRIPTION
Perl::Critic::Violation is the generic represntation of an individual Policy violation. Its primary purpose is to provide an abstraction layer so that clients of Perl::Critic don't have to know anything about PPI. The violations
method of all Perl::Critic::Policy subclasses must return a list of these Perl::Critic::Violation objects.
METHODS
- new( $description, $explanation, $location )
-
Retruns a reference to a new
Perl::Critic::Violation
object. The arguments are a description of the violation (as string), an explanation for the policy (as string) or a series of page numbers in PBB (as an ARRAY ref), and the location of the violation (as an ARRAY ref). The$location
must have two elements, representing the line and column number, in that order. - description ( void )
-
Returns a brief description of the policy that has been volated as a string.
- explanation( void )
-
Returns the explanation for this policy as a string or as reference to an array of page numbers in PBB.
- location( void )
-
Returns a two-element list containing the line and column number where the violation occurred.
OVERLOADS
Perl::Critic::Violation overloads the "" operator to produce neat little messages when evaluated in string context. The format is something like this:
Your violation description at line ##, column ##. See page ## of PBB
AUTHOR
Jeffrey Ryan Thalhammer <thaljef@cpan.org>
COPYRIGHT
Copyright (c) 2005 Jeffrey Ryan Thalhammer. All rights reserved.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. The full text of this license can be found in the LICENSE file included with this module.