perlcritic
perlcritic documentation
- Version in MegaLinter: 1.156
- Visit Official Web Site
- See How to configure perlcritic rules
- See How to disable perlcritic rules in files
- See Index of problems detected by perlcritic
Configuration in MegaLinter
- Enable perlcritic by adding
PERL_PERLCRITIC
in ENABLE_LINTERS variable - Disable perlcritic by adding
PERL_PERLCRITIC
in DISABLE_LINTERS variable
Variable | Description | Default value |
---|---|---|
PERL_PERLCRITIC_ARGUMENTS | User custom arguments to add in linter CLI call Ex: -s --foo "bar" |
|
PERL_PERLCRITIC_COMMAND_REMOVE_ARGUMENTS | User custom arguments to remove from command line before calling the linter Ex: -s --foo "bar" |
|
PERL_PERLCRITIC_FILTER_REGEX_INCLUDE | Custom regex including filter Ex: (src\|lib) |
Include every file |
PERL_PERLCRITIC_FILTER_REGEX_EXCLUDE | Custom regex excluding filter Ex: (test\|examples) |
Exclude no file |
PERL_PERLCRITIC_CLI_LINT_MODE | Override default CLI lint mode - file : Calls the linter for each file- project : Call the linter from the root of the project |
file |
PERL_PERLCRITIC_FILE_EXTENSIONS | Allowed file extensions. "*" matches any extension, "" matches empty extension. Empty list excludes all filesEx: [".py", ""] |
[".pl", ".pm", ".t", ""] |
PERL_PERLCRITIC_FILE_NAMES_REGEX | File name regex filters. Regular expression list for filtering files by their base names using regex full match. Empty list includes all files Ex: ["Dockerfile(-.+)?", "Jenkinsfile"] |
Include every file |
PERL_PERLCRITIC_PRE_COMMANDS | List of bash commands to run before the linter | None |
PERL_PERLCRITIC_POST_COMMANDS | List of bash commands to run after the linter | None |
PERL_PERLCRITIC_UNSECURED_ENV_VARIABLES | List of env variables explicitly not filtered before calling PERL_PERLCRITIC and its pre/post commands | None |
PERL_PERLCRITIC_DISABLE_ERRORS | Run linter but consider errors as warnings | false |
PERL_PERLCRITIC_DISABLE_ERRORS_IF_LESS_THAN | Maximum number of errors allowed | 0 |
PERL_PERLCRITIC_CLI_EXECUTABLE | Override CLI executable | ['perlcritic'] |
MegaLinter Flavors
This linter is available in the following flavors
Flavor | Description | Embedded linters | Info | |
---|---|---|---|---|
all | Default MegaLinter Flavor | 124 |
Behind the scenes
How are identified applicable files
- File extensions:
.pl
,.pm
,.t
, `` - Detected file content (regex):
^#!/usr/bin/env perl
,^#!/usr/bin/perl
How the linting is performed
- perlcritic is called one time by identified file (
file
CLI lint mode)
Example calls
perlcritic myfile.pl
Help content
Usage:
perlcritic [-12345 | --brutal | --cruel | --harsh | --stern | --gentle]
[--severity number | name] [{-p | --profile} file | --noprofile]
[--top [ number ]] [--theme expression] [--include pattern]
[--exclude pattern] [{-s | --single-policy} pattern]
[--only | --noonly] [--profile-strictness {warn|fatal|quiet}]
[--force | --noforce] [--statistics] [--statistics-only]
[--count | -C] [--verbose {number | format}] [--allow-unsafe]
[--color | --nocolor] [--pager pager] [--quiet]
[--color-severity-highest color_specification]
[--color-severity-high color_specification]
[--color-severity-medium color_specification]
[--color-severity-low color_specification]
[--color-severity-lowest color_specification]
[--files-with-violations | -l]
[--files-without-violations | -L]
[--program-extensions file_name_extension]
{FILE | DIRECTORY | STDIN}
perlcritic --profile-proto
perlcritic { --list | --list-enabled | --list-themes | --doc pattern [...] }
perlcritic { --help | --options | --man | --version }
Installation on mega-linter Docker image
- Dockerfile commands :
RUN curl -fsSL https://raw.githubusercontent.com/skaji/cpm/main/cpm | perl - install -g --show-build-log-on-failure --without-build --without-test --without-runtime Perl::Critic \
&& rm -rf /root/.perl-cpm