mirror of
https://github.com/super-linter/super-linter.git
synced 2024-11-29 04:01:02 -05:00
Powershell Initial Commit
This commit is contained in:
parent
2e94f3c355
commit
d39d5c62ff
4 changed files with 52 additions and 3 deletions
14
.automation/test/powershell/powershell_bad_1.ps1
Normal file
14
.automation/test/powershell/powershell_bad_1.ps1
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
#Plaintext Parameters
|
||||||
|
function BadFunction {
|
||||||
|
param(
|
||||||
|
[String]$Username = 'me',
|
||||||
|
[String]$Password = 'password'
|
||||||
|
)
|
||||||
|
$Username
|
||||||
|
$Password
|
||||||
|
$VariableThatIsNotUsedLater = '5'
|
||||||
|
try {
|
||||||
|
'Empty Catch Block'
|
||||||
|
} catch {}
|
||||||
|
}
|
||||||
|
|
1
.automation/test/powershell/powershell_good_1.ps1
Normal file
1
.automation/test/powershell/powershell_good_1.ps1
Normal file
|
@ -0,0 +1 @@
|
||||||
|
Write-Output "hello world!"
|
18
TEMPLATES/.powershell-psscriptanalyzer.psd1
Normal file
18
TEMPLATES/.powershell-psscriptanalyzer.psd1
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
#Documentation: https://github.com/PowerShell/PSScriptAnalyzer/blob/master/docs/markdown/Invoke-ScriptAnalyzer.md#-settings
|
||||||
|
@{
|
||||||
|
#CustomRulePath='path\to\CustomRuleModule.psm1'
|
||||||
|
#RecurseCustomRulePath='path\of\customrules'
|
||||||
|
#Severity = @(
|
||||||
|
# 'Error'
|
||||||
|
# 'Warning'
|
||||||
|
#)
|
||||||
|
#IncludeDefaultRules=$true
|
||||||
|
#ExcludeRules = @(
|
||||||
|
# 'PSAvoidUsingWriteHost',
|
||||||
|
# 'MyCustomRuleName'
|
||||||
|
#)
|
||||||
|
#IncludeRules = @(
|
||||||
|
# 'PSAvoidUsingWriteHost',
|
||||||
|
# 'MyCustomRuleName'
|
||||||
|
#)
|
||||||
|
}
|
|
@ -48,20 +48,24 @@ GO_LINTER_RULES="$DEFAULT_RULES_LOCATION/$GO_FILE_NAME" # Path to th
|
||||||
# Terraform Vars
|
# Terraform Vars
|
||||||
TERRAFORM_FILE_NAME='.tflint.hcl' # Name of the file
|
TERRAFORM_FILE_NAME='.tflint.hcl' # Name of the file
|
||||||
TERRAFORM_LINTER_RULES="$DEFAULT_RULES_LOCATION/$TERRAFORM_FILE_NAME" # Path to the Terraform lint rules
|
TERRAFORM_LINTER_RULES="$DEFAULT_RULES_LOCATION/$TERRAFORM_FILE_NAME" # Path to the Terraform lint rules
|
||||||
|
# Powershell Vars
|
||||||
|
POWERSHELL_FILE_NAME='.powershell-psccriptanalyzer.psd1' # Name of the file
|
||||||
|
POWERSHELL_LINTER_RULES="$DEFAULT_RULES_LOCATION/$POWERSHELL_FILE_NAME" # Path to the Powershell lint rules
|
||||||
|
|
||||||
|
|
||||||
#######################################
|
#######################################
|
||||||
# Linter array for information prints #
|
# Linter array for information prints #
|
||||||
#######################################
|
#######################################
|
||||||
LINTER_ARRAY=("jsonlint" "yamllint" "xmllint" "markdownlint" "shellcheck"
|
LINTER_ARRAY=("jsonlint" "yamllint" "xmllint" "markdownlint" "shellcheck"
|
||||||
"pylint" "perl" "rubocop" "coffeelint" "eslint" "standard"
|
"pylint" "perl" "rubocop" "coffeelint" "eslint" "standard"
|
||||||
"ansible-lint" "/dockerfilelint/bin/dockerfilelint" "golangci-lint" "tflint")
|
"ansible-lint" "/dockerfilelint/bin/dockerfilelint" "golangci-lint" "tflint" "powershell")
|
||||||
|
|
||||||
#############################
|
#############################
|
||||||
# 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' 'RUBY' 'PYTHON'
|
||||||
'COFFEESCRIPT' 'ANSIBLE' 'JAVASCRIPT_STANDARD' 'JAVASCRIPT_ES'
|
'COFFEESCRIPT' 'ANSIBLE' 'JAVASCRIPT_STANDARD' 'JAVASCRIPT_ES'
|
||||||
'TYPESCRIPT_STANDARD' 'TYPESCRIPT_ES' 'DOCKER' 'GO' 'TERRAFORM')
|
'TYPESCRIPT_STANDARD' 'TYPESCRIPT_ES' 'DOCKER' 'GO' 'TERRAFORM' 'POWERSHELL')
|
||||||
|
|
||||||
###################
|
###################
|
||||||
# GitHub ENV Vars #
|
# GitHub ENV Vars #
|
||||||
|
@ -88,6 +92,7 @@ VALIDATE_TYPESCRIPT_STANDARD="${VALIDATE_TYPESCRIPT_STANDARD}" # Boolean to val
|
||||||
VALIDATE_DOCKER="${VALIDATE_DOCKER}" # Boolean to validate language
|
VALIDATE_DOCKER="${VALIDATE_DOCKER}" # Boolean to validate language
|
||||||
VALIDATE_GO="${VALIDATE_GO}" # Boolean to validate language
|
VALIDATE_GO="${VALIDATE_GO}" # Boolean to validate language
|
||||||
VALIDATE_TERRAFORM="${VALIDATE_TERRAFORM}" # Boolean to validate language
|
VALIDATE_TERRAFORM="${VALIDATE_TERRAFORM}" # Boolean to validate language
|
||||||
|
VALIDATE_POWERSHELL="${VALIDATE_POWERSHELL}" # Boolean to validate language
|
||||||
TEST_CASE_RUN="${TEST_CASE_RUN}" # Boolean to validate only test cases
|
TEST_CASE_RUN="${TEST_CASE_RUN}" # Boolean to validate only test cases
|
||||||
|
|
||||||
##############
|
##############
|
||||||
|
@ -2225,6 +2230,17 @@ if [ "$VALIDATE_DOCKER" == "true" ]; then
|
||||||
LintCodebase "DOCKER" "/dockerfilelint/bin/dockerfilelint" "/dockerfilelint/bin/dockerfilelint" ".*\(Dockerfile\)\$" "${FILE_ARRAY_DOCKER[@]}"
|
LintCodebase "DOCKER" "/dockerfilelint/bin/dockerfilelint" "/dockerfilelint/bin/dockerfilelint" ".*\(Dockerfile\)\$" "${FILE_ARRAY_DOCKER[@]}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
######################
|
||||||
|
# POWERSHELL LINTING #
|
||||||
|
######################
|
||||||
|
if [ "$VALIDATE_POWERSHELL" == "true" ]; then
|
||||||
|
#############################
|
||||||
|
# Lint the powershell files #
|
||||||
|
#############################
|
||||||
|
# LintCodebase "FILE_TYPE" "LINTER_NAME" "LINTER_CMD" "FILE_TYPES_REGEX" "FILE_ARRAY"
|
||||||
|
LintCodebase "POWERSHELL" "pwsh" "pwsh -c 'Invoke-ScriptAnalyzer -Settings $POWERSHELL_LINTER_RULES -Path' " 'ps[md]?1$' "${FILE_ARRAY_POWERSHELL[@]}"
|
||||||
|
fi
|
||||||
|
|
||||||
##########
|
##########
|
||||||
# Footer #
|
# Footer #
|
||||||
##########
|
##########
|
||||||
|
|
Loading…
Reference in a new issue