NAME

Module::Checkstyle::Config - Handles configuration directives

SYNOPSIS

use Module::Checkstyle::Config;
my $config = Module::Checkstyle::Config->new();
my $value = $config->get_directive('max-per-file');

DESCRIPTION

METHODS

new ($source)

Constructs a new Module::Checkstyle::Config object. The optional argument $source can be either a reference to a GLOB as in new(\*DATA), a reference to a scalar containing the configuration new(\$config) or a scalar containing a path to a configuration file.

If the $source is ommited it will look for the configuration file located at ~/.module-checkstyle/config.

get_enabled_sections

Returns a list of enabled sections.

get_severity ($check, $directive)

Returns the severity level for a given directive specified by $directive in the section specified by $check. If $check is ommited it will try to figure out what section to read from by investigating the callers package and removing Module::Checkstyle::Check.

get_directive ($check, $directive)

Returns a the directive specified by $directive in the section specified by $check. If $check is ommited it will try to figure out what section to read from by investigating the callers package and removing Module::Checkstyle::Check.

FORMAT

Module::Checkstyle uses the INI file-format for its configuration file. The following example illustrates a sample config file:

; this is a sample config
global-error-level = warn

[Whitespace]
after-comma     = true
after-fat-comma = true

[Package]
max-per-file    = 1

Here we have a global configuration diretive, global-error-level, and a few directives applicable to a specified check.

SEVERITY

The directive global-error-level sets the severity of a style violation. If it's ommited it will default to 'warn'.

It is however possible to specify the severity on a per-config basis by prefixing the directives value with either 'warn' or 'error' as in matches-name = error qr/\w+/.

BOOLEAN DIRECTIVES

Some checks expect a boolean value when they read their config. Acceptable booleans are 1, y, yes and true.

REGEXP DIRECTIVES

Checks that matches names such as variable name or subroutine names expect a regular expression in the config.

To specify a regular expression the recommended way is to use the 'qr' operator as in matches-name = qr/\w+/. If you don't want to use another delimiter it is acceptable to specify the regular expression without 'qr' and using // as in matches-name = /\w+/.

SEE ALSO

Config::Tiny Module::Checkstyle