From 49243625fe71a055e54421a21e43c815c2871df7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Filip=20=C5=A0?= Date: Sun, 26 Jul 2020 21:01:29 +0200 Subject: [PATCH 01/17] Basic support for PHPCS and Psalm --- Dockerfile | 25 +++++++++++++++++++++++- dependencies/phive.xml | 6 ++++++ lib/linter.sh | 44 ++++++++++++++++++++++++++++++++---------- 3 files changed, 64 insertions(+), 11 deletions(-) create mode 100755 dependencies/phive.xml diff --git a/Dockerfile b/Dockerfile index 2d143824..f8574be7 100644 --- a/Dockerfile +++ b/Dockerfile @@ -65,8 +65,18 @@ RUN apk add --update --no-cache \ openjdk8-jre \ perl \ php7 \ + php7-phar \ + php7-json \ + php7-simplexml \ + php7-xmlwriter \ + php7-mbstring \ + php7-tokenizer \ + php7-ctype \ + php7-curl \ + php7-dom \ py3-setuptools \ - ruby ruby-dev ruby-bundler ruby-rdoc + ruby ruby-dev ruby-bundler ruby-rdoc \ + gnupg ######################################## # Copy dependencies files to container # @@ -96,6 +106,19 @@ ENV PATH="/node_modules/.bin:${PATH}" ############################## RUN bundle install +############################## +# Install Phive dependencies # +############################## +RUN wget -O phive.phar https://phar.io/releases/phive.phar \ + && wget -O phive.phar.asc https://phar.io/releases/phive.phar.asc \ + && gpg --keyserver pool.sks-keyservers.net --recv-keys 0x9D8A98B29B2D5D79 \ + && gpg --verify phive.phar.asc phive.phar \ + && chmod +x phive.phar \ + && mv phive.phar /usr/local/bin/phive \ + && rm phive.phar.asc \ + && phive install --trust-gpg-keys 31C7E470E2138192,8A03EA3B385DBAA1 +# Trusted GPG keys for PHP linters: phpcs, psalm + ######################################### # Install Powershell + PSScriptAnalyzer # ######################################### diff --git a/dependencies/phive.xml b/dependencies/phive.xml new file mode 100755 index 00000000..af2d5187 --- /dev/null +++ b/dependencies/phive.xml @@ -0,0 +1,6 @@ + + + + + + diff --git a/lib/linter.sh b/lib/linter.sh index d712ab4b..17aa4e98 100755 --- a/lib/linter.sh +++ b/lib/linter.sh @@ -107,7 +107,7 @@ LINTER_ARRAY=('ansible-lint' 'arm-ttk' 'asl-validator' 'cfn-lint' 'clj-kondo' LANGUAGE_ARRAY=('ANSIBLE' 'ARM' 'BASH' 'CLOUDFORMATION' 'CLOJURE' 'COFFEESCRIPT' 'CSS' 'DART' 'DOCKER' 'ENV' 'GO' 'GROOVY' 'HTML' 'JAVASCRIPT_ES' 'JAVASCRIPT_STANDARD' 'JSON' 'JSX' 'KOTLIN' 'MARKDOWN' 'OPENAPI' - 'PERL' 'PHP' 'POWERSHELL' 'PROTOBUF' 'PYTHON' + 'PERL' 'PHP_BUILTIN' 'PHP_PHPCS' 'PHP_PSALM' 'POWERSHELL' 'PROTOBUF' 'PYTHON' 'RAKU' 'RUBY' 'STATES' 'TERRAFORM' 'TERRAFORM_TERRASCAN' 'TSX' 'TYPESCRIPT_ES' 'TYPESCRIPT_STANDARD' 'XML' 'YML') @@ -154,7 +154,9 @@ VALIDATE_KOTLIN="${VALIDATE_KOTLIN}" # Boolean to vali VALIDATE_MARKDOWN="${VALIDATE_MD:-}" # Boolean to validate language VALIDATE_OPENAPI="${VALIDATE_OPENAPI}" # Boolean to validate language VALIDATE_PERL="${VALIDATE_PERL}" # Boolean to validate language -VALIDATE_PHP="${VALIDATE_PHP}" # Boolean to validate language +VALIDATE_PHP_BUILTIN="${VALIDATE_PHP_BUILTIN}" # Boolean to validate language +VALIDATE_PHP_PHPCS="${VALIDATE_PHP_PHPCS}" # Boolean to validate language +VALIDATE_PHP_PSALM="${VALIDATE_PHP_PSALM}" # Boolean to validate language VALIDATE_POWERSHELL="${VALIDATE_POWERSHELL}" # Boolean to validate language VALIDATE_PYTHON="${VALIDATE_PYTHON}" # Boolean to validate language VALIDATE_RAKU="${VALIDATE_RAKU}" # Boolean to validate language @@ -230,7 +232,9 @@ FILE_ARRAY_KOTLIN=() # Array of files to check FILE_ARRAY_MARKDOWN=() # Array of files to check FILE_ARRAY_OPENAPI=() # Array of files to check FILE_ARRAY_PERL=() # Array of files to check -FILE_ARRAY_PHP=() # Array of files to check +FILE_ARRAY_PHP_BUILTIN=() # Array of files to check +FILE_ARRAY_PHP_PHPCS=() # Array of files to check +FILE_ARRAY_PHP_PSALM=() # Array of files to check FILE_ARRAY_POWERSHELL=() # Array of files to check FILE_ARRAY_PROTOBUF=() # Array of files to check FILE_ARRAY_PYTHON=() # Array of files to check @@ -289,8 +293,12 @@ ERRORS_FOUND_OPENAPI=0 # Count of errors found export ERRORS_FOUND_OPENAPI # Workaround SC2034 ERRORS_FOUND_PERL=0 # Count of errors found export ERRORS_FOUND_PERL # Workaround SC2034 -ERRORS_FOUND_PHP=0 # Count of errors found -export ERRORS_FOUND_PHP # Workaround SC2034 +ERRORS_FOUND_PHP_BUILTIN=0 # Count of errors found +export ERRORS_FOUND_PHP_BUILTIN # Workaround SC2034 +ERRORS_FOUND_PHP_PHPCS=0 # Count of errors found +export ERRORS_FOUND_PHP_PHPCS # Workaround SC2034 +ERRORS_FOUND_PHP_PSALM=0 # Count of errors found +export ERRORS_FOUND_PHP_PSALM # Workaround SC2034 ERRORS_FOUND_POWERSHELL=0 # Count of errors found export ERRORS_FOUND_POWERSHELL # Workaround SC2034 ERRORS_FOUND_PROTOBUF=0 # Count of errors found @@ -1453,12 +1461,28 @@ fi ################ # PHP LINTING # ################ -if [ "${VALIDATE_PHP}" == "true" ]; then - ####################### - # Lint the PHP files # - ####################### +if [ "${VALIDATE_PHP_BUILTIN}" == "true" ]; then + ################################################ + # Lint the PHP files using built-in PHP linter # + ################################################ # LintCodebase "FILE_TYPE" "LINTER_NAME" "LINTER_CMD" "FILE_TYPES_REGEX" "FILE_ARRAY" - LintCodebase "PHP" "php" "php -l" ".*\.\(php\)\$" "${FILE_ARRAY_PHP[@]}" + LintCodebase "PHP_BUILTIN" "php" "php -l" ".*\.\(php\)\$" "${FILE_ARRAY_PHP_BUILTIN[@]}" +fi + +if [ "${VALIDATE_PHP_PHPCS}" == "true" ]; then + ############################################ + # Lint the PHP files using PHP CodeSniffer # + ############################################ + # LintCodebase "FILE_TYPE" "LINTER_NAME" "LINTER_CMD" "FILE_TYPES_REGEX" "FILE_ARRAY" + LintCodebase "PHP_PHPCS" "phpcs" "phpcs" ".*\.\(php\)\$" "${FILE_ARRAY_PHP_PHPCS[@]}" +fi + +if [ "${VALIDATE_PHP_PSALM}" == "true" ]; then + ################################## + # Lint the PHP files using Psalm # + ################################## + # LintCodebase "FILE_TYPE" "LINTER_NAME" "LINTER_CMD" "FILE_TYPES_REGEX" "FILE_ARRAY" + LintCodebase "PHP_PSALM" "psalm" "psalm" ".*\.\(php\)\$" "${FILE_ARRAY_PHP_PSALM[@]}" fi ###################### From 67cde9602e2aab954b0c1ac9dd0e221a889ca62f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Filip=20=C5=A0?= Date: Sun, 26 Jul 2020 21:30:45 +0200 Subject: [PATCH 02/17] Add support for PHPCS and Psalm config files --- TEMPLATES/phpcs.xml | 6 ++++++ TEMPLATES/psalm.xml | 4 ++++ lib/linter.sh | 10 ++++++++-- 3 files changed, 18 insertions(+), 2 deletions(-) create mode 100755 TEMPLATES/phpcs.xml create mode 100755 TEMPLATES/psalm.xml diff --git a/TEMPLATES/phpcs.xml b/TEMPLATES/phpcs.xml new file mode 100755 index 00000000..b319d759 --- /dev/null +++ b/TEMPLATES/phpcs.xml @@ -0,0 +1,6 @@ + + + + The default coding standard for usage with super-linter. Just includes PSR12. + + diff --git a/TEMPLATES/psalm.xml b/TEMPLATES/psalm.xml new file mode 100755 index 00000000..0eb2e126 --- /dev/null +++ b/TEMPLATES/psalm.xml @@ -0,0 +1,4 @@ + + + + diff --git a/lib/linter.sh b/lib/linter.sh index 17aa4e98..c5a829fa 100755 --- a/lib/linter.sh +++ b/lib/linter.sh @@ -68,6 +68,12 @@ MARKDOWN_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${MARKDOWN_FILE_NAME}" # OpenAPI Vars OPENAPI_FILE_NAME='.openapirc.yml' # Name of the file OPENAPI_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${OPENAPI_FILE_NAME}" # Path to the OpenAPI lint rules +# PHPCS Vars +PHP_PHPCS_FILE_NAME='phpcs.xml' # Name of the file +PHP_PHPCS_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${PHP_PHPCS_FILE_NAME}" # Path to the PHP CodeSniffer lint rules +# Psalm Vars +PHP_PSALM_FILE_NAME='psalm.xml' # Name of the file +PHP_PSALM_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${PHP_PSALM_FILE_NAME}" # Path to the Psalm lint rules # Powershell Vars POWERSHELL_FILE_NAME='.powershell-psscriptanalyzer.psd1' # Name of the file POWERSHELL_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${POWERSHELL_FILE_NAME}" # Path to the Powershell lint rules @@ -1474,7 +1480,7 @@ if [ "${VALIDATE_PHP_PHPCS}" == "true" ]; then # Lint the PHP files using PHP CodeSniffer # ############################################ # LintCodebase "FILE_TYPE" "LINTER_NAME" "LINTER_CMD" "FILE_TYPES_REGEX" "FILE_ARRAY" - LintCodebase "PHP_PHPCS" "phpcs" "phpcs" ".*\.\(php\)\$" "${FILE_ARRAY_PHP_PHPCS[@]}" + LintCodebase "PHP_PHPCS" "phpcs" "phpcs --standard=${PHP_PHPCS_LINTER_RULES}" ".*\.\(php\)\$" "${FILE_ARRAY_PHP_PHPCS[@]}" fi if [ "${VALIDATE_PHP_PSALM}" == "true" ]; then @@ -1482,7 +1488,7 @@ if [ "${VALIDATE_PHP_PSALM}" == "true" ]; then # Lint the PHP files using Psalm # ################################## # LintCodebase "FILE_TYPE" "LINTER_NAME" "LINTER_CMD" "FILE_TYPES_REGEX" "FILE_ARRAY" - LintCodebase "PHP_PSALM" "psalm" "psalm" ".*\.\(php\)\$" "${FILE_ARRAY_PHP_PSALM[@]}" + LintCodebase "PHP_PSALM" "psalm" "psalm --config=${PHP_PSALM_LINTER_RULES}" ".*\.\(php\)\$" "${FILE_ARRAY_PHP_PSALM[@]}" fi ###################### From d1827a81f7882d176f70baef09d80380103f3719 Mon Sep 17 00:00:00 2001 From: Lucas Gravley <29484535+admiralAwkbar@users.noreply.github.com> Date: Fri, 31 Jul 2020 09:17:04 -0500 Subject: [PATCH 03/17] fixin it --- lib/linter.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/linter.sh b/lib/linter.sh index 8e3d9e10..3d4eb9ef 100755 --- a/lib/linter.sh +++ b/lib/linter.sh @@ -268,7 +268,6 @@ FILE_ARRAY_LUA=() # Array of files to check FILE_ARRAY_MARKDOWN=() # Array of files to check FILE_ARRAY_OPENAPI=() # Array of files to check FILE_ARRAY_PERL=() # Array of files to check -FILE_ARRAY_PHP=() # Array of files to check FILE_ARRAY_PHP_BUILTIN=() # Array of files to check FILE_ARRAY_PHP_PHPCS=() # Array of files to check FILE_ARRAY_PHP_PSALM=() # Array of files to check From 84926171fb98a5d17246bc01b7b2d7c9778d6648 Mon Sep 17 00:00:00 2001 From: Lucas Gravley <29484535+admiralAwkbar@users.noreply.github.com> Date: Fri, 31 Jul 2020 09:54:58 -0500 Subject: [PATCH 04/17] fix arrays and add tests --- lib/buildFileList.sh | 4 +++- lib/possum.sh | 12 ++++++------ lib/worker.sh | 2 ++ 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/lib/buildFileList.sh b/lib/buildFileList.sh index 3e52de0f..b9b3de27 100755 --- a/lib/buildFileList.sh +++ b/lib/buildFileList.sh @@ -230,7 +230,9 @@ function BuildFileList() { ################################ # Append the file to the array # ################################ - FILE_ARRAY_PHP+=("${FILE}") + FILE_ARRAY_PHP_BUILTIN+=("${FILE}") + FILE_ARRAY_PHP_PHPCS+=("${FILE}") + FILE_ARRAY_PHP_PSALM+=("${FILE}") FILE_ARRAY_PHP_PHPSTAN+=("${FILE}") ########################################################## # Set the READ_ONLY_CHANGE_FLAG since this could be exec # diff --git a/lib/possum.sh b/lib/possum.sh index d867332b..172ccc00 100755 --- a/lib/possum.sh +++ b/lib/possum.sh @@ -8,12 +8,12 @@ cat << EOF @///////@///////////////@@@@ ( @, @/(&/@//////////////////// @ @////////////////////////@@ @ - @%////////(//////////%/////&@ @@ *,@ - @@@@@/@/#/////(&////////////////// .@ - *@@@@@. .%///(//@//////////////////&. .@@, @% - @@% .&@&&/@.@//&/////(////////// @@@@@@@@@ .. &@ - @@% @@@@@ @&/////////////////# @/ V @@/ ,@@@ @ -@@@% @@@@ .%@@@@//////#@ @ @@ @ .,. + @%////////(//////////%/////&@ @@ *,@ ______________ + @@@@@/@/#/////(&////////////////// .@ / \ + *@@@@@. .%///(//@//////////////////&. .@@, @% / Don't mind me \ + @@% .&@&&/@.@//&/////(////////// @@@@@@@@@ .. &@ / I'm just looking \ + @@% @@@@@ @&/////////////////# @/ V @@/ ,@@@ @ < for some trash... | +@@@% @@@@ .%@@@@//////#@ @ @@ @ .,. \__________________/ @@@/@( (@@@@% @/\ % @@@@( . .@@/\ # @ %@% diff --git a/lib/worker.sh b/lib/worker.sh index 31617599..3d35f1c7 100755 --- a/lib/worker.sh +++ b/lib/worker.sh @@ -590,6 +590,8 @@ function RunTestCases() { TestCodebase "MARKDOWN" "markdownlint" "markdownlint -c ${MARKDOWN_LINTER_RULES}" ".*\.\(md\)\$" "markdown" TestCodebase "PERL" "perl" "perl -Mstrict -cw" ".*\.\(pl\)\$" "perl" TestCodebase "PHP" "php" "php -l" ".*\.\(php\)\$" "php" + TestCodebase "PHP_PHPCS" "phpcs" "phpcs --standard=${PHP_PHPCS_LINTER_RULES}" ".*\.\(php\)\$" "php" + TestCodebase "PHP_PSALM" "psalm" "psalm --config=${PHP_PSALM_LINTER_RULES}" ".*\.\(php\)\$" "php" TestCodebase "PHP_PHPSTAN" "phpstan" "phpstan analyse --no-progress --no-ansi -c ${PHPSTAN_LINTER_RULES}" ".*\.\(php\)\$" "php" TestCodebase "OPENAPI" "spectral" "spectral lint -r ${OPENAPI_LINTER_RULES}" ".*\.\(ymlopenapi\|jsonopenapi\)\$" "openapi" TestCodebase "POWERSHELL" "pwsh" "Invoke-ScriptAnalyzer -EnableExit -Settings ${POWERSHELL_LINTER_RULES} -Path" ".*\.\(ps1\|psm1\|psd1\|ps1xml\|pssc\|psrc\|cdxml\)\$" "powershell" From 56894ef49a2388137fe3ead1bd4bef743e7a4584 Mon Sep 17 00:00:00 2001 From: Lucas Gravley <29484535+admiralAwkbar@users.noreply.github.com> Date: Mon, 3 Aug 2020 14:14:54 -0500 Subject: [PATCH 05/17] fixed the cool guy --- lib/possum.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/possum.sh b/lib/possum.sh index 172ccc00..92944cdd 100755 --- a/lib/possum.sh +++ b/lib/possum.sh @@ -9,11 +9,11 @@ cat << EOF @/(&/@//////////////////// @ @////////////////////////@@ @ @%////////(//////////%/////&@ @@ *,@ ______________ - @@@@@/@/#/////(&////////////////// .@ / \ - *@@@@@. .%///(//@//////////////////&. .@@, @% / Don't mind me \ - @@% .&@&&/@.@//&/////(////////// @@@@@@@@@ .. &@ / I'm just looking \ + @@@@@/@/#/////(&////////////////// .@ / \\ + *@@@@@. .%///(//@//////////////////&. .@@, @% / Don't mind me \\ + @@% .&@&&/@.@//&/////(////////// @@@@@@@@@ .. &@ / I'm just looking \\ @@% @@@@@ @&/////////////////# @/ V @@/ ,@@@ @ < for some trash... | -@@@% @@@@ .%@@@@//////#@ @ @@ @ .,. \__________________/ +@@@% @@@@ .%@@@@//////#@ @ @@ @ .,. \\__________________/ @@@/@( (@@@@% @/\ % @@@@( . .@@/\ # @ %@% From 12a064d4097813139d8f82ef9c380b75ca56da57 Mon Sep 17 00:00:00 2001 From: Lucas Gravley <29484535+admiralAwkbar@users.noreply.github.com> Date: Mon, 3 Aug 2020 14:17:54 -0500 Subject: [PATCH 06/17] add lib --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 9e1a9559..22d9a952 100644 --- a/Dockerfile +++ b/Dockerfile @@ -65,7 +65,7 @@ RUN apk add --update --no-cache \ npm nodejs-current \ openjdk8-jre \ perl \ - php7 php7-phar php7-json php7-mbstring \ + php7 php7-phar php7-json php7-mbstring php-xmlwriter \ php7-tokenizer php7-ctype php7-curl php7-dom \ py3-setuptools \ readline-dev \ From 7abb1db30b049bc0b4fbb75fc9e3de24bb1897b9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Filip=20=C5=A0?= Date: Sun, 26 Jul 2020 21:30:45 +0200 Subject: [PATCH 07/17] Support for PHPCS and Psalm config files --- TEMPLATES/phpcs.xml | 6 ++++++ TEMPLATES/psalm.xml | 4 ++++ lib/linter.sh | 10 ++++++++-- 3 files changed, 18 insertions(+), 2 deletions(-) create mode 100755 TEMPLATES/phpcs.xml create mode 100755 TEMPLATES/psalm.xml diff --git a/TEMPLATES/phpcs.xml b/TEMPLATES/phpcs.xml new file mode 100755 index 00000000..db39fed5 --- /dev/null +++ b/TEMPLATES/phpcs.xml @@ -0,0 +1,6 @@ + + + + The default coding standard for usage with GitHub Super-Linter. It just includes PSR12. + + diff --git a/TEMPLATES/psalm.xml b/TEMPLATES/psalm.xml new file mode 100755 index 00000000..0eb2e126 --- /dev/null +++ b/TEMPLATES/psalm.xml @@ -0,0 +1,4 @@ + + + + diff --git a/lib/linter.sh b/lib/linter.sh index 17aa4e98..c5a829fa 100755 --- a/lib/linter.sh +++ b/lib/linter.sh @@ -68,6 +68,12 @@ MARKDOWN_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${MARKDOWN_FILE_NAME}" # OpenAPI Vars OPENAPI_FILE_NAME='.openapirc.yml' # Name of the file OPENAPI_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${OPENAPI_FILE_NAME}" # Path to the OpenAPI lint rules +# PHPCS Vars +PHP_PHPCS_FILE_NAME='phpcs.xml' # Name of the file +PHP_PHPCS_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${PHP_PHPCS_FILE_NAME}" # Path to the PHP CodeSniffer lint rules +# Psalm Vars +PHP_PSALM_FILE_NAME='psalm.xml' # Name of the file +PHP_PSALM_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${PHP_PSALM_FILE_NAME}" # Path to the Psalm lint rules # Powershell Vars POWERSHELL_FILE_NAME='.powershell-psscriptanalyzer.psd1' # Name of the file POWERSHELL_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${POWERSHELL_FILE_NAME}" # Path to the Powershell lint rules @@ -1474,7 +1480,7 @@ if [ "${VALIDATE_PHP_PHPCS}" == "true" ]; then # Lint the PHP files using PHP CodeSniffer # ############################################ # LintCodebase "FILE_TYPE" "LINTER_NAME" "LINTER_CMD" "FILE_TYPES_REGEX" "FILE_ARRAY" - LintCodebase "PHP_PHPCS" "phpcs" "phpcs" ".*\.\(php\)\$" "${FILE_ARRAY_PHP_PHPCS[@]}" + LintCodebase "PHP_PHPCS" "phpcs" "phpcs --standard=${PHP_PHPCS_LINTER_RULES}" ".*\.\(php\)\$" "${FILE_ARRAY_PHP_PHPCS[@]}" fi if [ "${VALIDATE_PHP_PSALM}" == "true" ]; then @@ -1482,7 +1488,7 @@ if [ "${VALIDATE_PHP_PSALM}" == "true" ]; then # Lint the PHP files using Psalm # ################################## # LintCodebase "FILE_TYPE" "LINTER_NAME" "LINTER_CMD" "FILE_TYPES_REGEX" "FILE_ARRAY" - LintCodebase "PHP_PSALM" "psalm" "psalm" ".*\.\(php\)\$" "${FILE_ARRAY_PHP_PSALM[@]}" + LintCodebase "PHP_PSALM" "psalm" "psalm --config=${PHP_PSALM_LINTER_RULES}" ".*\.\(php\)\$" "${FILE_ARRAY_PHP_PSALM[@]}" fi ###################### From a4fec5d53b31091901cc9071d67e70bafca78622 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Filip=20=C5=A0?= Date: Mon, 27 Jul 2020 21:36:31 +0200 Subject: [PATCH 08/17] Support for testing PHPCS and Psalm --- .automation/test/local-storage.json | 1 + .automation/test/php/php_bad_2.php | 15 +++++++++++ .automation/test/php/php_good_2.php | 25 +++++++++++++++++++ .automation/test/php/reports/expected-PHP.tap | 7 ------ .../test/php/reports/expected-PHP_BUILTIN.tap | 12 +++++++++ .../test/php/reports/expected-PHP_PHPCS.tap | 12 +++++++++ .../test/php/reports/expected-PHP_PSALM.tap | 12 +++++++++ lib/buildFileList.sh | 4 ++- lib/worker.sh | 4 ++- 9 files changed, 83 insertions(+), 9 deletions(-) create mode 100644 .automation/test/local-storage.json create mode 100755 .automation/test/php/php_bad_2.php create mode 100755 .automation/test/php/php_good_2.php delete mode 100644 .automation/test/php/reports/expected-PHP.tap create mode 100755 .automation/test/php/reports/expected-PHP_BUILTIN.tap create mode 100755 .automation/test/php/reports/expected-PHP_PHPCS.tap create mode 100755 .automation/test/php/reports/expected-PHP_PSALM.tap diff --git a/.automation/test/local-storage.json b/.automation/test/local-storage.json new file mode 100644 index 00000000..782cb651 --- /dev/null +++ b/.automation/test/local-storage.json @@ -0,0 +1 @@ +{"anonymousUserId":"8f97180e-e0e9-4d33-a52d-f45c9fec4000"} diff --git a/.automation/test/php/php_bad_2.php b/.automation/test/php/php_bad_2.php new file mode 100755 index 00000000..106fe977 --- /dev/null +++ b/.automation/test/php/php_bad_2.php @@ -0,0 +1,15 @@ + + */ +function takesAnInt(int $i) { + return [$i, "hello"]; +} + +$data = ["some text", 5]; +takesAnInt($data[0]); + +$condition = rand(0, 5); +iff ($condition) { +} elseif ($condition) {} diff --git a/.automation/test/php/php_good_2.php b/.automation/test/php/php_good_2.php new file mode 100755 index 00000000..35348ec0 --- /dev/null +++ b/.automation/test/php/php_good_2.php @@ -0,0 +1,25 @@ + + */ +function helloName(string $name): array +{ + return ["hello", $name]; +} + +function helloSuperLinter(): void +{ + $hello = helloName("Super-Linter"); + echo implode(" ", $hello) . PHP_EOL; +} + +function helloOrWorld(): void +{ + $random = rand(0, 10); + if ($random >= 5) { + echo "Hello"; + } else { + echo "World"; + } +} diff --git a/.automation/test/php/reports/expected-PHP.tap b/.automation/test/php/reports/expected-PHP.tap deleted file mode 100644 index 48408065..00000000 --- a/.automation/test/php/reports/expected-PHP.tap +++ /dev/null @@ -1,7 +0,0 @@ -TAP version 13 -1..2 -not ok 1 - php_bad_1.php - --- - message: PHP Parse error syntax error, unexpected 'pe98y' (T_STRING) in /tmp/lint/.automation/test/php/php_bad_1.php on line 3\nErrors parsing /tmp/lint/.automation/test/php/php_bad_1.php\n - ... -ok 2 - php_good_1.php diff --git a/.automation/test/php/reports/expected-PHP_BUILTIN.tap b/.automation/test/php/reports/expected-PHP_BUILTIN.tap new file mode 100755 index 00000000..beb3656e --- /dev/null +++ b/.automation/test/php/reports/expected-PHP_BUILTIN.tap @@ -0,0 +1,12 @@ +TAP version 13 +1..4 +not ok 1 - php_bad_1.php + --- + message: PHP Parse error syntax error, unexpected 'pe98y' (T_STRING) in /tmp/lint/.automation/test/php/php_bad_1.php on line 3\nErrors parsing /tmp/lint/.automation/test/php/php_bad_1.php\n + ... +not ok 2 - php_bad_2.php + --- + message: PHP Parse error syntax error, unexpected '}' in /tmp/lint/.automation/test/php/php_bad_2.php on line 15\nErrors parsing /tmp/lint/.automation/test/php/php_bad_2.php\n + ... +ok 3 - php_good_1.php +ok 4 - php_good_2.php diff --git a/.automation/test/php/reports/expected-PHP_PHPCS.tap b/.automation/test/php/reports/expected-PHP_PHPCS.tap new file mode 100755 index 00000000..bf7e541d --- /dev/null +++ b/.automation/test/php/reports/expected-PHP_PHPCS.tap @@ -0,0 +1,12 @@ +TAP version 13 +1..4 +not ok 1 - php_bad_1.php + --- + message: \nFILE /tmp/lint/.automation/test/php/php_bad_1.php\n----------------------------------------------------------------------\nFOUND 7 ERRORS AFFECTING 1 LINE\n----------------------------------------------------------------------\n 3 | ERROR | [x] Expected at least 1 space before "-"; 0 found\n 3 | ERROR | [x] Expected at least 1 space after "-"; 0 found\n 3 | ERROR | [x] Expected at least 1 space before "="; 0 found\n 3 | ERROR | [x] Expected at least 1 space after "="; 0 found\n 3 | ERROR | [x] Expected at least 1 space before "-"; 0 found\n 3 | ERROR | [x] Expected at least 1 space before "-"; 0 found\n 3 | ERROR | [x] Expected at least 1 space after "-"; 0 found\n----------------------------------------------------------------------\nPHPCBF CAN FIX THE 7 MARKED SNIFF VIOLATIONS AUTOMATICALLY\n----------------------------------------------------------------------\n\n + ... +not ok 2 - php_bad_2.php + --- + message: \nFILE /tmp/lint/.automation/test/php/php_bad_2.php\n----------------------------------------------------------------------\nFOUND 4 ERRORS AND 1 WARNING AFFECTING 4 LINES\n----------------------------------------------------------------------\n 1 | WARNING | [ ] A file should declare new symbols (classes,\n | | functions, constants, etc.) and cause no other\n | | side effects, or it should execute logic with\n | | side effects, but should not do both. The first\n | | symbol is defined on line 6 and the first side\n | | effect is on line 10.\n 6 | ERROR | [x] Opening brace should be on a new line\n 14 | ERROR | [x] Space before opening parenthesis of function call\n | | prohibited\n 15 | ERROR | [x] Newline required after opening brace\n 15 | ERROR | [x] Closing brace must be on a line by itself\n----------------------------------------------------------------------\nPHPCBF CAN FIX THE 4 MARKED SNIFF VIOLATIONS AUTOMATICALLY\n----------------------------------------------------------------------\n\n + ... +ok 3 - php_good_1.php +ok 4 - php_good_2.php diff --git a/.automation/test/php/reports/expected-PHP_PSALM.tap b/.automation/test/php/reports/expected-PHP_PSALM.tap new file mode 100755 index 00000000..57baa89a --- /dev/null +++ b/.automation/test/php/reports/expected-PHP_PSALM.tap @@ -0,0 +1,12 @@ +TAP version 13 +1..4 +not ok 1 - php_bad_1.php + --- + message: Scanning files...\nAnalyzing files...\n\nE\n\nERROR ParseError - php/php_bad_1.php 3 2 - Syntax error, unexpected T_STRING on line 3 (see https //psalm.dev/173)\n2pe98y r-n0u823n=r 092u3- r08u2q098ry 09nq2yr09n2yr9 y2n-93yr 298yr3 29\n\n\nERROR UndefinedConstant - php/php_bad_1.php 3 2 - Const pe98y is not defined (see https //psalm.dev/020)\n2pe98y r-n0u823n=r 092u3- r08u2q098ry 09nq2yr09n2yr9 y2n-93yr 298yr3 29\n\n\nERROR UndefinedConstant - php/php_bad_1.php 3 8 - Const r is not defined (see https //psalm.dev/020)\n2pe98y r-n0u823n=r 092u3- r08u2q098ry 09nq2yr09n2yr9 y2n-93yr 298yr3 29\n\n\nERROR UndefinedConstant - php/php_bad_1.php 3 10 - Const n0u823n is not defined (see https //psalm.dev/020)\n2pe98y r-n0u823n=r 092u3- r08u2q098ry 09nq2yr09n2yr9 y2n-93yr 298yr3 29\n\n\nERROR ParseError - php/php_bad_1.php 3 17 - Syntax error, unexpected '=' on line 3 (see https //psalm.dev/173)\n2pe98y r-n0u823n=r 092u3- r08u2q098ry 09nq2yr09n2yr9 y2n-93yr 298yr3 29\n\n\nERROR UndefinedConstant - php/php_bad_1.php 3 18 - Const r is not defined (see https //psalm.dev/020)\n2pe98y r-n0u823n=r 092u3- r08u2q098ry 09nq2yr09n2yr9 y2n-93yr 298yr3 29\n\n\nERROR ParseError - php/php_bad_1.php 3 21 - Invalid numeric literal on line 3 (see https //psalm.dev/173)\n2pe98y r-n0u823n=r 092u3- r08u2q098ry 09nq2yr09n2yr9 y2n-93yr 298yr3 29\n\n\nERROR UndefinedConstant - php/php_bad_1.php 3 24 - Const u3 is not defined (see https //psalm.dev/020)\n2pe98y r-n0u823n=r 092u3- r08u2q098ry 09nq2yr09n2yr9 y2n-93yr 298yr3 29\n\n\nERROR UndefinedConstant - php/php_bad_1.php 3 28 - Const r08u2q098ry is not defined (see https //psalm.dev/020)\n2pe98y r-n0u823n=r 092u3- r08u2q098ry 09nq2yr09n2yr9 y2n-93yr 298yr3 29\n\n\nERROR ParseError - php/php_bad_1.php 3 40 - Syntax error, unexpected T_LNUMBER on line 3 (see https //psalm.dev/173)\n2pe98y r-n0u823n=r 092u3- r08u2q098ry 09nq2yr09n2yr9 y2n-93yr 298yr3 29\n\n\nERROR UndefinedConstant - php/php_bad_1.php 3 42 - Const nq2yr09n2yr9 is not defined (see https //psalm.dev/020)\n2pe98y r-n0u823n=r 092u3- r08u2q098ry 09nq2yr09n2yr9 y2n-93yr 298yr3 29\n\n\nERROR UndefinedConstant - php/php_bad_1.php 3 55 - Const y2n is not defined (see https //psalm.dev/020)\n2pe98y r-n0u823n=r 092u3- r08u2q098ry 09nq2yr09n2yr9 y2n-93yr 298yr3 29\n\n\nERROR ParseError - php/php_bad_1.php 3 61 - Syntax error, unexpected T_STRING on line 3 (see https //psalm.dev/173)\n2pe98y r-n0u823n=r 092u3- r08u2q098ry 09nq2yr09n2yr9 y2n-93yr 298yr3 29\n\n\nERROR UndefinedConstant - php/php_bad_1.php 3 61 - Const yr is not defined (see https //psalm.dev/020)\n2pe98y r-n0u823n=r 092u3- r08u2q098ry 09nq2yr09n2yr9 y2n-93yr 298yr3 29\n\n\nERROR UndefinedConstant - php/php_bad_1.php 3 68 - Const yr3 is not defined (see https //psalm.dev/020)\n2pe98y r-n0u823n=r 092u3- r08u2q098ry 09nq2yr09n2yr9 y2n-93yr 298yr3 29\n\n\n------------------------------\n15 errors found\n------------------------------\n\n + ... +not ok 2 - php_bad_2.php + --- + message: Scanning files...\nAnalyzing files...\n\nE\n\nERROR InvalidReturnType - php/php_bad_2.php 4 12 - The declared return type 'array' for takesAnInt is incorrect, got 'array{int, string(hello)}' (see https //psalm.dev/011)\n * @return array\n\n\nERROR InvalidReturnStatement - php/php_bad_2.php 7 12 - The inferred type 'array{int, string(hello)}' does not match the declared return type 'array' for takesAnInt (see https //psalm.dev/128)\n return [$i, "hello"];\n\n\nERROR InvalidScalarArgument - php/php_bad_2.php 11 12 - Argument 1 of takesAnInt expects int, string(some text) provided (see https //psalm.dev/012)\ntakesAnInt($data[0]);\n\n\nERROR ParseError - php/php_bad_2.php 15 1 - Syntax error, unexpected '}' on line 15 (see https //psalm.dev/173)\n} elseif ($condition) {}\n\n\n------------------------------\n4 errors found\n------------------------------\nPsalm can automatically fix 1 of these issues.\nRun Psalm again with \n--alter --issues=InvalidReturnType --dry-run\nto see what it can fix.\n------------------------------\n\n + ... +ok 3 - php_good_1.php +ok 4 - php_good_2.php diff --git a/lib/buildFileList.sh b/lib/buildFileList.sh index 00aebf1f..3cfea4a4 100755 --- a/lib/buildFileList.sh +++ b/lib/buildFileList.sh @@ -239,7 +239,9 @@ function BuildFileList() { ################################ # Append the file to the array # ################################ - FILE_ARRAY_PHP+=("${FILE}") + FILE_ARRAY_PHP_BUILTIN+=("${FILE}") + FILE_ARRAY_PHP_PHPCS+=("${FILE}") + FILE_ARRAY_PHP_PSALM+=("${FILE}") ########################################################## # Set the READ_ONLY_CHANGE_FLAG since this could be exec # ########################################################## diff --git a/lib/worker.sh b/lib/worker.sh index a7da7f04..bfee1023 100755 --- a/lib/worker.sh +++ b/lib/worker.sh @@ -597,7 +597,9 @@ function RunTestCases() { TestCodebase "KOTLIN" "ktlint" "ktlint" ".*\.\(kt\|kts\)\$" "kotlin" TestCodebase "MARKDOWN" "markdownlint" "markdownlint -c ${MARKDOWN_LINTER_RULES}" ".*\.\(md\)\$" "markdown" TestCodebase "PERL" "perl" "perl -Mstrict -cw" ".*\.\(pl\)\$" "perl" - TestCodebase "PHP" "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_PSALM" "psalm" "psalm --config=${PHP_PSALM_LINTER_RULES}" ".*\.\(php\)\$" "php" TestCodebase "OPENAPI" "spectral" "spectral lint -r ${OPENAPI_LINTER_RULES}" ".*\.\(ymlopenapi\|jsonopenapi\)\$" "openapi" TestCodebase "POWERSHELL" "pwsh" "Invoke-ScriptAnalyzer -EnableExit -Settings ${POWERSHELL_LINTER_RULES} -Path" ".*\.\(ps1\|psm1\|psd1\|ps1xml\|pssc\|psrc\|cdxml\)\$" "powershell" TestCodebase "PROTOBUF" "protolint" "protolint lint --config_path ${PROTOBUF_LINTER_RULES}" ".*\.\(proto\)\$" "protobuf" From 4f916eaf981ca65ef93fee983265ef560d10063d Mon Sep 17 00:00:00 2001 From: Lucas Gravley <29484535+admiralAwkbar@users.noreply.github.com> Date: Mon, 3 Aug 2020 14:28:50 -0500 Subject: [PATCH 09/17] mas deps --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 22d9a952..cd7db4d7 100644 --- a/Dockerfile +++ b/Dockerfile @@ -66,7 +66,7 @@ RUN apk add --update --no-cache \ openjdk8-jre \ perl \ php7 php7-phar php7-json php7-mbstring php-xmlwriter \ - php7-tokenizer php7-ctype php7-curl php7-dom \ + php7-tokenizer php7-ctype php7-curl php7-dom php7-simplexml \ py3-setuptools \ readline-dev \ ruby ruby-dev ruby-bundler ruby-rdoc \ From eee9c118af87f4c01e74ba625c068fca6f3dd22f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Filip=20=C5=A0?= Date: Mon, 3 Aug 2020 21:48:23 +0200 Subject: [PATCH 10/17] Install PHPStan with phive.xml --- Dockerfile | 15 ++------------- dependencies/phive.xml | 7 ++++--- 2 files changed, 6 insertions(+), 16 deletions(-) diff --git a/Dockerfile b/Dockerfile index cd7db4d7..2e76904f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -110,8 +110,8 @@ RUN wget -O phive.phar https://phar.io/releases/phive.phar \ && chmod +x phive.phar \ && mv phive.phar /usr/local/bin/phive \ && rm phive.phar.asc \ - && phive install --trust-gpg-keys 31C7E470E2138192,8A03EA3B385DBAA1 -# Trusted GPG keys for PHP linters: phpcs, psalm + && phive install --trust-gpg-keys 31C7E470E2138192,CF1A108D0E7AE720,8A03EA3B385DBAA1 +# Trusted GPG keys for PHP linters: phpcs, phpstan, psalm ######################################### # Install Powershell + PSScriptAnalyzer # @@ -218,17 +218,6 @@ RUN wget https://github.com/cvega/luarocks/archive/v3.3.1-super-linter.tar.gz -O RUN luarocks install luacheck -############################# -# Install Phive and PHPStan # -############################# -RUN wget -O phive.phar https://phar.io/releases/phive.phar \ - && wget -O phive.phar.asc https://phar.io/releases/phive.phar.asc \ - && gpg --keyserver pool.sks-keyservers.net --recv-keys 0x9D8A98B29B2D5D79 \ - && gpg --verify phive.phar.asc phive.phar \ - && chmod +x phive.phar \ - && mv phive.phar /usr/local/bin/phive \ - && yes | phive install -g phpstan - ########################################### # Load GitHub Env Vars for GitHub Actions # ########################################### diff --git a/dependencies/phive.xml b/dependencies/phive.xml index af2d5187..8d1b31d4 100755 --- a/dependencies/phive.xml +++ b/dependencies/phive.xml @@ -1,6 +1,7 @@ - - - + + + + From 6bd724519b3d3175ba660c23ee2e5a626ce92cc0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Filip=20=C5=A0?= Date: Mon, 3 Aug 2020 21:50:30 +0200 Subject: [PATCH 11/17] Remove old PHP report --- .automation/test/php/reports/expected-PHP.tap | 11 ----------- 1 file changed, 11 deletions(-) delete mode 100644 .automation/test/php/reports/expected-PHP.tap diff --git a/.automation/test/php/reports/expected-PHP.tap b/.automation/test/php/reports/expected-PHP.tap deleted file mode 100644 index 652ad276..00000000 --- a/.automation/test/php/reports/expected-PHP.tap +++ /dev/null @@ -1,11 +0,0 @@ -TAP version 13 -1..3 -not ok 1 - php_bad_1.php - --- - message: PHP Parse error syntax error, unexpected 'pe98y' (T_STRING) in /tmp/lint/.automation/test/php/php_bad_1.php on line 3\nErrors parsing /tmp/lint/.automation/test/php/php_bad_1.php\n - ... -not ok 2 - php_bad_2.php - --- - message: PHP Parse error syntax error, unexpected end of file, expecting variable (T_VARIABLE) or ${ (T_DOLLAR_OPEN_CURLY_BRACES) or {$ (T_CURLY_OPEN) in /tmp/lint/.automation/test/php/php_bad_2.php on line 5\nErrors parsing /tmp/lint/.automation/test/php/php_bad_2.php\n - ... -ok 3 - php_good_1.php From a9d494c57aed24ccae162b7266012d824e629ca9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Filip=20=C5=A0?= Date: Mon, 3 Aug 2020 21:54:33 +0200 Subject: [PATCH 12/17] Remvoe useless file --- .automation/test/local-storage.json | 1 - 1 file changed, 1 deletion(-) delete mode 100644 .automation/test/local-storage.json diff --git a/.automation/test/local-storage.json b/.automation/test/local-storage.json deleted file mode 100644 index 782cb651..00000000 --- a/.automation/test/local-storage.json +++ /dev/null @@ -1 +0,0 @@ -{"anonymousUserId":"8f97180e-e0e9-4d33-a52d-f45c9fec4000"} From db2dc2cea2b16870276da4a1a6778210723caefe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Filip=20=C5=A0?= Date: Mon, 3 Aug 2020 22:07:15 +0200 Subject: [PATCH 13/17] Add docs and backward compatibility --- README.md | 73 +++++++++++++++++++++++++++------------------------ lib/linter.sh | 2 +- 2 files changed, 39 insertions(+), 36 deletions(-) diff --git a/README.md b/README.md index 68c4c1ed..eec27ebb 100644 --- a/README.md +++ b/README.md @@ -41,39 +41,39 @@ The design of the **Super-Linter** is currently to allow linting to occur in **G Developers on **GitHub** can call the **GitHub Action** to lint their code base with the following list of linters: -| _Language_ | _Linter_ | -| -------------------------------- | -------------------------------------------------------------------------------------------------------- | -| **Ansible** | [ansible-lint](https://github.com/ansible/ansible-lint) | -| **Azure Resource Manager (ARM)** | [arm-ttk](https://github.com/azure/arm-ttk) | -| **AWS CloudFormation templates** | [cfn-lint](https://github.com/aws-cloudformation/cfn-python-lint/) | -| **CSS** | [stylelint](https://stylelint.io/) | -| **Clojure** | [clj-kondo](https://github.com/borkdude/clj-kondo) | -| **CoffeeScript** | [coffeelint](https://coffeelint.github.io/) | -| **Dart** | [dartanalyzer](https://dart.dev/guides/language/analysis-options) | -| **Dockerfile** | [dockerfilelint](https://github.com/replicatedhq/dockerfilelint.git) | -| **EDITORCONFIG** | [editorconfig-checker](https://github.com/editorconfig-checker/editorconfig-checker) | -| **ENV** | [dotenv-linter](https://github.com/dotenv-linter/dotenv-linter) | -| **Golang** | [golangci-lint](https://github.com/golangci/golangci-lint) | -| **Groovy** | [npm-groovy-lint](https://github.com/nvuillam/npm-groovy-lint) | -| **HTMLHint** | [HTMLHint](https://github.com/htmlhint/HTMLHint) | -| **JavaScript** | [eslint](https://eslint.org/) [standard js](https://standardjs.com/) | -| **JSON** | [jsonlint](https://github.com/zaach/jsonlint) | -| **Kotlin** | [ktlint](https://github.com/pinterest/ktlint) | -| **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) | -| **PHP** | [PHP](https://www.php.net/) | -| **PowerShell** | [PSScriptAnalyzer](https://github.com/PowerShell/Psscriptanalyzer) | -| **Protocol Buffers** | [protolint](https://github.com/yoheimuta/protolint) | -| **Python3** | [pylint](https://www.pylint.org/) [flake8](https://flake8.pycqa.org/en/latest/) | -| **Raku** | [raku](https://raku.org) | -| **Ruby** | [RuboCop](https://github.com/rubocop-hq/rubocop) | -| **Shell** | [Shellcheck](https://github.com/koalaman/shellcheck) | -| **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/) | -| **YAML** | [YamlLint](https://github.com/adrienverge/yamllint) | +| _Language_ | _Linter_ | +| -------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | +| **Ansible** | [ansible-lint](https://github.com/ansible/ansible-lint) | +| **Azure Resource Manager (ARM)** | [arm-ttk](https://github.com/azure/arm-ttk) | +| **AWS CloudFormation templates** | [cfn-lint](https://github.com/aws-cloudformation/cfn-python-lint/) | +| **CSS** | [stylelint](https://stylelint.io/) | +| **Clojure** | [clj-kondo](https://github.com/borkdude/clj-kondo) | +| **CoffeeScript** | [coffeelint](https://coffeelint.github.io/) | +| **Dart** | [dartanalyzer](https://dart.dev/guides/language/analysis-options) | +| **Dockerfile** | [dockerfilelint](https://github.com/replicatedhq/dockerfilelint.git) | +| **EDITORCONFIG** | [editorconfig-checker](https://github.com/editorconfig-checker/editorconfig-checker) | +| **ENV** | [dotenv-linter](https://github.com/dotenv-linter/dotenv-linter) | +| **Golang** | [golangci-lint](https://github.com/golangci/golangci-lint) | +| **Groovy** | [npm-groovy-lint](https://github.com/nvuillam/npm-groovy-lint) | +| **HTMLHint** | [HTMLHint](https://github.com/htmlhint/HTMLHint) | +| **JavaScript** | [eslint](https://eslint.org/) [standard js](https://standardjs.com/) | +| **JSON** | [jsonlint](https://github.com/zaach/jsonlint) | +| **Kotlin** | [ktlint](https://github.com/pinterest/ktlint) | +| **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) | +| **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) | +| **Python3** | [pylint](https://www.pylint.org/) [flake8](https://flake8.pycqa.org/en/latest/) | +| **Raku** | [raku](https://raku.org) | +| **Ruby** | [RuboCop](https://github.com/rubocop-hq/rubocop) | +| **Shell** | [Shellcheck](https://github.com/koalaman/shellcheck) | +| **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/) | +| **YAML** | [YamlLint](https://github.com/adrienverge/yamllint) | ## How to use @@ -210,8 +210,11 @@ and won't run anything unexpected. | **VALIDATE_MD** | `true` | Flag to enable or disable the linting process of the Markdown language. | | **VALIDATE_OPENAPI** | `true` | Flag to enable or disable the linting process of the OpenAPI language. | | **VALIDATE_PERL** | `true` | Flag to enable or disable the linting process of the Perl language. | -| **VALIDATE_PHP** | `true` | Flag to enable or disable the linting process of the PHP language. | -| **VALIDATE_PHP_PHPSTAN** | `true` | Flag to enable or disable the linting process of the PHP language (Utilizing: PHPStan). | +| **VALIDATE_PHP** | `true` | Flag to enable or disable the linting process of the PHP language. (Utilizing: PHP built-in linter) (keep for backward compatibility) | +| **VALIDATE_PHP_BUILTIN** | `true` | Flag to enable or disable the linting process of the PHP language. (Utilizing: PHP built-in linter) | +| **VALIDATE_PHP_PHPCS** | `true` | Flag to enable or disable the linting process of the PHP language. (Utilizing: PHP CodeSniffer) | +| **VALIDATE_PHP_PHPSTAN** | `true` | Flag to enable or disable the linting process of the PHP language. (Utilizing: PHPStan) | +| **VALIDATE_PHP_PSALM** | `true` | Flag to enable or disable the linting process of the PHP language. (Utilizing: PSalm) | | **VALIDATE_PROTOBUF** | `true` | Flag to enable or disable the linting process of the Protobuf language. | | **VALIDATE_PYTHON** | `true` | Flag to enable or disable the linting process of the Python language. (Utilizing: pylint) (keep for backward compatibility) | | **VALIDATE_PYTHON_PYLINT** | `true` | Flag to enable or disable the linting process of the Python language. (Utilizing: pylint) | diff --git a/lib/linter.sh b/lib/linter.sh index 7c8e3586..8dc6d46a 100755 --- a/lib/linter.sh +++ b/lib/linter.sh @@ -179,7 +179,7 @@ VALIDATE_LUA="${VALIDATE_LUA}" # Boolean t VALIDATE_MARKDOWN="${VALIDATE_MD:-}" # Boolean to validate language VALIDATE_OPENAPI="${VALIDATE_OPENAPI}" # Boolean to validate language VALIDATE_PERL="${VALIDATE_PERL}" # Boolean to validate language -VALIDATE_PHP_BUILTIN="${VALIDATE_PHP_BUILTIN}" # Boolean to validate language +VALIDATE_PHP_BUILTIN="${VALIDATE_PHP:-VALIDATE_PHP_BUILTIN}" # Boolean to validate language VALIDATE_PHP_PHPCS="${VALIDATE_PHP_PHPCS}" # Boolean to validate language VALIDATE_PHP_PHPSTAN="${VALIDATE_PHP_PHPSTAN}" # Boolean to validate language VALIDATE_PHP_PSALM="${VALIDATE_PHP_PSALM}" # Boolean to validate language From 2898e49402f9a86fc3f2a4e7442cc4c28fcaf8a4 Mon Sep 17 00:00:00 2001 From: Lucas Gravley <29484535+admiralAwkbar@users.noreply.github.com> Date: Tue, 4 Aug 2020 08:43:07 -0500 Subject: [PATCH 14/17] ignore php tap reports --- .../{expected-PHP_PHPCS.tap => expected-PHP_PHPCS.tap.ignored} | 0 ...{expected-PHP_PHPSTAN.tap => expected-PHP_PHPSTAN.tap.ignored} | 0 .../{expected-PHP_PSALM.tap => expected-PHP_PSALM.tap.ignored} | 0 3 files changed, 0 insertions(+), 0 deletions(-) rename .automation/test/php/reports/{expected-PHP_PHPCS.tap => expected-PHP_PHPCS.tap.ignored} (100%) rename .automation/test/php/reports/{expected-PHP_PHPSTAN.tap => expected-PHP_PHPSTAN.tap.ignored} (100%) rename .automation/test/php/reports/{expected-PHP_PSALM.tap => expected-PHP_PSALM.tap.ignored} (100%) diff --git a/.automation/test/php/reports/expected-PHP_PHPCS.tap b/.automation/test/php/reports/expected-PHP_PHPCS.tap.ignored similarity index 100% rename from .automation/test/php/reports/expected-PHP_PHPCS.tap rename to .automation/test/php/reports/expected-PHP_PHPCS.tap.ignored diff --git a/.automation/test/php/reports/expected-PHP_PHPSTAN.tap b/.automation/test/php/reports/expected-PHP_PHPSTAN.tap.ignored similarity index 100% rename from .automation/test/php/reports/expected-PHP_PHPSTAN.tap rename to .automation/test/php/reports/expected-PHP_PHPSTAN.tap.ignored diff --git a/.automation/test/php/reports/expected-PHP_PSALM.tap b/.automation/test/php/reports/expected-PHP_PSALM.tap.ignored similarity index 100% rename from .automation/test/php/reports/expected-PHP_PSALM.tap rename to .automation/test/php/reports/expected-PHP_PSALM.tap.ignored From 54ac2166004553ba4fc3921d435bdd7d1c7136be Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Filip=20=C5=A0?= Date: Tue, 4 Aug 2020 18:43:36 +0200 Subject: [PATCH 15/17] Fix file modes and re-add report --- .automation/test/php/php_bad_2.php | 0 .automation/test/php/php_good_2.php | 0 .automation/test/php/reports/expected-PHP_BUILTIN.tap | 0 .../test/php/reports/expected-PHP_PHPCS.tap.ignored | 0 ...ed-PHP_PHPSTAN.tap.ignored => expected-PHP_PHPSTAN.tap} | 7 ++++--- .../test/php/reports/expected-PHP_PSALM.tap.ignored | 0 TEMPLATES/phpcs.xml | 0 TEMPLATES/psalm.xml | 0 dependencies/phive.xml | 0 9 files changed, 4 insertions(+), 3 deletions(-) mode change 100755 => 100644 .automation/test/php/php_bad_2.php mode change 100755 => 100644 .automation/test/php/php_good_2.php mode change 100755 => 100644 .automation/test/php/reports/expected-PHP_BUILTIN.tap mode change 100755 => 100644 .automation/test/php/reports/expected-PHP_PHPCS.tap.ignored rename .automation/test/php/reports/{expected-PHP_PHPSTAN.tap.ignored => expected-PHP_PHPSTAN.tap} (59%) mode change 100755 => 100644 .automation/test/php/reports/expected-PHP_PSALM.tap.ignored mode change 100755 => 100644 TEMPLATES/phpcs.xml mode change 100755 => 100644 TEMPLATES/psalm.xml mode change 100755 => 100644 dependencies/phive.xml diff --git a/.automation/test/php/php_bad_2.php b/.automation/test/php/php_bad_2.php old mode 100755 new mode 100644 diff --git a/.automation/test/php/php_good_2.php b/.automation/test/php/php_good_2.php old mode 100755 new mode 100644 diff --git a/.automation/test/php/reports/expected-PHP_BUILTIN.tap b/.automation/test/php/reports/expected-PHP_BUILTIN.tap old mode 100755 new mode 100644 diff --git a/.automation/test/php/reports/expected-PHP_PHPCS.tap.ignored b/.automation/test/php/reports/expected-PHP_PHPCS.tap.ignored old mode 100755 new mode 100644 diff --git a/.automation/test/php/reports/expected-PHP_PHPSTAN.tap.ignored b/.automation/test/php/reports/expected-PHP_PHPSTAN.tap similarity index 59% rename from .automation/test/php/reports/expected-PHP_PHPSTAN.tap.ignored rename to .automation/test/php/reports/expected-PHP_PHPSTAN.tap index 053f0eb0..03f22dd1 100644 --- a/.automation/test/php/reports/expected-PHP_PHPSTAN.tap.ignored +++ b/.automation/test/php/reports/expected-PHP_PHPSTAN.tap @@ -1,11 +1,12 @@ TAP version 13 -1..3 +1..4 not ok 1 - php_bad_1.php --- message: ------ ---------------------------------------------- \n Line php_bad_1.php \n ------ ---------------------------------------------- \n 3 Invalid numeric literal on line 3 \n 3 Invalid numeric literal on line 3 \n 3 Syntax error, unexpected '=' on line 3 \n 3 Syntax error, unexpected T_LNUMBER on line 3 \n 3 Syntax error, unexpected T_STRING on line 3 \n 3 Syntax error, unexpected T_STRING on line 3 \n ------ ---------------------------------------------- \n\n [ERROR] Found 6 errors \n ... not ok 2 - php_bad_2.php --- - message: ------ ------------------------------------------------------- \n Line php_bad_2.php \n ------ ------------------------------------------------------- \n 5 Syntax error, unexpected EOF, expecting T_VARIABLE or \n T_DOLLAR_OPEN_CURLY_BRACES or T_CURLY_OPEN on line 5 \n ------ ------------------------------------------------------- \n\n [ERROR] Found 1 error \n + message: ------ ----------------------------------------- \n Line php_bad_2.php \n ------ ----------------------------------------- \n 15 Syntax error, unexpected '}' on line 15 \n ------ ----------------------------------------- \n\n [ERROR] Found 1 error \n ... -ok 3 - php_good_1.php \ No newline at end of file +ok 3 - php_good_1.php +ok 4 - php_good_2.php diff --git a/.automation/test/php/reports/expected-PHP_PSALM.tap.ignored b/.automation/test/php/reports/expected-PHP_PSALM.tap.ignored old mode 100755 new mode 100644 diff --git a/TEMPLATES/phpcs.xml b/TEMPLATES/phpcs.xml old mode 100755 new mode 100644 diff --git a/TEMPLATES/psalm.xml b/TEMPLATES/psalm.xml old mode 100755 new mode 100644 diff --git a/dependencies/phive.xml b/dependencies/phive.xml old mode 100755 new mode 100644 From 0c84fd5120dad6573506e196ab97524b6517363a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Filip=20=C5=A0?= Date: Tue, 4 Aug 2020 19:07:18 +0200 Subject: [PATCH 16/17] Fix PHPStan config --- lib/worker.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/worker.sh b/lib/worker.sh index 0212f151..3cde38b6 100755 --- a/lib/worker.sh +++ b/lib/worker.sh @@ -591,7 +591,7 @@ function RunTestCases() { TestCodebase "PERL" "perl" "perl -Mstrict -cw" ".*\.\(pl\)\$" "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 ${PHPSTAN_LINTER_RULES}" ".*\.\(php\)\$" "php" + TestCodebase "PHP_PHPSTAN" "phpstan" "phpstan analyse --no-progress --no-ansi -c ${PHP_PHPSTAN_LINTER_RULES}" ".*\.\(php\)\$" "php" TestCodebase "PHP_PSALM" "psalm" "psalm --config=${PHP_PSALM_LINTER_RULES}" ".*\.\(php\)\$" "php" TestCodebase "OPENAPI" "spectral" "spectral lint -r ${OPENAPI_LINTER_RULES}" ".*\.\(ymlopenapi\|jsonopenapi\)\$" "openapi" TestCodebase "POWERSHELL" "pwsh" "Invoke-ScriptAnalyzer -EnableExit -Settings ${POWERSHELL_LINTER_RULES} -Path" ".*\.\(ps1\|psm1\|psd1\|ps1xml\|pssc\|psrc\|cdxml\)\$" "powershell" From 8063ed91f516bc0d59bac6524b30603aa7bf55f5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Filip=20=C5=A0?= Date: Tue, 4 Aug 2020 19:24:15 +0200 Subject: [PATCH 17/17] Fix PHPStan config again --- lib/linter.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/linter.sh b/lib/linter.sh index 8dc6d46a..e044726d 100755 --- a/lib/linter.sh +++ b/lib/linter.sh @@ -1526,7 +1526,7 @@ if [ "${VALIDATE_PHP_PHPSTAN}" == "true" ]; then # Lint the PHP files using PHPStan # ####################### # LintCodebase "FILE_TYPE" "LINTER_NAME" "LINTER_CMD" "FILE_TYPES_REGEX" "FILE_ARRAY" - LintCodebase "PHP_PHPSTAN" "phpstan" "phpstan analyse --no-progress --no-ansi -c ${PHPSTAN_LINTER_RULES}" ".*\.\(php\)\$" "${FILE_ARRAY_PHP_PHPSTAN[@]}" + LintCodebase "PHP_PHPSTAN" "phpstan" "phpstan analyse --no-progress --no-ansi -c ${PHP_PHPSTAN_LINTER_RULES}" ".*\.\(php\)\$" "${FILE_ARRAY_PHP_PHPSTAN[@]}" fi if [ "${VALIDATE_PHP_PSALM}" == "true" ]; then