From 523b14a2df152e5d42c4c97b50f2c046eb8acba8 Mon Sep 17 00:00:00 2001 From: Tudor Marghidanu Date: Fri, 7 Aug 2020 14:58:40 +0200 Subject: [PATCH 1/4] PerlCritic basic implementation --- .github/linters/.perlcriticrc | 2 ++ Dockerfile | 7 ++++++- README.md | 4 ++-- TEMPLATES/.perlcriticrc | 2 ++ docs/disabling-linters.md | 2 +- lib/buildFileList.sh | 3 ++- lib/linter.sh | 2 +- lib/worker.sh | 2 +- 8 files changed, 17 insertions(+), 7 deletions(-) create mode 100644 .github/linters/.perlcriticrc create mode 100644 TEMPLATES/.perlcriticrc diff --git a/.github/linters/.perlcriticrc b/.github/linters/.perlcriticrc new file mode 100644 index 00000000..ad6196a3 --- /dev/null +++ b/.github/linters/.perlcriticrc @@ -0,0 +1,2 @@ +severity = 1 +verbose = %f:%l:%c [%s %p] %m near '%r'\n \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index 3ebe7199..c9d057a2 100644 --- a/Dockerfile +++ b/Dockerfile @@ -65,7 +65,7 @@ RUN apk add --update --no-cache \ musl-dev \ npm nodejs-current \ openjdk8-jre \ - perl \ + perl perl-dev \ php7 php7-phar php7-json php7-mbstring php-xmlwriter \ php7-tokenizer php7-ctype php7-curl php7-dom php7-simplexml \ py3-setuptools \ @@ -101,6 +101,11 @@ ENV PATH="/node_modules/.bin:${PATH}" ############################## RUN bundle install +############################## +# Installs Perl dependencies # +############################## +RUN curl -sL https://cpanmin.us/ | perl - -nq --no-wget Perl::Critic + ############################## # Install Phive dependencies # ############################## diff --git a/README.md b/README.md index 39fce71e..70c66c12 100644 --- a/README.md +++ b/README.md @@ -63,7 +63,7 @@ Developers on **GitHub** can call the **GitHub Action** to lint their code base | **Lua** | [luacheck](https://github.com/luarocks/luacheck) | | **Markdown** | [markdownlint](https://github.com/igorshubovych/markdownlint-cli#readme) | | **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/) | | **PowerShell** | [PSScriptAnalyzer](https://github.com/PowerShell/Psscriptanalyzer) | | **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) | | **Ruby** | [RuboCop](https://github.com/rubocop-hq/rubocop) | | **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) | | **TypeScript** | [eslint](https://eslint.org/) [standard js](https://standardjs.com/) | | **XML** | [LibXML](http://xmlsoft.org/) | diff --git a/TEMPLATES/.perlcriticrc b/TEMPLATES/.perlcriticrc new file mode 100644 index 00000000..ad6196a3 --- /dev/null +++ b/TEMPLATES/.perlcriticrc @@ -0,0 +1,2 @@ +severity = 1 +verbose = %f:%l:%c [%s %p] %m near '%r'\n \ No newline at end of file diff --git a/docs/disabling-linters.md b/docs/disabling-linters.md index c1d76476..42acb7f4 100644 --- a/docs/disabling-linters.md +++ b/docs/disabling-linters.md @@ -721,7 +721,7 @@ Here is more data ## Perl -- [perl](https://pkgs.alpinelinux.org/package/edge/main/x86/perl) +- `.github/linters/.perlcriticrc` ### Perl Config file diff --git a/lib/buildFileList.sh b/lib/buildFileList.sh index 9dd5502c..a55c35c0 100755 --- a/lib/buildFileList.sh +++ b/lib/buildFileList.sh @@ -200,7 +200,8 @@ function BuildFileList() { ###################### # 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 # ################################ diff --git a/lib/linter.sh b/lib/linter.sh index 6c689b85..abe9fb7d 100755 --- a/lib/linter.sh +++ b/lib/linter.sh @@ -1585,7 +1585,7 @@ if [ "${VALIDATE_PERL}" == "true" ]; then # Lint the perl files # ####################### # 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 ################ diff --git a/lib/worker.sh b/lib/worker.sh index 434fe2f0..029f2d42 100755 --- a/lib/worker.sh +++ b/lib/worker.sh @@ -590,7 +590,7 @@ function RunTestCases() { TestCodebase "KOTLIN" "ktlint" "ktlint" ".*\.\(kt\|kts\)\$" "kotlin" TestCodebase "LUA" "lua" "luacheck" ".*\.\(lua\)\$" "lua" 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_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" From 221f5862c7ce96614c30d614fd0143a68ef2e38b Mon Sep 17 00:00:00 2001 From: Tudor Marghidanu Date: Fri, 7 Aug 2020 17:03:53 +0200 Subject: [PATCH 2/4] Adjusting tests --- .automation/test/perl/perl_bad_1.pl | 1 - 1 file changed, 1 deletion(-) diff --git a/.automation/test/perl/perl_bad_1.pl b/.automation/test/perl/perl_bad_1.pl index 7b127b99..09add458 100644 --- a/.automation/test/perl/perl_bad_1.pl +++ b/.automation/test/perl/perl_bad_1.pl @@ -7,7 +7,6 @@ ############# # Load Libs # ############# -use strict; ################## #### GLOBALS: #### From a4b7076f30af0a34ee236645e8ddc760181b9c01 Mon Sep 17 00:00:00 2001 From: Tudor Marghidanu Date: Fri, 7 Aug 2020 17:15:27 +0200 Subject: [PATCH 3/4] Updating expected PERL report --- .automation/test/perl/reports/expected-PERL.tap | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.automation/test/perl/reports/expected-PERL.tap b/.automation/test/perl/reports/expected-PERL.tap index 932c3621..5c443e71 100644 --- a/.automation/test/perl/reports/expected-PERL.tap +++ b/.automation/test/perl/reports/expected-PERL.tap @@ -2,6 +2,6 @@ TAP version 13 1..2 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) ... ok 2 - perl_good_1.pl From 8309e9136f2fe78618e6dc292c0f9570c1fd7153 Mon Sep 17 00:00:00 2001 From: Tudor Marghidanu Date: Fri, 7 Aug 2020 17:25:00 +0200 Subject: [PATCH 4/4] Adjusting perl test report --- .automation/test/perl/reports/expected-PERL.tap | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.automation/test/perl/reports/expected-PERL.tap b/.automation/test/perl/reports/expected-PERL.tap index 5c443e71..e90e961d 100644 --- a/.automation/test/perl/reports/expected-PERL.tap +++ b/.automation/test/perl/reports/expected-PERL.tap @@ -2,6 +2,6 @@ TAP version 13 1..2 not ok 1 - perl_bad_1.pl --- - message: Code before strictures are enabled at line 14, column 1. See page 429 of PBP. (Severity 5) + 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