mirror of
https://github.com/super-linter/super-linter.git
synced 2024-11-22 00:31:07 -05:00
Basic support for PHPCS and Psalm
This commit is contained in:
parent
c9eae4876c
commit
49243625fe
3 changed files with 64 additions and 11 deletions
25
Dockerfile
25
Dockerfile
|
@ -65,8 +65,18 @@ RUN apk add --update --no-cache \
|
||||||
openjdk8-jre \
|
openjdk8-jre \
|
||||||
perl \
|
perl \
|
||||||
php7 \
|
php7 \
|
||||||
|
php7-phar \
|
||||||
|
php7-json \
|
||||||
|
php7-simplexml \
|
||||||
|
php7-xmlwriter \
|
||||||
|
php7-mbstring \
|
||||||
|
php7-tokenizer \
|
||||||
|
php7-ctype \
|
||||||
|
php7-curl \
|
||||||
|
php7-dom \
|
||||||
py3-setuptools \
|
py3-setuptools \
|
||||||
ruby ruby-dev ruby-bundler ruby-rdoc
|
ruby ruby-dev ruby-bundler ruby-rdoc \
|
||||||
|
gnupg
|
||||||
|
|
||||||
########################################
|
########################################
|
||||||
# Copy dependencies files to container #
|
# Copy dependencies files to container #
|
||||||
|
@ -96,6 +106,19 @@ ENV PATH="/node_modules/.bin:${PATH}"
|
||||||
##############################
|
##############################
|
||||||
RUN bundle install
|
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 #
|
# Install Powershell + PSScriptAnalyzer #
|
||||||
#########################################
|
#########################################
|
||||||
|
|
6
dependencies/phive.xml
vendored
Executable file
6
dependencies/phive.xml
vendored
Executable file
|
@ -0,0 +1,6 @@
|
||||||
|
<?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="psalm" version="^3.12" installed="3.12.2" location="/usr/local/bin/psalm" copy="true"/>
|
||||||
|
</phive>
|
|
@ -107,7 +107,7 @@ LINTER_ARRAY=('ansible-lint' 'arm-ttk' 'asl-validator' 'cfn-lint' 'clj-kondo'
|
||||||
LANGUAGE_ARRAY=('ANSIBLE' 'ARM' 'BASH' 'CLOUDFORMATION' 'CLOJURE' 'COFFEESCRIPT'
|
LANGUAGE_ARRAY=('ANSIBLE' 'ARM' 'BASH' 'CLOUDFORMATION' 'CLOJURE' 'COFFEESCRIPT'
|
||||||
'CSS' 'DART' 'DOCKER' 'ENV' 'GO' 'GROOVY' 'HTML' 'JAVASCRIPT_ES'
|
'CSS' 'DART' 'DOCKER' 'ENV' 'GO' 'GROOVY' 'HTML' 'JAVASCRIPT_ES'
|
||||||
'JAVASCRIPT_STANDARD' 'JSON' 'JSX' 'KOTLIN' 'MARKDOWN' 'OPENAPI'
|
'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'
|
'RAKU' 'RUBY' 'STATES' 'TERRAFORM' 'TERRAFORM_TERRASCAN' 'TSX' 'TYPESCRIPT_ES'
|
||||||
'TYPESCRIPT_STANDARD' 'XML' 'YML')
|
'TYPESCRIPT_STANDARD' 'XML' 'YML')
|
||||||
|
|
||||||
|
@ -154,7 +154,9 @@ VALIDATE_KOTLIN="${VALIDATE_KOTLIN}" # Boolean to vali
|
||||||
VALIDATE_MARKDOWN="${VALIDATE_MD:-}" # Boolean to validate language
|
VALIDATE_MARKDOWN="${VALIDATE_MD:-}" # Boolean to validate language
|
||||||
VALIDATE_OPENAPI="${VALIDATE_OPENAPI}" # Boolean to validate language
|
VALIDATE_OPENAPI="${VALIDATE_OPENAPI}" # 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_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_POWERSHELL="${VALIDATE_POWERSHELL}" # Boolean to validate language
|
||||||
VALIDATE_PYTHON="${VALIDATE_PYTHON}" # Boolean to validate language
|
VALIDATE_PYTHON="${VALIDATE_PYTHON}" # Boolean to validate language
|
||||||
VALIDATE_RAKU="${VALIDATE_RAKU}" # 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_MARKDOWN=() # Array of files to check
|
||||||
FILE_ARRAY_OPENAPI=() # Array of files to check
|
FILE_ARRAY_OPENAPI=() # 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_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_POWERSHELL=() # Array of files to check
|
||||||
FILE_ARRAY_PROTOBUF=() # Array of files to check
|
FILE_ARRAY_PROTOBUF=() # Array of files to check
|
||||||
FILE_ARRAY_PYTHON=() # 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
|
export ERRORS_FOUND_OPENAPI # Workaround SC2034
|
||||||
ERRORS_FOUND_PERL=0 # Count of errors found
|
ERRORS_FOUND_PERL=0 # Count of errors found
|
||||||
export ERRORS_FOUND_PERL # Workaround SC2034
|
export ERRORS_FOUND_PERL # Workaround SC2034
|
||||||
ERRORS_FOUND_PHP=0 # Count of errors found
|
ERRORS_FOUND_PHP_BUILTIN=0 # Count of errors found
|
||||||
export ERRORS_FOUND_PHP # Workaround SC2034
|
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
|
ERRORS_FOUND_POWERSHELL=0 # Count of errors found
|
||||||
export ERRORS_FOUND_POWERSHELL # Workaround SC2034
|
export ERRORS_FOUND_POWERSHELL # Workaround SC2034
|
||||||
ERRORS_FOUND_PROTOBUF=0 # Count of errors found
|
ERRORS_FOUND_PROTOBUF=0 # Count of errors found
|
||||||
|
@ -1453,12 +1461,28 @@ fi
|
||||||
################
|
################
|
||||||
# PHP LINTING #
|
# PHP LINTING #
|
||||||
################
|
################
|
||||||
if [ "${VALIDATE_PHP}" == "true" ]; then
|
if [ "${VALIDATE_PHP_BUILTIN}" == "true" ]; then
|
||||||
#######################
|
################################################
|
||||||
# Lint the PHP files #
|
# Lint the PHP files using built-in PHP linter #
|
||||||
#######################
|
################################################
|
||||||
# LintCodebase "FILE_TYPE" "LINTER_NAME" "LINTER_CMD" "FILE_TYPES_REGEX" "FILE_ARRAY"
|
# LintCodebase "FILE_TYPE" "LINTER_NAME" "LINTER_CMD" "FILE_TYPES_REGEX" "FILE_ARRAY"
|
||||||
LintCodebase "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
|
fi
|
||||||
|
|
||||||
######################
|
######################
|
||||||
|
|
Loading…
Reference in a new issue