mirror of
https://github.com/super-linter/super-linter.git
synced 2024-11-22 00:31:07 -05:00
Merge pull request #478 from filips123/support-for-phpcs-and-psalm
Support for PHPCS and Psalm
This commit is contained in:
commit
1e035771fd
15 changed files with 208 additions and 86 deletions
|
@ -1,4 +1,15 @@
|
|||
<?php
|
||||
|
||||
function f(int $i){}
|
||||
f("not int');
|
||||
/**
|
||||
* @return array<string>
|
||||
*/
|
||||
function takesAnInt(int $i) {
|
||||
return [$i, "hello"];
|
||||
}
|
||||
|
||||
$data = ["some text", 5];
|
||||
takesAnInt($data[0]);
|
||||
|
||||
$condition = rand(0, 5);
|
||||
iff ($condition) {
|
||||
} elseif ($condition) {}
|
||||
|
|
25
.automation/test/php/php_good_2.php
Normal file
25
.automation/test/php/php_good_2.php
Normal file
|
@ -0,0 +1,25 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @return array<string>
|
||||
*/
|
||||
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";
|
||||
}
|
||||
}
|
|
@ -1,11 +1,12 @@
|
|||
TAP version 13
|
||||
1..3
|
||||
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 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
|
||||
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
|
12
.automation/test/php/reports/expected-PHP_PHPCS.tap.ignored
Normal file
12
.automation/test/php/reports/expected-PHP_PHPCS.tap.ignored
Normal file
|
@ -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
|
|
@ -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
|
||||
ok 4 - php_good_2.php
|
||||
|
|
12
.automation/test/php/reports/expected-PHP_PSALM.tap.ignored
Normal file
12
.automation/test/php/reports/expected-PHP_PSALM.tap.ignored
Normal file
|
@ -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<array-key, string>' for takesAnInt is incorrect, got 'array{int, string(hello)}' (see https //psalm.dev/011)\n * @return array<string>\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<array-key, string>' 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[30;48;5;195m--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
|
28
Dockerfile
28
Dockerfile
|
@ -65,8 +65,8 @@ RUN apk add --update --no-cache \
|
|||
npm nodejs-current \
|
||||
openjdk8-jre \
|
||||
perl \
|
||||
php7 php7-phar php7-json php7-mbstring \
|
||||
php7-tokenizer php7-ctype php7-curl php7-dom \
|
||||
php7 php7-phar php7-json php7-mbstring php-xmlwriter \
|
||||
php7-tokenizer php7-ctype php7-curl php7-dom php7-simplexml \
|
||||
py3-setuptools \
|
||||
readline-dev \
|
||||
ruby ruby-dev ruby-bundler ruby-rdoc \
|
||||
|
@ -100,6 +100,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,CF1A108D0E7AE720,8A03EA3B385DBAA1
|
||||
# Trusted GPG keys for PHP linters: phpcs, phpstan, psalm
|
||||
|
||||
#########################################
|
||||
# Install Powershell + PSScriptAnalyzer #
|
||||
#########################################
|
||||
|
@ -205,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 #
|
||||
###########################################
|
||||
|
|
73
README.md
73
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) |
|
||||
|
|
6
TEMPLATES/phpcs.xml
Normal file
6
TEMPLATES/phpcs.xml
Normal file
|
@ -0,0 +1,6 @@
|
|||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
|
||||
<ruleset name="super-linter">
|
||||
<description>The default coding standard for usage with GitHub Super-Linter. It just includes PSR12.</description>
|
||||
<rule ref="PSR12" />
|
||||
</ruleset>
|
4
TEMPLATES/psalm.xml
Normal file
4
TEMPLATES/psalm.xml
Normal file
|
@ -0,0 +1,4 @@
|
|||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
|
||||
<psalm xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://getpsalm.org/schema/config" xmlns="https://getpsalm.org/schema/config">
|
||||
</psalm>
|
7
dependencies/phive.xml
vendored
Normal file
7
dependencies/phive.xml
vendored
Normal file
|
@ -0,0 +1,7 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<phive xmlns="https://phar.io/phive">
|
||||
<!-- When adding new linter, do not forget to add its GPG key ID to Dockerfile -->
|
||||
<phar name="phpcs" version="^3.5" installed="3.5.5" location="/usr/local/bin/phpcs" copy="true"/>
|
||||
<phar name="phpstan" version="^0.12" installed="0.12.34" location="/usr/local/bin/phpstan" copy="true"/>
|
||||
<phar name="psalm" version="^3.12" installed="3.12.2" location="/usr/local/bin/psalm" copy="true"/>
|
||||
</phive>
|
|
@ -230,8 +230,10 @@ 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_PHPSTAN+=("${FILE}")
|
||||
FILE_ARRAY_PHP_PSALM+=("${FILE}")
|
||||
##########################################################
|
||||
# Set the READ_ONLY_CHANGE_FLAG since this could be exec #
|
||||
##########################################################
|
||||
|
|
|
@ -72,11 +72,23 @@ MARKDOWN_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${MARKDOWN_FILE_NAME}" # Path t
|
|||
# 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
|
||||
# PHP Vars
|
||||
PHPSTAN_FILE_NAME='phpstan.neon' # Name of the file
|
||||
PHPSTAN_LINTER_RULES="${GITHUB_WORKSPACE}/${PHPSTAN_FILE_NAME}" # Path to the PHPStan lint rules in the repository
|
||||
if [ ! -f "$PHPSTAN_LINTER_RULES" ]; then
|
||||
PHPSTAN_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${PHPSTAN_FILE_NAME}" # Path to the PHPStan lint rules
|
||||
# PHPCS Vars
|
||||
PHP_PHPCS_FILE_NAME='phpcs.xml' # Name of the file
|
||||
PHP_PHPCS_LINTER_RULES="${GITHUB_WORKSPACE}/${PHP_PHPCS_FILE_NAME}" # Path to the PHP CodeSniffer lint rules in the repository
|
||||
if [ ! -f "$PHP_PHPCS_LINTER_RULES" ]; then
|
||||
PHP_PHPCS_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${PHP_PHPCS_FILE_NAME}" # Path to the PHP CodeSniffer lint rules
|
||||
fi
|
||||
# PHPStan Vars
|
||||
PHP_PHPSTAN_FILE_NAME='phpstan.neon' # Name of the file
|
||||
PHP_PHPSTAN_LINTER_RULES="${GITHUB_WORKSPACE}/${PHP_PHPSTAN_FILE_NAME}" # Path to the PHPStan lint rules in the repository
|
||||
if [ ! -f "$PHP_PHPSTAN_LINTER_RULES" ]; then
|
||||
PHP_PHPSTAN_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${PHP_PHPSTAN_FILE_NAME}" # Path to the PHPStan lint rules
|
||||
fi
|
||||
# Psalm Vars
|
||||
PHP_PSALM_FILE_NAME='psalm.xml' # Name of the file
|
||||
PHP_PSALM_LINTER_RULES="${GITHUB_WORKSPACE}/${PHP_PSALM_FILE_NAME}" # Path to the Psalm lint rules in the repository
|
||||
if [ ! -f "$PHP_PSALM_LINTER_RULES" ]; then
|
||||
PHP_PSALM_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${PHP_PSALM_FILE_NAME}" # Path to the Psalm lint rules
|
||||
fi
|
||||
# Powershell Vars
|
||||
POWERSHELL_FILE_NAME='.powershell-psscriptanalyzer.psd1' # Name of the file
|
||||
|
@ -117,9 +129,10 @@ LINTER_ARRAY=('ansible-lint' 'arm-ttk' 'asl-validator' 'cfn-lint' 'clj-kondo' 'c
|
|||
#############################
|
||||
LANGUAGE_ARRAY=('ANSIBLE' 'ARM' 'BASH' 'CLOUDFORMATION' 'CLOJURE' 'COFFEESCRIPT' 'CSS'
|
||||
'DART' 'DOCKER' 'ENV' 'GO' 'GROOVY' 'HTML' 'JAVASCRIPT_ES' 'JAVASCRIPT_STANDARD'
|
||||
'JSON' 'JSX' 'KOTLIN' 'LUA' 'MARKDOWN' 'OPENAPI' 'PERL' 'PHP' 'PHP_PHPSTAN' 'POWERSHELL'
|
||||
'PROTOBUF' 'PYTHON_PYLINT' 'PYTHON_FLAKE8' 'RAKU' 'RUBY' 'STATES' 'TERRAFORM'
|
||||
'TERRAFORM_TERRASCAN' 'TSX' 'TYPESCRIPT_ES' 'TYPESCRIPT_STANDARD' 'XML' 'YAML')
|
||||
'JSON' 'JSX' 'KOTLIN' 'LUA' 'MARKDOWN' 'OPENAPI' 'PERL' 'PHP_BUILTIN' 'PHP_PHPCS'
|
||||
'PHP_PHPSTAN' 'PHP_PSALM' 'POWERSHELL' 'PROTOBUF' 'PYTHON_PYLINT' 'PYTHON_FLAKE8'
|
||||
'RAKU' 'RUBY' 'STATES' 'TERRAFORM' 'TERRAFORM_TERRASCAN' 'TSX' 'TYPESCRIPT_ES'
|
||||
'TYPESCRIPT_STANDARD' 'XML' 'YAML')
|
||||
|
||||
############################################
|
||||
# Array for all languages that were linted #
|
||||
|
@ -166,8 +179,10 @@ 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="${VALIDATE_PHP}" # 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
|
||||
VALIDATE_POWERSHELL="${VALIDATE_POWERSHELL}" # Boolean to validate language
|
||||
VALIDATE_PYTHON_PYLINT="${VALIDATE_PYTHON:-$VALIDATE_PYTHON_PYLINT}" # Boolean to validate language
|
||||
VALIDATE_PYTHON_FLAKE8="${VALIDATE_PYTHON_FLAKE8}" # Boolean to validate language
|
||||
|
@ -259,8 +274,10 @@ 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_PHPSTAN=() # 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_PYLINT=() # Array of files to check
|
||||
|
@ -322,10 +339,14 @@ 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_PHPSTAN=0 # Count of errors found
|
||||
export ERRORS_FOUND_PHP_PHPSTAN # 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
|
||||
|
@ -1484,23 +1505,36 @@ 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 --standard=${PHP_PHPCS_LINTER_RULES}" ".*\.\(php\)\$" "${FILE_ARRAY_PHP_PHPCS[@]}"
|
||||
fi
|
||||
|
||||
###################
|
||||
# PHPStan LINTING #
|
||||
###################
|
||||
if [ "${VALIDATE_PHP_PHPSTAN}" == "true" ]; then
|
||||
#######################
|
||||
# Lint the PHP files #
|
||||
# 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
|
||||
##################################
|
||||
# Lint the PHP files using Psalm #
|
||||
##################################
|
||||
# LintCodebase "FILE_TYPE" "LINTER_NAME" "LINTER_CMD" "FILE_TYPES_REGEX" "FILE_ARRAY"
|
||||
LintCodebase "PHP_PSALM" "psalm" "psalm --config=${PHP_PSALM_LINTER_RULES}" ".*\.\(php\)\$" "${FILE_ARRAY_PHP_PSALM[@]}"
|
||||
fi
|
||||
|
||||
######################
|
||||
|
|
|
@ -8,12 +8,12 @@ cat << EOF
|
|||
@///////@///////////////@@@@ ( @,
|
||||
@/(&/@//////////////////// @
|
||||
@////////////////////////@@ @
|
||||
@%////////(//////////%/////&@ @@ *,@
|
||||
@@@@@/@/#/////(&////////////////// .@
|
||||
*@@@@@. .%///(//@//////////////////&. .@@, @%
|
||||
@@% .&@&&/@.@//&/////(////////// @@@@@@@@@ .. &@
|
||||
@@% @@@@@ @&/////////////////# @/ V @@/ ,@@@ @
|
||||
@@@% @@@@ .%@@@@//////#@ @ @@ @ .,.
|
||||
@%////////(//////////%/////&@ @@ *,@ ______________
|
||||
@@@@@/@/#/////(&////////////////// .@ / \\
|
||||
*@@@@@. .%///(//@//////////////////&. .@@, @% / Don't mind me \\
|
||||
@@% .&@&&/@.@//&/////(////////// @@@@@@@@@ .. &@ / I'm just looking \\
|
||||
@@% @@@@@ @&/////////////////# @/ V @@/ ,@@@ @ < for some trash... |
|
||||
@@@% @@@@ .%@@@@//////#@ @ @@ @ .,. \\__________________/
|
||||
@@@/@( (@@@@% @/\ %
|
||||
@@@@( . .@@/\ #
|
||||
@ %@%
|
||||
|
|
|
@ -589,8 +589,10 @@ function RunTestCases() {
|
|||
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 "PHP" "php" "php -l" ".*\.\(php\)\$" "php"
|
||||
TestCodebase "PHP_PHPSTAN" "phpstan" "phpstan analyse --no-progress --no-ansi -c ${PHPSTAN_LINTER_RULES}" ".*\.\(php\)\$" "php"
|
||||
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"
|
||||
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"
|
||||
|
|
Loading…
Reference in a new issue