Yet Another New Perl::Critic policy in the pipeline: RequirePackageNamePattern

In: Articles

27 Nov 2013

I have written up a first working version of yet another Perl::Critic policy, also this policy suggestion is highly experimental.

The policy assists in enforcing a package/module/class naming strategy, so if you prefer to have your modules names follow a certain pattern this policy could be of interest to you.

If you do not configure the policy it does not do anything. You can however configure it with as many patterns as you would like:

Patterns could look as follows:

^Acme # if you want all of you modules to start with Acme
Acme # if you want all of your modules to contain the work Acme
Acme$ # if you want all of you modules to end with Acme

For now you can only specify global patterns, but I was considering looking into the ability to specify different patterns for different directories:

Names
lib = <pattern1> || <pattern2>
t = <pattern1> || <pattern3>

And creating more complex patterns would also be great, like:

^Acme.*Test$

or:

^Acme && Test$

In addition the policy has the following configurable parameters:

- debug (for debugging)

- exempt_programs, so scripts etc. are not evaluated, these can however be of interest if you use inline packages

The motivation is to use the policy as a part of a coding standard for use at my work place, but I have developed it in my spare time since I wanted to contribute it to CPAN and as for my other policies I would like too use it on my own open source code base to begin with.

I will pack it up and push it to CPAN in a few days, but you are welcome to check it out on Github, please note that the policy is by no means done and much work remains.

jonasbn, logicLAB

Comment Form

About this blog

This blog acts as a channel for communicating logicLAB’s open source activities. Announcements on open source initiatives, involvements and releases of open source distributions of software products, projects and applications.

Photostream

  • jonasbn: Book wrote a more elaborate piece on CPAN deletions, which is worth mentioning: http://blogs.perl [...]
  • Neil Bowers: It would be good to hear your thoughts on supporting both an OO and procedural interface: what was t [...]
  • J: I'm experiencing the same issue as Petar. Anytime I click on any file, ‘No violations found’. N [...]
  • Petar: Nevermind that, I solved it with: perlcritic --brutal --verbose 5 lib t > perlcritic.txt || EX [...]
  • Petar: Hi Jonas, I tried adding perlcritic command as Windows batch command, but since my code has viola [...]

Calendar

November 2013
M T W T F S S
« Jul   Jan »
 123
45678910
11121314151617
18192021222324
252627282930