mirror of
https://github.com/super-linter/super-linter.git
synced 2024-11-10 02:53:36 -05:00
commit
d7f50f426c
14 changed files with 626 additions and 356 deletions
13
.automation/test/groovy/README.md
Normal file
13
.automation/test/groovy/README.md
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
# Groovy Test Cases
|
||||||
|
This folder holds the test cases for **Groovy**.
|
||||||
|
|
||||||
|
## 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.
|
6
.automation/test/groovy/groovy_bad_01.groovy
Normal file
6
.automation/test/groovy/groovy_bad_01.groovy
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
class Example {
|
||||||
|
static void main(String[] args)
|
||||||
|
File file = new File("E:/Example.txt")
|
||||||
|
The file ${file.absolutePath} has ${file.length()} bytes"
|
||||||
|
}
|
||||||
|
}
|
6
.automation/test/groovy/groovy_good_01.groovy
Normal file
6
.automation/test/groovy/groovy_good_01.groovy
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
class Example {
|
||||||
|
static void main(String[] args) {
|
||||||
|
File file = new File("E:/Example.txt")
|
||||||
|
println "The file ${file.absolutePath} has ${file.length()} bytes"
|
||||||
|
}
|
||||||
|
}
|
65
.github/linters/.groovylintrc.json
vendored
Normal file
65
.github/linters/.groovylintrc.json
vendored
Normal file
|
@ -0,0 +1,65 @@
|
||||||
|
{
|
||||||
|
"extends": "recommended",
|
||||||
|
"rules": {
|
||||||
|
"CatchException": {
|
||||||
|
"enabled": false
|
||||||
|
},
|
||||||
|
"CatchThrowable": {
|
||||||
|
"enabled": false
|
||||||
|
},
|
||||||
|
"ClassJavadoc": {
|
||||||
|
"enabled": false
|
||||||
|
},
|
||||||
|
"ClosureAsLastMethodParameter": {
|
||||||
|
"enabled": false
|
||||||
|
},
|
||||||
|
"DuplicateNumberLiteral": {
|
||||||
|
"enabled": false
|
||||||
|
},
|
||||||
|
"DuplicateStringLiteral": {
|
||||||
|
"enabled": false
|
||||||
|
},
|
||||||
|
"FieldTypeRequired": {
|
||||||
|
"enabled": false
|
||||||
|
},
|
||||||
|
"JavaIoPackageAccess": {
|
||||||
|
"enabled": false
|
||||||
|
},
|
||||||
|
"MethodParameterTypeRequired": {
|
||||||
|
"enabled": false
|
||||||
|
},
|
||||||
|
"MethodSize": {
|
||||||
|
"enabled": false
|
||||||
|
},
|
||||||
|
"NoDef": {
|
||||||
|
"enabled": false
|
||||||
|
},
|
||||||
|
"PrintStackTrace": {
|
||||||
|
"enabled": false
|
||||||
|
},
|
||||||
|
"PropertyName": {
|
||||||
|
"enabled": false
|
||||||
|
},
|
||||||
|
"SpaceAroundMapEntryColon": {
|
||||||
|
"enabled": false
|
||||||
|
},
|
||||||
|
"SystemExit": {
|
||||||
|
"enabled": false
|
||||||
|
},
|
||||||
|
"UnnecessaryGetter": {
|
||||||
|
"enabled": false
|
||||||
|
},
|
||||||
|
"UnnecessaryObjectReferences": {
|
||||||
|
"enabled": false
|
||||||
|
},
|
||||||
|
"UnnecessarySetter": {
|
||||||
|
"enabled": false
|
||||||
|
},
|
||||||
|
"VariableName": {
|
||||||
|
"enabled": false
|
||||||
|
},
|
||||||
|
"VariableTypeRequired": {
|
||||||
|
"enabled": false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -61,7 +61,7 @@ RUN apk add --update --no-cache \
|
||||||
libxml2-utils \
|
libxml2-utils \
|
||||||
make \
|
make \
|
||||||
musl-dev \
|
musl-dev \
|
||||||
npm nodejs \
|
npm nodejs-current \
|
||||||
openjdk8-jre \
|
openjdk8-jre \
|
||||||
perl \
|
perl \
|
||||||
php7 \
|
php7 \
|
||||||
|
|
|
@ -54,6 +54,7 @@ Developers on **GitHub** can call the **GitHub Action** to lint their code base
|
||||||
| **EDITORCONFIG** | [editorconfig-checker](https://github.com/editorconfig-checker/editorconfig-checker) |
|
| **EDITORCONFIG** | [editorconfig-checker](https://github.com/editorconfig-checker/editorconfig-checker) |
|
||||||
| **ENV** | [dotenv-linter](https://github.com/dotenv-linter/dotenv-linter) |
|
| **ENV** | [dotenv-linter](https://github.com/dotenv-linter/dotenv-linter) |
|
||||||
| **Golang** | [golangci-lint](https://github.com/golangci/golangci-lint) |
|
| **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) |
|
| **HTMLHint** | [HTMLHint](https://github.com/htmlhint/HTMLHint) |
|
||||||
| **JavaScript** | [eslint](https://eslint.org/) [standard js](https://standardjs.com/) |
|
| **JavaScript** | [eslint](https://eslint.org/) [standard js](https://standardjs.com/) |
|
||||||
| **JSON** | [jsonlint](https://github.com/zaach/jsonlint) |
|
| **JSON** | [jsonlint](https://github.com/zaach/jsonlint) |
|
||||||
|
@ -193,6 +194,7 @@ and won't run anything unexpected.
|
||||||
| **VALIDATE_EDITORCONFIG** | `true` | Flag to enable or disable the linting process with the editorconfig. |
|
| **VALIDATE_EDITORCONFIG** | `true` | Flag to enable or disable the linting process with the editorconfig. |
|
||||||
| **VALIDATE_ENV** | `true` | Flag to enable or disable the linting process of the ENV language. |
|
| **VALIDATE_ENV** | `true` | Flag to enable or disable the linting process of the ENV language. |
|
||||||
| **VALIDATE_GO** | `true` | Flag to enable or disable the linting process of the Golang language. |
|
| **VALIDATE_GO** | `true` | Flag to enable or disable the linting process of the Golang language. |
|
||||||
|
| **VALIDATE_GROOVY** | `true` | Flag to enable or disable the linting process of the language. |
|
||||||
| **VALIDATE_HTML** | `true` | Flag to enable or disable the linting process of the HTML language. |
|
| **VALIDATE_HTML** | `true` | Flag to enable or disable the linting process of the HTML language. |
|
||||||
| **VALIDATE_JAVASCRIPT_ES** | `true` | Flag to enable or disable the linting process of the Javascript language. (Utilizing: eslint) |
|
| **VALIDATE_JAVASCRIPT_ES** | `true` | Flag to enable or disable the linting process of the Javascript language. (Utilizing: eslint) |
|
||||||
| **VALIDATE_JAVASCRIPT_STANDARD** | `true` | Flag to enable or disable the linting process of the Javascript language. (Utilizing: standard) |
|
| **VALIDATE_JAVASCRIPT_STANDARD** | `true` | Flag to enable or disable the linting process of the Javascript language. (Utilizing: standard) |
|
||||||
|
|
65
TEMPLATES/.groovylintrc.json
Normal file
65
TEMPLATES/.groovylintrc.json
Normal file
|
@ -0,0 +1,65 @@
|
||||||
|
{
|
||||||
|
"extends": "recommended",
|
||||||
|
"rules": {
|
||||||
|
"CatchException": {
|
||||||
|
"enabled": false
|
||||||
|
},
|
||||||
|
"CatchThrowable": {
|
||||||
|
"enabled": false
|
||||||
|
},
|
||||||
|
"ClassJavadoc": {
|
||||||
|
"enabled": false
|
||||||
|
},
|
||||||
|
"ClosureAsLastMethodParameter": {
|
||||||
|
"enabled": false
|
||||||
|
},
|
||||||
|
"DuplicateNumberLiteral": {
|
||||||
|
"enabled": false
|
||||||
|
},
|
||||||
|
"DuplicateStringLiteral": {
|
||||||
|
"enabled": false
|
||||||
|
},
|
||||||
|
"FieldTypeRequired": {
|
||||||
|
"enabled": false
|
||||||
|
},
|
||||||
|
"JavaIoPackageAccess": {
|
||||||
|
"enabled": false
|
||||||
|
},
|
||||||
|
"MethodParameterTypeRequired": {
|
||||||
|
"enabled": false
|
||||||
|
},
|
||||||
|
"MethodSize": {
|
||||||
|
"enabled": false
|
||||||
|
},
|
||||||
|
"NoDef": {
|
||||||
|
"enabled": false
|
||||||
|
},
|
||||||
|
"PrintStackTrace": {
|
||||||
|
"enabled": false
|
||||||
|
},
|
||||||
|
"PropertyName": {
|
||||||
|
"enabled": false
|
||||||
|
},
|
||||||
|
"SpaceAroundMapEntryColon": {
|
||||||
|
"enabled": false
|
||||||
|
},
|
||||||
|
"SystemExit": {
|
||||||
|
"enabled": false
|
||||||
|
},
|
||||||
|
"UnnecessaryGetter": {
|
||||||
|
"enabled": false
|
||||||
|
},
|
||||||
|
"UnnecessaryObjectReferences": {
|
||||||
|
"enabled": false
|
||||||
|
},
|
||||||
|
"UnnecessarySetter": {
|
||||||
|
"enabled": false
|
||||||
|
},
|
||||||
|
"VariableName": {
|
||||||
|
"enabled": false
|
||||||
|
},
|
||||||
|
"VariableTypeRequired": {
|
||||||
|
"enabled": false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
2
dependencies/package.json
vendored
2
dependencies/package.json
vendored
|
@ -18,7 +18,9 @@
|
||||||
"standard": "^14.3.4",
|
"standard": "^14.3.4",
|
||||||
"stylelint": "^13.6.1",
|
"stylelint": "^13.6.1",
|
||||||
"stylelint-config-standard": "^20.0.0",
|
"stylelint-config-standard": "^20.0.0",
|
||||||
|
"npm-groovy-lint": "^5.5.0",
|
||||||
"typescript": "^3.9.7",
|
"typescript": "^3.9.7",
|
||||||
"asl-validator": "^1.7.0"
|
"asl-validator": "^1.7.0"
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,6 +32,7 @@ For some linters it is also possible to override rules on a case by case level w
|
||||||
- [Typescript Eslint](#typescript-eslint)
|
- [Typescript Eslint](#typescript-eslint)
|
||||||
- [Typescript Standard](#typescript-standard)
|
- [Typescript Standard](#typescript-standard)
|
||||||
- [Golang](#golang)
|
- [Golang](#golang)
|
||||||
|
- [Groovy](#groovy)
|
||||||
- [Dockerfile](#dockerfile)
|
- [Dockerfile](#dockerfile)
|
||||||
- [Terraform](#terraform)
|
- [Terraform](#terraform)
|
||||||
- [CSS](#css)
|
- [CSS](#css)
|
||||||
|
@ -678,6 +679,44 @@ alert("foo");
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
|
## Groovy
|
||||||
|
- [npm-groovy-lint](https://github.com/nvuillam/npm-groovy-lint)
|
||||||
|
|
||||||
|
### groovy-lint standard Config file
|
||||||
|
- `.github/linters/.groovylintrc.json`
|
||||||
|
- You can pass multiple rules and overwrite default rules
|
||||||
|
- File should be located at: `.github/linters/.groovylintrc.json`
|
||||||
|
|
||||||
|
### groovy-lint disable single line
|
||||||
|
```groovy
|
||||||
|
def variable = 1; // groovylint-disable-line
|
||||||
|
|
||||||
|
// groovylint-disable-next-line
|
||||||
|
def variable = 1;
|
||||||
|
|
||||||
|
/* groovylint-disable-next-line */
|
||||||
|
def variable = 1;
|
||||||
|
|
||||||
|
def variable = 1; /* groovylint-disable-line */
|
||||||
|
```
|
||||||
|
|
||||||
|
### groovy-lint disable code block
|
||||||
|
```groovy
|
||||||
|
/* groovylint-disable */
|
||||||
|
|
||||||
|
def variable = 1;
|
||||||
|
|
||||||
|
/* groovylint-enable */
|
||||||
|
```
|
||||||
|
|
||||||
|
### groovy-lint disable entire file
|
||||||
|
- At the top line of the file add the line:
|
||||||
|
```groovy
|
||||||
|
/* groovylint-disable */
|
||||||
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
## Dockerfile
|
## Dockerfile
|
||||||
|
|
||||||
- [dockerfilelint](https://github.com/replicatedhq/dockerfilelint.git)
|
- [dockerfilelint](https://github.com/replicatedhq/dockerfilelint.git)
|
||||||
|
|
|
@ -440,6 +440,15 @@ function BuildFileList() {
|
||||||
# Set the READ_ONLY_CHANGE_FLAG since this could be exec #
|
# Set the READ_ONLY_CHANGE_FLAG since this could be exec #
|
||||||
##########################################################
|
##########################################################
|
||||||
READ_ONLY_CHANGE_FLAG=1
|
READ_ONLY_CHANGE_FLAG=1
|
||||||
|
elif [ "$FILE_TYPE" == "groovy" ] || [ "$FILE_TYPE" == "jenkinsfile" ] || [ "$FILE_TYPE" == "gradle" ]; then
|
||||||
|
################################
|
||||||
|
# Append the file to the array #
|
||||||
|
################################
|
||||||
|
FILE_ARRAY_GROOVY+=("$FILE")
|
||||||
|
##########################################################
|
||||||
|
# Set the READ_ONLY_CHANGE_FLAG since this could be exec #
|
||||||
|
##########################################################
|
||||||
|
READ_ONLY_CHANGE_FLAG=1
|
||||||
else
|
else
|
||||||
##############################################
|
##############################################
|
||||||
# Use file to see if we can parse what it is #
|
# Use file to see if we can parse what it is #
|
||||||
|
|
722
lib/linter.sh
722
lib/linter.sh
|
@ -50,6 +50,9 @@ DOCKER_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${DOCKER_FILE_NAME}"
|
||||||
# Golang Vars
|
# Golang Vars
|
||||||
GO_FILE_NAME='.golangci.yml' # Name of the file
|
GO_FILE_NAME='.golangci.yml' # Name of the file
|
||||||
GO_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${GO_FILE_NAME}" # Path to the Go lint rules
|
GO_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${GO_FILE_NAME}" # Path to the Go lint rules
|
||||||
|
# Groovy Vars
|
||||||
|
GROOVY_FILE_NAME='.groovylintrc.json' # Name of the file
|
||||||
|
GROOVY_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${GROOVY_FILE_NAME}" # Path to the Groovy lint rules
|
||||||
# HTML Vars
|
# HTML Vars
|
||||||
HTML_FILE_NAME='.htmlhintrc' # Name of the file
|
HTML_FILE_NAME='.htmlhintrc' # Name of the file
|
||||||
HTML_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${HTML_FILE_NAME}" # Path to the CSS lint rules
|
HTML_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${HTML_FILE_NAME}" # Path to the CSS lint rules
|
||||||
|
@ -93,15 +96,16 @@ YAML_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${YAML_FILE_NAME}"
|
||||||
#######################################
|
#######################################
|
||||||
LINTER_ARRAY=('ansible-lint' 'arm-ttk' 'asl-validator' 'cfn-lint' 'clj-kondo'
|
LINTER_ARRAY=('ansible-lint' 'arm-ttk' 'asl-validator' 'cfn-lint' 'clj-kondo'
|
||||||
'coffeelint' 'dart' 'dockerfilelint' 'dotenv-linter' 'eslint' 'golangci-lint'
|
'coffeelint' 'dart' 'dockerfilelint' 'dotenv-linter' 'eslint' 'golangci-lint'
|
||||||
'htmlhint' 'jsonlint' 'ktlint' 'markdownlint' 'perl' 'protolint' 'pwsh'
|
'htmlhint' 'jsonlint' 'ktlint' 'markdownlint' 'npm-groovy-lint' 'perl'
|
||||||
'pylint' 'raku' 'rubocop' 'shellcheck' 'spectral' 'standard' 'stylelint'
|
'protolint' 'pwsh' 'pylint' 'raku' 'rubocop' 'shellcheck' 'spectral'
|
||||||
'tflint' 'xmllint' 'yamllint')
|
'standard' 'stylelint' 'tflint' 'xmllint' 'yamllint')
|
||||||
|
|
||||||
|
|
||||||
#############################
|
#############################
|
||||||
# Language array for prints #
|
# Language array for prints #
|
||||||
#############################
|
#############################
|
||||||
LANGUAGE_ARRAY=('ANSIBLE' 'ARM' 'BASH' 'CLOUDFORMATION' 'CLOJURE' 'COFFEESCRIPT'
|
LANGUAGE_ARRAY=('ANSIBLE' 'ARM' 'BASH' 'CLOUDFORMATION' 'CLOJURE' 'COFFEESCRIPT'
|
||||||
'CSS' 'DART' 'DOCKER' 'ENV' 'GO' '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' 'POWERSHELL' 'PROTOBUF' 'PYTHON'
|
||||||
'RAKU' 'RUBY' 'STATES' 'TERRAFORM' 'TSX' 'TYPESCRIPT_ES'
|
'RAKU' 'RUBY' 'STATES' 'TERRAFORM' 'TSX' 'TYPESCRIPT_ES'
|
||||||
|
@ -112,6 +116,7 @@ LANGUAGE_ARRAY=('ANSIBLE' 'ARM' 'BASH' 'CLOUDFORMATION' 'CLOJURE' 'COFFEESCRIPT'
|
||||||
############################################
|
############################################
|
||||||
LINTED_LANGUAGES_ARRAY=() # Will be filled at run time with all languages that were linted
|
LINTED_LANGUAGES_ARRAY=() # Will be filled at run time with all languages that were linted
|
||||||
|
|
||||||
|
|
||||||
###################
|
###################
|
||||||
# GitHub ENV Vars #
|
# GitHub ENV Vars #
|
||||||
###################
|
###################
|
||||||
|
@ -139,6 +144,7 @@ VALIDATE_DOCKER="${VALIDATE_DOCKER}" # Boolean to vali
|
||||||
VALIDATE_EDITORCONFIG="${VALIDATE_EDITORCONFIG}" # Boolean to validate files with editorconfig
|
VALIDATE_EDITORCONFIG="${VALIDATE_EDITORCONFIG}" # Boolean to validate files with editorconfig
|
||||||
VALIDATE_ENV="${VALIDATE_ENV}" # Boolean to validate language
|
VALIDATE_ENV="${VALIDATE_ENV}" # Boolean to validate language
|
||||||
VALIDATE_GO="${VALIDATE_GO}" # Boolean to validate language
|
VALIDATE_GO="${VALIDATE_GO}" # Boolean to validate language
|
||||||
|
VALIDATE_GROOVY="${VALIDATE_GROOVY}" # Boolean to validate language
|
||||||
VALIDATE_HTML="${VALIDATE_HTML}" # Boolean to validate language
|
VALIDATE_HTML="${VALIDATE_HTML}" # Boolean to validate language
|
||||||
VALIDATE_JAVASCRIPT_ES="${VALIDATE_JAVASCRIPT_ES}" # Boolean to validate language
|
VALIDATE_JAVASCRIPT_ES="${VALIDATE_JAVASCRIPT_ES}" # Boolean to validate language
|
||||||
VALIDATE_JAVASCRIPT_STANDARD="${VALIDATE_JAVASCRIPT_STANDARD}" # Boolean to validate language
|
VALIDATE_JAVASCRIPT_STANDARD="${VALIDATE_JAVASCRIPT_STANDARD}" # Boolean to validate language
|
||||||
|
@ -213,6 +219,7 @@ FILE_ARRAY_DART=() # Array of files to check
|
||||||
FILE_ARRAY_DOCKER=() # Array of files to check
|
FILE_ARRAY_DOCKER=() # Array of files to check
|
||||||
FILE_ARRAY_ENV=() # Array of files to check
|
FILE_ARRAY_ENV=() # Array of files to check
|
||||||
FILE_ARRAY_GO=() # Array of files to check
|
FILE_ARRAY_GO=() # Array of files to check
|
||||||
|
FILE_ARRAY_GROOVY=() # Array of files to check
|
||||||
FILE_ARRAY_HTML=() # Array of files to check
|
FILE_ARRAY_HTML=() # Array of files to check
|
||||||
FILE_ARRAY_JAVASCRIPT_ES=() # Array of files to check
|
FILE_ARRAY_JAVASCRIPT_ES=() # Array of files to check
|
||||||
FILE_ARRAY_JAVASCRIPT_STANDARD=() # Array of files to check
|
FILE_ARRAY_JAVASCRIPT_STANDARD=() # Array of files to check
|
||||||
|
@ -261,6 +268,8 @@ ERRORS_FOUND_ENV=0 # Count of errors found
|
||||||
export ERRORS_FOUND_ENV # Workaround SC2034
|
export ERRORS_FOUND_ENV # Workaround SC2034
|
||||||
ERRORS_FOUND_GO=0 # Count of errors found
|
ERRORS_FOUND_GO=0 # Count of errors found
|
||||||
export ERRORS_FOUND_GO # Workaround SC2034
|
export ERRORS_FOUND_GO # Workaround SC2034
|
||||||
|
ERRORS_FOUND_GROOVY=0 # Count of errors found
|
||||||
|
export ERRORS_FOUND_GROOVY # Workaround SC2034
|
||||||
ERRORS_FOUND_HTML=0 # Count of errors found
|
ERRORS_FOUND_HTML=0 # Count of errors found
|
||||||
export ERRORS_FOUND_HTML # Workaround SC2034
|
export ERRORS_FOUND_HTML # Workaround SC2034
|
||||||
ERRORS_FOUND_JAVASCRIPT_STANDARD=0 # Count of errors found
|
ERRORS_FOUND_JAVASCRIPT_STANDARD=0 # Count of errors found
|
||||||
|
@ -761,7 +770,7 @@ GetGitHubVars() {
|
||||||
############################
|
############################
|
||||||
# Validate we have a value #
|
# Validate we have a value #
|
||||||
############################
|
############################
|
||||||
if [ -z "${GITHUB_TOKEN}" ]; then
|
if [ -z "${GITHUB_TOKEN}" ] && [[ ${RUN_LOCAL} == "false" ]]; then
|
||||||
echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Failed to get [GITHUB_TOKEN]!${NC}"
|
echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Failed to get [GITHUB_TOKEN]!${NC}"
|
||||||
echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[${GITHUB_TOKEN}]${NC}"
|
echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[${GITHUB_TOKEN}]${NC}"
|
||||||
echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Please set a [GITHUB_TOKEN] from the main workflow environment to take advantage of multiple status reports!${NC}"
|
echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Please set a [GITHUB_TOKEN] from the main workflow environment to take advantage of multiple status reports!${NC}"
|
||||||
|
@ -1046,40 +1055,42 @@ GetValidationInfo
|
||||||
########################
|
########################
|
||||||
# Get the linter rules #
|
# Get the linter rules #
|
||||||
########################
|
########################
|
||||||
# Get YML rules
|
# Get Ansible rules
|
||||||
GetLinterRules "YAML"
|
GetLinterRules "ANSIBLE"
|
||||||
|
# Get ARM rules
|
||||||
|
GetLinterRules "ARM"
|
||||||
|
# Get CLOUDFORMATION rules
|
||||||
|
GetLinterRules "CLOUDFORMATION"
|
||||||
|
# Get Coffeescript rules
|
||||||
|
GetLinterRules "COFFEESCRIPT"
|
||||||
|
# Get CSS rules
|
||||||
|
GetLinterRules "CSS"
|
||||||
|
# Get DART rules
|
||||||
|
GetLinterRules "DART"
|
||||||
|
# Get Docker rules
|
||||||
|
GetLinterRules "DOCKER"
|
||||||
|
# Get Golang rules
|
||||||
|
GetLinterRules "GO"
|
||||||
|
# Get Groovy rules
|
||||||
|
GetLinterRules "GROOVY"
|
||||||
|
# Get HTML rules
|
||||||
|
GetLinterRules "HTML"
|
||||||
|
# Get JavaScript rules
|
||||||
|
GetLinterRules "JAVASCRIPT"
|
||||||
# Get Markdown rules
|
# Get Markdown rules
|
||||||
GetLinterRules "MARKDOWN"
|
GetLinterRules "MARKDOWN"
|
||||||
|
# Get PowerShell rules
|
||||||
|
GetLinterRules "POWERSHELL"
|
||||||
# Get Python rules
|
# Get Python rules
|
||||||
GetLinterRules "PYTHON"
|
GetLinterRules "PYTHON"
|
||||||
# Get Ruby rules
|
# Get Ruby rules
|
||||||
GetLinterRules "RUBY"
|
GetLinterRules "RUBY"
|
||||||
# Get Coffeescript rules
|
|
||||||
GetLinterRules "COFFEESCRIPT"
|
|
||||||
# Get Ansible rules
|
|
||||||
GetLinterRules "ANSIBLE"
|
|
||||||
# Get JavaScript rules
|
|
||||||
GetLinterRules "JAVASCRIPT"
|
|
||||||
# Get TypeScript rules
|
|
||||||
GetLinterRules "TYPESCRIPT"
|
|
||||||
# Get Golang rules
|
|
||||||
GetLinterRules "GO"
|
|
||||||
# Get Docker rules
|
|
||||||
GetLinterRules "DOCKER"
|
|
||||||
# Get Terraform rules
|
# Get Terraform rules
|
||||||
GetLinterRules "TERRAFORM"
|
GetLinterRules "TERRAFORM"
|
||||||
# Get PowerShell rules
|
# Get TypeScript rules
|
||||||
GetLinterRules "POWERSHELL"
|
GetLinterRules "TYPESCRIPT"
|
||||||
# Get ARM rules
|
# Get YML rules
|
||||||
GetLinterRules "ARM"
|
GetLinterRules "YAML"
|
||||||
# Get CSS rules
|
|
||||||
GetLinterRules "CSS"
|
|
||||||
# Get CLOUDFORMATION rules
|
|
||||||
GetLinterRules "CLOUDFORMATION"
|
|
||||||
# Get DART rules
|
|
||||||
GetLinterRules "DART"
|
|
||||||
# Get HTML rules
|
|
||||||
GetLinterRules "HTML"
|
|
||||||
|
|
||||||
#################################
|
#################################
|
||||||
# Check if were in verbose mode #
|
# Check if were in verbose mode #
|
||||||
|
@ -1118,48 +1129,48 @@ if [ "${VALIDATE_ALL_CODEBASE}" == "false" ]; then
|
||||||
BuildFileList
|
BuildFileList
|
||||||
fi
|
fi
|
||||||
|
|
||||||
###############
|
###################
|
||||||
# YML LINTING #
|
# ANSIBLE LINTING #
|
||||||
###############
|
###################
|
||||||
if [ "${VALIDATE_YAML}" == "true" ]; then
|
if [ "${VALIDATE_ANSIBLE}" == "true" ]; then
|
||||||
######################
|
##########################
|
||||||
# Lint the Yml Files #
|
# Lint the Ansible files #
|
||||||
######################
|
##########################
|
||||||
# LintCodebase "FILE_TYPE" "LINTER_NAME" "LINTER_CMD" "FILE_TYPES_REGEX" "FILE_ARRAY"
|
# Due to the nature of how we want to validate Ansible, we cannot use the
|
||||||
LintCodebase "YML" "yamllint" "yamllint -c ${YAML_LINTER_RULES}" ".*\.\(yml\|yaml\)\$" "${FILE_ARRAY_YML[@]}"
|
# standard loop, since it looks for an ansible folder, excludes certain
|
||||||
|
# files, and looks for additional changes, it should be an outlier
|
||||||
|
LintAnsibleFiles "${ANSIBLE_LINTER_RULES}" # Passing rules but not needed, dont want to exclude unused var
|
||||||
fi
|
fi
|
||||||
|
|
||||||
################
|
########################
|
||||||
# JSON LINTING #
|
# ARM Template LINTING #
|
||||||
################
|
########################
|
||||||
if [ "${VALIDATE_JSON}" == "true" ]; then
|
if [ "${VALIDATE_ARM}" == "true" ]; then
|
||||||
#######################
|
# If we are validating all codebase we need to build file list because not every json file is an ARM file
|
||||||
# Lint the json files #
|
if [ "${VALIDATE_ALL_CODEBASE}" == "true" ]; then
|
||||||
#######################
|
###############################################################################
|
||||||
# LintCodebase "FILE_TYPE" "LINTER_NAME" "LINTER_CMD" "FILE_TYPES_REGEX" "FILE_ARRAY"
|
# Set the file seperator to newline to allow for grabbing objects with spaces #
|
||||||
LintCodebase "JSON" "jsonlint" "jsonlint" ".*\.\(json\)\$" "${FILE_ARRAY_JSON[@]}"
|
###############################################################################
|
||||||
fi
|
IFS=$'\n'
|
||||||
|
|
||||||
###############
|
mapfile -t LIST_FILES < <(find "${GITHUB_WORKSPACE}" -type f -regex ".*\.\(json\)\$" 2>&1)
|
||||||
# XML LINTING #
|
for FILE in "${LIST_FILES[@]}"; do
|
||||||
###############
|
if DetectARMFile "${FILE}"; then
|
||||||
if [ "${VALIDATE_XML}" == "true" ]; then
|
FILE_ARRAY_ARM+=("${FILE}")
|
||||||
######################
|
fi
|
||||||
# Lint the XML Files #
|
done
|
||||||
######################
|
|
||||||
# LintCodebase "FILE_TYPE" "LINTER_NAME" "LINTER_CMD" "FILE_TYPES_REGEX" "FILE_ARRAY"
|
|
||||||
LintCodebase "XML" "xmllint" "xmllint" ".*\.\(xml\)\$" "${FILE_ARRAY_XML[@]}"
|
|
||||||
fi
|
|
||||||
|
|
||||||
####################
|
|
||||||
# MARKDOWN LINTING #
|
|
||||||
####################
|
|
||||||
if [ "${VALIDATE_MARKDOWN}" == "true" ]; then
|
|
||||||
###########################
|
###########################
|
||||||
# Lint the Markdown Files #
|
# Set IFS back to default #
|
||||||
###########################
|
###########################
|
||||||
|
IFS="${DEFAULT_IFS}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
###############################
|
||||||
|
# Lint the ARM Template files #
|
||||||
|
###############################
|
||||||
# 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 "MARKDOWN" "markdownlint" "markdownlint -c ${MARKDOWN_LINTER_RULES}" ".*\.\(md\)\$" "${FILE_ARRAY_MARKDOWN[@]}"
|
LintCodebase "ARM" "arm-ttk" "Import-Module ${ARM_TTK_PSD1} ; \${config} = \$(Import-PowerShellDataFile -Path ${ARM_LINTER_RULES}) ; Test-AzTemplate @config -TemplatePath" "disabledfileext" "${FILE_ARRAY_ARM[@]}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
################
|
################
|
||||||
|
@ -1173,17 +1184,6 @@ if [ "${VALIDATE_BASH}" == "true" ]; then
|
||||||
LintCodebase "BASH" "shellcheck" "shellcheck --color" ".*\.\(sh\|bash\|dash\|ksh\)\$" "${FILE_ARRAY_BASH[@]}"
|
LintCodebase "BASH" "shellcheck" "shellcheck --color" ".*\.\(sh\|bash\|dash\|ksh\)\$" "${FILE_ARRAY_BASH[@]}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
##################
|
|
||||||
# PYTHON LINTING #
|
|
||||||
##################
|
|
||||||
if [ "${VALIDATE_PYTHON}" == "true" ]; then
|
|
||||||
#########################
|
|
||||||
# Lint the python files #
|
|
||||||
#########################
|
|
||||||
# LintCodebase "FILE_TYPE" "LINTER_NAME" "LINTER_CMD" "FILE_TYPES_REGEX" "FILE_ARRAY"
|
|
||||||
LintCodebase "PYTHON" "pylint" "pylint --rcfile ${PYTHON_LINTER_RULES}" ".*\.\(py\)\$" "${FILE_ARRAY_PYTHON[@]}"
|
|
||||||
fi
|
|
||||||
|
|
||||||
##########################
|
##########################
|
||||||
# CLOUDFORMATION LINTING #
|
# CLOUDFORMATION LINTING #
|
||||||
##########################
|
##########################
|
||||||
|
@ -1215,52 +1215,18 @@ if [ "${VALIDATE_CLOUDFORMATION}" == "true" ]; then
|
||||||
LintCodebase "CLOUDFORMATION" "cfn-lint" "cfn-lint --config-file ${CLOUDFORMATION_LINTER_RULES}" "disabledfileext" "${FILE_ARRAY_CLOUDFORMATION[@]}"
|
LintCodebase "CLOUDFORMATION" "cfn-lint" "cfn-lint --config-file ${CLOUDFORMATION_LINTER_RULES}" "disabledfileext" "${FILE_ARRAY_CLOUDFORMATION[@]}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
################
|
###################
|
||||||
# PERL LINTING #
|
# CLOJURE LINTING #
|
||||||
################
|
###################
|
||||||
if [ "${VALIDATE_PERL}" == "true" ]; then
|
if [ "${VALIDATE_CLOJURE}" == "true" ]; then
|
||||||
#######################
|
#################################
|
||||||
# Lint the perl files #
|
# Get Clojure standard rules #
|
||||||
#######################
|
#################################
|
||||||
# LintCodebase "FILE_TYPE" "LINTER_NAME" "LINTER_CMD" "FILE_TYPES_REGEX" "FILE_ARRAY"
|
GetStandardRules "clj-kondo"
|
||||||
LintCodebase "PERL" "perl" "perl -Mstrict -cw" ".*\.\(pl\)\$" "${FILE_ARRAY_PERL[@]}"
|
#########################
|
||||||
fi
|
# Lint the Clojure files #
|
||||||
|
#########################
|
||||||
################
|
LintCodebase "CLOJURE" "clj-kondo" "clj-kondo --config ${CLOJURE_LINTER_RULES} --lint" ".*\.\(clj\|cljs\|cljc\|edn\)\$" "${FILE_ARRAY_CLOJURE[@]}"
|
||||||
# RAKU LINTING #
|
|
||||||
################
|
|
||||||
if [ "${VALIDATE_RAKU}" == "true" ]; then
|
|
||||||
#######################
|
|
||||||
# Lint the raku files #
|
|
||||||
#######################
|
|
||||||
echo "${GITHUB_WORKSPACE}/META6.json"
|
|
||||||
if [ -e "${GITHUB_WORKSPACE}/META6.json" ]; then
|
|
||||||
cd "${GITHUB_WORKSPACE}" && zef install --deps-only --/test .
|
|
||||||
fi
|
|
||||||
# LintCodebase "FILE_TYPE" "LINTER_NAME" "LINTER_CMD" "FILE_TYPES_REGEX" "FILE_ARRAY"
|
|
||||||
LintCodebase "RAKU" "raku" "raku -I ${GITHUB_WORKSPACE}/lib -c" ".*\.\(raku\|rakumod\|rakutest\|pm6\|pl6\|p6\)\$" "${FILE_ARRAY_RAKU[@]}"
|
|
||||||
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 #
|
|
||||||
################
|
|
||||||
if [ "${VALIDATE_RUBY}" == "true" ]; then
|
|
||||||
#######################
|
|
||||||
# Lint the ruby files #
|
|
||||||
#######################
|
|
||||||
# LintCodebase "FILE_TYPE" "LINTER_NAME" "LINTER_CMD" "FILE_TYPES_REGEX" "FILE_ARRAY"
|
|
||||||
LintCodebase "RUBY" "rubocop" "rubocop -c ${RUBY_LINTER_RULES} --force-exclusion" ".*\.\(rb\)\$" "${FILE_ARRAY_RUBY[@]}"
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
########################
|
########################
|
||||||
|
@ -1274,6 +1240,65 @@ if [ "${VALIDATE_COFFEE}" == "true" ]; then
|
||||||
LintCodebase "COFFEESCRIPT" "coffeelint" "coffeelint -f ${COFFEESCRIPT_LINTER_RULES}" ".*\.\(coffee\)\$" "${FILE_ARRAY_COFFEESCRIPT[@]}"
|
LintCodebase "COFFEESCRIPT" "coffeelint" "coffeelint -f ${COFFEESCRIPT_LINTER_RULES}" ".*\.\(coffee\)\$" "${FILE_ARRAY_COFFEESCRIPT[@]}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
###############
|
||||||
|
# CSS LINTING #
|
||||||
|
###############
|
||||||
|
if [ "${VALIDATE_CSS}" == "true" ]; then
|
||||||
|
#################################
|
||||||
|
# Get CSS standard rules #
|
||||||
|
#################################
|
||||||
|
GetStandardRules "stylelint"
|
||||||
|
#############################
|
||||||
|
# Lint the CSS files #
|
||||||
|
#############################
|
||||||
|
LintCodebase "CSS" "stylelint" "stylelint --config ${CSS_LINTER_RULES}" ".*\.\(css\)\$" "${FILE_ARRAY_CSS[@]}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
################
|
||||||
|
# DART LINTING #
|
||||||
|
################
|
||||||
|
if [ "${VALIDATE_DART}" == "true" ]; then
|
||||||
|
#######################
|
||||||
|
# Lint the Dart files #
|
||||||
|
#######################
|
||||||
|
# LintCodebase "FILE_TYPE" "LINTER_NAME" "LINTER_CMD" "FILE_TYPES_REGEX" "FILE_ARRAY"
|
||||||
|
LintCodebase "DART" "dart" "dartanalyzer --fatal-infos --fatal-warnings --options ${DART_LINTER_RULES}" ".*\.\(dart\)\$" "${FILE_ARRAY_DART[@]}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
##################
|
||||||
|
# DOCKER LINTING #
|
||||||
|
##################
|
||||||
|
if [ "${VALIDATE_DOCKER}" == "true" ]; then
|
||||||
|
#########################
|
||||||
|
# Lint the docker files #
|
||||||
|
#########################
|
||||||
|
# LintCodebase "FILE_TYPE" "LINTER_NAME" "LINTER_CMD" "FILE_TYPES_REGEX" "FILE_ARRAY"
|
||||||
|
# NOTE: dockerfilelint's "-c" option expects the folder *containing* the DOCKER_LINTER_RULES file
|
||||||
|
LintCodebase "DOCKER" "dockerfilelint" "dockerfilelint -c $(dirname ${DOCKER_LINTER_RULES})" ".*\(Dockerfile\)\$" "${FILE_ARRAY_DOCKER[@]}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
########################
|
||||||
|
# EDITORCONFIG LINTING #
|
||||||
|
########################
|
||||||
|
if [ "${VALIDATE_EDITORCONFIG}" == "true" ]; then
|
||||||
|
####################################
|
||||||
|
# Lint the files with editorconfig #
|
||||||
|
####################################
|
||||||
|
# LintCodebase "FILE_TYPE" "LINTER_NAME" "LINTER_CMD" "FILE_TYPES_REGEX" "FILE_ARRAY"
|
||||||
|
LintCodebase "EDITORCONFIG" "editorconfig-checker" "editorconfig-checker" "^.*$" "${FILE_ARRAY_ENV[@]}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
###############
|
||||||
|
# ENV LINTING #
|
||||||
|
###############
|
||||||
|
if [ "${VALIDATE_ENV}" == "true" ]; then
|
||||||
|
#######################
|
||||||
|
# Lint the env files #
|
||||||
|
#######################
|
||||||
|
# LintCodebase "FILE_TYPE" "LINTER_NAME" "LINTER_CMD" "FILE_TYPES_REGEX" "FILE_ARRAY"
|
||||||
|
LintCodebase "ENV" "dotenv-linter" "dotenv-linter" ".*\.\(env\).*\$" "${FILE_ARRAY_ENV[@]}"
|
||||||
|
fi
|
||||||
|
|
||||||
##################
|
##################
|
||||||
# GOLANG LINTING #
|
# GOLANG LINTING #
|
||||||
##################
|
##################
|
||||||
|
@ -1285,28 +1310,29 @@ if [ "${VALIDATE_GO}" == "true" ]; then
|
||||||
LintCodebase "GO" "golangci-lint" "golangci-lint run -c ${GO_LINTER_RULES}" ".*\.\(go\)\$" "${FILE_ARRAY_GO[@]}"
|
LintCodebase "GO" "golangci-lint" "golangci-lint run -c ${GO_LINTER_RULES}" ".*\.\(go\)\$" "${FILE_ARRAY_GO[@]}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#####################
|
##################
|
||||||
# TERRAFORM LINTING #
|
# GROOVY LINTING #
|
||||||
#####################
|
##################
|
||||||
if [ "${VALIDATE_TERRAFORM}" == "true" ]; then
|
if [ "$VALIDATE_GROOVY" == "true" ]; then
|
||||||
############################
|
#########################
|
||||||
# Lint the Terraform files #
|
# Lint the groovy files #
|
||||||
############################
|
#########################
|
||||||
# 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 "TERRAFORM" "tflint" "tflint -c ${TERRAFORM_LINTER_RULES}" ".*\.\(tf\)\$" "${FILE_ARRAY_TERRAFORM[@]}"
|
LintCodebase "GROOVY" "npm-groovy-lint" "npm-groovy-lint -c $GROOVY_LINTER_RULES --failon error" ".*\.\(groovy\|jenkinsfile\|gradle\)\$" "${FILE_ARRAY_GROOVY[@]}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
###################
|
################
|
||||||
# ANSIBLE LINTING #
|
# HTML LINTING #
|
||||||
###################
|
################
|
||||||
if [ "${VALIDATE_ANSIBLE}" == "true" ]; then
|
if [ "${VALIDATE_HTML}" == "true" ]; then
|
||||||
##########################
|
###########################
|
||||||
# Lint the Ansible files #
|
# Get HTML standard rules #
|
||||||
##########################
|
###########################
|
||||||
# Due to the nature of how we want to validate Ansible, we cannot use the
|
GetStandardRules "htmlhint"
|
||||||
# standard loop, since it looks for an ansible folder, excludes certain
|
#######################
|
||||||
# files, and looks for additional changes, it should be an outlier
|
# Lint the HTML files #
|
||||||
LintAnsibleFiles "${ANSIBLE_LINTER_RULES}" # Passing rules but not needed, dont want to exclude unused var
|
#######################
|
||||||
|
LintCodebase "HTML" "htmlhint" "htmlhint --config ${HTML_LINTER_RULES}" ".*\.\(html\)\$" "${FILE_ARRAY_HTML[@]}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
######################
|
######################
|
||||||
|
@ -1335,6 +1361,17 @@ if [ "${VALIDATE_JAVASCRIPT_STANDARD}" == "true" ]; then
|
||||||
LintCodebase "JAVASCRIPT_STANDARD" "standard" "standard ${JAVASCRIPT_STANDARD_LINTER_RULES}" ".*\.\(js\)\$" "${FILE_ARRAY_JAVASCRIPT_STANDARD[@]}"
|
LintCodebase "JAVASCRIPT_STANDARD" "standard" "standard ${JAVASCRIPT_STANDARD_LINTER_RULES}" ".*\.\(js\)\$" "${FILE_ARRAY_JAVASCRIPT_STANDARD[@]}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
################
|
||||||
|
# JSON LINTING #
|
||||||
|
################
|
||||||
|
if [ "${VALIDATE_JSON}" == "true" ]; then
|
||||||
|
#######################
|
||||||
|
# Lint the json files #
|
||||||
|
#######################
|
||||||
|
# LintCodebase "FILE_TYPE" "LINTER_NAME" "LINTER_CMD" "FILE_TYPES_REGEX" "FILE_ARRAY"
|
||||||
|
LintCodebase "JSON" "jsonlint" "jsonlint" ".*\.\(json\)\$" "${FILE_ARRAY_JSON[@]}"
|
||||||
|
fi
|
||||||
|
|
||||||
######################
|
######################
|
||||||
# JSX LINTING #
|
# JSX LINTING #
|
||||||
######################
|
######################
|
||||||
|
@ -1346,6 +1383,186 @@ if [ "${VALIDATE_JSX}" == "true" ]; then
|
||||||
LintCodebase "JSX" "eslint" "eslint --no-eslintrc -c ${JAVASCRIPT_LINTER_RULES}" ".*\.\(jsx\)\$" "${FILE_ARRAY_JSX[@]}"
|
LintCodebase "JSX" "eslint" "eslint --no-eslintrc -c ${JAVASCRIPT_LINTER_RULES}" ".*\.\(jsx\)\$" "${FILE_ARRAY_JSX[@]}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
##################
|
||||||
|
# KOTLIN LINTING #
|
||||||
|
##################
|
||||||
|
if [ "${VALIDATE_KOTLIN}" == "true" ]; then
|
||||||
|
#######################
|
||||||
|
# Lint the Kotlin files #
|
||||||
|
#######################
|
||||||
|
# LintCodebase "FILE_TYPE" "LINTER_NAME" "LINTER_CMD" "FILE_TYPES_REGEX" "FILE_ARRAY"
|
||||||
|
LintCodebase "KOTLIN" "ktlint" "ktlint" ".*\.\(kt\|kts\)\$" "${FILE_ARRAY_KOTLIN[@]}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
####################
|
||||||
|
# MARKDOWN LINTING #
|
||||||
|
####################
|
||||||
|
if [ "${VALIDATE_MARKDOWN}" == "true" ]; then
|
||||||
|
###########################
|
||||||
|
# Lint the Markdown Files #
|
||||||
|
###########################
|
||||||
|
# LintCodebase "FILE_TYPE" "LINTER_NAME" "LINTER_CMD" "FILE_TYPES_REGEX" "FILE_ARRAY"
|
||||||
|
LintCodebase "MARKDOWN" "markdownlint" "markdownlint -c ${MARKDOWN_LINTER_RULES}" ".*\.\(md\)\$" "${FILE_ARRAY_MARKDOWN[@]}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
###################
|
||||||
|
# OPENAPI LINTING #
|
||||||
|
###################
|
||||||
|
if [ "${VALIDATE_OPENAPI}" == "true" ]; then
|
||||||
|
# If we are validating all codebase we need to build file list because not every yml/json file is an OpenAPI file
|
||||||
|
if [ "${VALIDATE_ALL_CODEBASE}" == "true" ]; then
|
||||||
|
###############################################################################
|
||||||
|
# Set the file seperator to newline to allow for grabbing objects with spaces #
|
||||||
|
###############################################################################
|
||||||
|
IFS=$'\n'
|
||||||
|
|
||||||
|
mapfile -t LIST_FILES < <(find "${GITHUB_WORKSPACE}" -type f -regex ".*\.\(yml\|yaml\|json\)\$" 2>&1)
|
||||||
|
for FILE in "${LIST_FILES[@]}"; do
|
||||||
|
if DetectOpenAPIFile "${FILE}"; then
|
||||||
|
FILE_ARRAY_OPENAPI+=("${FILE}")
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
###########################
|
||||||
|
# Set IFS back to default #
|
||||||
|
###########################
|
||||||
|
IFS="${DEFAULT_IFS}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
##########################
|
||||||
|
# Lint the OpenAPI files #
|
||||||
|
##########################
|
||||||
|
# LintCodebase "FILE_TYPE" "LINTER_NAME" "LINTER_CMD" "FILE_TYPES_REGEX" "FILE_ARRAY"
|
||||||
|
LintCodebase "OPENAPI" "spectral" "spectral lint -r ${OPENAPI_LINTER_RULES}" "disabledfileext" "${FILE_ARRAY_OPENAPI[@]}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
################
|
||||||
|
# PERL LINTING #
|
||||||
|
################
|
||||||
|
if [ "${VALIDATE_PERL}" == "true" ]; then
|
||||||
|
#######################
|
||||||
|
# Lint the perl files #
|
||||||
|
#######################
|
||||||
|
# LintCodebase "FILE_TYPE" "LINTER_NAME" "LINTER_CMD" "FILE_TYPES_REGEX" "FILE_ARRAY"
|
||||||
|
LintCodebase "PERL" "perl" "perl -Mstrict -cw" ".*\.\(pl\)\$" "${FILE_ARRAY_PERL[@]}"
|
||||||
|
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
|
||||||
|
|
||||||
|
######################
|
||||||
|
# POWERSHELL LINTING #
|
||||||
|
######################
|
||||||
|
if [ "${VALIDATE_POWERSHELL}" == "true" ]; then
|
||||||
|
###############################################################
|
||||||
|
# For POWERSHELL, ensure PSScriptAnalyzer module is available #
|
||||||
|
###############################################################
|
||||||
|
ValidatePowershellModules
|
||||||
|
|
||||||
|
#############################
|
||||||
|
# Lint the powershell files #
|
||||||
|
#############################
|
||||||
|
# LintCodebase "FILE_TYPE" "LINTER_NAME" "LINTER_CMD" "FILE_TYPES_REGEX" "FILE_ARRAY"
|
||||||
|
LintCodebase "POWERSHELL" "pwsh" "Invoke-ScriptAnalyzer -EnableExit -Settings ${POWERSHELL_LINTER_RULES} -Path" ".*\.\(ps1\|psm1\|psd1\|ps1xml\|pssc\|psrc\|cdxml\)\$" "${FILE_ARRAY_POWERSHELL[@]}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
####################
|
||||||
|
# PROTOBUF LINTING #
|
||||||
|
####################
|
||||||
|
if [ "${VALIDATE_PROTOBUF}" == "true" ]; then
|
||||||
|
#######################
|
||||||
|
# Lint the Protocol Buffers files #
|
||||||
|
#######################
|
||||||
|
# LintCodebase "FILE_TYPE" "LINTER_NAME" "LINTER_CMD" "FILE_TYPES_REGEX" "FILE_ARRAY"
|
||||||
|
LintCodebase "PROTOBUF" "protolint" "protolint lint --config_path ${PROTOBUF_LINTER_RULES}" ".*\.\(proto\)\$" "${FILE_ARRAY_PROTOBUF[@]}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
##################
|
||||||
|
# PYTHON LINTING #
|
||||||
|
##################
|
||||||
|
if [ "${VALIDATE_PYTHON}" == "true" ]; then
|
||||||
|
#########################
|
||||||
|
# Lint the python files #
|
||||||
|
#########################
|
||||||
|
# LintCodebase "FILE_TYPE" "LINTER_NAME" "LINTER_CMD" "FILE_TYPES_REGEX" "FILE_ARRAY"
|
||||||
|
LintCodebase "PYTHON" "pylint" "pylint --rcfile ${PYTHON_LINTER_RULES}" ".*\.\(py\)\$" "${FILE_ARRAY_PYTHON[@]}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
################
|
||||||
|
# RAKU LINTING #
|
||||||
|
################
|
||||||
|
if [ "${VALIDATE_RAKU}" == "true" ]; then
|
||||||
|
#######################
|
||||||
|
# Lint the raku files #
|
||||||
|
#######################
|
||||||
|
echo "${GITHUB_WORKSPACE}/META6.json"
|
||||||
|
if [ -e "${GITHUB_WORKSPACE}/META6.json" ]; then
|
||||||
|
cd "${GITHUB_WORKSPACE}" && zef install --deps-only --/test .
|
||||||
|
fi
|
||||||
|
# LintCodebase "FILE_TYPE" "LINTER_NAME" "LINTER_CMD" "FILE_TYPES_REGEX" "FILE_ARRAY"
|
||||||
|
LintCodebase "RAKU" "raku" "raku -I ${GITHUB_WORKSPACE}/lib -c" ".*\.\(raku\|rakumod\|rakutest\|pm6\|pl6\|p6\)\$" "${FILE_ARRAY_RAKU[@]}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
################
|
||||||
|
# RUBY LINTING #
|
||||||
|
################
|
||||||
|
if [ "${VALIDATE_RUBY}" == "true" ]; then
|
||||||
|
#######################
|
||||||
|
# Lint the ruby files #
|
||||||
|
#######################
|
||||||
|
# LintCodebase "FILE_TYPE" "LINTER_NAME" "LINTER_CMD" "FILE_TYPES_REGEX" "FILE_ARRAY"
|
||||||
|
LintCodebase "RUBY" "rubocop" "rubocop -c ${RUBY_LINTER_RULES} --force-exclusion" ".*\.\(rb\)\$" "${FILE_ARRAY_RUBY[@]}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
######################
|
||||||
|
# AWS STATES LINTING #
|
||||||
|
######################
|
||||||
|
if [ "${VALIDATE_STATES}" == "true" ]; then
|
||||||
|
# If we are validating all codebase we need to build file list because not every json file is an aws states file
|
||||||
|
if [ "${VALIDATE_ALL_CODEBASE}" == "true" ]; then
|
||||||
|
###############################################################################
|
||||||
|
# Set the file seperator to newline to allow for grabbing objects with spaces #
|
||||||
|
###############################################################################
|
||||||
|
IFS=$'\n'
|
||||||
|
|
||||||
|
mapfile -t LIST_FILES < <(find "${GITHUB_WORKSPACE}" -type f -regex ".*\.\(json\)\$" 2>&1)
|
||||||
|
for FILE in "${LIST_FILES[@]}"; do
|
||||||
|
if DetectAWSStatesFIle "${FILE}"; then
|
||||||
|
FILE_ARRAY_STATES+=("${FILE}")
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
###########################
|
||||||
|
# Set IFS back to default #
|
||||||
|
###########################
|
||||||
|
IFS="${DEFAULT_IFS}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
#########################
|
||||||
|
# Lint the STATES files #
|
||||||
|
#########################
|
||||||
|
LintCodebase "STATES" "asl-validator" "asl-validator --json-path" "disabledfileext" "${FILE_ARRAY_STATES[@]}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
#####################
|
||||||
|
# TERRAFORM LINTING #
|
||||||
|
#####################
|
||||||
|
if [ "${VALIDATE_TERRAFORM}" == "true" ]; then
|
||||||
|
############################
|
||||||
|
# Lint the Terraform files #
|
||||||
|
############################
|
||||||
|
# LintCodebase "FILE_TYPE" "LINTER_NAME" "LINTER_CMD" "FILE_TYPES_REGEX" "FILE_ARRAY"
|
||||||
|
LintCodebase "TERRAFORM" "tflint" "tflint -c ${TERRAFORM_LINTER_RULES}" ".*\.\(tf\)\$" "${FILE_ARRAY_TERRAFORM[@]}"
|
||||||
|
fi
|
||||||
|
|
||||||
######################
|
######################
|
||||||
# TSX LINTING #
|
# TSX LINTING #
|
||||||
######################
|
######################
|
||||||
|
@ -1381,220 +1598,25 @@ if [ "${VALIDATE_TYPESCRIPT_STANDARD}" == "true" ]; then
|
||||||
fi
|
fi
|
||||||
|
|
||||||
###############
|
###############
|
||||||
# CSS LINTING #
|
# XML LINTING #
|
||||||
###############
|
###############
|
||||||
if [ "${VALIDATE_CSS}" == "true" ]; then
|
if [ "${VALIDATE_XML}" == "true" ]; then
|
||||||
#################################
|
######################
|
||||||
# Get CSS standard rules #
|
# Lint the XML Files #
|
||||||
#################################
|
######################
|
||||||
GetStandardRules "stylelint"
|
# LintCodebase "FILE_TYPE" "LINTER_NAME" "LINTER_CMD" "FILE_TYPES_REGEX" "FILE_ARRAY"
|
||||||
#############################
|
LintCodebase "XML" "xmllint" "xmllint" ".*\.\(xml\)\$" "${FILE_ARRAY_XML[@]}"
|
||||||
# Lint the CSS files #
|
|
||||||
#############################
|
|
||||||
LintCodebase "CSS" "stylelint" "stylelint --config ${CSS_LINTER_RULES}" ".*\.\(css\)\$" "${FILE_ARRAY_CSS[@]}"
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
###############
|
###############
|
||||||
# ENV LINTING #
|
# YML LINTING #
|
||||||
###############
|
###############
|
||||||
if [ "${VALIDATE_ENV}" == "true" ]; then
|
if [ "${VALIDATE_YAML}" == "true" ]; then
|
||||||
#######################
|
######################
|
||||||
# Lint the env files #
|
# Lint the Yml Files #
|
||||||
#######################
|
######################
|
||||||
# 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 "ENV" "dotenv-linter" "dotenv-linter" ".*\.\(env\).*\$" "${FILE_ARRAY_ENV[@]}"
|
LintCodebase "YML" "yamllint" "yamllint -c ${YAML_LINTER_RULES}" ".*\.\(yml\|yaml\)\$" "${FILE_ARRAY_YML[@]}"
|
||||||
fi
|
|
||||||
|
|
||||||
##################
|
|
||||||
# KOTLIN LINTING #
|
|
||||||
##################
|
|
||||||
if [ "${VALIDATE_KOTLIN}" == "true" ]; then
|
|
||||||
#######################
|
|
||||||
# Lint the Kotlin files #
|
|
||||||
#######################
|
|
||||||
# LintCodebase "FILE_TYPE" "LINTER_NAME" "LINTER_CMD" "FILE_TYPES_REGEX" "FILE_ARRAY"
|
|
||||||
LintCodebase "KOTLIN" "ktlint" "ktlint" ".*\.\(kt\|kts\)\$" "${FILE_ARRAY_KOTLIN[@]}"
|
|
||||||
fi
|
|
||||||
|
|
||||||
########################
|
|
||||||
# EDITORCONFIG LINTING #
|
|
||||||
########################
|
|
||||||
if [ "${VALIDATE_EDITORCONFIG}" == "true" ]; then
|
|
||||||
####################################
|
|
||||||
# Lint the files with editorconfig #
|
|
||||||
####################################
|
|
||||||
# LintCodebase "FILE_TYPE" "LINTER_NAME" "LINTER_CMD" "FILE_TYPES_REGEX" "FILE_ARRAY"
|
|
||||||
LintCodebase "EDITORCONFIG" "editorconfig-checker" "editorconfig-checker" "^.*$" "${FILE_ARRAY_ENV[@]}"
|
|
||||||
fi
|
|
||||||
|
|
||||||
##################
|
|
||||||
# DART LINTING #
|
|
||||||
##################
|
|
||||||
if [ "${VALIDATE_DART}" == "true" ]; then
|
|
||||||
#######################
|
|
||||||
# Lint the Dart files #
|
|
||||||
#######################
|
|
||||||
# LintCodebase "FILE_TYPE" "LINTER_NAME" "LINTER_CMD" "FILE_TYPES_REGEX" "FILE_ARRAY"
|
|
||||||
LintCodebase "DART" "dart" "dartanalyzer --fatal-infos --fatal-warnings --options ${DART_LINTER_RULES}" ".*\.\(dart\)\$" "${FILE_ARRAY_DART[@]}"
|
|
||||||
fi
|
|
||||||
|
|
||||||
##################
|
|
||||||
# DOCKER LINTING #
|
|
||||||
##################
|
|
||||||
if [ "${VALIDATE_DOCKER}" == "true" ]; then
|
|
||||||
#########################
|
|
||||||
# Lint the docker files #
|
|
||||||
#########################
|
|
||||||
# LintCodebase "FILE_TYPE" "LINTER_NAME" "LINTER_CMD" "FILE_TYPES_REGEX" "FILE_ARRAY"
|
|
||||||
# NOTE: dockerfilelint's "-c" option expects the folder *containing* the DOCKER_LINTER_RULES file
|
|
||||||
LintCodebase "DOCKER" "dockerfilelint" "dockerfilelint -c $(dirname ${DOCKER_LINTER_RULES})" ".*\(Dockerfile\)\$" "${FILE_ARRAY_DOCKER[@]}"
|
|
||||||
fi
|
|
||||||
|
|
||||||
###################
|
|
||||||
# CLOJURE LINTING #
|
|
||||||
###################
|
|
||||||
if [ "${VALIDATE_CLOJURE}" == "true" ]; then
|
|
||||||
#################################
|
|
||||||
# Get Clojure standard rules #
|
|
||||||
#################################
|
|
||||||
GetStandardRules "clj-kondo"
|
|
||||||
#########################
|
|
||||||
# Lint the Clojure files #
|
|
||||||
#########################
|
|
||||||
LintCodebase "CLOJURE" "clj-kondo" "clj-kondo --config ${CLOJURE_LINTER_RULES} --lint" ".*\.\(clj\|cljs\|cljc\|edn\)\$" "${FILE_ARRAY_CLOJURE[@]}"
|
|
||||||
fi
|
|
||||||
|
|
||||||
##################
|
|
||||||
# PROTOBUF LINTING #
|
|
||||||
##################
|
|
||||||
if [ "${VALIDATE_PROTOBUF}" == "true" ]; then
|
|
||||||
#######################
|
|
||||||
# Lint the Protocol Buffers files #
|
|
||||||
#######################
|
|
||||||
# LintCodebase "FILE_TYPE" "LINTER_NAME" "LINTER_CMD" "FILE_TYPES_REGEX" "FILE_ARRAY"
|
|
||||||
LintCodebase "PROTOBUF" "protolint" "protolint lint --config_path ${PROTOBUF_LINTER_RULES}" ".*\.\(proto\)\$" "${FILE_ARRAY_PROTOBUF[@]}"
|
|
||||||
fi
|
|
||||||
|
|
||||||
######################
|
|
||||||
# POWERSHELL LINTING #
|
|
||||||
######################
|
|
||||||
if [ "${VALIDATE_POWERSHELL}" == "true" ]; then
|
|
||||||
###############################################################
|
|
||||||
# For POWERSHELL, ensure PSScriptAnalyzer module is available #
|
|
||||||
###############################################################
|
|
||||||
ValidatePowershellModules
|
|
||||||
|
|
||||||
#############################
|
|
||||||
# Lint the powershell files #
|
|
||||||
#############################
|
|
||||||
# LintCodebase "FILE_TYPE" "LINTER_NAME" "LINTER_CMD" "FILE_TYPES_REGEX" "FILE_ARRAY"
|
|
||||||
LintCodebase "POWERSHELL" "pwsh" "Invoke-ScriptAnalyzer -EnableExit -Settings ${POWERSHELL_LINTER_RULES} -Path" ".*\.\(ps1\|psm1\|psd1\|ps1xml\|pssc\|psrc\|cdxml\)\$" "${FILE_ARRAY_POWERSHELL[@]}"
|
|
||||||
fi
|
|
||||||
|
|
||||||
########################
|
|
||||||
# ARM Template LINTING #
|
|
||||||
########################
|
|
||||||
if [ "${VALIDATE_ARM}" == "true" ]; then
|
|
||||||
# If we are validating all codebase we need to build file list because not every json file is an ARM file
|
|
||||||
if [ "${VALIDATE_ALL_CODEBASE}" == "true" ]; then
|
|
||||||
###############################################################################
|
|
||||||
# Set the file seperator to newline to allow for grabbing objects with spaces #
|
|
||||||
###############################################################################
|
|
||||||
IFS=$'\n'
|
|
||||||
|
|
||||||
mapfile -t LIST_FILES < <(find "${GITHUB_WORKSPACE}" -type f -regex ".*\.\(json\)\$" 2>&1)
|
|
||||||
for FILE in "${LIST_FILES[@]}"; do
|
|
||||||
if DetectARMFile "${FILE}"; then
|
|
||||||
FILE_ARRAY_ARM+=("${FILE}")
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
|
|
||||||
###########################
|
|
||||||
# Set IFS back to default #
|
|
||||||
###########################
|
|
||||||
IFS="${DEFAULT_IFS}"
|
|
||||||
fi
|
|
||||||
|
|
||||||
###############################
|
|
||||||
# Lint the ARM Template files #
|
|
||||||
###############################
|
|
||||||
# LintCodebase "FILE_TYPE" "LINTER_NAME" "LINTER_CMD" "FILE_TYPES_REGEX" "FILE_ARRAY"
|
|
||||||
LintCodebase "ARM" "arm-ttk" "Import-Module ${ARM_TTK_PSD1} ; \${config} = \$(Import-PowerShellDataFile -Path ${ARM_LINTER_RULES}) ; Test-AzTemplate @config -TemplatePath" "disabledfileext" "${FILE_ARRAY_ARM[@]}"
|
|
||||||
fi
|
|
||||||
|
|
||||||
###################
|
|
||||||
# OPENAPI LINTING #
|
|
||||||
###################
|
|
||||||
if [ "${VALIDATE_OPENAPI}" == "true" ]; then
|
|
||||||
# If we are validating all codebase we need to build file list because not every yml/json file is an OpenAPI file
|
|
||||||
if [ "${VALIDATE_ALL_CODEBASE}" == "true" ]; then
|
|
||||||
###############################################################################
|
|
||||||
# Set the file seperator to newline to allow for grabbing objects with spaces #
|
|
||||||
###############################################################################
|
|
||||||
IFS=$'\n'
|
|
||||||
|
|
||||||
mapfile -t LIST_FILES < <(find "${GITHUB_WORKSPACE}" -type f -regex ".*\.\(yml\|yaml\|json\)\$" 2>&1)
|
|
||||||
for FILE in "${LIST_FILES[@]}"; do
|
|
||||||
if DetectOpenAPIFile "${FILE}"; then
|
|
||||||
FILE_ARRAY_OPENAPI+=("${FILE}")
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
|
|
||||||
###########################
|
|
||||||
# Set IFS back to default #
|
|
||||||
###########################
|
|
||||||
IFS="${DEFAULT_IFS}"
|
|
||||||
fi
|
|
||||||
|
|
||||||
##########################
|
|
||||||
# Lint the OpenAPI files #
|
|
||||||
##########################
|
|
||||||
# LintCodebase "FILE_TYPE" "LINTER_NAME" "LINTER_CMD" "FILE_TYPES_REGEX" "FILE_ARRAY"
|
|
||||||
LintCodebase "OPENAPI" "spectral" "spectral lint -r ${OPENAPI_LINTER_RULES}" "disabledfileext" "${FILE_ARRAY_OPENAPI[@]}"
|
|
||||||
fi
|
|
||||||
|
|
||||||
################
|
|
||||||
# HTML LINTING #
|
|
||||||
################
|
|
||||||
if [ "${VALIDATE_HTML}" == "true" ]; then
|
|
||||||
#################################
|
|
||||||
# Get HTML standard rules #
|
|
||||||
#################################
|
|
||||||
GetStandardRules "htmlhint"
|
|
||||||
#############################
|
|
||||||
# Lint the HTML files #
|
|
||||||
#############################
|
|
||||||
LintCodebase "HTML" "htmlhint" "htmlhint --config ${HTML_LINTER_RULES}" ".*\.\(html\)\$" "${FILE_ARRAY_HTML[@]}"
|
|
||||||
fi
|
|
||||||
|
|
||||||
######################
|
|
||||||
# AWS STATES LINTING #
|
|
||||||
######################
|
|
||||||
if [ "${VALIDATE_STATES}" == "true" ]; then
|
|
||||||
# If we are validating all codebase we need to build file list because not every json file is an aws states file
|
|
||||||
if [ "${VALIDATE_ALL_CODEBASE}" == "true" ]; then
|
|
||||||
###############################################################################
|
|
||||||
# Set the file seperator to newline to allow for grabbing objects with spaces #
|
|
||||||
###############################################################################
|
|
||||||
IFS=$'\n'
|
|
||||||
|
|
||||||
mapfile -t LIST_FILES < <(find "${GITHUB_WORKSPACE}" -type f -regex ".*\.\(json\)\$" 2>&1)
|
|
||||||
for FILE in "${LIST_FILES[@]}"; do
|
|
||||||
if DetectAWSStatesFIle "${FILE}"; then
|
|
||||||
FILE_ARRAY_STATES+=("${FILE}")
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
|
|
||||||
###########################
|
|
||||||
# Set IFS back to default #
|
|
||||||
###########################
|
|
||||||
IFS="${DEFAULT_IFS}"
|
|
||||||
fi
|
|
||||||
|
|
||||||
#########################
|
|
||||||
# Lint the STATES files #
|
|
||||||
#########################
|
|
||||||
LintCodebase "STATES" "asl-validator" "asl-validator --json-path" "disabledfileext" "${FILE_ARRAY_STATES[@]}"
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
###########
|
###########
|
||||||
|
|
|
@ -46,6 +46,7 @@ function GetValidationInfo() {
|
||||||
################################
|
################################
|
||||||
# Convert strings to lowercase #
|
# Convert strings to lowercase #
|
||||||
################################
|
################################
|
||||||
|
|
||||||
# Loop through all languages
|
# Loop through all languages
|
||||||
for LANGUAGE in "${LANGUAGE_ARRAY[@]}"; do
|
for LANGUAGE in "${LANGUAGE_ARRAY[@]}"; do
|
||||||
# build the variable
|
# build the variable
|
||||||
|
@ -54,6 +55,7 @@ function GetValidationInfo() {
|
||||||
eval "${VALIDATE_LANGUAGE}=${!VALIDATE_LANGUAGE,,}"
|
eval "${VALIDATE_LANGUAGE}=${!VALIDATE_LANGUAGE,,}"
|
||||||
done
|
done
|
||||||
|
|
||||||
|
|
||||||
################################################
|
################################################
|
||||||
# Determine if any linters were explicitly set #
|
# Determine if any linters were explicitly set #
|
||||||
################################################
|
################################################
|
||||||
|
@ -90,6 +92,20 @@ function GetValidationInfo() {
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
|
######################################
|
||||||
|
# Validate if we should check GROOVY #
|
||||||
|
######################################
|
||||||
|
if [[ $ANY_SET == "true" ]]; then
|
||||||
|
# Some linter flags were set - only run those set to true
|
||||||
|
if [[ -z $VALIDATE_GROOVY ]]; then
|
||||||
|
# GROOVY flag was not set - default to false
|
||||||
|
VALIDATE_GROOVY="false"
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
# No linter flags were set - default all to true
|
||||||
|
VALIDATE_GROOVY="true"
|
||||||
|
fi
|
||||||
|
|
||||||
#######################################
|
#######################################
|
||||||
# Print which linters we are enabling #
|
# Print which linters we are enabling #
|
||||||
#######################################
|
#######################################
|
||||||
|
|
|
@ -138,10 +138,11 @@ function LintCodebase() {
|
||||||
# Lint the files #
|
# Lint the files #
|
||||||
##################
|
##################
|
||||||
for FILE in "${LIST_FILES[@]}"; do
|
for FILE in "${LIST_FILES[@]}"; do
|
||||||
#####################
|
###################################
|
||||||
# Get the file name #
|
# Get the file name and directory #
|
||||||
#####################
|
###################################
|
||||||
FILE_NAME=$(basename "${FILE}" 2>&1)
|
FILE_NAME=$(basename "${FILE}" 2>&1)
|
||||||
|
DIR_NAME=$(dirname "${FILE}" 2>&1)
|
||||||
|
|
||||||
#####################################################
|
#####################################################
|
||||||
# Make sure we dont lint node modules or test cases #
|
# Make sure we dont lint node modules or test cases #
|
||||||
|
@ -193,6 +194,17 @@ function LintCodebase() {
|
||||||
pwsh -NoProfile -NoLogo -Command "${LINTER_COMMAND} ${FILE}; if (\${Error}.Count) { exit 1 }"
|
pwsh -NoProfile -NoLogo -Command "${LINTER_COMMAND} ${FILE}; if (\${Error}.Count) { exit 1 }"
|
||||||
exit $? 2>&1
|
exit $? 2>&1
|
||||||
)
|
)
|
||||||
|
###############################################################################
|
||||||
|
# Corner case for groovy as we have to pass it as path and file in ant format #
|
||||||
|
###############################################################################
|
||||||
|
elif [[ ${FILE_TYPE} == "GROOVY" ]]; then
|
||||||
|
#######################################
|
||||||
|
# Lint the file with the updated path #
|
||||||
|
#######################################
|
||||||
|
LINT_CMD=$(
|
||||||
|
cd "${GITHUB_WORKSPACE}" || exit
|
||||||
|
${LINTER_COMMAND} --path "${DIR_NAME}" --files "$FILE_NAME" 2>&1
|
||||||
|
)
|
||||||
else
|
else
|
||||||
################################
|
################################
|
||||||
# Lint the file with the rules #
|
# Lint the file with the rules #
|
||||||
|
@ -326,6 +338,7 @@ function TestCodebase() {
|
||||||
# Get the file name #
|
# Get the file name #
|
||||||
#####################
|
#####################
|
||||||
FILE_NAME=$(basename "${FILE}" 2>&1)
|
FILE_NAME=$(basename "${FILE}" 2>&1)
|
||||||
|
DIR_NAME=$(dirname "${FILE}" 2>&1)
|
||||||
|
|
||||||
############################
|
############################
|
||||||
# Get the file pass status #
|
# Get the file pass status #
|
||||||
|
@ -400,6 +413,17 @@ function TestCodebase() {
|
||||||
pwsh -NoProfile -NoLogo -Command "${LINTER_COMMAND} ${FILE}; if (\${Error}.Count) { exit 1 }"
|
pwsh -NoProfile -NoLogo -Command "${LINTER_COMMAND} ${FILE}; if (\${Error}.Count) { exit 1 }"
|
||||||
exit $? 2>&1
|
exit $? 2>&1
|
||||||
)
|
)
|
||||||
|
###############################################################################
|
||||||
|
# Corner case for groovy as we have to pass it as path and file in ant format #
|
||||||
|
###############################################################################
|
||||||
|
elif [[ ${FILE_TYPE} == "GROOVY" ]]; then
|
||||||
|
#######################################
|
||||||
|
# Lint the file with the updated path #
|
||||||
|
#######################################
|
||||||
|
LINT_CMD=$(
|
||||||
|
cd "${GITHUB_WORKSPACE}" || exit
|
||||||
|
${LINTER_COMMAND} --path "${DIR_NAME}" --files "$FILE_NAME" 2>&1
|
||||||
|
)
|
||||||
else
|
else
|
||||||
################################
|
################################
|
||||||
# Lint the file with the rules #
|
# Lint the file with the rules #
|
||||||
|
@ -566,6 +590,7 @@ function RunTestCases() {
|
||||||
TestCodebase "EDITORCONFIG" "editorconfig-checker" "editorconfig-checker" ".*\.ext$" "editorconfig-checker"
|
TestCodebase "EDITORCONFIG" "editorconfig-checker" "editorconfig-checker" ".*\.ext$" "editorconfig-checker"
|
||||||
TestCodebase "ENV" "dotenv-linter" "dotenv-linter" ".*\.\(env\)\$" "env"
|
TestCodebase "ENV" "dotenv-linter" "dotenv-linter" ".*\.\(env\)\$" "env"
|
||||||
TestCodebase "GO" "golangci-lint" "golangci-lint run -c ${GO_LINTER_RULES}" ".*\.\(go\)\$" "golang"
|
TestCodebase "GO" "golangci-lint" "golangci-lint run -c ${GO_LINTER_RULES}" ".*\.\(go\)\$" "golang"
|
||||||
|
TestCodebase "GROOVY" "npm-groovy-lint" "npm-groovy-lint -c $GROOVY_LINTER_RULES --failon error" ".*\.\(groovy\|jenkinsfile\|gradle\)\$" "groovy"
|
||||||
TestCodebase "HTML" "htmlhint" "htmlhint --config ${HTML_LINTER_RULES}" ".*\.\(html\)\$" "html"
|
TestCodebase "HTML" "htmlhint" "htmlhint --config ${HTML_LINTER_RULES}" ".*\.\(html\)\$" "html"
|
||||||
TestCodebase "JAVASCRIPT_ES" "eslint" "eslint --no-eslintrc -c ${JAVASCRIPT_LINTER_RULES}" ".*\.\(js\)\$" "javascript"
|
TestCodebase "JAVASCRIPT_ES" "eslint" "eslint --no-eslintrc -c ${JAVASCRIPT_LINTER_RULES}" ".*\.\(js\)\$" "javascript"
|
||||||
TestCodebase "JAVASCRIPT_STANDARD" "standard" "standard ${JAVASCRIPT_STANDARD_LINTER_RULES}" ".*\.\(js\)\$" "javascript"
|
TestCodebase "JAVASCRIPT_STANDARD" "standard" "standard ${JAVASCRIPT_STANDARD_LINTER_RULES}" ".*\.\(js\)\$" "javascript"
|
||||||
|
|
Loading…
Reference in a new issue