Merge pull request #534 from marghidanu/master

PerlCritic basic implementation
This commit is contained in:
Lukas Gravley 2020-08-07 11:56:09 -05:00 committed by GitHub
commit 1746012dab
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
10 changed files with 18 additions and 9 deletions

View file

@ -7,7 +7,6 @@
############# #############
# Load Libs # # Load Libs #
############# #############
use strict;
################## ##################
#### GLOBALS: #### #### GLOBALS: ####

View file

@ -2,6 +2,6 @@ TAP version 13
1..2 1..2
not ok 1 - perl_bad_1.pl not ok 1 - perl_bad_1.pl
--- ---
message: Global symbol "$here" requires explicit package name (did you forget to declare "my $here"?) at /tmp/lint/.automation/test/perl/perl_bad_1.pl line 37.\n/tmp/lint/.automation/test/perl/perl_bad_1.pl had compilation errors.\n message: Code before strictures are enabled at line 14, column 1. See page 429 of PBP. (Severity 5)\n
... ...
ok 2 - perl_good_1.pl ok 2 - perl_good_1.pl

2
.github/linters/.perlcriticrc vendored Normal file
View file

@ -0,0 +1,2 @@
severity = 1
verbose = %f:%l:%c [%s %p] %m near '%r'\n

View file

@ -65,7 +65,7 @@ RUN apk add --update --no-cache \
musl-dev \ musl-dev \
npm nodejs-current \ npm nodejs-current \
openjdk8-jre \ openjdk8-jre \
perl \ perl perl-dev \
php7 php7-phar php7-json php7-mbstring php-xmlwriter \ php7 php7-phar php7-json php7-mbstring php-xmlwriter \
php7-tokenizer php7-ctype php7-curl php7-dom php7-simplexml \ php7-tokenizer php7-ctype php7-curl php7-dom php7-simplexml \
py3-setuptools \ py3-setuptools \
@ -101,6 +101,11 @@ ENV PATH="/node_modules/.bin:${PATH}"
############################## ##############################
RUN bundle install RUN bundle install
##############################
# Installs Perl dependencies #
##############################
RUN curl -sL https://cpanmin.us/ | perl - -nq --no-wget Perl::Critic
############################## ##############################
# Install Phive dependencies # # Install Phive dependencies #
############################## ##############################

View file

@ -63,7 +63,7 @@ Developers on **GitHub** can call the **GitHub Action** to lint their code base
| **Lua** | [luacheck](https://github.com/luarocks/luacheck) | | **Lua** | [luacheck](https://github.com/luarocks/luacheck) |
| **Markdown** | [markdownlint](https://github.com/igorshubovych/markdownlint-cli#readme) | | **Markdown** | [markdownlint](https://github.com/igorshubovych/markdownlint-cli#readme) |
| **OpenAPI** | [spectral](https://github.com/stoplightio/spectral) | | **OpenAPI** | [spectral](https://github.com/stoplightio/spectral) |
| **Perl** | [perl](https://pkgs.alpinelinux.org/package/edge/main/x86/perl) | | **Perl** | [perlcritic](https://metacpan.org/pod/Perl::Critic) |
| **PHP** | [PHP built-in linter](https://www.php.net/) [PHP CodeSniffer](https://github.com/squizlabs/PHP_CodeSniffer) [PHPStan](https://phpstan.org/n) [Psalm](https://psalm.dev/) | | **PHP** | [PHP built-in linter](https://www.php.net/) [PHP CodeSniffer](https://github.com/squizlabs/PHP_CodeSniffer) [PHPStan](https://phpstan.org/n) [Psalm](https://psalm.dev/) |
| **PowerShell** | [PSScriptAnalyzer](https://github.com/PowerShell/Psscriptanalyzer) | | **PowerShell** | [PSScriptAnalyzer](https://github.com/PowerShell/Psscriptanalyzer) |
| **Protocol Buffers** | [protolint](https://github.com/yoheimuta/protolint) | | **Protocol Buffers** | [protolint](https://github.com/yoheimuta/protolint) |
@ -71,7 +71,7 @@ Developers on **GitHub** can call the **GitHub Action** to lint their code base
| **Raku** | [raku](https://raku.org) | | **Raku** | [raku](https://raku.org) |
| **Ruby** | [RuboCop](https://github.com/rubocop-hq/rubocop) | | **Ruby** | [RuboCop](https://github.com/rubocop-hq/rubocop) |
| **Shell** | [Shellcheck](https://github.com/koalaman/shellcheck) | | **Shell** | [Shellcheck](https://github.com/koalaman/shellcheck) |
| **SQL** | [sql-lint](https://github.com/joereynolds/sql-lint) | | **SQL** | [sql-lint](https://github.com/joereynolds/sql-lint) |
| **Terraform** | [tflint](https://github.com/terraform-linters/tflint) [terrascan](https://github.com/accurics/terrascan) | | **Terraform** | [tflint](https://github.com/terraform-linters/tflint) [terrascan](https://github.com/accurics/terrascan) |
| **TypeScript** | [eslint](https://eslint.org/) [standard js](https://standardjs.com/) | | **TypeScript** | [eslint](https://eslint.org/) [standard js](https://standardjs.com/) |
| **XML** | [LibXML](http://xmlsoft.org/) | | **XML** | [LibXML](http://xmlsoft.org/) |

2
TEMPLATES/.perlcriticrc Normal file
View file

@ -0,0 +1,2 @@
severity = 1
verbose = %f:%l:%c [%s %p] %m near '%r'\n

View file

@ -721,7 +721,7 @@ Here is more data
## Perl ## Perl
- [perl](https://pkgs.alpinelinux.org/package/edge/main/x86/perl) - `.github/linters/.perlcriticrc`
### Perl Config file ### Perl Config file

View file

@ -200,7 +200,8 @@ function BuildFileList() {
###################### ######################
# Get the PERL files # # Get the PERL files #
###################### ######################
elif [ "${FILE_TYPE}" == "pl" ]; then elif [ "${FILE_TYPE}" == "pl" ] || [ "${FILE_TYPE}" == "pm" ] ||
[ "${FILE_TYPE}" == "t" ]; then
################################ ################################
# Append the file to the array # # Append the file to the array #
################################ ################################

View file

@ -1585,7 +1585,7 @@ if [ "${VALIDATE_PERL}" == "true" ]; then
# Lint the perl files # # Lint the perl files #
####################### #######################
# LintCodebase "FILE_TYPE" "LINTER_NAME" "LINTER_CMD" "FILE_TYPES_REGEX" "FILE_ARRAY" # LintCodebase "FILE_TYPE" "LINTER_NAME" "LINTER_CMD" "FILE_TYPES_REGEX" "FILE_ARRAY"
LintCodebase "PERL" "perl" "perl -Mstrict -cw" ".*\.\(pl\)\$" "${FILE_ARRAY_PERL[@]}" LintCodebase "PERL" "perl" "perlcritic" ".*\.\(pl\|pm\|t\)\$" "${FILE_ARRAY_PERL[@]}"
fi fi
################ ################

View file

@ -590,7 +590,7 @@ function RunTestCases() {
TestCodebase "KOTLIN" "ktlint" "ktlint" ".*\.\(kt\|kts\)\$" "kotlin" TestCodebase "KOTLIN" "ktlint" "ktlint" ".*\.\(kt\|kts\)\$" "kotlin"
TestCodebase "LUA" "lua" "luacheck" ".*\.\(lua\)\$" "lua" TestCodebase "LUA" "lua" "luacheck" ".*\.\(lua\)\$" "lua"
TestCodebase "MARKDOWN" "markdownlint" "markdownlint -c ${MARKDOWN_LINTER_RULES}" ".*\.\(md\)\$" "markdown" TestCodebase "MARKDOWN" "markdownlint" "markdownlint -c ${MARKDOWN_LINTER_RULES}" ".*\.\(md\)\$" "markdown"
TestCodebase "PERL" "perl" "perl -Mstrict -cw" ".*\.\(pl\)\$" "perl" TestCodebase "PERL" "perl" "perlcritic" ".*\.\(pl\|pm\|t\)\$" "perl"
TestCodebase "PHP_BUILTIN" "php" "php -l" ".*\.\(php\)\$" "php" TestCodebase "PHP_BUILTIN" "php" "php -l" ".*\.\(php\)\$" "php"
TestCodebase "PHP_PHPCS" "phpcs" "phpcs --standard=${PHP_PHPCS_LINTER_RULES}" ".*\.\(php\)\$" "php" TestCodebase "PHP_PHPCS" "phpcs" "phpcs --standard=${PHP_PHPCS_LINTER_RULES}" ".*\.\(php\)\$" "php"
TestCodebase "PHP_PHPSTAN" "phpstan" "phpstan analyse --no-progress --no-ansi -c ${PHP_PHPSTAN_LINTER_RULES}" ".*\.\(php\)\$" "php" TestCodebase "PHP_PHPSTAN" "phpstan" "phpstan analyse --no-progress --no-ansi -c ${PHP_PHPSTAN_LINTER_RULES}" ".*\.\(php\)\$" "php"