mirror of
https://github.com/super-linter/super-linter.git
synced 2024-11-22 14:10:56 -05:00
commit
599d98f858
7 changed files with 91 additions and 1 deletions
13
.automation/test/php/README.md
Normal file
13
.automation/test/php/README.md
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
# PHP Test Cases
|
||||||
|
This folder holds the test cases for **PHP**.
|
||||||
|
|
||||||
|
## Additional Docs
|
||||||
|
No Additional information is needed for this test case.
|
||||||
|
|
||||||
|
## Good Test Cases
|
||||||
|
The test cases denoted: `LANGUAGE_good_FILE.EXTENSION` are all valid, and should pass successfully when linted.
|
||||||
|
- **Note:** They are linted utilizing the default linter rules.
|
||||||
|
|
||||||
|
## Bad Test Cases
|
||||||
|
The test cases denoted: `LANGUAGE_bad_FILE.EXTENSION` are **NOT** valid, and should trigger errors when linted.
|
||||||
|
- **Note:** They are linted utilizing the default linter rules.
|
3
.automation/test/php/php_bad_1.php
Normal file
3
.automation/test/php/php_bad_1.php
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
2pe98y r-n0u823n=r 092u3- r08u2q098ry 09nq2yr09n2yr9 y2n-93yr 298yr3 29
|
3
.automation/test/php/php_good_1.php
Normal file
3
.automation/test/php/php_good_1.php
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
echo "Hello World!", PHP_EOL;
|
|
@ -28,6 +28,7 @@ RUN apk add --no-cache \
|
||||||
ruby ruby-dev ruby-bundler ruby-rdoc make \
|
ruby ruby-dev ruby-bundler ruby-rdoc make \
|
||||||
py3-setuptools ansible-lint \
|
py3-setuptools ansible-lint \
|
||||||
go \
|
go \
|
||||||
|
php7 \
|
||||||
ca-certificates less ncurses-terminfo-base \
|
ca-certificates less ncurses-terminfo-base \
|
||||||
krb5-libs libgcc libintl libssl1.1 libstdc++ \
|
krb5-libs libgcc libintl libssl1.1 libstdc++ \
|
||||||
tzdata userspace-rcu zlib icu-libs lttng-ust
|
tzdata userspace-rcu zlib icu-libs lttng-ust
|
||||||
|
@ -143,6 +144,7 @@ ENV GITHUB_SHA=${GITHUB_SHA} \
|
||||||
VALIDATE_MD=${VALIDATE_MD} \
|
VALIDATE_MD=${VALIDATE_MD} \
|
||||||
VALIDATE_BASH=${VALIDATE_BASH} \
|
VALIDATE_BASH=${VALIDATE_BASH} \
|
||||||
VALIDATE_PERL=${VALIDATE_PERL} \
|
VALIDATE_PERL=${VALIDATE_PERL} \
|
||||||
|
VALIDATE_PHP=${VALIDATE_PHP} \
|
||||||
VALIDATE_PYTHON=${VALIDATE_PYTHON} \
|
VALIDATE_PYTHON=${VALIDATE_PYTHON} \
|
||||||
VALIDATE_RUBY=${VALIDATE_RUBY} \
|
VALIDATE_RUBY=${VALIDATE_RUBY} \
|
||||||
VALIDATE_COFFEE=${VALIDATE_COFFEE} \
|
VALIDATE_COFFEE=${VALIDATE_COFFEE} \
|
||||||
|
|
|
@ -27,6 +27,7 @@ Developers on **GitHub** can call the **GitHub Action** to lint their code base
|
||||||
| **JSON** | [jsonlint](https://github.com/zaach/jsonlint) |
|
| **JSON** | [jsonlint](https://github.com/zaach/jsonlint) |
|
||||||
| **Markdown** | [markdownlint](https://github.com/igorshubovych/markdownlint-cli#readme) |
|
| **Markdown** | [markdownlint](https://github.com/igorshubovych/markdownlint-cli#readme) |
|
||||||
| **Perl** | [perl](https://pkgs.alpinelinux.org/package/edge/main/x86/perl) |
|
| **Perl** | [perl](https://pkgs.alpinelinux.org/package/edge/main/x86/perl) |
|
||||||
|
| **PHP** | [PHP](https://www.php.net/) |
|
||||||
| **Python3** | [pylint](https://www.pylint.org/) |
|
| **Python3** | [pylint](https://www.pylint.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) |
|
||||||
|
@ -125,6 +126,7 @@ and won't run anything unexpected.
|
||||||
| **VALIDATE_MD** | `true` | Flag to enable or disable the linting process of the language. |
|
| **VALIDATE_MD** | `true` | Flag to enable or disable the linting process of the language. |
|
||||||
| **VALIDATE_BASH** | `true` | Flag to enable or disable the linting process of the language. |
|
| **VALIDATE_BASH** | `true` | Flag to enable or disable the linting process of the language. |
|
||||||
| **VALIDATE_PERL** | `true` | Flag to enable or disable the linting process of the language. |
|
| **VALIDATE_PERL** | `true` | Flag to enable or disable the linting process of the language. |
|
||||||
|
| **VALIDATE_PHP** | `true` | Flag to enable or disable the linting process of the language. |
|
||||||
| **VALIDATE_PYTHON** | `true` | Flag to enable or disable the linting process of the language. |
|
| **VALIDATE_PYTHON** | `true` | Flag to enable or disable the linting process of the language. |
|
||||||
| **VALIDATE_RUBY** | `true` | Flag to enable or disable the linting process of the language. |
|
| **VALIDATE_RUBY** | `true` | Flag to enable or disable the linting process of the language. |
|
||||||
| **VALIDATE_COFFEE** | `true` | Flag to enable or disable the linting process of the language . |
|
| **VALIDATE_COFFEE** | `true` | Flag to enable or disable the linting process of the language . |
|
||||||
|
|
|
@ -11,6 +11,7 @@ Below is examples and documentation for each language and the various methods to
|
||||||
- [JSON](#json)
|
- [JSON](#json)
|
||||||
- [Markdown](#markdown)
|
- [Markdown](#markdown)
|
||||||
- [Perl](#perl)
|
- [Perl](#perl)
|
||||||
|
- [PHP](#php)
|
||||||
- [XML](#xml)
|
- [XML](#xml)
|
||||||
- [Coffeescript](#coffeescript)
|
- [Coffeescript](#coffeescript)
|
||||||
- [Javascript Eslint](#javascript-eslint)
|
- [Javascript Eslint](#javascript-eslint)
|
||||||
|
@ -303,6 +304,23 @@ Here is more data
|
||||||
|
|
||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
## PHP
|
||||||
|
- [PHP](https://www.php.net/)
|
||||||
|
|
||||||
|
### PHP Config file
|
||||||
|
- There is no top level *configuration file* available at this time
|
||||||
|
|
||||||
|
### PHP disable single line
|
||||||
|
- There is currently **No** way to disable rules inline of the file(s)
|
||||||
|
|
||||||
|
### PHP disable code block
|
||||||
|
- There is currently **No** way to disable rules inline of the file(s)
|
||||||
|
|
||||||
|
### PHP disable entire file
|
||||||
|
- There is currently **No** way to disable rules inline of the file(s)
|
||||||
|
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
|
||||||
## XML
|
## XML
|
||||||
- [XML](http://xmlsoft.org/)
|
- [XML](http://xmlsoft.org/)
|
||||||
|
|
||||||
|
|
|
@ -66,7 +66,7 @@ LINTER_ARRAY=("jsonlint" "yamllint" "xmllint" "markdownlint" "shellcheck"
|
||||||
#############################
|
#############################
|
||||||
# Language array for prints #
|
# Language array for prints #
|
||||||
#############################
|
#############################
|
||||||
LANGUAGE_ARRAY=('YML' 'JSON' 'XML' 'MARKDOWN' 'BASH' 'PERL' 'RUBY' 'PYTHON'
|
LANGUAGE_ARRAY=('YML' 'JSON' 'XML' 'MARKDOWN' 'BASH' 'PERL' 'PHP' 'RUBY' 'PYTHON'
|
||||||
'COFFEESCRIPT' 'ANSIBLE' 'JAVASCRIPT_STANDARD' 'JAVASCRIPT_ES'
|
'COFFEESCRIPT' 'ANSIBLE' 'JAVASCRIPT_STANDARD' 'JAVASCRIPT_ES'
|
||||||
'TYPESCRIPT_STANDARD' 'TYPESCRIPT_ES' 'DOCKER' 'GO' 'TERRAFORM' 'CSS'
|
'TYPESCRIPT_STANDARD' 'TYPESCRIPT_ES' 'DOCKER' 'GO' 'TERRAFORM' 'CSS'
|
||||||
'ENV' 'POWERSHELL')
|
'ENV' 'POWERSHELL')
|
||||||
|
@ -86,6 +86,7 @@ VALIDATE_XML="${VALIDATE_XML}" # Boolean to validate lang
|
||||||
VALIDATE_MD="${VALIDATE_MD}" # Boolean to validate language
|
VALIDATE_MD="${VALIDATE_MD}" # Boolean to validate language
|
||||||
VALIDATE_BASH="${VALIDATE_BASH}" # Boolean to validate language
|
VALIDATE_BASH="${VALIDATE_BASH}" # Boolean to validate language
|
||||||
VALIDATE_PERL="${VALIDATE_PERL}" # Boolean to validate language
|
VALIDATE_PERL="${VALIDATE_PERL}" # Boolean to validate language
|
||||||
|
VALIDATE_PHP="${VALIDATE_PHP}" # Boolean to validate language
|
||||||
VALIDATE_PYTHON="${VALIDATE_PYTHON}" # Boolean to validate language
|
VALIDATE_PYTHON="${VALIDATE_PYTHON}" # Boolean to validate language
|
||||||
VALIDATE_RUBY="${VALIDATE_RUBY}" # Boolean to validate language
|
VALIDATE_RUBY="${VALIDATE_RUBY}" # Boolean to validate language
|
||||||
VALIDATE_COFFEE="${VALIDATE_COFFEE}" # Boolean to validate language
|
VALIDATE_COFFEE="${VALIDATE_COFFEE}" # Boolean to validate language
|
||||||
|
@ -132,6 +133,7 @@ FILE_ARRAY_XML=() # Array of files to check
|
||||||
FILE_ARRAY_MD=() # Array of files to check
|
FILE_ARRAY_MD=() # Array of files to check
|
||||||
FILE_ARRAY_BASH=() # Array of files to check
|
FILE_ARRAY_BASH=() # Array of files to check
|
||||||
FILE_ARRAY_PERL=() # Array of files to check
|
FILE_ARRAY_PERL=() # Array of files to check
|
||||||
|
FILE_ARRAY_PHP=() # Array of files to check
|
||||||
FILE_ARRAY_RUBY=() # Array of files to check
|
FILE_ARRAY_RUBY=() # Array of files to check
|
||||||
FILE_ARRAY_PYTHON=() # Array of files to check
|
FILE_ARRAY_PYTHON=() # Array of files to check
|
||||||
FILE_ARRAY_COFFEESCRIPT=() # Array of files to check
|
FILE_ARRAY_COFFEESCRIPT=() # Array of files to check
|
||||||
|
@ -155,6 +157,7 @@ ERRORS_FOUND_XML=0 # Count of errors found
|
||||||
ERRORS_FOUND_MARKDOWN=0 # Count of errors found
|
ERRORS_FOUND_MARKDOWN=0 # Count of errors found
|
||||||
ERRORS_FOUND_BASH=0 # Count of errors found
|
ERRORS_FOUND_BASH=0 # Count of errors found
|
||||||
ERRORS_FOUND_PERL=0 # Count of errors found
|
ERRORS_FOUND_PERL=0 # Count of errors found
|
||||||
|
ERRORS_FOUND_PHP=0 # Count of errors found
|
||||||
ERRORS_FOUND_RUBY=0 # Count of errors found
|
ERRORS_FOUND_RUBY=0 # Count of errors found
|
||||||
ERRORS_FOUND_PYTHON=0 # Count of errors found
|
ERRORS_FOUND_PYTHON=0 # Count of errors found
|
||||||
ERRORS_FOUND_COFFEESCRIPT=0 # Count of errors found
|
ERRORS_FOUND_COFFEESCRIPT=0 # Count of errors found
|
||||||
|
@ -734,6 +737,7 @@ GetValidationInfo()
|
||||||
VALIDATE_MD=$(echo "$VALIDATE_MD" | awk '{print tolower($0)}')
|
VALIDATE_MD=$(echo "$VALIDATE_MD" | awk '{print tolower($0)}')
|
||||||
VALIDATE_BASH=$(echo "$VALIDATE_BASH" | awk '{print tolower($0)}')
|
VALIDATE_BASH=$(echo "$VALIDATE_BASH" | awk '{print tolower($0)}')
|
||||||
VALIDATE_PERL=$(echo "$VALIDATE_PERL" | awk '{print tolower($0)}')
|
VALIDATE_PERL=$(echo "$VALIDATE_PERL" | awk '{print tolower($0)}')
|
||||||
|
VALIDATE_PHP=$(echo "$VALIDATE_PHP" | awk '{print tolower($0)}')
|
||||||
VALIDATE_PYTHON=$(echo "$VALIDATE_PYTHON" | awk '{print tolower($0)}')
|
VALIDATE_PYTHON=$(echo "$VALIDATE_PYTHON" | awk '{print tolower($0)}')
|
||||||
VALIDATE_RUBY=$(echo "$VALIDATE_RUBY" | awk '{print tolower($0)}')
|
VALIDATE_RUBY=$(echo "$VALIDATE_RUBY" | awk '{print tolower($0)}')
|
||||||
VALIDATE_COFFEE=$(echo "$VALIDATE_COFFEE" | awk '{print tolower($0)}')
|
VALIDATE_COFFEE=$(echo "$VALIDATE_COFFEE" | awk '{print tolower($0)}')
|
||||||
|
@ -759,6 +763,7 @@ GetValidationInfo()
|
||||||
-n "$VALIDATE_MD" || \
|
-n "$VALIDATE_MD" || \
|
||||||
-n "$VALIDATE_BASH" || \
|
-n "$VALIDATE_BASH" || \
|
||||||
-n "$VALIDATE_PERL" || \
|
-n "$VALIDATE_PERL" || \
|
||||||
|
-n "$VALIDATE_PHP" || \
|
||||||
-n "$VALIDATE_PYTHON" || \
|
-n "$VALIDATE_PYTHON" || \
|
||||||
-n "$VALIDATE_RUBY" || \
|
-n "$VALIDATE_RUBY" || \
|
||||||
-n "$VALIDATE_COFFEE" || \
|
-n "$VALIDATE_COFFEE" || \
|
||||||
|
@ -860,6 +865,20 @@ GetValidationInfo()
|
||||||
VALIDATE_PERL="true"
|
VALIDATE_PERL="true"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
####################################
|
||||||
|
# Validate if we should check PHP #
|
||||||
|
####################################
|
||||||
|
if [[ "$ANY_SET" == "true" ]]; then
|
||||||
|
# Some linter flags were set - only run those set to true
|
||||||
|
if [[ -z "$VALIDATE_PHP" ]]; then
|
||||||
|
# PHP flag was not set - default to false
|
||||||
|
VALIDATE_PHP="false"
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
# No linter flags were set - default all to true
|
||||||
|
VALIDATE_PHP="true"
|
||||||
|
fi
|
||||||
|
|
||||||
######################################
|
######################################
|
||||||
# Validate if we should check PYTHON #
|
# Validate if we should check PYTHON #
|
||||||
######################################
|
######################################
|
||||||
|
@ -1089,6 +1108,11 @@ GetValidationInfo()
|
||||||
else
|
else
|
||||||
PRINT_ARRAY+=("- Excluding [PERL] files in code base...")
|
PRINT_ARRAY+=("- Excluding [PERL] files in code base...")
|
||||||
fi
|
fi
|
||||||
|
if [[ "$VALIDATE_PHP" == "true" ]]; then
|
||||||
|
PRINT_ARRAY+=("- Validating [PHP] files in code base...")
|
||||||
|
else
|
||||||
|
PRINT_ARRAY+=("- Excluding [PHP] files in code base...")
|
||||||
|
fi
|
||||||
if [[ "$VALIDATE_PYTHON" == "true" ]]; then
|
if [[ "$VALIDATE_PYTHON" == "true" ]]; then
|
||||||
PRINT_ARRAY+=("- Validating [PYTHON] files in code base...")
|
PRINT_ARRAY+=("- Validating [PYTHON] files in code base...")
|
||||||
else
|
else
|
||||||
|
@ -1403,6 +1427,18 @@ BuildFileList()
|
||||||
##########################################################
|
##########################################################
|
||||||
READ_ONLY_CHANGE_FLAG=1
|
READ_ONLY_CHANGE_FLAG=1
|
||||||
######################
|
######################
|
||||||
|
# Get the PHP files #
|
||||||
|
######################
|
||||||
|
elif [ "$FILE_TYPE" == "php" ]; then
|
||||||
|
################################
|
||||||
|
# Append the file to the array #
|
||||||
|
################################
|
||||||
|
FILE_ARRAY_PHP+=("$FILE")
|
||||||
|
##########################################################
|
||||||
|
# Set the READ_ONLY_CHANGE_FLAG since this could be exec #
|
||||||
|
##########################################################
|
||||||
|
READ_ONLY_CHANGE_FLAG=1
|
||||||
|
######################
|
||||||
# Get the RUBY files #
|
# Get the RUBY files #
|
||||||
######################
|
######################
|
||||||
elif [ "$FILE_TYPE" == "rb" ]; then
|
elif [ "$FILE_TYPE" == "rb" ]; then
|
||||||
|
@ -2037,6 +2073,7 @@ Footer()
|
||||||
[ "$ERRORS_FOUND_MARKDOWN" -ne 0 ] || \
|
[ "$ERRORS_FOUND_MARKDOWN" -ne 0 ] || \
|
||||||
[ "$ERRORS_FOUND_BASH" -ne 0 ] || \
|
[ "$ERRORS_FOUND_BASH" -ne 0 ] || \
|
||||||
[ "$ERRORS_FOUND_PERL" -ne 0 ] || \
|
[ "$ERRORS_FOUND_PERL" -ne 0 ] || \
|
||||||
|
[ "$ERRORS_FOUND_PHP" -ne 0 ] || \
|
||||||
[ "$ERRORS_FOUND_PYTHON" -ne 0 ] || \
|
[ "$ERRORS_FOUND_PYTHON" -ne 0 ] || \
|
||||||
[ "$ERRORS_FOUND_COFFEESCRIPT" -ne 0 ] || \
|
[ "$ERRORS_FOUND_COFFEESCRIPT" -ne 0 ] || \
|
||||||
[ "$ERRORS_FOUND_ANSIBLE" -ne 0 ] || \
|
[ "$ERRORS_FOUND_ANSIBLE" -ne 0 ] || \
|
||||||
|
@ -2097,6 +2134,7 @@ RunTestCases()
|
||||||
TestCodebase "BASH" "shellcheck" "shellcheck" ".*\.\(sh\)\$"
|
TestCodebase "BASH" "shellcheck" "shellcheck" ".*\.\(sh\)\$"
|
||||||
TestCodebase "PYTHON" "pylint" "pylint --rcfile $PYTHON_LINTER_RULES -E" ".*\.\(py\)\$"
|
TestCodebase "PYTHON" "pylint" "pylint --rcfile $PYTHON_LINTER_RULES -E" ".*\.\(py\)\$"
|
||||||
TestCodebase "PERL" "perl" "perl -Mstrict -cw" ".*\.\(pl\)\$"
|
TestCodebase "PERL" "perl" "perl -Mstrict -cw" ".*\.\(pl\)\$"
|
||||||
|
TestCodebase "PHP" "php" "php -l" ".*\.\(php\)\$"
|
||||||
TestCodebase "RUBY" "rubocop" "rubocop -c $RUBY_LINTER_RULES" ".*\.\(rb\)\$"
|
TestCodebase "RUBY" "rubocop" "rubocop -c $RUBY_LINTER_RULES" ".*\.\(rb\)\$"
|
||||||
TestCodebase "GO" "golangci-lint" "golangci-lint run -c $GO_LINTER_RULES" ".*\.\(go\)\$"
|
TestCodebase "GO" "golangci-lint" "golangci-lint run -c $GO_LINTER_RULES" ".*\.\(go\)\$"
|
||||||
TestCodebase "COFFEESCRIPT" "coffeelint" "coffeelint -f $COFFEESCRIPT_LINTER_RULES" ".*\.\(coffee\)\$"
|
TestCodebase "COFFEESCRIPT" "coffeelint" "coffeelint -f $COFFEESCRIPT_LINTER_RULES" ".*\.\(coffee\)\$"
|
||||||
|
@ -2277,6 +2315,17 @@ if [ "$VALIDATE_PERL" == "true" ]; then
|
||||||
LintCodebase "PERL" "perl" "perl -Mstrict -cw" ".*\.\(pl\)\$" "${FILE_ARRAY_PERL[@]}"
|
LintCodebase "PERL" "perl" "perl -Mstrict -cw" ".*\.\(pl\)\$" "${FILE_ARRAY_PERL[@]}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
################
|
||||||
|
# PHP LINTING #
|
||||||
|
################
|
||||||
|
if [ "$VALIDATE_PHP" == "true" ]; then
|
||||||
|
#######################
|
||||||
|
# Lint the PHP files #
|
||||||
|
#######################
|
||||||
|
# LintCodebase "FILE_TYPE" "LINTER_NAME" "LINTER_CMD" "FILE_TYPES_REGEX" "FILE_ARRAY"
|
||||||
|
LintCodebase "PHP" "php" "php -l" ".*\.\(php\)\$" "${FILE_ARRAY_PHP[@]}"
|
||||||
|
fi
|
||||||
|
|
||||||
################
|
################
|
||||||
# RUBY LINTING #
|
# RUBY LINTING #
|
||||||
################
|
################
|
||||||
|
|
Loading…
Reference in a new issue