Perl::Critic::DEVELOPER

Perl::Critic::DEVELOPER is a Perl module that contains a tutorial about how to make new Perl::Critic::Policy modules.
Download

Perl::Critic::DEVELOPER Ranking & Summary

Advertisement

  • Rating:
  • License:
  • Perl Artistic License
  • Price:
  • FREE
  • Publisher Name:
  • Jeffrey Ryan Thalhammer
  • Publisher web site:
  • http://search.cpan.org/~elliotjs/Perl-Critic/lib/Perl/Critic.pm

Perl::Critic::DEVELOPER Tags


Perl::Critic::DEVELOPER Description

Perl::Critic::DEVELOPER is a Perl module that contains a tutorial about how to make new Perl::Critic::Policy modules. Perl::Critic::DEVELOPER is a Perl module that contains a tutorial about how to make new Perl::Critic::Policy modules.For developers who want to create custom coding standards, the following tells how to create a Policy module for Perl::Critic. Although the Perl::Critic distribution already includes a number of Policies based on Damian Conway's book Perl Best Practices (which will be referred to via "PBP" from here on), Perl::Critic is not limited to his guidelines and can be used to enforce any practice, preference, or style that you want to follow. You can even write Policies to enforce contradictory guidelines. All you need to do is write a corresponding Perl::Critic::Policy subclass, which may require as little as 10 lines of code.BACKGROUNDThe heart of Perl::Critic is PPI, a parser and lexer for Perl. PPI transforms Perl source code into a Document Object Model (DOM). Each token in the document is represented by a PPI class, such as PPI::Token::Operator or PPI::Token::Word, and then organized into structure classes, like PPI::Statement::Expression and PPI::Structure::Subroutine. The root node of the hierarchy is the PPI::Document.The Perl::Critic engine traverses each node in the PPI::Document tree and invokes each of the Perl::Critic::Policy subclasses at the appropriate node. The Policy can inspect the node, look at the surrounding nodes, and do whatever else it wants. If the Policy decides that that a coding standard has been violated, it returns one or more Perl::Critic::Violation objects. If there are no violations, then the Policy returns nothing.Policies are usually written based on existing policies, so let's look at one to see how it works. The RequireBlockGrep.pm Policy is relatively simple and demonstrates most of the important issues. The goal of this Policy is to enforce that every call to grep uses a block for the first argument and not an expression. The reasons for this Policy are discussed in detail in PBP. Requirements: · Perl


Perl::Critic::DEVELOPER Related Software