NAME
Module::Checkstyle - Validate that your code confirms to coding guidelines
SYNOPSIS
use Module::Checkstyle;
my $checkstyle = Module::Checkstyle->new();
$checkstyle->check("/path/to/my_script.pl");
foreach my $problem ($checkstyle->get_problems) {
print $problem, "\n";
}
DESCRIPTION
Module::Checkstyle is a tool similar to checkstyle http://checkstyle.sourceforge.net for Java. It allows you to validate that your code confirms to a set of guidelines checking various things such as indentation, naming, whitespace, complexity and so forth.
Module::Checkstyle is also extensible so your organization can implement custom checks that are not provided by the standard distribution. There is a guide on how to write checks in Module::Checkstyle::Check
USAGE
Module::Checkstyle is mostly used via the provided module-checkstyle
tool. You probablly want to read module-checkstyle.
METHODS
- new ($config)
-
Creates a
Module::Checkstyle
object. The optional argument $config is passed directly to the constructor ofModule::Checkstyle::Config
. If ommited it will load the configuration from ~/.module-checkstyle/config if it exists. - check(@paths , $args);
-
Checks all paths given in @files. If a path is a directory it is reqursively searched for "parsable" files which will be checked.
The optional argument $args must be a HASH reference and may contain the following options:
- ignore_common
-
If ignore_common is set to a false value the
check
method will not ignore what it considers to be common files such as MANIFEST, inc/*, blib/*, Makefile.PL, Build.PL etc. If it is ommited or set to a true value common files will be ignored.
This method returns a true value if there are any violations reported in the
Module::Checkstyle
object it is invoked on. To flush the problem list callflush_problems
first. - flush_problems
-
Flushes the list of problems. In list context it returns the current a list of
Module::Checkstyle::Problem
objects. In scalar context it returns a reference to the list. - get_problems
-
In list context it returns a list of
Module::Checkstyle::Problem
objects that has been found by the checker since last flush. In scalar context it returns a reference to the list.
CONTRIBUTING
This project is work in progress which means it can always be improved. If you are interested in contributing tests, bug-fixes, new checks or other please contact me via email (the address is below). I get a lot of email so don't be suprised if you don't get an answer right away.
If you're sending me a patch please submit it in unified diff format (diff -u) complete with test-cases via http://rt.cpan.org/
If you want to write a check module you think should be included in this distribution it can either can be mailed directly to me (the address is below) or posted via http://rt.perl.org. Mark the bug as wishlist or (empty).
BUGS AND LIMITATIONS
Please report any bugs or feature requests to bug-module-checkstyle@rt.cpan.org
, or through the web interface at http://rt.cpan.org.
THANKS
Special thanks goes to Adam Kennedy (ADAMK) for creating PPI which is what made this all possible in the first place.
AUTHOR
Claes Jacobsson <claesjac@cpan.org>
LICENCE AND COPYRIGHT
Copyright (c) 2005, Claes Jacobsson <claesjac@cpan.org>
. All rights reserved.
This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See perlartistic.
DISCLAIMER OF WARRANTY
BECAUSE THIS SOFTWARE IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE SOFTWARE, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE SOFTWARE "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE SOFTWARE IS WITH YOU. SHOULD THE SOFTWARE PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR, OR CORRECTION.
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE SOFTWARE AS PERMITTED BY THE ABOVE LICENCE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE SOFTWARE (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE SOFTWARE TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.