From 32eb1cccdaa6104feeffc254c512d2a30c3b087b Mon Sep 17 00:00:00 2001 From: Stephen Abbene <11637137+sabbene@users.noreply.github.com> Date: Mon, 28 Mar 2022 06:56:50 -0700 Subject: [PATCH] Add Perl::Critic::Community and PERL_PERLCRITIC_OPTIONS to allow passing command line options to perlcritic (#2684) Co-authored-by: Stephen Abbene --- Dockerfile | 2 +- README.md | 1 + lib/linter.sh | 8 +++++++- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 9678d59d..01f8a9b4 100644 --- a/Dockerfile +++ b/Dockerfile @@ -108,7 +108,7 @@ RUN npm config set package-lock true \ ############################## # Installs Perl dependencies # ############################## -RUN curl --retry 5 --retry-delay 5 -sL https://cpanmin.us/ | perl - -nq --no-wget Perl::Critic \ +RUN curl --retry 5 --retry-delay 5 -sL https://cpanmin.us/ | perl - -nq --no-wget Perl::Critic Perl::Critic::Community \ ####################### # Installs ActionLint # ####################### diff --git a/README.md b/README.md index 7c7bc9af..d585edb5 100644 --- a/README.md +++ b/README.md @@ -310,6 +310,7 @@ But if you wish to select or exclude specific linters, we give you full control | **MARKDOWN_CUSTOM_RULE_GLOBS** | `.markdown-lint/rules,rules/**` | Comma-separated list of [file globs](https://github.com/igorshubovych/markdownlint-cli#globbing) matching [custom Markdownlint rule files](https://github.com/DavidAnson/markdownlint/blob/main/doc/CustomRules.md). | | **MULTI_STATUS** | `true` | A status API is made for each language that is linted to make visual parsing easier. | | **NATURAL_LANGUAGE_CONFIG_FILE** | `.textlintrc` | Filename for [textlint configuration](https://textlint.github.io/docs/getting-started.html#configuration) (ex: `.textlintrc`) | +| **PERL_PERLCRITIC_OPTIONS** | `null` | Additional arguments to pass to the command-line when running **perlcritic** (Example: --theme community) | | **PHP_CONFIG_FILE** | `php.ini` | Filename for [PHP Configuration](https://www.php.net/manual/en/configuration.file.php) (ex: `php.ini`) | | **PROTOBUF_CONFIG_FILE** | `.protolintrc.yml` | Filename for [protolint configuration](https://github.com/yoheimuta/protolint/blob/master/_example/config/.protolint.yaml) (ex: `.protolintrc.yml`) | | **PYTHON_BLACK_CONFIG_FILE** | `.python-black` | Filename for [black configuration](https://github.com/psf/black/blob/main/docs/guides/using_black_with_other_tools.md#black-compatible-configurations) (ex: `.isort.cfg`, `pyproject.toml`) | diff --git a/lib/linter.sh b/lib/linter.sh index ac4e0305..de26d295 100755 --- a/lib/linter.sh +++ b/lib/linter.sh @@ -136,6 +136,8 @@ MARKDOWN_FILE_NAME="${MARKDOWN_CONFIG_FILE:-.markdown-lint.yml}" # shellcheck disable=SC2034 # Variable is referenced indirectly OPENAPI_FILE_NAME=".openapirc.yml" # shellcheck disable=SC2034 # Variable is referenced indirectly +PERL_PERLCRITIC_OPTIONS="${PERL_PERLCRITIC_OPTIONS:-null}" +# shellcheck disable=SC2034 # Variable is referenced indirectly PHP_BUILTIN_FILE_NAME="${PHP_CONFIG_FILE:-php.ini}" # shellcheck disable=SC2034 # Variable is referenced indirectly PHP_PHPCS_FILE_NAME="phpcs.xml" @@ -930,7 +932,11 @@ if [ -n "${MARKDOWN_CUSTOM_RULE_GLOBS}" ]; then fi LINTER_COMMANDS_ARRAY['NATURAL_LANGUAGE']="textlint -c ${NATURAL_LANGUAGE_LINTER_RULES}" LINTER_COMMANDS_ARRAY['OPENAPI']="spectral lint -r ${OPENAPI_LINTER_RULES} -D" -LINTER_COMMANDS_ARRAY['PERL']="perlcritic" +if [ "${PERL_PERLCRITIC_OPTIONS}" == "null" ] || [ -z "${PERL_PERLCRITIC_OPTIONS}" ]; then + LINTER_COMMANDS_ARRAY['PERL']="perlcritic" +else + LINTER_COMMANDS_ARRAY['PERL']="perlcritic ${PERL_PERLCRITIC_OPTIONS}" +fi LINTER_COMMANDS_ARRAY['PHP_BUILTIN']="php -l -c ${PHP_BUILTIN_LINTER_RULES}" LINTER_COMMANDS_ARRAY['PHP_PHPCS']="phpcs --standard=${PHP_PHPCS_LINTER_RULES}" LINTER_COMMANDS_ARRAY['PHP_PHPSTAN']="phpstan analyse --no-progress --no-ansi --memory-limit 1G -c ${PHP_PHPSTAN_LINTER_RULES}"