From afe4f087cbe98a614b5a63b6865a901c5e5e445e Mon Sep 17 00:00:00 2001 From: Lucas Gravley <29484535+admiralAwkbar@users.noreply.github.com> Date: Tue, 14 Jul 2020 09:28:58 -0500 Subject: [PATCH 001/135] Adding groovy --- .automation/test/groovy/README.md | 13 +++++++ .automation/test/groovy/groovy_bad_01.groovy | 6 +++ .automation/test/groovy/groovy_good_01.groovy | 6 +++ README.md | 6 ++- dependencies/package.json | 3 +- docs/disabling-linters.md | 39 +++++++++++++++++++ lib/buildFileList.sh | 9 +++++ lib/linter.sh | 24 +++++++++++- lib/validation.sh | 21 ++++++++++ lib/worker.sh | 1 + 10 files changed, 123 insertions(+), 5 deletions(-) create mode 100644 .automation/test/groovy/README.md create mode 100644 .automation/test/groovy/groovy_bad_01.groovy create mode 100644 .automation/test/groovy/groovy_good_01.groovy diff --git a/.automation/test/groovy/README.md b/.automation/test/groovy/README.md new file mode 100644 index 00000000..b08a3b4f --- /dev/null +++ b/.automation/test/groovy/README.md @@ -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. diff --git a/.automation/test/groovy/groovy_bad_01.groovy b/.automation/test/groovy/groovy_bad_01.groovy new file mode 100644 index 00000000..7d071754 --- /dev/null +++ b/.automation/test/groovy/groovy_bad_01.groovy @@ -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" + } +} diff --git a/.automation/test/groovy/groovy_good_01.groovy b/.automation/test/groovy/groovy_good_01.groovy new file mode 100644 index 00000000..d0375dab --- /dev/null +++ b/.automation/test/groovy/groovy_good_01.groovy @@ -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" + } +} diff --git a/README.md b/README.md index 1593506c..eaef2b86 100644 --- a/README.md +++ b/README.md @@ -40,10 +40,11 @@ Developers on **GitHub** can call the **GitHub Action** to lint their code base | **Clojure** | [clj-kondo](https://github.com/borkdude/clj-kondo) | | **CoffeeScript** | [coffeelint](https://coffeelint.github.io/) | | **Dockerfile** | [dockerfilelint](https://github.com/replicatedhq/dockerfilelint.git) | -| **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) | | **Golang** | [golangci-lint](https://github.com/golangci/golangci-lint) | -| **HTMLHint** | [HTMLHint](https://github.com/htmlhint/HTMLHint) | +| **Groovy** | [npm-groovy-lint](https://github.com/nvuillam/npm-groovy-lint) | +| **HTML** | [HTMLHint](https://github.com/htmlhint/HTMLHint) | | **JavaScript** | [eslint](https://eslint.org/) [standard js](https://standardjs.com/) | | **JSON** | [jsonlint](https://github.com/zaach/jsonlint) | | **Kotlin** | [ktlint](https://github.com/pinterest/ktlint) | @@ -177,6 +178,7 @@ and won't run anything unexpected. | **VALIDATE_TYPESCRIPT_STANDARD** | `true` | Flag to enable or disable the linting process of the language. (Utilizing: standard) | | **VALIDATE_DOCKER** | `true` | Flag to enable or disable the linting process of the language. | | **VALIDATE_GO** | `true` | Flag to enable or disable the linting process of the language. | +| **VALIDATE_GROOVY** | `true` | Flag to enable or disable the linting process of the language. | | **VALIDATE_POWERSHELL** | `true` | Flag to enable or disable the linting process of the language. | | **VALIDATE_ARM** | `true` | Flag to enable or disable the linting process of the language. | | **VALIDATE_TERRAFORM** | `true` | Flag to enable or disable the linting process of the language. | diff --git a/dependencies/package.json b/dependencies/package.json index e5a2934d..76182dbd 100644 --- a/dependencies/package.json +++ b/dependencies/package.json @@ -18,6 +18,7 @@ "standard": "^14.3.4", "stylelint": "^13.6.1", "stylelint-config-standard": "^20.0.0", - "typescript": "^3.9.6" + "typescript": "^3.9.6", + "npm-groovy-lint": "^5.5.0" } } diff --git a/docs/disabling-linters.md b/docs/disabling-linters.md index fb622005..4c50972d 100644 --- a/docs/disabling-linters.md +++ b/docs/disabling-linters.md @@ -30,6 +30,7 @@ For some linters it is also possible to override rules on a case by case level w - [Typescript Eslint](#typescript-eslint) - [Typescript Standard](#typescript-standard) - [Golang](#golang) +- [Groovy](#groovy) - [Dockerfile](#dockerfile) - [Terraform](#terraform) - [CSS](#css) @@ -563,6 +564,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 - [dockerfilelint](https://github.com/replicatedhq/dockerfilelint.git) diff --git a/lib/buildFileList.sh b/lib/buildFileList.sh index 06f0110f..965bb6b9 100755 --- a/lib/buildFileList.sh +++ b/lib/buildFileList.sh @@ -421,6 +421,15 @@ function BuildFileList() { # Set the READ_ONLY_CHANGE_FLAG since this could be exec # ########################################################## READ_ONLY_CHANGE_FLAG=1 + elif [ "$FILE_TYPE" == "groovy" ] || [ "$FILE_TYPE" == "jenkinsfile" ]; 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 ############################################## # Use file to see if we can parse what it is # diff --git a/lib/linter.sh b/lib/linter.sh index 324084be..15424722 100755 --- a/lib/linter.sh +++ b/lib/linter.sh @@ -59,6 +59,9 @@ DOCKER_LINTER_RULES="$DEFAULT_RULES_LOCATION/$DOCKER_FILE_NAME" # Path t # Golang Vars GO_FILE_NAME='.golangci.yml' # Name of the file 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 Go lint rules # Terraform Vars TERRAFORM_FILE_NAME='.tflint.hcl' # Name of the file TERRAFORM_LINTER_RULES="$DEFAULT_RULES_LOCATION/$TERRAFORM_FILE_NAME" # Path to the Terraform lint rules @@ -91,7 +94,7 @@ LINTER_ARRAY=("jsonlint" "yamllint" "xmllint" "markdownlint" "shellcheck" "pylint" "perl" "raku" "rubocop" "coffeelint" "eslint" "standard" "ansible-lint" "dockerfilelint" "golangci-lint" "tflint" "stylelint" "dotenv-linter" "pwsh" "arm-ttk" "ktlint" "protolint" "clj-kondo" - "spectral" "cfn-lint" "htmlhint") + "spectral" "cfn-lint" "htmlhint" "npm-groovy-lint") ############################# # Language array for prints # @@ -100,7 +103,7 @@ LANGUAGE_ARRAY=('YML' 'JSON' 'XML' 'MARKDOWN' 'BASH' 'PERL' 'RAKU' 'PHP' 'RUBY' 'COFFEESCRIPT' 'ANSIBLE' 'JAVASCRIPT_STANDARD' 'JAVASCRIPT_ES' 'JSX' 'TSX' 'TYPESCRIPT_STANDARD' 'TYPESCRIPT_ES' 'DOCKER' 'GO' 'TERRAFORM' 'CSS' 'ENV' 'POWERSHELL' 'ARM' 'KOTLIN' 'PROTOBUF' 'CLOJURE' 'OPENAPI' - 'CFN' 'HTML') + 'CFN' 'HTML' 'GROOVY') ################### # GitHub ENV Vars # @@ -144,6 +147,7 @@ VALIDATE_EDITORCONFIG="${VALIDATE_EDITORCONFIG}" # Boolean to vali TEST_CASE_RUN="${TEST_CASE_RUN}" # Boolean to validate only test cases DISABLE_ERRORS="${DISABLE_ERRORS}" # Boolean to enable warning-only output without throwing errors VALIDATE_HTML="${VALIDATE_HTML}" # Boolean to validate language +VALIDATE_GROOVY="${VALIDATE_GROOVY}" # Boolean to validate language ############## # Debug Vars # @@ -207,6 +211,7 @@ FILE_ARRAY_KOTLIN=() # Array of files to check FILE_ARRAY_PROTOBUF=() # Array of files to check FILE_ARRAY_OPENAPI=() # Array of files to check FILE_ARRAY_HTML=() # Array of files to check +FILE_ARRAY_GROOVY=() # Array of files to check ############ # Counters # @@ -242,6 +247,7 @@ ERRORS_FOUND_KOTLIN=0 # Count of errors found ERRORS_FOUND_PROTOBUF=0 # Count of errors found ERRORS_FOUND_OPENAPI=0 # Count of errors found ERRORS_FOUND_HTML=0 # Count of errors found +ERRORS_FOUND_GROOVY=0 # Count of errors found ################################################################################ ########################## FUNCTIONS BELOW ##################################### @@ -802,6 +808,7 @@ Footer() { [ "$ERRORS_FOUND_PROTOBUF" -ne 0 ] || [ "$ERRORS_FOUND_CLOJURE" -ne 0 ] || [ "$ERRORS_FOUND_KOTLIN" -ne 0 ] || + [ "$ERRORS_FOUND_GROOVY" -ne 0 ] || [ "$ERRORS_FOUND_HTML" -ne 0 ]; then # Failed exit echo -e "${NC}${F[R]}Exiting with errors found!${NC}" @@ -861,6 +868,8 @@ GetLinterRules "JAVASCRIPT" GetLinterRules "TYPESCRIPT" # Get Golang rules GetLinterRules "GO" +# Get Groovy rules +GetLinterRules "GROOVY" # Get Docker rules GetLinterRules "DOCKER" # Get Terraform rules @@ -1054,6 +1063,17 @@ if [ "$VALIDATE_GO" == "true" ]; then LintCodebase "GO" "golangci-lint" "golangci-lint run -c $GO_LINTER_RULES" ".*\.\(go\)\$" "${FILE_ARRAY_GO[@]}" fi +################## +# GROOVY LINTING # +################## +if [ "$VALIDATE_GROOVY" == "true" ]; then + ######################### + # Lint the groovy files # + ######################### + # LintCodebase "FILE_TYPE" "LINTER_NAME" "LINTER_CMD" "FILE_TYPES_REGEX" "FILE_ARRAY" + LintCodebase "GROOVY" "npm-groovy-lint" "npm-groovy-lint -c $GROOVY_LINTER_RULES -f" ".*\.\(groovy\|jenkinsfile\|gradle\)\$" "${FILE_ARRAY_GROOVY[@]}" +fi + ##################### # TERRAFORM LINTING # ##################### diff --git a/lib/validation.sh b/lib/validation.sh index 8782e326..6f62c022 100755 --- a/lib/validation.sh +++ b/lib/validation.sh @@ -77,6 +77,7 @@ function GetValidationInfo() { VALIDATE_OPENAPI=$(echo "$VALIDATE_OPENAPI" | awk '{print tolower($0)}') VALIDATE_EDITORCONFIG=$(echo "$VALIDATE_EDITORCONFIG" | awk '{print tolower($0)}') VALIDATE_HTML=$(echo "$VALIDATE_HTML" | awk '{print tolower($0)}') + VALIDATE_GROOVY=$(echo "$VALIDATE_GROOVY" | awk '{print tolower($0)}') ################################################ # Determine if any linters were explicitly set # @@ -100,6 +101,7 @@ function GetValidationInfo() { $VALIDATE_TYPESCRIPT_STANDARD || -n \ $VALIDATE_DOCKER || -n \ $VALIDATE_GO || -n \ + $VALIDATE_GROOVY || -n \ $VALIDATE_TERRAFORM || -n \ $VALIDATE_POWERSHELL || -n \ $VALIDATE_ARM || -n \ @@ -551,6 +553,20 @@ function GetValidationInfo() { VALIDATE_HTML="true" fi + ###################################### + # 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 # ####################################### @@ -699,6 +715,11 @@ function GetValidationInfo() { else PRINT_ARRAY+=("- Excluding [HTML] files in code base...") fi + if [[ $VALIDATE_GROOVY == "true" ]]; then + PRINT_ARRAY+=("- Validating [GROOVY] files in code base...") + else + PRINT_ARRAY+=("- Excluding [GROOVY] files in code base...") + fi ############################## # Validate Ansible Directory # diff --git a/lib/worker.sh b/lib/worker.sh index eb2ed7e5..792ae2fa 100755 --- a/lib/worker.sh +++ b/lib/worker.sh @@ -483,6 +483,7 @@ function RunTestCases() { TestCodebase "PROTOBUF" "protolint" "protolint lint --config_path $PROTOBUF_LINTER_RULES" ".*\.\(proto\)\$" "protobuf" TestCodebase "OPENAPI" "spectral" "spectral lint -r $OPENAPI_LINTER_RULES" ".*\.\(ymlopenapi\|jsonopenapi\)\$" "openapi" TestCodebase "HTML" "htmlhint" "htmlhint --config $HTML_LINTER_RULES" ".*\.\(html\)\$" "html" + TestCodebase "GROOVY" "npm-groovy-lint" "npm-groovy-lint -c $GROOVY_LINTER_RULES -f" ".*\.\(groovy\|jenkinsfile\|gradle\)\$" "groovy" ################# # Footer prints # From c4647a283f395dc837fd51d17e22129237b745ce Mon Sep 17 00:00:00 2001 From: Lucas Gravley <29484535+admiralAwkbar@users.noreply.github.com> Date: Tue, 14 Jul 2020 09:47:54 -0500 Subject: [PATCH 002/135] adding the templates --- .github/linters/.groovylintrc.json | 65 ++++++++++++++++++++++++++++++ TEMPLATES/.groovylintrc.json | 65 ++++++++++++++++++++++++++++++ 2 files changed, 130 insertions(+) create mode 100644 .github/linters/.groovylintrc.json create mode 100644 TEMPLATES/.groovylintrc.json diff --git a/.github/linters/.groovylintrc.json b/.github/linters/.groovylintrc.json new file mode 100644 index 00000000..474f8151 --- /dev/null +++ b/.github/linters/.groovylintrc.json @@ -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 + } + } +} diff --git a/TEMPLATES/.groovylintrc.json b/TEMPLATES/.groovylintrc.json new file mode 100644 index 00000000..474f8151 --- /dev/null +++ b/TEMPLATES/.groovylintrc.json @@ -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 + } + } +} From 995048321e148475664efdbe2b4321695ccc63cf Mon Sep 17 00:00:00 2001 From: Lucas Gravley <29484535+admiralAwkbar@users.noreply.github.com> Date: Tue, 14 Jul 2020 11:48:31 -0500 Subject: [PATCH 003/135] fixed parse --- Dockerfile | 4 ++-- lib/linter.sh | 2 +- lib/worker.sh | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Dockerfile b/Dockerfile index 4088461c..1ff70db5 100644 --- a/Dockerfile +++ b/Dockerfile @@ -37,7 +37,7 @@ ARG RAKUBREW_HOME=/tmp/rakubrew #################### # Run APK installs # #################### -RUN apk add --no-cache \ +RUN apk add --update --no-cache \ ansible-lint \ bash \ curl \ @@ -50,7 +50,7 @@ RUN apk add --no-cache \ make \ musl-dev \ npm \ - nodejs \ + nodejs-current \ openjdk8-jre \ perl \ php7 \ diff --git a/lib/linter.sh b/lib/linter.sh index 15424722..19715716 100755 --- a/lib/linter.sh +++ b/lib/linter.sh @@ -1071,7 +1071,7 @@ if [ "$VALIDATE_GROOVY" == "true" ]; then # Lint the groovy files # ######################### # LintCodebase "FILE_TYPE" "LINTER_NAME" "LINTER_CMD" "FILE_TYPES_REGEX" "FILE_ARRAY" - LintCodebase "GROOVY" "npm-groovy-lint" "npm-groovy-lint -c $GROOVY_LINTER_RULES -f" ".*\.\(groovy\|jenkinsfile\|gradle\)\$" "${FILE_ARRAY_GROOVY[@]}" + LintCodebase "GROOVY" "npm-groovy-lint" "npm-groovy-lint -c $GROOVY_LINTER_RULES -s" ".*\.\(groovy\|jenkinsfile\|gradle\)\$" "${FILE_ARRAY_GROOVY[@]}" fi ##################### diff --git a/lib/worker.sh b/lib/worker.sh index 792ae2fa..a1744219 100755 --- a/lib/worker.sh +++ b/lib/worker.sh @@ -483,7 +483,7 @@ function RunTestCases() { TestCodebase "PROTOBUF" "protolint" "protolint lint --config_path $PROTOBUF_LINTER_RULES" ".*\.\(proto\)\$" "protobuf" TestCodebase "OPENAPI" "spectral" "spectral lint -r $OPENAPI_LINTER_RULES" ".*\.\(ymlopenapi\|jsonopenapi\)\$" "openapi" TestCodebase "HTML" "htmlhint" "htmlhint --config $HTML_LINTER_RULES" ".*\.\(html\)\$" "html" - TestCodebase "GROOVY" "npm-groovy-lint" "npm-groovy-lint -c $GROOVY_LINTER_RULES -f" ".*\.\(groovy\|jenkinsfile\|gradle\)\$" "groovy" + TestCodebase "GROOVY" "npm-groovy-lint" "npm-groovy-lint -c $GROOVY_LINTER_RULES -s" ".*\.\(groovy\|jenkinsfile\|gradle\)\$" "groovy" ################# # Footer prints # From b191b0ed0b5a4499d204b17a2368a8237937cf13 Mon Sep 17 00:00:00 2001 From: Lucas Gravley <29484535+admiralAwkbar@users.noreply.github.com> Date: Tue, 21 Jul 2020 13:48:50 -0500 Subject: [PATCH 004/135] Adding states linter: --- dependencies/Gemfile.lock | 2 +- dependencies/package-lock.json | 1413 +++++++++++++++++--------------- dependencies/package.json | 4 +- 3 files changed, 750 insertions(+), 669 deletions(-) diff --git a/dependencies/Gemfile.lock b/dependencies/Gemfile.lock index 12f9f0d7..9df0518b 100644 --- a/dependencies/Gemfile.lock +++ b/dependencies/Gemfile.lock @@ -9,7 +9,7 @@ GEM zeitwerk (~> 2.2, >= 2.2.2) ast (2.4.1) concurrent-ruby (1.1.6) - i18n (1.8.3) + i18n (1.8.4) concurrent-ruby (~> 1.0) jaro_winkler (1.5.4) minitest (5.14.1) diff --git a/dependencies/package-lock.json b/dependencies/package-lock.json index cb0600bd..06703cc7 100644 --- a/dependencies/package-lock.json +++ b/dependencies/package-lock.json @@ -4,210 +4,280 @@ "lockfileVersion": 1, "dependencies": { "@babel/code-frame": { - "version": "7.10.3", - "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.10.3.tgz", - "integrity": "sha512-fDx9eNW0qz0WkUeqL6tXEXzVlPh6Y5aCDEZesl0xBGA8ndRukX91Uk44ZqnkECp01NAZUdCAl+aiQNGi0k88Eg==", + "version": "7.10.4", + "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.10.4.tgz", + "integrity": "sha512-vG6SvB6oYEhvgisZNFRmRCUkLz11c7rp+tbNTynGqc6mS1d5ATd/sGyV6W0KZZnXRKMTzZDRgQT3Ou9jhpAfUg==", "requires": { - "@babel/highlight": "^7.10.3" + "@babel/highlight": "^7.10.4" } }, "@babel/core": { - "version": "7.10.3", - "resolved": "https://registry.npmjs.org/@babel/core/-/core-7.10.3.tgz", - "integrity": "sha512-5YqWxYE3pyhIi84L84YcwjeEgS+fa7ZjK6IBVGTjDVfm64njkR2lfDhVR5OudLk8x2GK59YoSyVv+L/03k1q9w==", + "version": "7.10.5", + "resolved": "https://registry.npmjs.org/@babel/core/-/core-7.10.5.tgz", + "integrity": "sha512-O34LQooYVDXPl7QWCdW9p4NR+QlzOr7xShPPJz8GsuCU3/8ua/wqTr7gmnxXv+WBESiGU/G5s16i6tUvHkNb+w==", "requires": { - "@babel/code-frame": "^7.10.3", - "@babel/generator": "^7.10.3", - "@babel/helper-module-transforms": "^7.10.1", - "@babel/helpers": "^7.10.1", - "@babel/parser": "^7.10.3", - "@babel/template": "^7.10.3", - "@babel/traverse": "^7.10.3", - "@babel/types": "^7.10.3", + "@babel/code-frame": "^7.10.4", + "@babel/generator": "^7.10.5", + "@babel/helper-module-transforms": "^7.10.5", + "@babel/helpers": "^7.10.4", + "@babel/parser": "^7.10.5", + "@babel/template": "^7.10.4", + "@babel/traverse": "^7.10.5", + "@babel/types": "^7.10.5", "convert-source-map": "^1.7.0", "debug": "^4.1.0", "gensync": "^1.0.0-beta.1", "json5": "^2.1.2", - "lodash": "^4.17.13", + "lodash": "^4.17.19", "resolve": "^1.3.2", "semver": "^5.4.1", "source-map": "^0.5.0" }, "dependencies": { + "lodash": { + "version": "4.17.19", + "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.19.tgz", + "integrity": "sha512-JNvd8XER9GQX0v2qJgsaN/mzFCNA5BRe/j8JN9d+tWyGLSodKQHKFicdwNYzWwI3wjRnaKPsGj1XkBjx/F96DQ==" + }, "semver": { "version": "5.7.1", "resolved": "https://registry.npmjs.org/semver/-/semver-5.7.1.tgz", "integrity": "sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ==" + }, + "source-map": { + "version": "0.5.7", + "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.5.7.tgz", + "integrity": "sha1-igOdLRAh0i0eoUyA2OpGi6LvP8w=" } } }, "@babel/generator": { - "version": "7.10.3", - "resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.10.3.tgz", - "integrity": "sha512-drt8MUHbEqRzNR0xnF8nMehbY11b1SDkRw03PSNH/3Rb2Z35oxkddVSi3rcaak0YJQ86PCuE7Qx1jSFhbLNBMA==", + "version": "7.10.5", + "resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.10.5.tgz", + "integrity": "sha512-3vXxr3FEW7E7lJZiWQ3bM4+v/Vyr9C+hpolQ8BGFr9Y8Ri2tFLWTixmwKBafDujO1WVah4fhZBeU1bieKdghig==", "requires": { - "@babel/types": "^7.10.3", + "@babel/types": "^7.10.5", "jsesc": "^2.5.1", - "lodash": "^4.17.13", "source-map": "^0.5.0" + }, + "dependencies": { + "source-map": { + "version": "0.5.7", + "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.5.7.tgz", + "integrity": "sha1-igOdLRAh0i0eoUyA2OpGi6LvP8w=" + } } }, "@babel/helper-function-name": { - "version": "7.10.3", - "resolved": "https://registry.npmjs.org/@babel/helper-function-name/-/helper-function-name-7.10.3.tgz", - "integrity": "sha512-FvSj2aiOd8zbeqijjgqdMDSyxsGHaMt5Tr0XjQsGKHD3/1FP3wksjnLAWzxw7lvXiej8W1Jt47SKTZ6upQNiRw==", + "version": "7.10.4", + "resolved": "https://registry.npmjs.org/@babel/helper-function-name/-/helper-function-name-7.10.4.tgz", + "integrity": "sha512-YdaSyz1n8gY44EmN7x44zBn9zQ1Ry2Y+3GTA+3vH6Mizke1Vw0aWDM66FOYEPw8//qKkmqOckrGgTYa+6sceqQ==", "requires": { - "@babel/helper-get-function-arity": "^7.10.3", - "@babel/template": "^7.10.3", - "@babel/types": "^7.10.3" + "@babel/helper-get-function-arity": "^7.10.4", + "@babel/template": "^7.10.4", + "@babel/types": "^7.10.4" } }, "@babel/helper-get-function-arity": { - "version": "7.10.3", - "resolved": "https://registry.npmjs.org/@babel/helper-get-function-arity/-/helper-get-function-arity-7.10.3.tgz", - "integrity": "sha512-iUD/gFsR+M6uiy69JA6fzM5seno8oE85IYZdbVVEuQaZlEzMO2MXblh+KSPJgsZAUx0EEbWXU0yJaW7C9CdAVg==", + "version": "7.10.4", + "resolved": "https://registry.npmjs.org/@babel/helper-get-function-arity/-/helper-get-function-arity-7.10.4.tgz", + "integrity": "sha512-EkN3YDB+SRDgiIUnNgcmiD361ti+AVbL3f3Henf6dqqUyr5dMsorno0lJWJuLhDhkI5sYEpgj6y9kB8AOU1I2A==", "requires": { - "@babel/types": "^7.10.3" + "@babel/types": "^7.10.4" } }, "@babel/helper-member-expression-to-functions": { - "version": "7.10.3", - "resolved": "https://registry.npmjs.org/@babel/helper-member-expression-to-functions/-/helper-member-expression-to-functions-7.10.3.tgz", - "integrity": "sha512-q7+37c4EPLSjNb2NmWOjNwj0+BOyYlssuQ58kHEWk1Z78K5i8vTUsteq78HMieRPQSl/NtpQyJfdjt3qZ5V2vw==", + "version": "7.10.5", + "resolved": "https://registry.npmjs.org/@babel/helper-member-expression-to-functions/-/helper-member-expression-to-functions-7.10.5.tgz", + "integrity": "sha512-HiqJpYD5+WopCXIAbQDG0zye5XYVvcO9w/DHp5GsaGkRUaamLj2bEtu6i8rnGGprAhHM3qidCMgp71HF4endhA==", "requires": { - "@babel/types": "^7.10.3" + "@babel/types": "^7.10.5" } }, "@babel/helper-module-imports": { - "version": "7.10.3", - "resolved": "https://registry.npmjs.org/@babel/helper-module-imports/-/helper-module-imports-7.10.3.tgz", - "integrity": "sha512-Jtqw5M9pahLSUWA+76nhK9OG8nwYXzhQzVIGFoNaHnXF/r4l7kz4Fl0UAW7B6mqC5myoJiBP5/YQlXQTMfHI9w==", + "version": "7.10.4", + "resolved": "https://registry.npmjs.org/@babel/helper-module-imports/-/helper-module-imports-7.10.4.tgz", + "integrity": "sha512-nEQJHqYavI217oD9+s5MUBzk6x1IlvoS9WTPfgG43CbMEeStE0v+r+TucWdx8KFGowPGvyOkDT9+7DHedIDnVw==", "requires": { - "@babel/types": "^7.10.3" + "@babel/types": "^7.10.4" } }, "@babel/helper-module-transforms": { - "version": "7.10.1", - "resolved": "https://registry.npmjs.org/@babel/helper-module-transforms/-/helper-module-transforms-7.10.1.tgz", - "integrity": "sha512-RLHRCAzyJe7Q7sF4oy2cB+kRnU4wDZY/H2xJFGof+M+SJEGhZsb+GFj5j1AD8NiSaVBJ+Pf0/WObiXu/zxWpFg==", + "version": "7.10.5", + "resolved": "https://registry.npmjs.org/@babel/helper-module-transforms/-/helper-module-transforms-7.10.5.tgz", + "integrity": "sha512-4P+CWMJ6/j1W915ITJaUkadLObmCRRSC234uctJfn/vHrsLNxsR8dwlcXv9ZhJWzl77awf+mWXSZEKt5t0OnlA==", "requires": { - "@babel/helper-module-imports": "^7.10.1", - "@babel/helper-replace-supers": "^7.10.1", - "@babel/helper-simple-access": "^7.10.1", - "@babel/helper-split-export-declaration": "^7.10.1", - "@babel/template": "^7.10.1", - "@babel/types": "^7.10.1", - "lodash": "^4.17.13" + "@babel/helper-module-imports": "^7.10.4", + "@babel/helper-replace-supers": "^7.10.4", + "@babel/helper-simple-access": "^7.10.4", + "@babel/helper-split-export-declaration": "^7.10.4", + "@babel/template": "^7.10.4", + "@babel/types": "^7.10.5", + "lodash": "^4.17.19" + }, + "dependencies": { + "lodash": { + "version": "4.17.19", + "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.19.tgz", + "integrity": "sha512-JNvd8XER9GQX0v2qJgsaN/mzFCNA5BRe/j8JN9d+tWyGLSodKQHKFicdwNYzWwI3wjRnaKPsGj1XkBjx/F96DQ==" + } } }, "@babel/helper-optimise-call-expression": { - "version": "7.10.3", - "resolved": "https://registry.npmjs.org/@babel/helper-optimise-call-expression/-/helper-optimise-call-expression-7.10.3.tgz", - "integrity": "sha512-kT2R3VBH/cnSz+yChKpaKRJQJWxdGoc6SjioRId2wkeV3bK0wLLioFpJROrX0U4xr/NmxSSAWT/9Ih5snwIIzg==", + "version": "7.10.4", + "resolved": "https://registry.npmjs.org/@babel/helper-optimise-call-expression/-/helper-optimise-call-expression-7.10.4.tgz", + "integrity": "sha512-n3UGKY4VXwXThEiKrgRAoVPBMqeoPgHVqiHZOanAJCG9nQUL2pLRQirUzl0ioKclHGpGqRgIOkgcIJaIWLpygg==", "requires": { - "@babel/types": "^7.10.3" + "@babel/types": "^7.10.4" } }, "@babel/helper-replace-supers": { - "version": "7.10.1", - "resolved": "https://registry.npmjs.org/@babel/helper-replace-supers/-/helper-replace-supers-7.10.1.tgz", - "integrity": "sha512-SOwJzEfpuQwInzzQJGjGaiG578UYmyi2Xw668klPWV5n07B73S0a9btjLk/52Mlcxa+5AdIYqws1KyXRfMoB7A==", + "version": "7.10.4", + "resolved": "https://registry.npmjs.org/@babel/helper-replace-supers/-/helper-replace-supers-7.10.4.tgz", + "integrity": "sha512-sPxZfFXocEymYTdVK1UNmFPBN+Hv5mJkLPsYWwGBxZAxaWfFu+xqp7b6qWD0yjNuNL2VKc6L5M18tOXUP7NU0A==", "requires": { - "@babel/helper-member-expression-to-functions": "^7.10.1", - "@babel/helper-optimise-call-expression": "^7.10.1", - "@babel/traverse": "^7.10.1", - "@babel/types": "^7.10.1" + "@babel/helper-member-expression-to-functions": "^7.10.4", + "@babel/helper-optimise-call-expression": "^7.10.4", + "@babel/traverse": "^7.10.4", + "@babel/types": "^7.10.4" } }, "@babel/helper-simple-access": { - "version": "7.10.1", - "resolved": "https://registry.npmjs.org/@babel/helper-simple-access/-/helper-simple-access-7.10.1.tgz", - "integrity": "sha512-VSWpWzRzn9VtgMJBIWTZ+GP107kZdQ4YplJlCmIrjoLVSi/0upixezHCDG8kpPVTBJpKfxTH01wDhh+jS2zKbw==", + "version": "7.10.4", + "resolved": "https://registry.npmjs.org/@babel/helper-simple-access/-/helper-simple-access-7.10.4.tgz", + "integrity": "sha512-0fMy72ej/VEvF8ULmX6yb5MtHG4uH4Dbd6I/aHDb/JVg0bbivwt9Wg+h3uMvX+QSFtwr5MeItvazbrc4jtRAXw==", "requires": { - "@babel/template": "^7.10.1", - "@babel/types": "^7.10.1" + "@babel/template": "^7.10.4", + "@babel/types": "^7.10.4" } }, "@babel/helper-split-export-declaration": { - "version": "7.10.1", - "resolved": "https://registry.npmjs.org/@babel/helper-split-export-declaration/-/helper-split-export-declaration-7.10.1.tgz", - "integrity": "sha512-UQ1LVBPrYdbchNhLwj6fetj46BcFwfS4NllJo/1aJsT+1dLTEnXJL0qHqtY7gPzF8S2fXBJamf1biAXV3X077g==", + "version": "7.10.4", + "resolved": "https://registry.npmjs.org/@babel/helper-split-export-declaration/-/helper-split-export-declaration-7.10.4.tgz", + "integrity": "sha512-pySBTeoUff56fL5CBU2hWm9TesA4r/rOkI9DyJLvvgz09MB9YtfIYe3iBriVaYNaPe+Alua0vBIOVOLs2buWhg==", "requires": { - "@babel/types": "^7.10.1" + "@babel/types": "^7.10.4" } }, "@babel/helper-validator-identifier": { - "version": "7.10.3", - "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.10.3.tgz", - "integrity": "sha512-bU8JvtlYpJSBPuj1VUmKpFGaDZuLxASky3LhaKj3bmpSTY6VWooSM8msk+Z0CZoErFye2tlABF6yDkT3FOPAXw==" + "version": "7.10.4", + "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.10.4.tgz", + "integrity": "sha512-3U9y+43hz7ZM+rzG24Qe2mufW5KhvFg/NhnNph+i9mgCtdTCtMJuI1TMkrIUiK7Ix4PYlRF9I5dhqaLYA/ADXw==" }, "@babel/helpers": { - "version": "7.10.1", - "resolved": "https://registry.npmjs.org/@babel/helpers/-/helpers-7.10.1.tgz", - "integrity": "sha512-muQNHF+IdU6wGgkaJyhhEmI54MOZBKsFfsXFhboz1ybwJ1Kl7IHlbm2a++4jwrmY5UYsgitt5lfqo1wMFcHmyw==", + "version": "7.10.4", + "resolved": "https://registry.npmjs.org/@babel/helpers/-/helpers-7.10.4.tgz", + "integrity": "sha512-L2gX/XeUONeEbI78dXSrJzGdz4GQ+ZTA/aazfUsFaWjSe95kiCuOZ5HsXvkiw3iwF+mFHSRUfJU8t6YavocdXA==", "requires": { - "@babel/template": "^7.10.1", - "@babel/traverse": "^7.10.1", - "@babel/types": "^7.10.1" + "@babel/template": "^7.10.4", + "@babel/traverse": "^7.10.4", + "@babel/types": "^7.10.4" } }, "@babel/highlight": { - "version": "7.10.3", - "resolved": "https://registry.npmjs.org/@babel/highlight/-/highlight-7.10.3.tgz", - "integrity": "sha512-Ih9B/u7AtgEnySE2L2F0Xm0GaM729XqqLfHkalTsbjXGyqmf/6M0Cu0WpvqueUlW+xk88BHw9Nkpj49naU+vWw==", + "version": "7.10.4", + "resolved": "https://registry.npmjs.org/@babel/highlight/-/highlight-7.10.4.tgz", + "integrity": "sha512-i6rgnR/YgPEQzZZnbTHHuZdlE8qyoBNalD6F+q4vAFlcMEcqmkoG+mPqJYJCo63qPf74+Y1UZsl3l6f7/RIkmA==", "requires": { - "@babel/helper-validator-identifier": "^7.10.3", + "@babel/helper-validator-identifier": "^7.10.4", "chalk": "^2.0.0", "js-tokens": "^4.0.0" + }, + "dependencies": { + "ansi-styles": { + "version": "3.2.1", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.1.tgz", + "integrity": "sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==", + "requires": { + "color-convert": "^1.9.0" + } + }, + "chalk": { + "version": "2.4.2", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.2.tgz", + "integrity": "sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ==", + "requires": { + "ansi-styles": "^3.2.1", + "escape-string-regexp": "^1.0.5", + "supports-color": "^5.3.0" + } + }, + "color-convert": { + "version": "1.9.3", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.3.tgz", + "integrity": "sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg==", + "requires": { + "color-name": "1.1.3" + } + }, + "color-name": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.3.tgz", + "integrity": "sha1-p9BVi9icQveV3UIyj3QIMcpTvCU=" + } } }, "@babel/parser": { - "version": "7.10.3", - "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.10.3.tgz", - "integrity": "sha512-oJtNJCMFdIMwXGmx+KxuaD7i3b8uS7TTFYW/FNG2BT8m+fmGHoiPYoH0Pe3gya07WuFmM5FCDIr1x0irkD/hyA==" + "version": "7.10.5", + "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.10.5.tgz", + "integrity": "sha512-wfryxy4bE1UivvQKSQDU4/X6dr+i8bctjUjj8Zyt3DQy7NtPizJXT8M52nqpNKL+nq2PW8lxk4ZqLj0fD4B4hQ==" }, "@babel/runtime": { - "version": "7.10.4", - "resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.10.4.tgz", - "integrity": "sha512-UpTN5yUJr9b4EX2CnGNWIvER7Ab83ibv0pcvvHc4UOdrBI5jb8bj+32cCwPX6xu0mt2daFNjYhoi+X7beH0RSw==", + "version": "7.10.5", + "resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.10.5.tgz", + "integrity": "sha512-otddXKhdNn7d0ptoFRHtMLa8LqDxLYwTjB4nYgM1yy5N6gU/MUf8zqyyLltCH3yAVitBzmwK4us+DD0l/MauAg==", "requires": { "regenerator-runtime": "^0.13.4" } }, "@babel/template": { - "version": "7.10.3", - "resolved": "https://registry.npmjs.org/@babel/template/-/template-7.10.3.tgz", - "integrity": "sha512-5BjI4gdtD+9fHZUsaxPHPNpwa+xRkDO7c7JbhYn2afvrkDu5SfAAbi9AIMXw2xEhO/BR35TqiW97IqNvCo/GqA==", + "version": "7.10.4", + "resolved": "https://registry.npmjs.org/@babel/template/-/template-7.10.4.tgz", + "integrity": "sha512-ZCjD27cGJFUB6nmCB1Enki3r+L5kJveX9pq1SvAUKoICy6CZ9yD8xO086YXdYhvNjBdnekm4ZnaP5yC8Cs/1tA==", "requires": { - "@babel/code-frame": "^7.10.3", - "@babel/parser": "^7.10.3", - "@babel/types": "^7.10.3" + "@babel/code-frame": "^7.10.4", + "@babel/parser": "^7.10.4", + "@babel/types": "^7.10.4" } }, "@babel/traverse": { - "version": "7.10.3", - "resolved": "https://registry.npmjs.org/@babel/traverse/-/traverse-7.10.3.tgz", - "integrity": "sha512-qO6623eBFhuPm0TmmrUFMT1FulCmsSeJuVGhiLodk2raUDFhhTECLd9E9jC4LBIWziqt4wgF6KuXE4d+Jz9yug==", + "version": "7.10.5", + "resolved": "https://registry.npmjs.org/@babel/traverse/-/traverse-7.10.5.tgz", + "integrity": "sha512-yc/fyv2gUjPqzTz0WHeRJH2pv7jA9kA7mBX2tXl/x5iOE81uaVPuGPtaYk7wmkx4b67mQ7NqI8rmT2pF47KYKQ==", "requires": { - "@babel/code-frame": "^7.10.3", - "@babel/generator": "^7.10.3", - "@babel/helper-function-name": "^7.10.3", - "@babel/helper-split-export-declaration": "^7.10.1", - "@babel/parser": "^7.10.3", - "@babel/types": "^7.10.3", + "@babel/code-frame": "^7.10.4", + "@babel/generator": "^7.10.5", + "@babel/helper-function-name": "^7.10.4", + "@babel/helper-split-export-declaration": "^7.10.4", + "@babel/parser": "^7.10.5", + "@babel/types": "^7.10.5", "debug": "^4.1.0", "globals": "^11.1.0", - "lodash": "^4.17.13" + "lodash": "^4.17.19" + }, + "dependencies": { + "lodash": { + "version": "4.17.19", + "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.19.tgz", + "integrity": "sha512-JNvd8XER9GQX0v2qJgsaN/mzFCNA5BRe/j8JN9d+tWyGLSodKQHKFicdwNYzWwI3wjRnaKPsGj1XkBjx/F96DQ==" + } } }, "@babel/types": { - "version": "7.10.3", - "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.10.3.tgz", - "integrity": "sha512-nZxaJhBXBQ8HVoIcGsf9qWep3Oh3jCENK54V4mRF7qaJabVsAYdbTtmSD8WmAp1R6ytPiu5apMwSXyxB1WlaBA==", + "version": "7.10.5", + "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.10.5.tgz", + "integrity": "sha512-ixV66KWfCI6GKoA/2H9v6bQdbfXEwwpOdQ8cRvb4F+eyvhlaHxWFMQB4+3d9QFJXZsiiiqVrewNV0DFEQpyT4Q==", "requires": { - "@babel/helper-validator-identifier": "^7.10.3", - "lodash": "^4.17.13", + "@babel/helper-validator-identifier": "^7.10.4", + "lodash": "^4.17.19", "to-fast-properties": "^2.0.0" + }, + "dependencies": { + "lodash": { + "version": "4.17.19", + "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.19.tgz", + "integrity": "sha512-JNvd8XER9GQX0v2qJgsaN/mzFCNA5BRe/j8JN9d+tWyGLSodKQHKFicdwNYzWwI3wjRnaKPsGj1XkBjx/F96DQ==" + } } }, "@coffeelint/cli": { @@ -221,31 +291,6 @@ "resolve": "^1.17.0", "strip-json-comments": "^3.1.1", "yargs": "^15.4.1" - }, - "dependencies": { - "strip-json-comments": { - "version": "3.1.1", - "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-3.1.1.tgz", - "integrity": "sha512-6fPc+R4ihwqP6N/aIv2f1gMH8lOVtWQHoqC4yK6oSDVVocumAsfCqjkXnqiYMhmMwS/mEHLp7Vehlt3ql6lEig==" - }, - "yargs": { - "version": "15.4.1", - "resolved": "https://registry.npmjs.org/yargs/-/yargs-15.4.1.tgz", - "integrity": "sha512-aePbxDmcYW++PaqBsJ+HYUFwCdv4LVvdnhBy78E57PIor8/OVvhMrADFFEDh8DHDFRv/O9i3lPhsENjO7QX0+A==", - "requires": { - "cliui": "^6.0.0", - "decamelize": "^1.2.0", - "find-up": "^4.1.0", - "get-caller-file": "^2.0.1", - "require-directory": "^2.1.1", - "require-main-filename": "^2.0.0", - "set-blocking": "^2.0.0", - "string-width": "^4.2.0", - "which-module": "^2.0.0", - "y18n": "^4.0.0", - "yargs-parser": "^18.1.2" - } - } } }, "@nodelib/fs.scandir": { @@ -352,44 +397,23 @@ "yargs": "15.3.1" }, "dependencies": { - "chalk": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.0.0.tgz", - "integrity": "sha512-N9oWFcegS0sFr9oh1oz2d7Npos6vNoWW9HvtCg5N1KRFpUhaAhvTv5Y58g880fZaEYSNm3qDz8SU1UrGvp+n7A==", + "yargs": { + "version": "15.3.1", + "resolved": "https://registry.npmjs.org/yargs/-/yargs-15.3.1.tgz", + "integrity": "sha512-92O1HWEjw27sBfgmXiixJWT5hRBp2eobqXicLtPBIDBhYB+1HpwZlXmbW2luivBJHBzki+7VyCLRtAkScbTBQA==", "requires": { - "ansi-styles": "^4.1.0", - "supports-color": "^7.1.0" + "cliui": "^6.0.0", + "decamelize": "^1.2.0", + "find-up": "^4.1.0", + "get-caller-file": "^2.0.1", + "require-directory": "^2.1.1", + "require-main-filename": "^2.0.0", + "set-blocking": "^2.0.0", + "string-width": "^4.2.0", + "which-module": "^2.0.0", + "y18n": "^4.0.0", + "yargs-parser": "^18.1.1" } - }, - "fast-glob": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/fast-glob/-/fast-glob-3.1.0.tgz", - "integrity": "sha512-TrUz3THiq2Vy3bjfQUB2wNyPdGBeGmdjbzzBLhfHN4YFurYptCKwGq/TfiRavbGywFRzY6U2CdmQ1zmsY5yYaw==", - "requires": { - "@nodelib/fs.stat": "^2.0.2", - "@nodelib/fs.walk": "^1.2.3", - "glob-parent": "^5.1.0", - "merge2": "^1.3.0", - "micromatch": "^4.0.2" - } - }, - "has-flag": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", - "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==" - }, - "supports-color": { - "version": "7.1.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.1.0.tgz", - "integrity": "sha512-oRSIpR8pxT1Wr2FquTNnGet79b3BWljqOuoW/h4oBhxJ/HUbX5nX6JSruTkvXDCFMwDPvsaTTbvMLKZWSy0R5g==", - "requires": { - "has-flag": "^4.0.0" - } - }, - "tslib": { - "version": "1.11.1", - "resolved": "https://registry.npmjs.org/tslib/-/tslib-1.11.1.tgz", - "integrity": "sha512-aZW88SY8kQbU7gpV19lN24LtXh/yD4ZZg6qieAJDDg+YBsJcSmLGK9QpnUjAKVG/xefmvJGd1WUmfpT/g6AJGA==" } } }, @@ -418,9 +442,9 @@ "integrity": "sha512-PdY8p2Ufgtorf4d2DbKMfknILMa8KwuyyMMR/2lgK1mLaU8F5PKWYc+h9hIzC+ar0bh7m9h2rINo32m7ADfVyA==" }, "@stylelint/postcss-css-in-js": { - "version": "0.37.1", - "resolved": "https://registry.npmjs.org/@stylelint/postcss-css-in-js/-/postcss-css-in-js-0.37.1.tgz", - "integrity": "sha512-UMf2Rni3JGKi3ZwYRGMYJ5ipOA5ENJSKMtYA/pE1ZLURwdh7B5+z2r73RmWvub+N0UuH1Lo+TGfCgYwPvqpXNw==", + "version": "0.37.2", + "resolved": "https://registry.npmjs.org/@stylelint/postcss-css-in-js/-/postcss-css-in-js-0.37.2.tgz", + "integrity": "sha512-nEhsFoJurt8oUmieT8qy4nk81WRHmJynmVwn/Vts08PL9fhgIsMhk1GId5yAN643OzqEEb5S/6At2TZW7pqPDA==", "requires": { "@babel/core": ">=7.9.0" } @@ -499,18 +523,6 @@ "eslint-utils": "^2.0.0" } }, - "@typescript-eslint/experimental-utils": { - "version": "3.7.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/experimental-utils/-/experimental-utils-3.7.0.tgz", - "integrity": "sha512-xpfXXAfZqhhqs5RPQBfAFrWDHoNxD5+sVB5A46TF58Bq1hRfVROrWHcQHHUM9aCBdy9+cwATcvCbRg8aIRbaHQ==", - "requires": { - "@types/json-schema": "^7.0.3", - "@typescript-eslint/types": "3.7.0", - "@typescript-eslint/typescript-estree": "3.7.0", - "eslint-scope": "^5.0.0", - "eslint-utils": "^2.0.0" - } - }, "@typescript-eslint/parser": { "version": "3.7.0", "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-3.7.0.tgz", @@ -551,34 +563,6 @@ "eslint-visitor-keys": "^1.1.0" } }, - "@typescript-eslint/types": { - "version": "3.7.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-3.7.0.tgz", - "integrity": "sha512-reCaK+hyKkKF+itoylAnLzFeNYAEktB0XVfSQvf0gcVgpz1l49Lt6Vo9x4MVCCxiDydA0iLAjTF/ODH0pbfnpg==" - }, - "@typescript-eslint/typescript-estree": { - "version": "3.7.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-3.7.0.tgz", - "integrity": "sha512-xr5oobkYRebejlACGr1TJ0Z/r0a2/HUf0SXqPvlgUMwiMqOCu/J+/Dr9U3T0IxpE5oLFSkqMx1FE/dKaZ8KsOQ==", - "requires": { - "@typescript-eslint/types": "3.7.0", - "@typescript-eslint/visitor-keys": "3.7.0", - "debug": "^4.1.1", - "glob": "^7.1.6", - "is-glob": "^4.0.1", - "lodash": "^4.17.15", - "semver": "^7.3.2", - "tsutils": "^3.17.1" - } - }, - "@typescript-eslint/visitor-keys": { - "version": "3.7.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-3.7.0.tgz", - "integrity": "sha512-k5PiZdB4vklUpUX4NBncn5RBKty8G3ihTY+hqJsCdMuD0v4jofI5xuqwnVcWxfv6iTm2P/dfEa2wMUnsUY8ODw==", - "requires": { - "eslint-visitor-keys": "^1.1.0" - } - }, "JSV": { "version": "4.0.2", "resolved": "https://registry.npmjs.org/JSV/-/JSV-4.0.2.tgz", @@ -691,6 +675,16 @@ "resolved": "https://registry.npmjs.org/arrify/-/arrify-2.0.1.tgz", "integrity": "sha512-3duEwti880xqi4eAMN8AyR4a0ByT90zoYdLlevfrvU43vb0YZwZVfxOgxWrLXXXpyugL0hNZc9G6BiB5B3nUug==" }, + "asl-validator": { + "version": "1.7.0", + "resolved": "https://registry.npmjs.org/asl-validator/-/asl-validator-1.7.0.tgz", + "integrity": "sha512-63vmNSjb8HV5Ln43lBCEtN+1RoBX9ZMfeJrNTesNsLjfsan9H8Gdvy+Rjnk21QpvS9+j0uyefNqfWBL4qGt4Jw==", + "requires": { + "ajv": "^6.12.2", + "commander": "^5.1.0", + "jsonpath": "^1.0.2" + } + }, "asn1": { "version": "0.2.4", "resolved": "https://registry.npmjs.org/asn1/-/asn1-0.2.4.tgz", @@ -725,12 +719,12 @@ "integrity": "sha1-x57Zf380y48robyXkLzDZkdLS3k=" }, "autoprefixer": { - "version": "9.8.4", - "resolved": "https://registry.npmjs.org/autoprefixer/-/autoprefixer-9.8.4.tgz", - "integrity": "sha512-84aYfXlpUe45lvmS+HoAWKCkirI/sw4JK0/bTeeqgHYco3dcsOn0NqdejISjptsYwNji/21dnkDri9PsYKk89A==", + "version": "9.8.5", + "resolved": "https://registry.npmjs.org/autoprefixer/-/autoprefixer-9.8.5.tgz", + "integrity": "sha512-C2p5KkumJlsTHoNv9w31NrBRgXhf6eCMteJuHZi2xhkgC+5Vm40MEtCKPhc0qdgAOhox0YPy1SQHTAky05UoKg==", "requires": { "browserslist": "^4.12.0", - "caniuse-lite": "^1.0.30001087", + "caniuse-lite": "^1.0.30001097", "colorette": "^1.2.0", "normalize-range": "^0.1.2", "num2fraction": "^1.2.2", @@ -791,6 +785,39 @@ "json-to-ast": "^2.0.3", "jsonpointer": "^4.0.1", "leven": "^3.1.0" + }, + "dependencies": { + "ansi-styles": { + "version": "3.2.1", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.1.tgz", + "integrity": "sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==", + "requires": { + "color-convert": "^1.9.0" + } + }, + "chalk": { + "version": "2.4.2", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.2.tgz", + "integrity": "sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ==", + "requires": { + "ansi-styles": "^3.2.1", + "escape-string-regexp": "^1.0.5", + "supports-color": "^5.3.0" + } + }, + "color-convert": { + "version": "1.9.3", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.3.tgz", + "integrity": "sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg==", + "requires": { + "color-name": "1.1.3" + } + }, + "color-name": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.3.tgz", + "integrity": "sha1-p9BVi9icQveV3UIyj3QIMcpTvCU=" + } } }, "blueimp-md5": { @@ -816,12 +843,12 @@ } }, "browserslist": { - "version": "4.12.1", - "resolved": "https://registry.npmjs.org/browserslist/-/browserslist-4.12.1.tgz", - "integrity": "sha512-WMjXwFtPskSW1pQUDJRxvRKRkeCr7usN0O/Za76N+F4oadaTdQHotSGcX9jT/Hs7mSKPkyMFNvqawB/1HzYDKQ==", + "version": "4.13.0", + "resolved": "https://registry.npmjs.org/browserslist/-/browserslist-4.13.0.tgz", + "integrity": "sha512-MINatJ5ZNrLnQ6blGvePd/QOz9Xtu+Ne+x29iQSCHfkU5BugKVJwZKn/iiL8UbpIpa3JhviKjz+XxMo0m2caFQ==", "requires": { - "caniuse-lite": "^1.0.30001088", - "electron-to-chromium": "^1.3.481", + "caniuse-lite": "^1.0.30001093", + "electron-to-chromium": "^1.3.488", "escalade": "^3.0.1", "node-releases": "^1.1.58" } @@ -852,9 +879,9 @@ } }, "caniuse-lite": { - "version": "1.0.30001088", - "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001088.tgz", - "integrity": "sha512-6eYUrlShRYveyqKG58HcyOfPgh3zb2xqs7NvT2VVtP3hEUeeWvc3lqhpeMTxYWBBeeaT9A4bKsrtjATm66BTHg==" + "version": "1.0.30001104", + "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001104.tgz", + "integrity": "sha512-pkpCg7dmI/a7WcqM2yfdOiT4Xx5tzyoHAXWsX5/HxZ3TemwDZs0QXdqbE0UPLPVy/7BeK7693YfzfRYfu1YVpg==" }, "caseless": { "version": "0.12.0", @@ -867,35 +894,26 @@ "integrity": "sha512-MOli1W+nfbPLlKEhInaxhRdp7KVLFxLN5ykwzHgLsLI3H3gs5jjFAK4Eoj3OzzcxCtumDaI8onoVDeQyWaNTkw==" }, "chalk": { - "version": "2.4.2", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.2.tgz", - "integrity": "sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ==", + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.0.0.tgz", + "integrity": "sha512-N9oWFcegS0sFr9oh1oz2d7Npos6vNoWW9HvtCg5N1KRFpUhaAhvTv5Y58g880fZaEYSNm3qDz8SU1UrGvp+n7A==", "requires": { - "ansi-styles": "^3.2.1", - "escape-string-regexp": "^1.0.5", - "supports-color": "^5.3.0" + "ansi-styles": "^4.1.0", + "supports-color": "^7.1.0" }, "dependencies": { - "ansi-styles": { - "version": "3.2.1", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.1.tgz", - "integrity": "sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==", - "requires": { - "color-convert": "^1.9.0" - } + "has-flag": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", + "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==" }, - "color-convert": { - "version": "1.9.3", - "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.3.tgz", - "integrity": "sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg==", + "supports-color": { + "version": "7.1.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.1.0.tgz", + "integrity": "sha512-oRSIpR8pxT1Wr2FquTNnGet79b3BWljqOuoW/h4oBhxJ/HUbX5nX6JSruTkvXDCFMwDPvsaTTbvMLKZWSy0R5g==", "requires": { - "color-name": "1.1.3" + "has-flag": "^4.0.0" } - }, - "color-name": { - "version": "1.1.3", - "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.3.tgz", - "integrity": "sha1-p9BVi9icQveV3UIyj3QIMcpTvCU=" } } }, @@ -994,9 +1012,9 @@ "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==" }, "colorette": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/colorette/-/colorette-1.2.0.tgz", - "integrity": "sha512-soRSroY+OF/8OdA3PTQXwaDJeMc7TfknKKrxeSCencL2a4+Tx5zhxmmv7hdpCjhKBjehzp8+bwe/T68K0hpIjw==" + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/colorette/-/colorette-1.2.1.tgz", + "integrity": "sha512-puCDz0CzydiSYOrnXpz/PKd69zRrribezjtE9yd4zvytoRc8+RY/KJPvtPFKZS3E3wP6neGyMe0vOTlHO5L3Pw==" }, "colors": { "version": "1.4.0", @@ -1012,12 +1030,9 @@ } }, "commander": { - "version": "2.9.0", - "resolved": "https://registry.npmjs.org/commander/-/commander-2.9.0.tgz", - "integrity": "sha1-nJkJQXbhIkDLItbFFGCYQA/g99Q=", - "requires": { - "graceful-readlink": ">= 1.0.0" - } + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/commander/-/commander-5.1.0.tgz", + "integrity": "sha512-P0CysNDQ7rtVw4QIQtm+MRxV66vKFSvlsQvGYXZWR3qFU0jlMKHZZZgw8e+8DSah4UDKMqnknRDQz+xuQXQ/Zg==" }, "concat-map": { "version": "0.0.1", @@ -1170,13 +1185,6 @@ "ast-types": "0.x.x", "escodegen": "1.x.x", "esprima": "3.x.x" - }, - "dependencies": { - "esprima": { - "version": "3.1.3", - "resolved": "https://registry.npmjs.org/esprima/-/esprima-3.1.3.tgz", - "integrity": "sha1-/cpRzuYTOJXjyI1TXOSdv/YqRjM=" - } } }, "deglob": { @@ -1271,15 +1279,6 @@ "wrap-ansi": "^2.0.0" } }, - "find-up": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/find-up/-/find-up-1.1.2.tgz", - "integrity": "sha1-ay6YIrGizgpgq2TWEOzK1TyyTQ8=", - "requires": { - "path-exists": "^2.0.0", - "pinkie-promise": "^2.0.0" - } - }, "get-caller-file": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/get-caller-file/-/get-caller-file-1.0.3.tgz", @@ -1293,55 +1292,6 @@ "number-is-nan": "^1.0.0" } }, - "load-json-file": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/load-json-file/-/load-json-file-1.1.0.tgz", - "integrity": "sha1-lWkFcI1YtLq0wiYbBPWfMcmTdMA=", - "requires": { - "graceful-fs": "^4.1.2", - "parse-json": "^2.2.0", - "pify": "^2.0.0", - "pinkie-promise": "^2.0.0", - "strip-bom": "^2.0.0" - } - }, - "path-exists": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-2.1.0.tgz", - "integrity": "sha1-D+tsZPD8UY2adU3V77YscCJ2H0s=", - "requires": { - "pinkie-promise": "^2.0.0" - } - }, - "path-type": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/path-type/-/path-type-1.1.0.tgz", - "integrity": "sha1-WcRPfuSR2nBNpBXaWkBwuk+P5EE=", - "requires": { - "graceful-fs": "^4.1.2", - "pify": "^2.0.0", - "pinkie-promise": "^2.0.0" - } - }, - "read-pkg": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/read-pkg/-/read-pkg-1.1.0.tgz", - "integrity": "sha1-9f+qXs0pyzHAR0vKfXVra7KePyg=", - "requires": { - "load-json-file": "^1.0.0", - "normalize-package-data": "^2.3.2", - "path-type": "^1.0.0" - } - }, - "read-pkg-up": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/read-pkg-up/-/read-pkg-up-1.0.1.tgz", - "integrity": "sha1-nWPBMnbAZZGNV/ACpX9AobZD+wI=", - "requires": { - "find-up": "^1.0.0", - "read-pkg": "^1.0.0" - } - }, "require-main-filename": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/require-main-filename/-/require-main-filename-1.0.1.tgz", @@ -1365,14 +1315,6 @@ "ansi-regex": "^2.0.0" } }, - "strip-bom": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/strip-bom/-/strip-bom-2.0.0.tgz", - "integrity": "sha1-YhmoVhZSBJHzV4i9vxRHqZx+aw4=", - "requires": { - "is-utf8": "^0.2.0" - } - }, "supports-color": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-2.0.0.tgz", @@ -1483,9 +1425,9 @@ } }, "electron-to-chromium": { - "version": "1.3.483", - "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.3.483.tgz", - "integrity": "sha512-+05RF8S9rk8S0G8eBCqBRBaRq7+UN3lDs2DAvnG8SBSgQO3hjy0+qt4CmRk5eiuGbTcaicgXfPmBi31a+BD3lg==" + "version": "1.3.502", + "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.3.502.tgz", + "integrity": "sha512-TIeXOaHAvfP7FemGUtAJxStmOc1YFGWFNqdey/4Nk41L9b1nMmDVDGNMIWhZJvOfJxix6Cv5FGEnBK+yvw3UTg==" }, "emoji-regex": { "version": "8.0.0", @@ -1560,9 +1502,9 @@ } }, "escalade": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/escalade/-/escalade-3.0.1.tgz", - "integrity": "sha512-DR6NO3h9niOT+MZs7bjxlj2a1k+POu5RN8CLTPX2+i78bRi9eLe7+0zXgUHMnGXWybYcL61E9hGhPKqedy8tQA==" + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/escalade/-/escalade-3.0.2.tgz", + "integrity": "sha512-gPYAU37hYCUhW5euPeR+Y74F7BL+IBsV93j5cvGriSaD1aG6MGsqsV1yamRdrWrb2j3aiZvb0X+UBOWpx3JWtQ==" }, "escape-string-regexp": { "version": "1.0.5", @@ -1581,46 +1523,10 @@ "source-map": "~0.6.1" }, "dependencies": { - "levn": { - "version": "0.3.0", - "resolved": "https://registry.npmjs.org/levn/-/levn-0.3.0.tgz", - "integrity": "sha1-OwmSTt+fCDwEkP3UwLxEIeBHZO4=", - "requires": { - "prelude-ls": "~1.1.2", - "type-check": "~0.3.2" - } - }, - "optionator": { - "version": "0.8.3", - "resolved": "https://registry.npmjs.org/optionator/-/optionator-0.8.3.tgz", - "integrity": "sha512-+IW9pACdk3XWmmTXG8m3upGUJst5XRGzxMRjXzAuJ1XnIFNvfhjjIuYkDvysnPQ7qzqVzLt78BCruntqRhWQbA==", - "requires": { - "deep-is": "~0.1.3", - "fast-levenshtein": "~2.0.6", - "levn": "~0.3.0", - "prelude-ls": "~1.1.2", - "type-check": "~0.3.2", - "word-wrap": "~1.2.3" - } - }, - "prelude-ls": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/prelude-ls/-/prelude-ls-1.1.2.tgz", - "integrity": "sha1-IZMqVJ9eUv/ZqCf1cOBL5iqX2lQ=" - }, - "source-map": { - "version": "0.6.1", - "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", - "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", - "optional": true - }, - "type-check": { - "version": "0.3.2", - "resolved": "https://registry.npmjs.org/type-check/-/type-check-0.3.2.tgz", - "integrity": "sha1-WITKtRLPHTVeP7eE8wgEsrUg23I=", - "requires": { - "prelude-ls": "~1.1.2" - } + "esprima": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/esprima/-/esprima-4.0.1.tgz", + "integrity": "sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A==" } } }, @@ -1667,15 +1573,6 @@ "v8-compile-cache": "^2.0.3" }, "dependencies": { - "chalk": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.0.tgz", - "integrity": "sha512-qwx12AxXe2Q5xQ43Ac//I6v5aXTipYrSESdOgzrN+9XjgEpyjpKuvSGaN4qE93f7TQTlerQQ8S+EQ0EyDoVL1A==", - "requires": { - "ansi-styles": "^4.1.0", - "supports-color": "^7.1.0" - } - }, "globals": { "version": "12.4.0", "resolved": "https://registry.npmjs.org/globals/-/globals-12.4.0.tgz", @@ -1684,27 +1581,49 @@ "type-fest": "^0.8.1" } }, - "has-flag": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", - "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==" - }, "ignore": { "version": "4.0.6", "resolved": "https://registry.npmjs.org/ignore/-/ignore-4.0.6.tgz", "integrity": "sha512-cyFDKrqc/YdcWFniJhzI42+AzS+gNwmUzOSFcRCQYwySuBBBy/KjuxWLZ/FHEH6Moq1NizMOBWyTcv8O4OZIMg==" }, + "levn": { + "version": "0.4.1", + "resolved": "https://registry.npmjs.org/levn/-/levn-0.4.1.tgz", + "integrity": "sha512-+bT2uH4E5LGE7h/n3evcS/sQlJXCpIp6ym8OWJ5eV6+67Dsql/LaaT7qJBAt2rzfoa/5QBGBhxDix1dMt2kQKQ==", + "requires": { + "prelude-ls": "^1.2.1", + "type-check": "~0.4.0" + } + }, "lodash": { "version": "4.17.19", "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.19.tgz", "integrity": "sha512-JNvd8XER9GQX0v2qJgsaN/mzFCNA5BRe/j8JN9d+tWyGLSodKQHKFicdwNYzWwI3wjRnaKPsGj1XkBjx/F96DQ==" }, - "supports-color": { - "version": "7.1.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.1.0.tgz", - "integrity": "sha512-oRSIpR8pxT1Wr2FquTNnGet79b3BWljqOuoW/h4oBhxJ/HUbX5nX6JSruTkvXDCFMwDPvsaTTbvMLKZWSy0R5g==", + "optionator": { + "version": "0.9.1", + "resolved": "https://registry.npmjs.org/optionator/-/optionator-0.9.1.tgz", + "integrity": "sha512-74RlY5FCnhq4jRxVUPKDaRwrVNXMqsGsiW6AJw4XK8hmtm10wC0ypZBLw5IIp85NZMr91+qd1RvvENwg7jjRFw==", "requires": { - "has-flag": "^4.0.0" + "deep-is": "^0.1.3", + "fast-levenshtein": "^2.0.6", + "levn": "^0.4.1", + "prelude-ls": "^1.2.1", + "type-check": "^0.4.0", + "word-wrap": "^1.2.3" + } + }, + "prelude-ls": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/prelude-ls/-/prelude-ls-1.2.1.tgz", + "integrity": "sha512-vkcDPrRZo1QZLbn5RLGPpg/WmIQ65qoWWhcGKf/b5eplkkarX0m9z8ppCat4mlOqUsWpyNuYgO3VRyrYHSzX5g==" + }, + "type-check": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/type-check/-/type-check-0.4.0.tgz", + "integrity": "sha512-XleUoc9uwGXqjWwXaUTZAmzMcFZ5858QA2vvx1Ur5xIcixXIP+8LnFDgRplU30us6teqdlskFfu+ae4K79Ooew==", + "requires": { + "prelude-ls": "^1.2.1" } } } @@ -1829,10 +1748,101 @@ "isarray": "^1.0.0" } }, + "find-up": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/find-up/-/find-up-2.1.0.tgz", + "integrity": "sha1-RdG35QbHF93UgndaK3eSCjwMV6c=", + "requires": { + "locate-path": "^2.0.0" + } + }, + "isarray": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", + "integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=" + }, + "load-json-file": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/load-json-file/-/load-json-file-2.0.0.tgz", + "integrity": "sha1-eUfkIUmvgNaWy/eXvKq8/h/inKg=", + "requires": { + "graceful-fs": "^4.1.2", + "parse-json": "^2.2.0", + "pify": "^2.0.0", + "strip-bom": "^3.0.0" + } + }, + "locate-path": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-2.0.0.tgz", + "integrity": "sha1-K1aLJl7slExtnA3pw9u7ygNUzY4=", + "requires": { + "p-locate": "^2.0.0", + "path-exists": "^3.0.0" + } + }, "ms": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=" + }, + "p-limit": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-1.3.0.tgz", + "integrity": "sha512-vvcXsLAJ9Dr5rQOPk7toZQZJApBl2K4J6dANSsEuh6QI41JYcsS/qhTGa9ErIUUgK3WNQoJYvylxvjqmiqEA9Q==", + "requires": { + "p-try": "^1.0.0" + } + }, + "p-locate": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-2.0.0.tgz", + "integrity": "sha1-IKAQOyIqcMj9OcwuWAaA893l7EM=", + "requires": { + "p-limit": "^1.1.0" + } + }, + "p-try": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/p-try/-/p-try-1.0.0.tgz", + "integrity": "sha1-y8ec26+P1CKOE/Yh8rGiN8GyB7M=" + }, + "path-exists": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-3.0.0.tgz", + "integrity": "sha1-zg6+ql94yxiSXqfYENe1mwEP1RU=" + }, + "path-type": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/path-type/-/path-type-2.0.0.tgz", + "integrity": "sha1-8BLMuEFbcJb8LaoQVMPXI4lZTHM=", + "requires": { + "pify": "^2.0.0" + } + }, + "read-pkg": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/read-pkg/-/read-pkg-2.0.0.tgz", + "integrity": "sha1-jvHAYjxqbbDcZxPEv6xGMysjaPg=", + "requires": { + "load-json-file": "^2.0.0", + "normalize-package-data": "^2.3.2", + "path-type": "^2.0.0" + } + }, + "read-pkg-up": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/read-pkg-up/-/read-pkg-up-2.0.0.tgz", + "integrity": "sha1-a3KoBImE4MQeeVEP1en6mbO1Sb4=", + "requires": { + "find-up": "^2.0.0", + "read-pkg": "^2.0.0" + } + }, + "strip-bom": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/strip-bom/-/strip-bom-3.0.0.tgz", + "integrity": "sha1-IzTBjpx1n3vdVv3vfprj1YjmjtM=" } } }, @@ -1968,9 +1978,9 @@ } }, "esprima": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/esprima/-/esprima-4.0.1.tgz", - "integrity": "sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A==" + "version": "3.1.3", + "resolved": "https://registry.npmjs.org/esprima/-/esprima-3.1.3.tgz", + "integrity": "sha1-/cpRzuYTOJXjyI1TXOSdv/YqRjM=" }, "esquery": { "version": "1.3.1", @@ -2044,16 +2054,15 @@ "integrity": "sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==" }, "fast-glob": { - "version": "3.2.4", - "resolved": "https://registry.npmjs.org/fast-glob/-/fast-glob-3.2.4.tgz", - "integrity": "sha512-kr/Oo6PX51265qeuCYsyGypiO5uJFgBS0jksyG7FUeCyQzNwYnzrNIMR1NXfkZXsMYXYLRAHgISHBz8gQcxKHQ==", + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/fast-glob/-/fast-glob-3.1.0.tgz", + "integrity": "sha512-TrUz3THiq2Vy3bjfQUB2wNyPdGBeGmdjbzzBLhfHN4YFurYptCKwGq/TfiRavbGywFRzY6U2CdmQ1zmsY5yYaw==", "requires": { "@nodelib/fs.stat": "^2.0.2", "@nodelib/fs.walk": "^1.2.3", "glob-parent": "^5.1.0", "merge2": "^1.3.0", - "micromatch": "^4.0.2", - "picomatch": "^2.2.1" + "micromatch": "^4.0.2" } }, "fast-json-stable-stringify": { @@ -2166,11 +2175,6 @@ "xregexp": "2.0.0" }, "dependencies": { - "isarray": { - "version": "0.0.1", - "resolved": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz", - "integrity": "sha1-ihis/Kmo9Bd+Cav8YDiTmwXR7t8=" - }, "readable-stream": { "version": "1.1.14", "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-1.1.14.tgz", @@ -2181,11 +2185,6 @@ "isarray": "0.0.1", "string_decoder": "~0.10.x" } - }, - "string_decoder": { - "version": "0.10.31", - "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-0.10.31.tgz", - "integrity": "sha1-YuIDvEF2bGwoyfyEMB2rHFMQ+pQ=" } } }, @@ -2239,28 +2238,6 @@ "version": "2.0.0", "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=" - }, - "readable-stream": { - "version": "2.3.7", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.7.tgz", - "integrity": "sha512-Ebho8K4jIbHAxnuxi7o42OrZgF/ZTNcsZj6nRKyUmkhLFq8CHItp/fy6hQZuZmP/n3yZ9VBUbp4zz/mX8hmYPw==", - "requires": { - "core-util-is": "~1.0.0", - "inherits": "~2.0.3", - "isarray": "~1.0.0", - "process-nextick-args": "~2.0.0", - "safe-buffer": "~5.1.1", - "string_decoder": "~1.1.1", - "util-deprecate": "~1.0.1" - } - }, - "string_decoder": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", - "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==", - "requires": { - "safe-buffer": "~5.1.0" - } } } }, @@ -2369,6 +2346,21 @@ "ignore": "^5.1.4", "merge2": "^1.3.0", "slash": "^3.0.0" + }, + "dependencies": { + "fast-glob": { + "version": "3.2.4", + "resolved": "https://registry.npmjs.org/fast-glob/-/fast-glob-3.2.4.tgz", + "integrity": "sha512-kr/Oo6PX51265qeuCYsyGypiO5uJFgBS0jksyG7FUeCyQzNwYnzrNIMR1NXfkZXsMYXYLRAHgISHBz8gQcxKHQ==", + "requires": { + "@nodelib/fs.stat": "^2.0.2", + "@nodelib/fs.walk": "^1.2.3", + "glob-parent": "^5.1.0", + "merge2": "^1.3.0", + "micromatch": "^4.0.2", + "picomatch": "^2.2.1" + } + } } }, "globjoin": { @@ -2481,32 +2473,10 @@ "xml": "1.0.1" }, "dependencies": { - "chalk": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.0.0.tgz", - "integrity": "sha512-N9oWFcegS0sFr9oh1oz2d7Npos6vNoWW9HvtCg5N1KRFpUhaAhvTv5Y58g880fZaEYSNm3qDz8SU1UrGvp+n7A==", - "requires": { - "ansi-styles": "^4.1.0", - "supports-color": "^7.1.0" - } - }, - "commander": { - "version": "5.1.0", - "resolved": "https://registry.npmjs.org/commander/-/commander-5.1.0.tgz", - "integrity": "sha512-P0CysNDQ7rtVw4QIQtm+MRxV66vKFSvlsQvGYXZWR3qFU0jlMKHZZZgw8e+8DSah4UDKMqnknRDQz+xuQXQ/Zg==" - }, - "has-flag": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", - "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==" - }, - "supports-color": { - "version": "7.1.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.1.0.tgz", - "integrity": "sha512-oRSIpR8pxT1Wr2FquTNnGet79b3BWljqOuoW/h4oBhxJ/HUbX5nX6JSruTkvXDCFMwDPvsaTTbvMLKZWSy0R5g==", - "requires": { - "has-flag": "^4.0.0" - } + "strip-json-comments": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-3.1.0.tgz", + "integrity": "sha512-e6/d0eBu7gHtdCqFt0xJr642LdToM5/cN4Qb9DbHjVx1CP5RyeM+zH7pbecEmDv/lBqb0QH+6Uqq75rxFPkM0w==" } } }, @@ -2527,6 +2497,29 @@ "version": "1.1.2", "resolved": "https://registry.npmjs.org/entities/-/entities-1.1.2.tgz", "integrity": "sha512-f2LZMYl1Fzu7YSBKg+RoROelpOaNrcGmE9AZubeDfrCEia483oW4MI4VyFd5VNHIgQ/7qm1I0wUHK1eJnn2y2w==" + }, + "readable-stream": { + "version": "3.6.0", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.6.0.tgz", + "integrity": "sha512-BViHy7LKeTz4oNnkcLJ+lVSL6vpiFeX6/d3oSH8zCW7UxP2onchk+vTGB143xuFjHS3deTgkKoXXymXqymiIdA==", + "requires": { + "inherits": "^2.0.3", + "string_decoder": "^1.1.1", + "util-deprecate": "^1.0.1" + } + }, + "safe-buffer": { + "version": "5.2.1", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz", + "integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==" + }, + "string_decoder": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.3.0.tgz", + "integrity": "sha512-hkRX8U1WjJFd8LsDJ2yQ/wWWxaopEsABU1XfkM8A+j0+85JAGppt16cr1Whg6KIbb4okU6Mql6BOj+uup/wKeA==", + "requires": { + "safe-buffer": "~5.2.0" + } } } }, @@ -2662,9 +2655,9 @@ "integrity": "sha512-RZY5huIKCMRWDUqZlEi72f/lmXKMvuszcMBduliQ3nnWbx9X/ZBQO7DijMEYS9EhHBb2qacRUMtC7svLwe0lcw==" }, "inquirer": { - "version": "7.3.0", - "resolved": "https://registry.npmjs.org/inquirer/-/inquirer-7.3.0.tgz", - "integrity": "sha512-K+LZp6L/6eE5swqIcVXrxl21aGDU4S50gKH0/d96OMQnSBCyGyZl/oZhbkVmdp5sBoINHd4xZvFSARh2dk6DWA==", + "version": "7.3.2", + "resolved": "https://registry.npmjs.org/inquirer/-/inquirer-7.3.2.tgz", + "integrity": "sha512-DF4osh1FM6l0RJc5YWYhSDB6TawiBRlbV9Cox8MWlidU218Tb7fm3lQTULyUJDfJ0tjbzl0W4q651mrCCEM55w==", "requires": { "ansi-escapes": "^4.2.1", "chalk": "^4.1.0", @@ -2672,7 +2665,7 @@ "cli-width": "^3.0.0", "external-editor": "^3.0.3", "figures": "^3.0.0", - "lodash": "^4.17.15", + "lodash": "^4.17.16", "mute-stream": "0.0.8", "run-async": "^2.4.0", "rxjs": "^6.6.0", @@ -2695,6 +2688,11 @@ "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==" }, + "lodash": { + "version": "4.17.19", + "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.19.tgz", + "integrity": "sha512-JNvd8XER9GQX0v2qJgsaN/mzFCNA5BRe/j8JN9d+tWyGLSodKQHKFicdwNYzWwI3wjRnaKPsGj1XkBjx/F96DQ==" + }, "supports-color": { "version": "7.1.0", "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.1.0.tgz", @@ -2844,9 +2842,9 @@ "integrity": "sha512-5SMO8RVennx3nZrqtKwCGyyetPE9VDba5ugvKLaD4KopPG5kR4mQ7tNt/r7feL5yt5h3lpuBbIUmCOG2eSzXHA==" }, "isarray": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", - "integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=" + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz", + "integrity": "sha1-ihis/Kmo9Bd+Cav8YDiTmwXR7t8=" }, "isexe": { "version": "2.0.0", @@ -2870,6 +2868,13 @@ "requires": { "argparse": "^1.0.7", "esprima": "^4.0.0" + }, + "dependencies": { + "esprima": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/esprima/-/esprima-4.0.1.tgz", + "integrity": "sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A==" + } } }, "jsbn": { @@ -2938,15 +2943,32 @@ "nomnom": "^1.5.x" } }, + "jsonpath": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/jsonpath/-/jsonpath-1.0.2.tgz", + "integrity": "sha512-rmzlgFZiQPc6q4HDyK8s9Qb4oxBnI5sF61y/Co5PV0lc3q2bIuRsNdueVbhoSHdKM4fxeimphOAtfz47yjCfeA==", + "requires": { + "esprima": "1.2.2", + "static-eval": "2.0.2", + "underscore": "1.7.0" + }, + "dependencies": { + "esprima": { + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/esprima/-/esprima-1.2.2.tgz", + "integrity": "sha1-dqD9Zvz+FU/SkmZ9wmQBl1CxZXs=" + } + } + }, "jsonpath-plus": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/jsonpath-plus/-/jsonpath-plus-4.0.0.tgz", "integrity": "sha512-e0Jtg4KAzDJKKwzbLaUtinCn0RZseWBVRTRGihSpvFlM3wTR7ExSp+PTdeTsDrLNJUe7L7JYJe8mblHX5SCT6A==" }, "jsonpointer": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/jsonpointer/-/jsonpointer-4.0.1.tgz", - "integrity": "sha1-T9kss04OnbPInIYi7PUfm5eMbLk=" + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/jsonpointer/-/jsonpointer-4.1.0.tgz", + "integrity": "sha512-CXcRvMyTlnR53xMcKnuMzfCA5i/nfblTnnr74CZb6C4vG39eu6w51t7nKmU5MfLfbTgGItliNyjO/ciNPDqClg==" }, "jsprim": { "version": "1.4.1", @@ -2992,12 +3014,12 @@ "integrity": "sha512-qsda+H8jTaUaN/x5vzW2rzc+8Rw4TAQ/4KjB46IwK5VH+IlVeeeje/EoZRpiXvIqjFgK84QffqPztGI3VBLG1A==" }, "levn": { - "version": "0.4.1", - "resolved": "https://registry.npmjs.org/levn/-/levn-0.4.1.tgz", - "integrity": "sha512-+bT2uH4E5LGE7h/n3evcS/sQlJXCpIp6ym8OWJ5eV6+67Dsql/LaaT7qJBAt2rzfoa/5QBGBhxDix1dMt2kQKQ==", + "version": "0.3.0", + "resolved": "https://registry.npmjs.org/levn/-/levn-0.3.0.tgz", + "integrity": "sha1-OwmSTt+fCDwEkP3UwLxEIeBHZO4=", "requires": { - "prelude-ls": "^1.2.1", - "type-check": "~0.4.0" + "prelude-ls": "~1.1.2", + "type-check": "~0.3.2" } }, "lines-and-columns": { @@ -3014,14 +3036,15 @@ } }, "load-json-file": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/load-json-file/-/load-json-file-2.0.0.tgz", - "integrity": "sha1-eUfkIUmvgNaWy/eXvKq8/h/inKg=", + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/load-json-file/-/load-json-file-1.1.0.tgz", + "integrity": "sha1-lWkFcI1YtLq0wiYbBPWfMcmTdMA=", "requires": { "graceful-fs": "^4.1.2", "parse-json": "^2.2.0", "pify": "^2.0.0", - "strip-bom": "^3.0.0" + "pinkie-promise": "^2.0.0", + "strip-bom": "^2.0.0" } }, "locate-path": { @@ -3053,30 +3076,6 @@ "integrity": "sha512-FN8JBzLx6CzeMrB0tg6pqlGU1wCrXW+ZXGH481kfsBqer0hToTIiHdjH4Mq8xJUbvATujKCvaREGWpGUionraA==", "requires": { "chalk": "^4.0.0" - }, - "dependencies": { - "chalk": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.0.tgz", - "integrity": "sha512-qwx12AxXe2Q5xQ43Ac//I6v5aXTipYrSESdOgzrN+9XjgEpyjpKuvSGaN4qE93f7TQTlerQQ8S+EQ0EyDoVL1A==", - "requires": { - "ansi-styles": "^4.1.0", - "supports-color": "^7.1.0" - } - }, - "has-flag": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", - "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==" - }, - "supports-color": { - "version": "7.1.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.1.0.tgz", - "integrity": "sha512-oRSIpR8pxT1Wr2FquTNnGet79b3BWljqOuoW/h4oBhxJ/HUbX5nX6JSruTkvXDCFMwDPvsaTTbvMLKZWSy0R5g==", - "requires": { - "has-flag": "^4.0.0" - } - } } }, "longest-streak": { @@ -3159,6 +3158,19 @@ "rc": "~1.2.7" }, "dependencies": { + "commander": { + "version": "2.9.0", + "resolved": "https://registry.npmjs.org/commander/-/commander-2.9.0.tgz", + "integrity": "sha1-nJkJQXbhIkDLItbFFGCYQA/g99Q=", + "requires": { + "graceful-readlink": ">= 1.0.0" + } + }, + "esprima": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/esprima/-/esprima-4.0.1.tgz", + "integrity": "sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A==" + }, "get-stdin": { "version": "5.0.1", "resolved": "https://registry.npmjs.org/get-stdin/-/get-stdin-5.0.1.tgz", @@ -3392,9 +3404,9 @@ "integrity": "sha512-8dG4H5ujfvFiqDmVu9fQ5bOHUC15JMjMY/Zumv26oOvvVJjM67KF8koCWIabKQ1GJIa9r2mMZscBq/TbdOcmNA==" }, "node-releases": { - "version": "1.1.58", - "resolved": "https://registry.npmjs.org/node-releases/-/node-releases-1.1.58.tgz", - "integrity": "sha512-NxBudgVKiRh/2aPWMgPR7bPTX0VPmGx5QBwCtdHitnqFE5/O8DeBXuIMH1nwNnw/aMo6AjOrpsHzfY3UbUJ7yg==" + "version": "1.1.59", + "resolved": "https://registry.npmjs.org/node-releases/-/node-releases-1.1.59.tgz", + "integrity": "sha512-H3JrdUczbdiwxN5FuJPyCHnGHIFqQ0wWxo+9j1kAXAzqNMAHlo+4I/sYYxpyK0irQ73HgdiyzD32oqQDcU2Osw==" }, "nomnom": { "version": "1.8.1", @@ -3424,6 +3436,11 @@ "version": "0.1.1", "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-0.1.1.tgz", "integrity": "sha1-OeipjQRNFQZgq+SmgIrPcLt7yZE=" + }, + "underscore": { + "version": "1.6.0", + "resolved": "https://registry.npmjs.org/underscore/-/underscore-1.6.0.tgz", + "integrity": "sha1-izixDKze9jM3uLJOT/htRa6lKag=" } } }, @@ -3545,16 +3562,16 @@ } }, "optionator": { - "version": "0.9.1", - "resolved": "https://registry.npmjs.org/optionator/-/optionator-0.9.1.tgz", - "integrity": "sha512-74RlY5FCnhq4jRxVUPKDaRwrVNXMqsGsiW6AJw4XK8hmtm10wC0ypZBLw5IIp85NZMr91+qd1RvvENwg7jjRFw==", + "version": "0.8.3", + "resolved": "https://registry.npmjs.org/optionator/-/optionator-0.8.3.tgz", + "integrity": "sha512-+IW9pACdk3XWmmTXG8m3upGUJst5XRGzxMRjXzAuJ1XnIFNvfhjjIuYkDvysnPQ7qzqVzLt78BCruntqRhWQbA==", "requires": { - "deep-is": "^0.1.3", - "fast-levenshtein": "^2.0.6", - "levn": "^0.4.1", - "prelude-ls": "^1.2.1", - "type-check": "^0.4.0", - "word-wrap": "^1.2.3" + "deep-is": "~0.1.3", + "fast-levenshtein": "~2.0.6", + "levn": "~0.3.0", + "prelude-ls": "~1.1.2", + "type-check": "~0.3.2", + "word-wrap": "~1.2.3" } }, "os-locale": { @@ -3694,11 +3711,13 @@ "integrity": "sha512-GSmOT2EbHrINBf9SR7CDELwlJ8AENk3Qn7OikK4nFYAu3Ote2+JYNVvkpAEQm3/TLNEJFD/xZJjzyxg3KBWOzw==" }, "path-type": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/path-type/-/path-type-2.0.0.tgz", - "integrity": "sha1-8BLMuEFbcJb8LaoQVMPXI4lZTHM=", + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/path-type/-/path-type-1.1.0.tgz", + "integrity": "sha1-WcRPfuSR2nBNpBXaWkBwuk+P5EE=", "requires": { - "pify": "^2.0.0" + "graceful-fs": "^4.1.2", + "pify": "^2.0.0", + "pinkie-promise": "^2.0.0" } }, "performance-now": { @@ -3794,6 +3813,11 @@ "resolved": "https://registry.npmjs.org/pify/-/pify-4.0.1.tgz", "integrity": "sha512-uB80kBFb/tfd68bVleG9T5GGsGPjJrLAUpR5PZIrhBnIaRTQRjqdJSsIKkOP6OAIFbj7GOrcudc5pNjZ+geV2g==" }, + "strip-bom": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/strip-bom/-/strip-bom-3.0.0.tgz", + "integrity": "sha1-IzTBjpx1n3vdVv3vfprj1YjmjtM=" + }, "type-fest": { "version": "0.3.1", "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-0.3.1.tgz", @@ -3874,10 +3898,46 @@ "supports-color": "^6.1.0" }, "dependencies": { - "source-map": { - "version": "0.6.1", - "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", - "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==" + "ansi-styles": { + "version": "3.2.1", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.1.tgz", + "integrity": "sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==", + "requires": { + "color-convert": "^1.9.0" + } + }, + "chalk": { + "version": "2.4.2", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.2.tgz", + "integrity": "sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ==", + "requires": { + "ansi-styles": "^3.2.1", + "escape-string-regexp": "^1.0.5", + "supports-color": "^5.3.0" + }, + "dependencies": { + "supports-color": { + "version": "5.5.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz", + "integrity": "sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==", + "requires": { + "has-flag": "^3.0.0" + } + } + } + }, + "color-convert": { + "version": "1.9.3", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.3.tgz", + "integrity": "sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg==", + "requires": { + "color-name": "1.1.3" + } + }, + "color-name": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.3.tgz", + "integrity": "sha1-p9BVi9icQveV3UIyj3QIMcpTvCU=" }, "supports-color": { "version": "6.1.0", @@ -3921,6 +3981,37 @@ "postcss": "^7.0.7" }, "dependencies": { + "ansi-styles": { + "version": "3.2.1", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.1.tgz", + "integrity": "sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==", + "requires": { + "color-convert": "^1.9.0" + } + }, + "chalk": { + "version": "2.4.2", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.2.tgz", + "integrity": "sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ==", + "requires": { + "ansi-styles": "^3.2.1", + "escape-string-regexp": "^1.0.5", + "supports-color": "^5.3.0" + } + }, + "color-convert": { + "version": "1.9.3", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.3.tgz", + "integrity": "sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg==", + "requires": { + "color-name": "1.1.3" + } + }, + "color-name": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.3.tgz", + "integrity": "sha1-p9BVi9icQveV3UIyj3QIMcpTvCU=" + }, "log-symbols": { "version": "2.2.0", "resolved": "https://registry.npmjs.org/log-symbols/-/log-symbols-2.2.0.tgz", @@ -3982,9 +4073,9 @@ "integrity": "sha512-97DXOFbQJhk71ne5/Mt6cOu6yxsSfM0QGQyl0L25Gca4yGWEGJaig7l7gbCX623VqTBNGLRLaVUCnNkcedlRSQ==" }, "prelude-ls": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/prelude-ls/-/prelude-ls-1.2.1.tgz", - "integrity": "sha512-vkcDPrRZo1QZLbn5RLGPpg/WmIQ65qoWWhcGKf/b5eplkkarX0m9z8ppCat4mlOqUsWpyNuYgO3VRyrYHSzX5g==" + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/prelude-ls/-/prelude-ls-1.1.2.tgz", + "integrity": "sha1-IZMqVJ9eUv/ZqCf1cOBL5iqX2lQ=" }, "prettier": { "version": "2.0.5", @@ -4100,77 +4191,70 @@ "integrity": "sha512-24e6ynE2H+OKt4kqsOvNd8kBpV65zoxbA4BVsEOB3ARVWQki/DHzaUoC5KuON/BiccDaCCTZBuOcfZs70kR8bQ==" }, "read-pkg": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/read-pkg/-/read-pkg-2.0.0.tgz", - "integrity": "sha1-jvHAYjxqbbDcZxPEv6xGMysjaPg=", + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/read-pkg/-/read-pkg-1.1.0.tgz", + "integrity": "sha1-9f+qXs0pyzHAR0vKfXVra7KePyg=", "requires": { - "load-json-file": "^2.0.0", + "load-json-file": "^1.0.0", "normalize-package-data": "^2.3.2", - "path-type": "^2.0.0" + "path-type": "^1.0.0" } }, "read-pkg-up": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/read-pkg-up/-/read-pkg-up-2.0.0.tgz", - "integrity": "sha1-a3KoBImE4MQeeVEP1en6mbO1Sb4=", + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/read-pkg-up/-/read-pkg-up-1.0.1.tgz", + "integrity": "sha1-nWPBMnbAZZGNV/ACpX9AobZD+wI=", "requires": { - "find-up": "^2.0.0", - "read-pkg": "^2.0.0" + "find-up": "^1.0.0", + "read-pkg": "^1.0.0" }, "dependencies": { "find-up": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/find-up/-/find-up-2.1.0.tgz", - "integrity": "sha1-RdG35QbHF93UgndaK3eSCjwMV6c=", + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/find-up/-/find-up-1.1.2.tgz", + "integrity": "sha1-ay6YIrGizgpgq2TWEOzK1TyyTQ8=", "requires": { - "locate-path": "^2.0.0" + "path-exists": "^2.0.0", + "pinkie-promise": "^2.0.0" } }, - "locate-path": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-2.0.0.tgz", - "integrity": "sha1-K1aLJl7slExtnA3pw9u7ygNUzY4=", - "requires": { - "p-locate": "^2.0.0", - "path-exists": "^3.0.0" - } - }, - "p-limit": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-1.3.0.tgz", - "integrity": "sha512-vvcXsLAJ9Dr5rQOPk7toZQZJApBl2K4J6dANSsEuh6QI41JYcsS/qhTGa9ErIUUgK3WNQoJYvylxvjqmiqEA9Q==", - "requires": { - "p-try": "^1.0.0" - } - }, - "p-locate": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-2.0.0.tgz", - "integrity": "sha1-IKAQOyIqcMj9OcwuWAaA893l7EM=", - "requires": { - "p-limit": "^1.1.0" - } - }, - "p-try": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/p-try/-/p-try-1.0.0.tgz", - "integrity": "sha1-y8ec26+P1CKOE/Yh8rGiN8GyB7M=" - }, "path-exists": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-3.0.0.tgz", - "integrity": "sha1-zg6+ql94yxiSXqfYENe1mwEP1RU=" + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-2.1.0.tgz", + "integrity": "sha1-D+tsZPD8UY2adU3V77YscCJ2H0s=", + "requires": { + "pinkie-promise": "^2.0.0" + } } } }, "readable-stream": { - "version": "3.6.0", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.6.0.tgz", - "integrity": "sha512-BViHy7LKeTz4oNnkcLJ+lVSL6vpiFeX6/d3oSH8zCW7UxP2onchk+vTGB143xuFjHS3deTgkKoXXymXqymiIdA==", + "version": "2.3.7", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.7.tgz", + "integrity": "sha512-Ebho8K4jIbHAxnuxi7o42OrZgF/ZTNcsZj6nRKyUmkhLFq8CHItp/fy6hQZuZmP/n3yZ9VBUbp4zz/mX8hmYPw==", "requires": { - "inherits": "^2.0.3", - "string_decoder": "^1.1.1", - "util-deprecate": "^1.0.1" + "core-util-is": "~1.0.0", + "inherits": "~2.0.3", + "isarray": "~1.0.0", + "process-nextick-args": "~2.0.0", + "safe-buffer": "~5.1.1", + "string_decoder": "~1.1.1", + "util-deprecate": "~1.0.1" + }, + "dependencies": { + "isarray": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", + "integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=" + }, + "string_decoder": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", + "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==", + "requires": { + "safe-buffer": "~5.1.0" + } + } } }, "redent": { @@ -4193,9 +4277,9 @@ "integrity": "sha512-ZOIzd8yVsQQA7j8GCSlPGXwg5PfmA1mrq0JP4nGhh54LaKN3xdai/vHUDu74pKwV8OxseMS65u2NImosQcSD0Q==" }, "remark": { - "version": "12.0.0", - "resolved": "https://registry.npmjs.org/remark/-/remark-12.0.0.tgz", - "integrity": "sha512-oX4lMIS0csgk8AEbzY0h2jdR0ngiCHOpwwpxjmRa5TqAkeknY+tkhjRJGZqnCmvyuWh55/0SW5WY3R3nn3PH9A==", + "version": "12.0.1", + "resolved": "https://registry.npmjs.org/remark/-/remark-12.0.1.tgz", + "integrity": "sha512-gS7HDonkdIaHmmP/+shCPejCEEW+liMp/t/QwmF0Xt47Rpuhl32lLtDV1uKWvGoq+kxr5jSgg5oAIpGuyULjUw==", "requires": { "remark-parse": "^8.0.0", "remark-stringify": "^8.0.0", @@ -4203,9 +4287,9 @@ } }, "remark-parse": { - "version": "8.0.2", - "resolved": "https://registry.npmjs.org/remark-parse/-/remark-parse-8.0.2.tgz", - "integrity": "sha512-eMI6kMRjsAGpMXXBAywJwiwAse+KNpmt+BK55Oofy4KvBZEqUDj6mWbGLJZrujoPIPPxDXzn3T9baRlpsm2jnQ==", + "version": "8.0.3", + "resolved": "https://registry.npmjs.org/remark-parse/-/remark-parse-8.0.3.tgz", + "integrity": "sha512-E1K9+QLGgggHxCQtLt++uXltxEprmWzNfg+MxpfHsZlrddKzZ/hZyWHDbK3/Ap8HJQqYJRXP+jHczdL6q6i85Q==", "requires": { "ccount": "^1.0.0", "collapse-white-space": "^1.0.2", @@ -4226,9 +4310,9 @@ } }, "remark-stringify": { - "version": "8.1.0", - "resolved": "https://registry.npmjs.org/remark-stringify/-/remark-stringify-8.1.0.tgz", - "integrity": "sha512-FSPZv1ds76oAZjurhhuV5qXSUSoz6QRPuwYK38S41sLHwg4oB7ejnmZshj7qwjgYLf93kdz6BOX9j5aidNE7rA==", + "version": "8.1.1", + "resolved": "https://registry.npmjs.org/remark-stringify/-/remark-stringify-8.1.1.tgz", + "integrity": "sha512-q4EyPZT3PcA3Eq7vPpT6bIdokXzFGp9i85igjmhRyXWmPs0Y6/d2FYwUNotKAWyLch7g0ASZJn/KHHcHZQ163A==", "requires": { "ccount": "^1.0.0", "is-alphanumeric": "^1.0.0", @@ -4471,9 +4555,9 @@ } }, "source-map": { - "version": "0.5.7", - "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.5.7.tgz", - "integrity": "sha1-igOdLRAh0i0eoUyA2OpGi6LvP8w=" + "version": "0.6.1", + "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", + "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==" }, "spdx-correct": { "version": "3.1.1", @@ -4550,6 +4634,37 @@ "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-4.1.0.tgz", "integrity": "sha512-1apePfXM1UOSqw0o9IiFAovVz9M5S1Dg+4TrDwfMewQ6p/rmMueb7tWZjQ1rx4Loy1ArBggoqGpfqqdI4rondg==" }, + "ansi-styles": { + "version": "3.2.1", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.1.tgz", + "integrity": "sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==", + "requires": { + "color-convert": "^1.9.0" + } + }, + "chalk": { + "version": "2.4.2", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.2.tgz", + "integrity": "sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ==", + "requires": { + "ansi-styles": "^3.2.1", + "escape-string-regexp": "^1.0.5", + "supports-color": "^5.3.0" + } + }, + "color-convert": { + "version": "1.9.3", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.3.tgz", + "integrity": "sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg==", + "requires": { + "color-name": "1.1.3" + } + }, + "color-name": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.3.tgz", + "integrity": "sha1-p9BVi9icQveV3UIyj3QIMcpTvCU=" + }, "cross-spawn": { "version": "6.0.5", "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-6.0.5.tgz", @@ -4644,38 +4759,11 @@ "resolved": "https://registry.npmjs.org/ignore/-/ignore-4.0.6.tgz", "integrity": "sha512-cyFDKrqc/YdcWFniJhzI42+AzS+gNwmUzOSFcRCQYwySuBBBy/KjuxWLZ/FHEH6Moq1NizMOBWyTcv8O4OZIMg==" }, - "levn": { - "version": "0.3.0", - "resolved": "https://registry.npmjs.org/levn/-/levn-0.3.0.tgz", - "integrity": "sha1-OwmSTt+fCDwEkP3UwLxEIeBHZO4=", - "requires": { - "prelude-ls": "~1.1.2", - "type-check": "~0.3.2" - } - }, - "optionator": { - "version": "0.8.3", - "resolved": "https://registry.npmjs.org/optionator/-/optionator-0.8.3.tgz", - "integrity": "sha512-+IW9pACdk3XWmmTXG8m3upGUJst5XRGzxMRjXzAuJ1XnIFNvfhjjIuYkDvysnPQ7qzqVzLt78BCruntqRhWQbA==", - "requires": { - "deep-is": "~0.1.3", - "fast-levenshtein": "~2.0.6", - "levn": "~0.3.0", - "prelude-ls": "~1.1.2", - "type-check": "~0.3.2", - "word-wrap": "~1.2.3" - } - }, "path-key": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/path-key/-/path-key-2.0.1.tgz", "integrity": "sha1-QRyttXTFoUDTpLGRDUDYDMn0C0A=" }, - "prelude-ls": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/prelude-ls/-/prelude-ls-1.1.2.tgz", - "integrity": "sha1-IZMqVJ9eUv/ZqCf1cOBL5iqX2lQ=" - }, "regexpp": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/regexpp/-/regexpp-2.0.1.tgz", @@ -4707,14 +4795,6 @@ "ansi-regex": "^4.1.0" } }, - "type-check": { - "version": "0.3.2", - "resolved": "https://registry.npmjs.org/type-check/-/type-check-0.3.2.tgz", - "integrity": "sha1-WITKtRLPHTVeP7eE8wgEsrUg23I=", - "requires": { - "prelude-ls": "~1.1.2" - } - }, "which": { "version": "1.3.1", "resolved": "https://registry.npmjs.org/which/-/which-1.3.1.tgz", @@ -4748,6 +4828,14 @@ "resolved": "https://registry.npmjs.org/state-toggle/-/state-toggle-1.0.3.tgz", "integrity": "sha512-d/5Z4/2iiCnHw6Xzghyhb+GcmF89bxwgXG60wjIiZaxnymbyOmI8Hk4VqHXiVVp6u2ysaskFfXg3ekCj4WNftQ==" }, + "static-eval": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/static-eval/-/static-eval-2.0.2.tgz", + "integrity": "sha512-N/D219Hcr2bPjLxPiV+TQE++Tsmrady7TqAJugLy7Xk1EumfDWS/f5dtBbkRCGE7wKKXuYockQoj8Rm2/pVKyg==", + "requires": { + "escodegen": "^1.8.1" + } + }, "statuses": { "version": "1.5.0", "resolved": "https://registry.npmjs.org/statuses/-/statuses-1.5.0.tgz", @@ -4787,19 +4875,9 @@ } }, "string_decoder": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.3.0.tgz", - "integrity": "sha512-hkRX8U1WjJFd8LsDJ2yQ/wWWxaopEsABU1XfkM8A+j0+85JAGppt16cr1Whg6KIbb4okU6Mql6BOj+uup/wKeA==", - "requires": { - "safe-buffer": "~5.2.0" - }, - "dependencies": { - "safe-buffer": { - "version": "5.2.1", - "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz", - "integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==" - } - } + "version": "0.10.31", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-0.10.31.tgz", + "integrity": "sha1-YuIDvEF2bGwoyfyEMB2rHFMQ+pQ=" }, "stringify-entities": { "version": "3.0.1", @@ -4822,9 +4900,12 @@ } }, "strip-bom": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/strip-bom/-/strip-bom-3.0.0.tgz", - "integrity": "sha1-IzTBjpx1n3vdVv3vfprj1YjmjtM=" + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/strip-bom/-/strip-bom-2.0.0.tgz", + "integrity": "sha1-YhmoVhZSBJHzV4i9vxRHqZx+aw4=", + "requires": { + "is-utf8": "^0.2.0" + } }, "strip-indent": { "version": "3.0.0", @@ -4835,9 +4916,9 @@ } }, "strip-json-comments": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-3.1.0.tgz", - "integrity": "sha512-e6/d0eBu7gHtdCqFt0xJr642LdToM5/cN4Qb9DbHjVx1CP5RyeM+zH7pbecEmDv/lBqb0QH+6Uqq75rxFPkM0w==" + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-3.1.1.tgz", + "integrity": "sha512-6fPc+R4ihwqP6N/aIv2f1gMH8lOVtWQHoqC4yK6oSDVVocumAsfCqjkXnqiYMhmMwS/mEHLp7Vehlt3ql6lEig==" }, "style-search": { "version": "0.1.0", @@ -5084,9 +5165,9 @@ "integrity": "sha512-rvuRbTarPXmMb79SmzEp8aqXNKcK+y0XaB298IXueQ8I2PsrATcPBCSPyK/dDNa2iWOhKlfNnOjdAOTBU/nkFA==" }, "tslib": { - "version": "1.13.0", - "resolved": "https://registry.npmjs.org/tslib/-/tslib-1.13.0.tgz", - "integrity": "sha512-i/6DQjL8Xf3be4K/E6Wgpekn5Qasl1usyw++dAA35Ue5orEn65VIxOA+YvNNl9HV3qv70T7CNwjODHZrLwvd1Q==" + "version": "1.11.1", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-1.11.1.tgz", + "integrity": "sha512-aZW88SY8kQbU7gpV19lN24LtXh/yD4ZZg6qieAJDDg+YBsJcSmLGK9QpnUjAKVG/xefmvJGd1WUmfpT/g6AJGA==" }, "tsutils": { "version": "3.17.1", @@ -5110,11 +5191,11 @@ "integrity": "sha1-WuaBd/GS1EViadEIr6k/+HQ/T2Q=" }, "type-check": { - "version": "0.4.0", - "resolved": "https://registry.npmjs.org/type-check/-/type-check-0.4.0.tgz", - "integrity": "sha512-XleUoc9uwGXqjWwXaUTZAmzMcFZ5858QA2vvx1Ur5xIcixXIP+8LnFDgRplU30us6teqdlskFfu+ae4K79Ooew==", + "version": "0.3.2", + "resolved": "https://registry.npmjs.org/type-check/-/type-check-0.3.2.tgz", + "integrity": "sha1-WITKtRLPHTVeP7eE8wgEsrUg23I=", "requires": { - "prelude-ls": "^1.2.1" + "prelude-ls": "~1.1.2" } }, "type-fest": { @@ -5141,9 +5222,9 @@ "integrity": "sha512-8Y75pvTYkLJW2hWQHXxoqRgV7qb9B+9vFEtidML+7koHUFapnVJAZ6cKs+Qjz5Aw3aZWHMC6u0wJE3At+nSGwA==" }, "underscore": { - "version": "1.6.0", - "resolved": "https://registry.npmjs.org/underscore/-/underscore-1.6.0.tgz", - "integrity": "sha1-izixDKze9jM3uLJOT/htRa6lKag=" + "version": "1.7.0", + "resolved": "https://registry.npmjs.org/underscore/-/underscore-1.7.0.tgz", + "integrity": "sha1-a7rwh3UA02vjTsqlhODbn+8DUgk=" }, "unherit": { "version": "1.1.3", @@ -5202,9 +5283,9 @@ } }, "unist-util-visit": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/unist-util-visit/-/unist-util-visit-2.0.2.tgz", - "integrity": "sha512-HoHNhGnKj6y+Sq+7ASo2zpVdfdRifhTgX2KTU3B/sO/TTlZchp7E3S4vjRzDJ7L60KmrCPsQkVK3lEF3cz36XQ==", + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/unist-util-visit/-/unist-util-visit-2.0.3.tgz", + "integrity": "sha512-iJ4/RczbJMkD0712mGktuGpm/U4By4FfDonL7N/9tATGIF4imikjOuagyMY53tnZq3NP6BcmlrHhEKAfGWjh7Q==", "requires": { "@types/unist": "^2.0.0", "unist-util-is": "^4.0.0", @@ -5212,9 +5293,9 @@ } }, "unist-util-visit-parents": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/unist-util-visit-parents/-/unist-util-visit-parents-3.0.2.tgz", - "integrity": "sha512-yJEfuZtzFpQmg1OSCyS9M5NJRrln/9FbYosH3iW0MG402QbdbaB8ZESwUv9RO6nRfLAKvWcMxCwdLWOov36x/g==", + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/unist-util-visit-parents/-/unist-util-visit-parents-3.1.0.tgz", + "integrity": "sha512-0g4wbluTF93npyPrp/ymd3tCDTMnP0yo2akFD2FIBAYXq/Sga3lwaU1D8OYKbtpioaI6CkDcQ6fsMnmtzt7htw==", "requires": { "@types/unist": "^2.0.0", "unist-util-is": "^4.0.0" @@ -5391,9 +5472,9 @@ "integrity": "sha512-yr2icI4glYaNG+KWONODapy2/jDdMSDnrONSjblABjD9B4Z5LgiircSt8m8sRZFNi08kG9Sm0uSHtEmP3zaEGg==" }, "yargs": { - "version": "15.3.1", - "resolved": "https://registry.npmjs.org/yargs/-/yargs-15.3.1.tgz", - "integrity": "sha512-92O1HWEjw27sBfgmXiixJWT5hRBp2eobqXicLtPBIDBhYB+1HpwZlXmbW2luivBJHBzki+7VyCLRtAkScbTBQA==", + "version": "15.4.1", + "resolved": "https://registry.npmjs.org/yargs/-/yargs-15.4.1.tgz", + "integrity": "sha512-aePbxDmcYW++PaqBsJ+HYUFwCdv4LVvdnhBy78E57PIor8/OVvhMrADFFEDh8DHDFRv/O9i3lPhsENjO7QX0+A==", "requires": { "cliui": "^6.0.0", "decamelize": "^1.2.0", @@ -5405,7 +5486,7 @@ "string-width": "^4.2.0", "which-module": "^2.0.0", "y18n": "^4.0.0", - "yargs-parser": "^18.1.1" + "yargs-parser": "^18.1.2" } }, "yargs-parser": { diff --git a/dependencies/package.json b/dependencies/package.json index 19ce0341..2dd354f4 100644 --- a/dependencies/package.json +++ b/dependencies/package.json @@ -5,7 +5,6 @@ "@stoplight/spectral": "^5.4.0", "@typescript-eslint/eslint-plugin": "^3.7.0", "@typescript-eslint/parser": "^3.7.0", - "@typescript-eslint/eslint-plugin": "^3.7.0", "babel-eslint": "^10.1.0", "dockerfilelint": "^1.5.0", "eslint": "^7.5.0", @@ -19,6 +18,7 @@ "standard": "^14.3.4", "stylelint": "^13.6.1", "stylelint-config-standard": "^20.0.0", - "typescript": "^3.9.7" + "typescript": "^3.9.7", + "asl-validator": "^1.7.0" } } From 1971c8359e2daab4cbc4b243fe64f6dff1a6bac8 Mon Sep 17 00:00:00 2001 From: Lucas Gravley <29484535+admiralAwkbar@users.noreply.github.com> Date: Tue, 21 Jul 2020 13:50:04 -0500 Subject: [PATCH 005/135] Adding states linter --- .automation/test/states/README.md | 13 + .../test/states/reports/expected-STATES.tap | 7 + .automation/test/states/states_bad_1.json | 10 + .automation/test/states/states_good_1.json | 11 + Dockerfile | 83 +++---- README.md | 92 ++++---- lib/buildFileList.sh | 9 + lib/linter.sh | 222 ++++++++++-------- lib/validation.sh | 68 ++++-- lib/worker.sh | 1 + 10 files changed, 313 insertions(+), 203 deletions(-) create mode 100644 .automation/test/states/README.md create mode 100644 .automation/test/states/reports/expected-STATES.tap create mode 100644 .automation/test/states/states_bad_1.json create mode 100644 .automation/test/states/states_good_1.json diff --git a/.automation/test/states/README.md b/.automation/test/states/README.md new file mode 100644 index 00000000..fd526bb2 --- /dev/null +++ b/.automation/test/states/README.md @@ -0,0 +1,13 @@ +# AWS States language Test Cases +This folder holds the test cases for **AWS States Language**. + +## 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. diff --git a/.automation/test/states/reports/expected-STATES.tap b/.automation/test/states/reports/expected-STATES.tap new file mode 100644 index 00000000..e9be32b5 --- /dev/null +++ b/.automation/test/states/reports/expected-STATES.tap @@ -0,0 +1,7 @@ +TAP version 13 +1..2 +not ok 1 - json_bad_1.json + --- + message: Error Parse error on line 6 \n...ng" { "level" 'ignore', "space\n----------------------^\nExpecting 'STRING', 'NUMBER', 'NULL', 'TRUE', 'FALSE', '{', '[', got 'undefined'\n at Object.parseError (/node_modules/jsonlint/lib/jsonlint.js 55 11)\n at Object.parse (/node_modules/jsonlint/lib/jsonlint.js 132 22)\n at parse (/node_modules/jsonlint/lib/cli.js 82 14)\n at main (/node_modules/jsonlint/lib/cli.js 135 14)\n at Object. (/node_modules/jsonlint/lib/cli.js 179 1)\n at Module._compile (internal/modules/cjs/loader.js 1138 30)\n at Object.Module._extensions..js (internal/modules/cjs/loader.js 1158 10)\n at Module.load (internal/modules/cjs/loader.js 986 32)\n at Function.Module._load (internal/modules/cjs/loader.js 879 14)\n at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js 71 12)\n + ... +ok 2 - json_good_1.json diff --git a/.automation/test/states/states_bad_1.json b/.automation/test/states/states_bad_1.json new file mode 100644 index 00000000..36b15b64 --- /dev/null +++ b/.automation/test/states/states_bad_1.json @@ -0,0 +1,10 @@ +{ + "Comment": "A simple minimal example of the States language", + "StartAt": "Hello World", + "States": { + "Hello World": { + "Resource": "arn:aws:lambda:us-east-1:123456789012:function:HelloWorld", + "End": true + } + } +} diff --git a/.automation/test/states/states_good_1.json b/.automation/test/states/states_good_1.json new file mode 100644 index 00000000..0c1be861 --- /dev/null +++ b/.automation/test/states/states_good_1.json @@ -0,0 +1,11 @@ +{ + "Comment": "A simple minimal example of the States language", + "StartAt": "Hello World", + "States": { + "Hello World": { + "Type": "Task", + "Resource": "arn:aws:lambda:us-east-1:123456789012:function:HelloWorld", + "End": true + } + } +} diff --git a/Dockerfile b/Dockerfile index 37dd951a..6d216eed 100644 --- a/Dockerfile +++ b/Dockerfile @@ -190,50 +190,51 @@ RUN echo "http://dl-cdn.alpinelinux.org/alpine/edge/testing/" >> /etc/apk/reposi ########################################### # Load GitHub Env Vars for GitHub Actions # ########################################### -ENV GITHUB_SHA=${GITHUB_SHA} \ - GITHUB_EVENT_PATH=${GITHUB_EVENT_PATH} \ - GITHUB_WORKSPACE=${GITHUB_WORKSPACE} \ - DEFAULT_BRANCH=${DEFAULT_BRANCH} \ - VALIDATE_ALL_CODEBASE=${VALIDATE_ALL_CODEBASE} \ - LINTER_RULES_PATH=${LINTER_RULES_PATH} \ - VALIDATE_YAML=${VALIDATE_YAML} \ - VALIDATE_JSON=${VALIDATE_JSON} \ - VALIDATE_XML=${VALIDATE_XML} \ - VALIDATE_MD=${VALIDATE_MD} \ - VALIDATE_BASH=${VALIDATE_BASH} \ - VALIDATE_PERL=${VALIDATE_PERL} \ - VALIDATE_RAKU=${VALIDATE_RAKU} \ - VALIDATE_PHP=${VALIDATE_PHP} \ - VALIDATE_PYTHON=${VALIDATE_PYTHON} \ - VALIDATE_RUBY=${VALIDATE_RUBY} \ - VALIDATE_COFFEE=${VALIDATE_COFFEE} \ - VALIDATE_ANSIBLE=${VALIDATE_ANSIBLE} \ - VALIDATE_DOCKER=${VALIDATE_DOCKER} \ - VALIDATE_JAVASCRIPT_ES=${VALIDATE_JAVASCRIPT_ES} \ - VALIDATE_JAVASCRIPT_STANDARD=${VALIDATE_JAVASCRIPT_STANDARD} \ - VALIDATE_TYPESCRIPT_ES=${VALIDATE_TYPESCRIPT_ES} \ - VALIDATE_TYPESCRIPT_STANDARD=${VALIDATE_TYPESCRIPT_STANDARD} \ - VALIDATE_GO=${VALIDATE_GO} \ - VALIDATE_TERRAFORM=${VALIDATE_TERRAFORM} \ - VALIDATE_CSS=${VALIDATE_CSS} \ - VALIDATE_ENV=${VALIDATE_ENV} \ - VALIDATE_HTML=${VALIDATE_HTML} \ - VALIDATE_CLOJURE=${VALIDATE_CLOJURE} \ - VALIDATE_KOTLIN=${VALIDATE_KOTLIN} \ - VALIDATE_DART=${VALIDATE_DART} \ - VALIDATE_POWERSHELL=${VALIDATE_POWERSHELL} \ - VALIDATE_ARM=${VALIDATE_ARM} \ - VALIDATE_OPENAPI=${VALIDATE_OPENAPI} \ - VALIDATE_PROTOBUF=${VALIDATE_PROTOBUF} \ - VALIDATE_EDITORCONFIG=${VALIDATE_EDITORCONFIG} \ +ENV ACTIONS_RUNNER_DEBUG=${ACTIONS_RUNNER_DEBUG} \ ANSIBLE_DIRECTORY=${ANSIBLE_DIRECTORY} \ + DEFAULT_BRANCH=${DEFAULT_BRANCH} \ + DISABLE_ERRORS=${DISABLE_ERRORS} \ + GITHUB_EVENT_PATH=${GITHUB_EVENT_PATH} \ + GITHUB_SHA=${GITHUB_SHA} \ + GITHUB_WORKSPACE=${GITHUB_WORKSPACE} \ + LINTER_RULES_PATH=${LINTER_RULES_PATH} \ + OUTPUT_DETAILS=${OUTPUT_DETAILS} \ + OUTPUT_FOLDER=${OUTPUT_FOLDER} \ + OUTPUT_FORMAT=${OUTPUT_FORMAT} \ RUN_LOCAL=${RUN_LOCAL} \ TEST_CASE_RUN=${TEST_CASE_RUN} \ - ACTIONS_RUNNER_DEBUG=${ACTIONS_RUNNER_DEBUG} \ - DISABLE_ERRORS=${DISABLE_ERRORS} \ - OUTPUT_FORMAT=${OUTPUT_FORMAT} \ - OUTPUT_FOLDER=${OUTPUT_FOLDER} \ - OUTPUT_DETAILS=${OUTPUT_DETAILS} + VALIDATE_ALL_CODEBASE=${VALIDATE_ALL_CODEBASE} \ + VALIDATE_ANSIBLE=${VALIDATE_ANSIBLE} \ + VALIDATE_ARM=${VALIDATE_ARM} \ + VALIDATE_BASH=${VALIDATE_BASH} \ + VALIDATE_CLOJURE=${VALIDATE_CLOJURE} \ + VALIDATE_COFFEE=${VALIDATE_COFFEE} \ + VALIDATE_CSS=${VALIDATE_CSS} \ + VALIDATE_DART=${VALIDATE_DART} \ + VALIDATE_DOCKER=${VALIDATE_DOCKER} \ + VALIDATE_EDITORCONFIG=${VALIDATE_EDITORCONFIG} \ + VALIDATE_ENV=${VALIDATE_ENV} \ + VALIDATE_GO=${VALIDATE_GO} \ + VALIDATE_HTML=${VALIDATE_HTML} \ + VALIDATE_JAVASCRIPT_ES=${VALIDATE_JAVASCRIPT_ES} \ + VALIDATE_JAVASCRIPT_STANDARD=${VALIDATE_JAVASCRIPT_STANDARD} \ + VALIDATE_JSON=${VALIDATE_JSON} \ + VALIDATE_KOTLIN=${VALIDATE_KOTLIN} \ + VALIDATE_MD=${VALIDATE_MD} \ + VALIDATE_OPENAPI=${VALIDATE_OPENAPI} \ + VALIDATE_PERL=${VALIDATE_PERL} \ + VALIDATE_PHP=${VALIDATE_PHP} \ + VALIDATE_POWERSHELL=${VALIDATE_POWERSHELL} \ + VALIDATE_PROTOBUF=${VALIDATE_PROTOBUF} \ + VALIDATE_PYTHON=${VALIDATE_PYTHON} \ + VALIDATE_RAKU=${VALIDATE_RAKU} \ + VALIDATE_RUBY=${VALIDATE_RUBY} \ + VALIDATE_STATES=${VALIDATE_STATES} \ + VALIDATE_TERRAFORM=${VALIDATE_TERRAFORM} \ + VALIDATE_TYPESCRIPT_ES=${VALIDATE_TYPESCRIPT_ES} \ + VALIDATE_TYPESCRIPT_STANDARD=${VALIDATE_TYPESCRIPT_STANDARD} \ + VALIDATE_XML=${VALIDATE_XML} \ + VALIDATE_YAML=${VALIDATE_YAML} ############################# # Copy scripts to container # diff --git a/README.md b/README.md index 9ad35000..657f1861 100644 --- a/README.md +++ b/README.md @@ -33,17 +33,18 @@ Developers on **GitHub** can call the **GitHub Action** to lint their code base | *Language* | *Linter* | | --- | --- | | **Ansible** | [ansible-lint](https://github.com/ansible/ansible-lint) | -| **Azure Resource Manager (ARM)** | [arm-ttk](https://github.com/azure/arm-ttk) | +| **Azure Resource Manager (ARM)** | [arm-ttk](https://github.com/azure/arm-ttk) | | **AWS CloudFormation templates** | [cfn-lint](https://github.com/aws-cloudformation/cfn-python-lint/) | +| **AWS States Language | [asl-validator](https://github.com/ChristopheBougere/asl-validator) | | **CSS** | [stylelint](https://stylelint.io/) | | **Clojure** | [clj-kondo](https://github.com/borkdude/clj-kondo) | | **CoffeeScript** | [coffeelint](https://coffeelint.github.io/) | -| **Dart** | [dartanalyzer](https://dart.dev/guides/language/analysis-options) | +| **Dart** | [dartanalyzer](https://dart.dev/guides/language/analysis-options) | | **Dockerfile** | [dockerfilelint](https://github.com/replicatedhq/dockerfilelint.git) | | **EDITORCONFIG** | [editorconfig-checker](https://github.com/editorconfig-checker/editorconfig-checker) | | **ENV** | [dotenv-linter](https://github.com/dotenv-linter/dotenv-linter) | | **Golang** | [golangci-lint](https://github.com/golangci/golangci-lint) | -| **HTMLHint** | [HTMLHint](https://github.com/htmlhint/HTMLHint) | +| **HTMLHint** | [HTMLHint](https://github.com/htmlhint/HTMLHint) | | **JavaScript** | [eslint](https://eslint.org/) [standard js](https://standardjs.com/) | | **JSON** | [jsonlint](https://github.com/zaach/jsonlint) | | **Kotlin** | [ktlint](https://github.com/pinterest/ktlint) | @@ -154,53 +155,54 @@ and won't run anything unexpected. | **ENV VAR** | **Default Value** | **Notes** | | --- | --- | --- | -| **VALIDATE_ALL_CODEBASE** | `true` | Will parse the entire repository and find all files to validate across all types. **NOTE:** When set to `false`, only **new** or **edited** files will be parsed for validation. | -| **DEFAULT_BRANCH** | `master` | The name of the repository default branch. | -| **LINTER_RULES_PATH** | `.github/linters` | Directory for all linter configuration rules. | -| **VALIDATE_YAML** | `true` |Flag to enable or disable the linting process of the language. | -| **VALIDATE_JSON** | `true` | Flag to enable or disable the linting process of the language. | -| **VALIDATE_XML** | `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_PERL** | `true` | Flag to enable or disable the linting process of the language. | -| **VALIDATE_RAKU** | `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_RUBY** | `true` | Flag to enable or disable the linting process of the language. | -| **RUBY_CONFIG_FILE** | `.ruby-lint.yml` | Filename for [rubocop configuration](https://docs.rubocop.org/rubocop/configuration.html) (ex: `.ruby-lint.yml`, `.rubocop.yml`)| -| **VALIDATE_COFFEE** | `true` | Flag to enable or disable the linting process of the language . | -| **VALIDATE_ANSIBLE** | `true` | Flag to enable or disable the linting process of the language. | -| **VALIDATE_JAVASCRIPT_ES** | `true` | Flag to enable or disable the linting process of the language. (Utilizing: eslint) | -| **JAVASCRIPT_ES_CONFIG_FILE** | `.eslintrc.yml` | Filename for [eslint configuration](https://eslint.org/docs/user-guide/configuring#configuration-file-formats) (ex: `.eslintrc.yml`, `.eslintrc.json`)| -| **VALIDATE_JAVASCRIPT_STANDARD** | `true` | Flag to enable or disable the linting process of the language. (Utilizing: standard) | -| **VALIDATE_JSX** | `true` | Flag to enable or disable the linting process for jsx files (Utilizing: eslint) | -| **VALIDATE_TSX** | `true` | Flag to enable or disable the linting process for tsx files (Utilizing: eslint) | -| **VALIDATE_TYPESCRIPT_ES** | `true` | Flag to enable or disable the linting process of the language. (Utilizing: eslint) | -| **TYPESCRIPT_ES_CONFIG_FILE** | `.eslintrc.yml` | Filename for [eslint configuration](https://eslint.org/docs/user-guide/configuring#configuration-file-formats) (ex: `.eslintrc.yml`, `.eslintrc.json`)| -| **VALIDATE_TYPESCRIPT_STANDARD** | `true` | Flag to enable or disable the linting process of the language. (Utilizing: standard) | -| **VALIDATE_DOCKER** | `true` | Flag to enable or disable the linting process of the language. | -| **VALIDATE_GO** | `true` | Flag to enable or disable the linting process of the language. | -| **VALIDATE_POWERSHELL** | `true` | Flag to enable or disable the linting process of the language. | -| **VALIDATE_ARM** | `true` | Flag to enable or disable the linting process of the language. | -| **VALIDATE_TERRAFORM** | `true` | Flag to enable or disable the linting process of the language. | -| **VALIDATE_CSS** | `true` | Flag to enable or disable the linting process of the language. | -| **VALIDATE_ENV** | `true` | Flag to enable or disable the linting process of the language. | -| **VALIDATE_CLOJURE** | `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 language. | -| **VALIDATE_KOTLIN** | `true` | Flag to enable or disable the linting process of the language. | -| **VALIDATE_DART** | `true` | Flag to enable or disable the linting process of the language. | -| **VALIDATE_OPENAPI** | `true` | Flag to enable or disable the linting process of the language. | -| **VALIDATE_CLOUDFORMATION** | `true` | Flag to enable or disable the linting process of the language. | -| **VALIDATE_PROTOBUF** | `true` | Flag to enable or disable the linting process of the language. | -| **VALIDATE_EDITORCONFIG** | `true` | Flag to enable or disable the linting process with the editorconfig. | -| **ANSIBLE_DIRECTORY** | `/ansible` | Flag to set the root directory for Ansible file location(s). | | **ACTIONS_RUNNER_DEBUG** | `false` | Flag to enable additional information about the linter, versions, and additional output. | -| **DISABLE_ERRORS** | `false` | Flag to have the linter complete with exit code 0 even if errors were detected. | +| **ANSIBLE_DIRECTORY** | `/ansible` | Flag to set the root directory for Ansible file location(s). | +| **DEFAULT_BRANCH** | `master` | The name of the repository default branch. | | **DEFAULT_WORKSPACE** | `/tmp/lint` | The location containing files to lint if you are running locally. | +| **DISABLE_ERRORS** | `false` | Flag to have the linter complete with exit code 0 even if errors were detected. | +| **JAVASCRIPT_ES_CONFIG_FILE** | `.eslintrc.yml` | Filename for [eslint configuration](https://eslint.org/docs/user-guide/configuring#configuration-file-formats) (ex: `.eslintrc.yml`, `.eslintrc.json`)| +| **LINTER_RULES_PATH** | `.github/linters` | Directory for all linter configuration rules. | +| **MULTI_STATUS** | `true` | A status API is made for each language that is linted to make visual parsing easier. | | **OUTPUT_FORMAT** | `none` | The report format to be generated, besides the stdout one. Output format of tap is currently using v13 of the specification. Supported formats: tap | | **OUTPUT_FOLDER** | `super-linter.report` | The location where the output reporting will be generated to. Output folder must not previously exist. | | **OUTPUT_DETAILS** | `simpler` | What level of details to be reported. Supported formats: simpler or detailed. | -| **MULTI_STATUS** | `true` | A status API is made for each language that is linted to make visual parsing easier. | +| **RUBY_CONFIG_FILE** | `.ruby-lint.yml` | Filename for [rubocop configuration](https://docs.rubocop.org/rubocop/configuration.html) (ex: `.ruby-lint.yml`, `.rubocop.yml`)| +| **TYPESCRIPT_ES_CONFIG_FILE** | `.eslintrc.yml` | Filename for [eslint configuration](https://eslint.org/docs/user-guide/configuring#configuration-file-formats) (ex: `.eslintrc.yml`, `.eslintrc.json`)| +| **VALIDATE_ALL_CODEBASE** | `true` | Will parse the entire repository and find all files to validate across all types. **NOTE:** When set to `false`, only **new** or **edited** files will be parsed for validation. | +| **VALIDATE_ANSIBLE** | `true` | Flag to enable or disable the linting process of the Ansible language. | +| **VALIDATE_ARM** | `true` | Flag to enable or disable the linting process of the ARM language. | +| **VALIDATE_BASH** | `true` | Flag to enable or disable the linting process of the Bash language. | +| **VALIDATE_CLOJURE** | `true` | Flag to enable or disable the linting process of the Clojure language. | +| **VALIDATE_CLOUDFORMATION** | `true` | Flag to enable or disable the linting process of the AWS Cloud Formation language. | +| **VALIDATE_COFFEE** | `true` | Flag to enable or disable the linting process of the Coffeescript language . | +| **VALIDATE_CSS** | `true` | Flag to enable or disable the linting process of the CSS language. | +| **VALIDATE_DART** | `true` | Flag to enable or disable the linting process of the Dart language. | +| **VALIDATE_DOCKER** | `true` | Flag to enable or disable the linting process of the Docker language. | +| **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_GO** | `true` | Flag to enable or disable the linting process of the Golang 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_STANDARD** | `true` | Flag to enable or disable the linting process of the Javascript language. (Utilizing: standard) | +| **VALIDATE_JSON** | `true` | Flag to enable or disable the linting process of the JSON language. | +| **VALIDATE_JSX** | `true` | Flag to enable or disable the linting process for jsx files (Utilizing: eslint) | +| **VALIDATE_KOTLIN** | `true` | Flag to enable or disable the linting process of the Kotlin language. | +| **VALIDATE_MD** | `true` | Flag to enable or disable the linting process of the Markdown language. | +| **VALIDATE_OPENAPI** | `true` | Flag to enable or disable the linting process of the OpenAPI language. | +| **VALIDATE_PERL** | `true` | Flag to enable or disable the linting process of the Perl language. | +| **VALIDATE_PHP** | `true` | Flag to enable or disable the linting process of the PHP language. | +| **VALIDATE_PROTOBUF** | `true` | Flag to enable or disable the linting process of the Protobuf language. | +| **VALIDATE_PYTHON** | `true` | Flag to enable or disable the linting process of the Python language. | +| **VALIDATE_POWERSHELL** | `true` | Flag to enable or disable the linting process of the Powershell language. | +| **VALIDATE_RAKU** | `true` | Flag to enable or disable the linting process of the Raku language. | +| **VALIDATE_RUBY** | `true` | Flag to enable or disable the linting process of the Ruby language. | +| **VALIDATE_STATES** | `true` | Flag to enable or disable the linting process for AWS States Language. | +| **VALIDATE_TERRAFORM** | `true` | Flag to enable or disable the linting process of the Terraform language. | +| **VALIDATE_TSX** | `true` | Flag to enable or disable the linting process for tsx files (Utilizing: eslint) | +| **VALIDATE_TYPESCRIPT_ES** | `true` | Flag to enable or disable the linting process of the Typescript language. (Utilizing: eslint) | +| **VALIDATE_TYPESCRIPT_STANDARD** | `true` | Flag to enable or disable the linting process of the Typescript language. (Utilizing: standard) | +| **VALIDATE_XML** | `true` | Flag to enable or disable the linting process of the XML language. | +| **VALIDATE_YAML** | `true` |Flag to enable or disable the linting process of the YAML language. | ### Template rules files You can use the **GitHub** **Super-Linter** *with* or *without* your own personal rules sets. This allows for greater flexibility for each individual code base. The Template rules all try to follow the standards we believe should be enabled at the basic level. diff --git a/lib/buildFileList.sh b/lib/buildFileList.sh index 7e105d32..6cf87663 100755 --- a/lib/buildFileList.sh +++ b/lib/buildFileList.sh @@ -160,6 +160,15 @@ function BuildFileList() { ################################ FILE_ARRAY_CFN+=("$FILE") fi + ############################################ + # Check if the file is AWS States Language # + ############################################ + if DetectAWSStatesFIle "$FILE"; then + ################################ + # Append the file to the array # + ################################ + FILE_ARRAY_STATES+=("$FILE") + fi ########################################################## # Set the READ_ONLY_CHANGE_FLAG since this could be exec # ########################################################## diff --git a/lib/linter.sh b/lib/linter.sh index 030bb170..f1a87849 100755 --- a/lib/linter.sh +++ b/lib/linter.sh @@ -21,89 +21,91 @@ source /action/lib/worker.sh # Source the function script(s) ########### # GLOBALS # ########### -# Default Vars -DEFAULT_RULES_LOCATION='/action/lib/.automation' # Default rules files location -LINTER_RULES_PATH="${LINTER_RULES_PATH:-.github/linters}" # Linter Path Directory -# YAML Vars -YAML_FILE_NAME='.yaml-lint.yml' # Name of the file -YAML_LINTER_RULES="$DEFAULT_RULES_LOCATION/$YAML_FILE_NAME" # Path to the yaml lint rules -# MD Vars -MARKDOWN_FILE_NAME='.markdown-lint.yml' # Name of the file -MARKDOWN_LINTER_RULES="$DEFAULT_RULES_LOCATION/$MARKDOWN_FILE_NAME" # Path to the markdown lint rules -# Python Vars -PYTHON_FILE_NAME='.python-lint' # Name of the file -PYTHON_LINTER_RULES="$DEFAULT_RULES_LOCATION/$PYTHON_FILE_NAME" # Path to the python lint rules -# Cloudformation Vars -CFN_FILE_NAME='.cfnlintrc.yml' # Name of the file -CFN_LINTER_RULES="$DEFAULT_RULES_LOCATION/$CFN_FILE_NAME" # Path to the cloudformation lint rules -# Ruby Vars -RUBY_FILE_NAME="${RUBY_CONFIG_FILE:-.ruby-lint.yml}" # Name of the file -RUBY_LINTER_RULES="$DEFAULT_RULES_LOCATION/$RUBY_FILE_NAME" # Path to the ruby lint rules -# Coffee Vars -COFFEE_FILE_NAME='.coffee-lint.json' # Name of the file -COFFEESCRIPT_LINTER_RULES="$DEFAULT_RULES_LOCATION/$COFFEE_FILE_NAME" # Path to the coffeescript lint rules -# Javascript Vars -JAVASCRIPT_FILE_NAME="${JAVASCRIPT_ES_CONFIG_FILE:-.eslintrc.yml}" # Name of the file -JAVASCRIPT_LINTER_RULES="$DEFAULT_RULES_LOCATION/$JAVASCRIPT_FILE_NAME" # Path to the Javascript lint rules -JAVASCRIPT_STANDARD_LINTER_RULES='' # ENV string to pass when running js standard -# Typescript Vars -TYPESCRIPT_FILE_NAME="${TYPESCRIPT_ES_CONFIG_FILE:-.eslintrc.yml}" # Name of the file -TYPESCRIPT_LINTER_RULES="$DEFAULT_RULES_LOCATION/$TYPESCRIPT_FILE_NAME" # Path to the Typescript lint rules -TYPESCRIPT_STANDARD_LINTER_RULES='' # ENV string to pass when running js standard # Ansible Vars ANSIBLE_FILE_NAME='.ansible-lint.yml' # Name of the file ANSIBLE_LINTER_RULES="$DEFAULT_RULES_LOCATION/$ANSIBLE_FILE_NAME" # Path to the Ansible lint rules +# Azure Resource Manager Vars +ARM_FILE_NAME='.arm-ttk.psd1' # Name of the file +ARM_LINTER_RULES="$DEFAULT_RULES_LOCATION/$ARM_FILE_NAME" # Path to the ARM lint rules +# Cloudformation Vars +CFN_FILE_NAME='.cfnlintrc.yml' # Name of the file +CFN_LINTER_RULES="$DEFAULT_RULES_LOCATION/$CFN_FILE_NAME" # Path to the cloudformation lint rules +# Clojure Vars +CLOJURE_FILE_NAME='.clj-kondo/config.edn' # Name of the file +CLOJURE_LINTER_RULES="$DEFAULT_RULES_LOCATION/$CLOJURE_FILE_NAME" # Path to the Clojure lint rules +# Coffee Vars +COFFEESCRIPT_LINTER_RULES="$DEFAULT_RULES_LOCATION/$COFFEE_FILE_NAME" # Path to the coffeescript lint rules +COFFEE_FILE_NAME='.coffee-lint.json' # Name of the file +# CSS Vars +CSS_FILE_NAME='.stylelintrc.json' # Name of the file +CSS_LINTER_RULES="$DEFAULT_RULES_LOCATION/$CSS_FILE_NAME" # Path to the CSS lint rules +# Dart Vars +DART_FILE_NAME='analysis_options.yaml' # Name of the file +DART_LINTER_RULES="$DEFAULT_RULES_LOCATION/$DART_FILE_NAME" # Path to the DART lint rules +# Default Vars +DEFAULT_RULES_LOCATION='/action/lib/.automation' # Default rules files location # Docker Vars DOCKER_FILE_NAME='.dockerfilelintrc' # Name of the file DOCKER_LINTER_RULES="$DEFAULT_RULES_LOCATION/$DOCKER_FILE_NAME" # Path to the Docker lint rules # Golang Vars GO_FILE_NAME='.golangci.yml' # Name of the file GO_LINTER_RULES="$DEFAULT_RULES_LOCATION/$GO_FILE_NAME" # Path to the Go lint rules -# Terraform Vars -TERRAFORM_FILE_NAME='.tflint.hcl' # Name of the file -TERRAFORM_LINTER_RULES="$DEFAULT_RULES_LOCATION/$TERRAFORM_FILE_NAME" # Path to the Terraform lint rules -# Powershell Vars -POWERSHELL_FILE_NAME='.powershell-psscriptanalyzer.psd1' # Name of the file -POWERSHELL_LINTER_RULES="$DEFAULT_RULES_LOCATION/$POWERSHELL_FILE_NAME" # Path to the Powershell lint rules -# Azure Resource Manager Vars -ARM_FILE_NAME='.arm-ttk.psd1' # Name of the file -ARM_LINTER_RULES="$DEFAULT_RULES_LOCATION/$ARM_FILE_NAME" # Path to the ARM lint rules -# CSS Vars -CSS_FILE_NAME='.stylelintrc.json' # Name of the file -CSS_LINTER_RULES="$DEFAULT_RULES_LOCATION/$CSS_FILE_NAME" # Path to the CSS lint rules -# OpenAPI Vars -OPENAPI_FILE_NAME='.openapirc.yml' # Name of the file -OPENAPI_LINTER_RULES="$DEFAULT_RULES_LOCATION/$OPENAPI_FILE_NAME" # Path to the OpenAPI lint rules -# Protocol Buffers Vars -PROTOBUF_FILE_NAME='.protolintrc.yml' # Name of the file -PROTOBUF_LINTER_RULES="$DEFAULT_RULES_LOCATION/$PROTOBUF_FILE_NAME" # Path to the Protocol Buffers lint rules -# Clojure Vars -CLOJURE_FILE_NAME='.clj-kondo/config.edn' # Name of the file -CLOJURE_LINTER_RULES="$DEFAULT_RULES_LOCATION/$CLOJURE_FILE_NAME" # Path to the Clojure lint rules -# Dart Vars -DART_FILE_NAME='analysis_options.yaml' # Name of the file -DART_LINTER_RULES="$DEFAULT_RULES_LOCATION/$DART_FILE_NAME" # Path to the DART lint rules # HTML Vars HTML_FILE_NAME='.htmlhintrc' # Name of the file HTML_LINTER_RULES="$DEFAULT_RULES_LOCATION/$HTML_FILE_NAME" # Path to the CSS lint rules +# Javascript Vars +JAVASCRIPT_FILE_NAME="${JAVASCRIPT_ES_CONFIG_FILE:-.eslintrc.yml}" # Name of the file +JAVASCRIPT_LINTER_RULES="$DEFAULT_RULES_LOCATION/$JAVASCRIPT_FILE_NAME" # Path to the Javascript lint rules +JAVASCRIPT_STANDARD_LINTER_RULES='' # ENV string to pass when running js standard +# Default linter path +LINTER_RULES_PATH="${LINTER_RULES_PATH:-.github/linters}" # Linter Path Directory +# MD Vars +MARKDOWN_FILE_NAME='.markdown-lint.yml' # Name of the file +MARKDOWN_LINTER_RULES="$DEFAULT_RULES_LOCATION/$MARKDOWN_FILE_NAME" # Path to the markdown lint rules +# OpenAPI Vars +OPENAPI_FILE_NAME='.openapirc.yml' # Name of the file +OPENAPI_LINTER_RULES="$DEFAULT_RULES_LOCATION/$OPENAPI_FILE_NAME" # Path to the OpenAPI lint rules +# Powershell Vars +POWERSHELL_FILE_NAME='.powershell-psscriptanalyzer.psd1' # Name of the file +POWERSHELL_LINTER_RULES="$DEFAULT_RULES_LOCATION/$POWERSHELL_FILE_NAME" # Path to the Powershell lint rules +# Protocol Buffers Vars +PROTOBUF_FILE_NAME='.protolintrc.yml' # Name of the file +PROTOBUF_LINTER_RULES="$DEFAULT_RULES_LOCATION/$PROTOBUF_FILE_NAME" # Path to the Protocol Buffers lint rules +# Python Vars +PYTHON_FILE_NAME='.python-lint' # Name of the file +PYTHON_LINTER_RULES="$DEFAULT_RULES_LOCATION/$PYTHON_FILE_NAME" # Path to the python lint rules +# Ruby Vars +RUBY_FILE_NAME="${RUBY_CONFIG_FILE:-.ruby-lint.yml}" # Name of the file +RUBY_LINTER_RULES="$DEFAULT_RULES_LOCATION/$RUBY_FILE_NAME" # Path to the ruby lint rules +# Terraform Vars +TERRAFORM_FILE_NAME='.tflint.hcl' # Name of the file +TERRAFORM_LINTER_RULES="$DEFAULT_RULES_LOCATION/$TERRAFORM_FILE_NAME" # Path to the Terraform lint rules +# Typescript Vars +TYPESCRIPT_FILE_NAME="${TYPESCRIPT_ES_CONFIG_FILE:-.eslintrc.yml}" # Name of the file +TYPESCRIPT_LINTER_RULES="$DEFAULT_RULES_LOCATION/$TYPESCRIPT_FILE_NAME" # Path to the Typescript lint rules +TYPESCRIPT_STANDARD_LINTER_RULES='' # ENV string to pass when running js standard +# YAML Vars +YAML_FILE_NAME='.yaml-lint.yml' # Name of the file +YAML_LINTER_RULES="$DEFAULT_RULES_LOCATION/$YAML_FILE_NAME" # Path to the yaml lint rules ####################################### # Linter array for information prints # ####################################### -LINTER_ARRAY=("jsonlint" "yamllint" "xmllint" "markdownlint" "shellcheck" - "pylint" "perl" "raku" "rubocop" "coffeelint" "eslint" "standard" - "ansible-lint" "dockerfilelint" "golangci-lint" "tflint" - "stylelint" "dotenv-linter" "pwsh" "arm-ttk" "ktlint" "protolint" "clj-kondo" - "spectral" "cfn-lint" "dart" "htmlhint") +LINTER_ARRAY=('ansible-lint' 'arm-ttk' 'asl-validator' 'cfn-lint' 'clj-kondo' 'coffeelint' + 'dart' 'dockerfilelint' 'dotenv-linter' 'eslint' 'golangci-lint' 'htmlhint' + 'jsonlint' 'ktlint' 'markdownlint' 'perl' 'protolint' 'pwsh' 'pylint' + 'raku' 'rubocop' 'shellcheck' 'spectral' 'standard' 'stylelint' 'tflint' + 'xmllint' 'yamllint') ############################# # Language array for prints # ############################# LANGUAGE_ARRAY=('ANSIBLE' 'ARM' 'BASH' 'CFN' 'CLOJURE' 'COFFEESCRIPT' - 'CSS' 'DART' 'DOCKER' 'ENV' 'GO' 'HTML' - 'JAVASCRIPT_ES' 'JAVASCRIPT_STANDARD' 'JSON' 'JSX' 'KOTLIN' 'OPENAPI' - 'MARKDOWN' 'PERL' 'PHP' 'POWERSHELL' 'PROTOBUF' 'PYTHON' 'RAKU' 'RUBY' - 'TERRAFORM' 'TSX' 'TYPESCRIPT_ES' 'TYPESCRIPT_STANDARD' 'XML' 'YML' ) + 'CSS' 'DART' 'DOCKER' 'ENV' 'GO' 'HTML' 'JAVASCRIPT_ES' + 'JAVASCRIPT_STANDARD' 'JSON' 'JSX' 'KOTLIN' 'MARKDOWN' 'OPENAPI' + 'PERL' 'PHP' 'POWERSHELL' 'PROTOBUF' 'PYTHON' + 'RAKU' 'RUBY' 'STATES' 'TERRAFORM' 'TSX' 'TYPESCRIPT_ES' 'TYPESCRIPT_STANDARD' + 'XML' 'YML') ############################################ # Array for all languages that were linted # @@ -113,15 +115,17 @@ LINTED_LANGUAGES_ARRAY=() # Will be filled at run time with all languages that w ################### # GitHub ENV Vars # ################### -GITHUB_SHA="${GITHUB_SHA}" # GitHub sha from the commit +ANSIBLE_DIRECTORY="${ANSIBLE_DIRECTORY}" # Ansible Directory +DEFAULT_BRANCH="${DEFAULT_BRANCH:-master}" # Default Git Branch to use (master by default) +DISABLE_ERRORS="${DISABLE_ERRORS}" # Boolean to enable warning-only output without throwing errors GITHUB_EVENT_PATH="${GITHUB_EVENT_PATH}" # Github Event Path -GITHUB_WORKSPACE="${GITHUB_WORKSPACE}" # Github Workspace -GITHUB_TOKEN="${GITHUB_TOKEN}" # GitHub Token passed from environment GITHUB_REPOSITORY="${GITHUB_REPOSITORY}" # GitHub Org/Repo passed from system GITHUB_RUN_ID="${GITHUB_RUN_ID}" # GitHub RUn ID to point to logs -DEFAULT_BRANCH="${DEFAULT_BRANCH:-master}" # Default Git Branch to use (master by default) +GITHUB_SHA="${GITHUB_SHA}" # GitHub sha from the commit +GITHUB_TOKEN="${GITHUB_TOKEN}" # GitHub Token passed from environment +GITHUB_WORKSPACE="${GITHUB_WORKSPACE}" # Github Workspace MULTI_STATUS="${MULTI_STATUS:-true}" # Multiple status are created for each check ran -ANSIBLE_DIRECTORY="${ANSIBLE_DIRECTORY}" # Ansible Directory +TEST_CASE_RUN="${TEST_CASE_RUN}" # Boolean to validate only test cases VALIDATE_ALL_CODEBASE="${VALIDATE_ALL_CODEBASE}" # Boolean to validate all files VALIDATE_ANSIBLE="${VALIDATE_ANSIBLE}" # Boolean to validate language VALIDATE_ARM="${VALIDATE_ARM}" # Boolean to validate language @@ -149,14 +153,13 @@ VALIDATE_POWERSHELL="${VALIDATE_POWERSHELL}" # Boolean to vali VALIDATE_PYTHON="${VALIDATE_PYTHON}" # Boolean to validate language VALIDATE_RAKU="${VALIDATE_RAKU}" # Boolean to validate language VALIDATE_RUBY="${VALIDATE_RUBY}" # Boolean to validate language +VALIDATE_STATES="${VALIDATE_STATES}" # Boolean to validate language VALIDATE_TERRAFORM="${VALIDATE_TERRAFORM}" # Boolean to validate language VALIDATE_TSX="${VALIDATE_TSX}" # Boolean to validate language VALIDATE_TYPESCRIPT_ES="${VALIDATE_TYPESCRIPT_ES}" # Boolean to validate language VALIDATE_TYPESCRIPT_STANDARD="${VALIDATE_TYPESCRIPT_STANDARD}" # Boolean to validate language VALIDATE_XML="${VALIDATE_XML}" # Boolean to validate language VALIDATE_YAML="${VALIDATE_YAML}" # Boolean to validate language -TEST_CASE_RUN="${TEST_CASE_RUN}" # Boolean to validate only test cases -DISABLE_ERRORS="${DISABLE_ERRORS}" # Boolean to enable warning-only output without throwing errors ############## # Debug Vars # @@ -225,6 +228,7 @@ FILE_ARRAY_PROTOBUF=() # Array of files to check FILE_ARRAY_PYTHON=() # Array of files to check FILE_ARRAY_RAKU=() # Array of files to check FILE_ARRAY_RUBY=() # Array of files to check +FILE_ARRAY_STATES=() # Array of files to check FILE_ARRAY_TERRAFORM=() # Array of files to check FILE_ARRAY_TSX=() # Array of files to check FILE_ARRAY_TYPESCRIPT_ES=() # Array of files to check @@ -261,6 +265,7 @@ ERRORS_FOUND_PROTOBUF=0 # Count of errors found ERRORS_FOUND_PYTHON=0 # Count of errors found ERRORS_FOUND_RAKU=0 # Count of errors found ERRORS_FOUND_RUBY=0 # Count of errors found +ERRORS_FOUND_STATES=0 # Count of errors found ERRORS_FOUND_TERRAFORM=0 # Count of errors found ERRORS_FOUND_TSX=0 # Count of errors found ERRORS_FOUND_TYPESCRIPT_STANDARD=0 # Count of errors found @@ -574,7 +579,28 @@ DetectCloudFormationFile() { ########################################## return 1 } +################################################################################ +#### Function DetectAWSStatesFIle ############################################## +DetectAWSStatesFIle() { + ################ + # Pull in Vars # + ################ + FILE="$1" # File that we need to validate + # https://states-language.net/spec.html#example + ############################### + # check if file has resources # + ############################### + if grep '"Resource": *"arn"*' "$FILE"; then + # Found it + return 0 + fi + + ################################################# + # No identifiers of a AWS States Language found # + ################################################# + return 1 +} ################################################################################ #### Function GetGitHubVars #################################################### GetGitHubVars() { @@ -936,38 +962,38 @@ Footer() { ############################### # Exit with 1 if errors found # ############################### - elif [ "$ERRORS_FOUND_YML" -ne 0 ] || - [ "$ERRORS_FOUND_JSON" -ne 0 ] || - [ "$ERRORS_FOUND_XML" -ne 0 ] || - [ "$ERRORS_FOUND_MARKDOWN" -ne 0 ] || + elif [ "$ERRORS_FOUND_ANSIBLE" -ne 0 ] || + [ "$ERRORS_FOUND_ARM" -ne 0 ] || [ "$ERRORS_FOUND_BASH" -ne 0 ] || - [ "$ERRORS_FOUND_PERL" -ne 0 ] || - [ "$ERRORS_FOUND_RAKU" -ne 0 ] || - [ "$ERRORS_FOUND_PHP" -ne 0 ] || - [ "$ERRORS_FOUND_PYTHON" -ne 0 ] || + [ "$ERRORS_FOUND_CFN" -ne 0 ] || + [ "$ERRORS_FOUND_CLOJURE" -ne 0 ] || [ "$ERRORS_FOUND_COFFEESCRIPT" -ne 0 ] || - [ "$ERRORS_FOUND_ANSIBLE" -ne 0 ] || + [ "$ERRORS_FOUND_CSS" -ne 0 ] || + [ "$ERRORS_FOUND_DART" -ne 0 ] || + [ "$ERRORS_FOUND_DOCKER" -ne 0 ] || + [ "$ERRORS_FOUND_ENV" -ne 0 ] || + [ "$ERRORS_FOUND_GO" -ne 0 ] || + [ "$ERRORS_FOUND_HTML" -ne 0 ] || [ "$ERRORS_FOUND_JAVASCRIPT_ES" -ne 0 ] || [ "$ERRORS_FOUND_JAVASCRIPT_STANDARD" -ne 0 ] || + [ "$ERRORS_FOUND_JSON" -ne 0 ] || [ "$ERRORS_FOUND_JSX" -ne 0 ] || + [ "$ERRORS_FOUND_KOTLIN" -ne 0 ] || + [ "$ERRORS_FOUND_MARKDOWN" -ne 0 ] || + [ "$ERRORS_FOUND_OPENAPI" -ne 0 ] || + [ "$ERRORS_FOUND_PERL" -ne 0 ] || + [ "$ERRORS_FOUND_PHP" -ne 0 ] || + [ "$ERRORS_FOUND_POWERSHELL" -ne 0 ] || + [ "$ERRORS_FOUND_PROTOBUF" -ne 0 ] || + [ "$ERRORS_FOUND_PYTHON" -ne 0 ] || + [ "$ERRORS_FOUND_RAKU" -ne 0 ] || + [ "$ERRORS_FOUND_RUBY" -ne 0 ] || + [ "$ERRORS_FOUND_TERRAFORM" -ne 0 ] || [ "$ERRORS_FOUND_TSX" -ne 0 ] || [ "$ERRORS_FOUND_TYPESCRIPT_ES" -ne 0 ] || [ "$ERRORS_FOUND_TYPESCRIPT_STANDARD" -ne 0 ] || - [ "$ERRORS_FOUND_DOCKER" -ne 0 ] || - [ "$ERRORS_FOUND_GO" -ne 0 ] || - [ "$ERRORS_FOUND_TERRAFORM" -ne 0 ] || - [ "$ERRORS_FOUND_POWERSHELL" -ne 0 ] || - [ "$ERRORS_FOUND_ARM" -ne 0 ] || - [ "$ERRORS_FOUND_RUBY" -ne 0 ] || - [ "$ERRORS_FOUND_CSS" -ne 0 ] || - [ "$ERRORS_FOUND_CFN" -ne 0 ] || - [ "$ERRORS_FOUND_ENV" -ne 0 ] || - [ "$ERRORS_FOUND_OPENAPI" -ne 0 ] || - [ "$ERRORS_FOUND_PROTOBUF" -ne 0 ] || - [ "$ERRORS_FOUND_CLOJURE" -ne 0 ] || - [ "$ERRORS_FOUND_KOTLIN" -ne 0 ] || - [ "$ERRORS_FOUND_DART" -ne 0 ] || - [ "$ERRORS_FOUND_HTML" -ne 0 ]; then + [ "$ERRORS_FOUND_XML" -ne 0 ] || + [ "$ERRORS_FOUND_YML" -ne 0 ]; then # Failed exit echo -e "${NC}${F[R]}Exiting with errors found!${NC}" exit 1 @@ -1500,6 +1526,16 @@ if [ "$VALIDATE_HTML" == "true" ]; then LintCodebase "HTML" "htmlhint" "htmlhint --config $HTML_LINTER_RULES" ".*\.\(html\)\$" "${FILE_ARRAY_HTML[@]}" fi +###################### +# AWS STATES LINTING # +###################### +if [ "$VALIDATE_STATES" == "true" ]; then + ######################### + # Lint the STATES files # + ######################### + LintCodebase "STATES" "asl-validator" "asl-validator --json-path" ".*\.\(json\)\$" "${FILE_ARRAY_STATES[@]}" +fi + ########## # Footer # ########## diff --git a/lib/validation.sh b/lib/validation.sh index 9be40a60..bbfaa08e 100755 --- a/lib/validation.sh +++ b/lib/validation.sh @@ -72,6 +72,7 @@ function GetValidationInfo() { VALIDATE_PYTHON="${VALIDATE_PYTHON,,}" VALIDATE_RAKU="${VALIDATE_RAKU,,}" VALIDATE_RUBY="${VALIDATE_RUBY,,}" + VALIDATE_STATES="${VALIDATE_STATES,,}" VALIDATE_TERRAFORM="${VALIDATE_TERRAFORM,,}" VALIDATE_TSX="${VALIDATE_TSX,,}" VALIDATE_TYPESCRIPT_ES="${VALIDATE_TYPESCRIPT_ES,,}" @@ -83,36 +84,36 @@ function GetValidationInfo() { # Determine if any linters were explicitly set # ################################################ ANY_SET="false" - if [[ -n $VALIDATE_YAML || -n \ - $VALIDATE_JSON || -n \ - $VALIDATE_XML || -n \ - $VALIDATE_MARKDOWN || -n \ + if [[ -n $VALIDATE_ANSIBLE || -n \ + $VALIDATE_ARM || -n \ $VALIDATE_BASH || -n \ - $VALIDATE_PERL || -n \ - $VALIDATE_RAKU || -n \ - $VALIDATE_PHP || -n \ - $VALIDATE_PYTHON || -n \ - $VALIDATE_RUBY || -n \ + $VALIDATE_CLOJURE || -n \ $VALIDATE_COFFEE || -n \ - $VALIDATE_ANSIBLE || -n \ + $VALIDATE_CSS || -n \ + $VALIDATE_DART || -n \ + $VALIDATE_DOCKER || -n \ + $VALIDATE_EDITORCONFIG || -n \ + $VALIDATE_ENV || -n \ + $VALIDATE_GO || -n \ + $VALIDATE_HTML ]]; then || -n \ $VALIDATE_JAVASCRIPT_ES || -n \ $VALIDATE_JAVASCRIPT_STANDARD || -n \ + $VALIDATE_JSON || -n \ + $VALIDATE_KOTLIN || -n \ + $VALIDATE_MARKDOWN || -n \ + $VALIDATE_OPENAPI || -n \ + $VALIDATE_PERL || -n \ + $VALIDATE_PHP || -n \ + $VALIDATE_POWERSHELL || -n \ + $VALIDATE_PROTOBUF || -n \ + $VALIDATE_PYTHON || -n \ + $VALIDATE_RAKU || -n \ + $VALIDATE_RUBY || -n \ + $VALIDATE_TERRAFORM || -n \ $VALIDATE_TYPESCRIPT_ES || -n \ $VALIDATE_TYPESCRIPT_STANDARD || -n \ - $VALIDATE_DOCKER || -n \ - $VALIDATE_GO || -n \ - $VALIDATE_TERRAFORM || -n \ - $VALIDATE_POWERSHELL || -n \ - $VALIDATE_ARM || -n \ - $VALIDATE_CSS || -n \ - $VALIDATE_ENV || -n \ - $VALIDATE_CLOJURE || -n \ - $VALIDATE_PROTOBUF || -n \ - $VALIDATE_OPENAPI || -n \ - $VALIDATE_KOTLIN || -n \ - $VALIDATE_DART || -n \ - $VALIDATE_EDITORCONFIG || -n \ - $VALIDATE_HTML ]]; then + $VALIDATE_XML || -n \ + $VALIDATE_YAML ]]; then ANY_SET="true" fi @@ -256,6 +257,20 @@ function GetValidationInfo() { VALIDATE_RUBY="true" fi + ########################################## + # Validate if we should check AWS States # + ########################################## + if [[ $ANY_SET == "true" ]]; then + # Some linter flags were set - only run those set to true + if [[ -z $VALIDATE_STATES ]]; then + # STATES flag was not set - default to false + VALIDATE_STATES="false" + fi + else + # No linter flags were set - default all to true + VALIDATE_STATES="true" + fi + ###################################### # Validate if we should check COFFEE # ###################################### @@ -720,6 +735,11 @@ function GetValidationInfo() { else PRINT_ARRAY+=("- Excluding [HTML] files in code base...") fi + if [[ $VALIDATE_STATES == "true" ]]; then + PRINT_ARRAY+=("- Validating [AWS STATES] files in code base...") + else + PRINT_ARRAY+=("- Excluding [AWS STATES] files in code base...") + fi ############################## # Validate Ansible Directory # diff --git a/lib/worker.sh b/lib/worker.sh index 17db091c..ef3055aa 100755 --- a/lib/worker.sh +++ b/lib/worker.sh @@ -578,6 +578,7 @@ function RunTestCases() { TestCodebase "PYTHON" "pylint" "pylint --rcfile $PYTHON_LINTER_RULES" ".*\.\(py\)\$" "python" TestCodebase "RAKU" "raku" "raku -c" ".*\.\(raku\|rakumod\|rakutest\|pm6\|pl6\|p6\)\$" "raku" TestCodebase "RUBY" "rubocop" "rubocop -c $RUBY_LINTER_RULES" ".*\.\(rb\)\$" "ruby" + TestCodebase "STATES" "asl-validator" "asl-validator --json-path" ".*\.\(json\)\$" "states" TestCodebase "TERRAFORM" "tflint" "tflint -c $TERRAFORM_LINTER_RULES" ".*\.\(tf\)\$" "terraform" TestCodebase "TYPESCRIPT_ES" "eslint" "eslint --no-eslintrc -c $TYPESCRIPT_LINTER_RULES" ".*\.\(ts\)\$" "typescript" TestCodebase "TYPESCRIPT_STANDARD" "standard" "standard --parser @typescript-eslint/parser --plugin @typescript-eslint/eslint-plugin $TYPESCRIPT_STANDARD_LINTER_RULES" ".*\.\(ts\)\$" "typescript" From ea77cfa8860cdb25b83263c28f70b1618ca081c2 Mon Sep 17 00:00:00 2001 From: Lucas Gravley <29484535+admiralAwkbar@users.noreply.github.com> Date: Tue, 21 Jul 2020 13:55:27 -0500 Subject: [PATCH 006/135] cleanup of big clean --- .github/workflows/stack-linter.yml | 1 + lib/linter.sh | 1 + lib/validation.sh | 2 +- 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/stack-linter.yml b/.github/workflows/stack-linter.yml index d301d0c4..33f611e9 100644 --- a/.github/workflows/stack-linter.yml +++ b/.github/workflows/stack-linter.yml @@ -44,3 +44,4 @@ jobs: uses: docker://github/super-linter:latest env: VALIDATE_ALL_CODEBASE: false + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/lib/linter.sh b/lib/linter.sh index f1a87849..714709a0 100755 --- a/lib/linter.sh +++ b/lib/linter.sh @@ -988,6 +988,7 @@ Footer() { [ "$ERRORS_FOUND_PYTHON" -ne 0 ] || [ "$ERRORS_FOUND_RAKU" -ne 0 ] || [ "$ERRORS_FOUND_RUBY" -ne 0 ] || + [ "$ERRORS_FOUND_STATES" -ne 0 ] || [ "$ERRORS_FOUND_TERRAFORM" -ne 0 ] || [ "$ERRORS_FOUND_TSX" -ne 0 ] || [ "$ERRORS_FOUND_TYPESCRIPT_ES" -ne 0 ] || diff --git a/lib/validation.sh b/lib/validation.sh index bbfaa08e..8d784e09 100755 --- a/lib/validation.sh +++ b/lib/validation.sh @@ -95,7 +95,7 @@ function GetValidationInfo() { $VALIDATE_EDITORCONFIG || -n \ $VALIDATE_ENV || -n \ $VALIDATE_GO || -n \ - $VALIDATE_HTML ]]; then || -n \ + $VALIDATE_HTML || -n \ $VALIDATE_JAVASCRIPT_ES || -n \ $VALIDATE_JAVASCRIPT_STANDARD || -n \ $VALIDATE_JSON || -n \ From d7bbd8d3bbaaba16ea0586644ce7a345474d1ec4 Mon Sep 17 00:00:00 2001 From: Lucas Gravley <29484535+admiralAwkbar@users.noreply.github.com> Date: Tue, 21 Jul 2020 14:06:01 -0500 Subject: [PATCH 007/135] adding var --- Dockerfile | 1 + 1 file changed, 1 insertion(+) diff --git a/Dockerfile b/Dockerfile index 6d216eed..5b244efe 100644 --- a/Dockerfile +++ b/Dockerfile @@ -196,6 +196,7 @@ ENV ACTIONS_RUNNER_DEBUG=${ACTIONS_RUNNER_DEBUG} \ DISABLE_ERRORS=${DISABLE_ERRORS} \ GITHUB_EVENT_PATH=${GITHUB_EVENT_PATH} \ GITHUB_SHA=${GITHUB_SHA} \ + GITHUB_TOKEN=${GITHUB_TOKEN} \ GITHUB_WORKSPACE=${GITHUB_WORKSPACE} \ LINTER_RULES_PATH=${LINTER_RULES_PATH} \ OUTPUT_DETAILS=${OUTPUT_DETAILS} \ From 1bb5236960830a30705336e1aa27669c5bf3e2e5 Mon Sep 17 00:00:00 2001 From: Lucas Gravley <29484535+admiralAwkbar@users.noreply.github.com> Date: Tue, 21 Jul 2020 14:23:56 -0500 Subject: [PATCH 008/135] Fixes --- lib/linter.sh | 4 ++-- lib/validation.sh | 60 +++++++++++++++++++++++------------------------ 2 files changed, 32 insertions(+), 32 deletions(-) diff --git a/lib/linter.sh b/lib/linter.sh index 714709a0..aa4fbcb7 100755 --- a/lib/linter.sh +++ b/lib/linter.sh @@ -23,10 +23,10 @@ source /action/lib/worker.sh # Source the function script(s) ########### # Ansible Vars ANSIBLE_FILE_NAME='.ansible-lint.yml' # Name of the file -ANSIBLE_LINTER_RULES="$DEFAULT_RULES_LOCATION/$ANSIBLE_FILE_NAME" # Path to the Ansible lint rules +ANSIBLE_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${ANSIBLE_FILE_NAME}" # Path to the Ansible lint rules # Azure Resource Manager Vars ARM_FILE_NAME='.arm-ttk.psd1' # Name of the file -ARM_LINTER_RULES="$DEFAULT_RULES_LOCATION/$ARM_FILE_NAME" # Path to the ARM lint rules +ARM_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${ARM_FILE_NAME}" # Path to the ARM lint rules # Cloudformation Vars CFN_FILE_NAME='.cfnlintrc.yml' # Name of the file CFN_LINTER_RULES="$DEFAULT_RULES_LOCATION/$CFN_FILE_NAME" # Path to the cloudformation lint rules diff --git a/lib/validation.sh b/lib/validation.sh index 8d784e09..e5ef62f3 100755 --- a/lib/validation.sh +++ b/lib/validation.sh @@ -84,36 +84,36 @@ function GetValidationInfo() { # Determine if any linters were explicitly set # ################################################ ANY_SET="false" - if [[ -n $VALIDATE_ANSIBLE || -n \ - $VALIDATE_ARM || -n \ - $VALIDATE_BASH || -n \ - $VALIDATE_CLOJURE || -n \ - $VALIDATE_COFFEE || -n \ - $VALIDATE_CSS || -n \ - $VALIDATE_DART || -n \ - $VALIDATE_DOCKER || -n \ - $VALIDATE_EDITORCONFIG || -n \ - $VALIDATE_ENV || -n \ - $VALIDATE_GO || -n \ - $VALIDATE_HTML || -n \ - $VALIDATE_JAVASCRIPT_ES || -n \ - $VALIDATE_JAVASCRIPT_STANDARD || -n \ - $VALIDATE_JSON || -n \ - $VALIDATE_KOTLIN || -n \ - $VALIDATE_MARKDOWN || -n \ - $VALIDATE_OPENAPI || -n \ - $VALIDATE_PERL || -n \ - $VALIDATE_PHP || -n \ - $VALIDATE_POWERSHELL || -n \ - $VALIDATE_PROTOBUF || -n \ - $VALIDATE_PYTHON || -n \ - $VALIDATE_RAKU || -n \ - $VALIDATE_RUBY || -n \ - $VALIDATE_TERRAFORM || -n \ - $VALIDATE_TYPESCRIPT_ES || -n \ - $VALIDATE_TYPESCRIPT_STANDARD || -n \ - $VALIDATE_XML || -n \ - $VALIDATE_YAML ]]; then + if [[ -n ${VALIDATE_ANSIBLE} || -n \ + ${VALIDATE_ARM} || -n \ + ${VALIDATE_BASH} || -n \ + ${VALIDATE_CLOJURE} || -n \ + ${VALIDATE_COFFEE} || -n \ + ${VALIDATE_CSS} || -n \ + ${VALIDATE_DART} || -n \ + ${VALIDATE_DOCKER} || -n \ + ${VALIDATE_EDITORCONFIG} || -n \ + ${VALIDATE_ENV} || -n \ + ${VALIDATE_GO} || -n \ + ${VALIDATE_HTML} || -n \ + ${VALIDATE_JAVASCRIPT_ES} || -n \ + ${VALIDATE_JAVASCRIPT_STANDARD} || -n \ + ${VALIDATE_JSON} || -n \ + ${VALIDATE_KOTLIN} || -n \ + ${VALIDATE_MARKDOWN} || -n \ + ${VALIDATE_OPENAPI} || -n \ + ${VALIDATE_PERL} || -n \ + ${VALIDATE_PHP} || -n \ + ${VALIDATE_POWERSHELL} || -n \ + ${VALIDATE_PROTOBUF} || -n \ + ${VALIDATE_PYTHON} || -n \ + ${VALIDATE_RAKU} || -n \ + ${VALIDATE_RUBY} || -n \ + ${VALIDATE_TERRAFORM} || -n \ + ${VALIDATE_TYPESCRIPT_ES} || -n \ + ${VALIDATE_TYPESCRIPT_STANDARD} || -n \ + ${VALIDATE_XML} || -n \ + ${VALIDATE_YAML} ]]; then ANY_SET="true" fi From e5a2baf30f5f56ecc8d9f58954d9db59e96e384e Mon Sep 17 00:00:00 2001 From: Casey Vega Date: Tue, 21 Jul 2020 12:25:42 -0700 Subject: [PATCH 009/135] add dart template --- TEMPLATES/analysis_options.yaml | 57 +++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 TEMPLATES/analysis_options.yaml diff --git a/TEMPLATES/analysis_options.yaml b/TEMPLATES/analysis_options.yaml new file mode 100644 index 00000000..0c444f44 --- /dev/null +++ b/TEMPLATES/analysis_options.yaml @@ -0,0 +1,57 @@ +--- +########################## +########################## +## Dart Linter rules ## +########################## +########################## + +# Pedantic Rules +# https://github.com/dart-lang/pedantic + +linter: + rules: + - always_declare_return_types + - always_require_non_null_named_parameters + - annotate_overrides + - avoid_empty_else + - avoid_init_to_null + - avoid_null_checks_in_equality_operators + - avoid_relative_lib_imports + - avoid_return_types_on_setters + - avoid_shadowing_type_parameters + - avoid_types_as_parameter_names + - camel_case_extensions + - curly_braces_in_flow_control_structures + - empty_catches + - empty_constructor_bodies + - library_names + - library_prefixes + - no_duplicate_case_values + - null_closures + - omit_local_variable_types + - prefer_adjacent_string_concatenation + - prefer_collection_literals + - prefer_conditional_assignment + - prefer_contains + - prefer_equal_for_default_values + - prefer_final_fields + - prefer_for_elements_to_map_fromIterable + - prefer_generic_function_type_aliases + - prefer_if_null_operators + - prefer_is_empty + - prefer_is_not_empty + - prefer_iterable_whereType + - prefer_single_quotes + - prefer_spread_collections + - recursive_getters + - slash_for_doc_comments + - type_init_formals + - unawaited_futures + - unnecessary_const + - unnecessary_new + - unnecessary_null_in_if_null_operators + - unnecessary_this + - unrelated_type_equality_checks + - use_function_type_syntax_for_parameters + - use_rethrow_when_possible + - valid_regexps From daba819f8592eafe96eb30ebe94d89fe6096a06f Mon Sep 17 00:00:00 2001 From: Casey Vega Date: Tue, 21 Jul 2020 12:33:36 -0700 Subject: [PATCH 010/135] update linter.sh - remove pub On second thought, I do not like this approach because it's asking `pub` questions it has already answered for each file, coupled with the fact that `|| true` means pub can fail for whatever reason. Looking at the other linters, and looking at the recent bug report in #120 I think it's safe to assume that pub, or any package manager can be called as a first step and then proceed to super lint. --- lib/linter.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/linter.sh b/lib/linter.sh index a4310c38..78092223 100755 --- a/lib/linter.sh +++ b/lib/linter.sh @@ -1388,7 +1388,7 @@ if [ "${VALIDATE_DART}" == "true" ]; then # Lint the Dart files # ####################### # LintCodebase "FILE_TYPE" "LINTER_NAME" "LINTER_CMD" "FILE_TYPES_REGEX" "FILE_ARRAY" - LintCodebase "DART" "dart" "pub get || true && dartanalyzer --fatal-infos --fatal-warnings --options ${DART_LINTER_RULES}" ".*\.\(dart\)\$" "${FILE_ARRAY_DART[@]}" + LintCodebase "DART" "dart" "dartanalyzer --fatal-infos --fatal-warnings --options ${DART_LINTER_RULES}" ".*\.\(dart\)\$" "${FILE_ARRAY_DART[@]}" fi ################## From af7101fd92d832d6a4ef13098a28a69670b34868 Mon Sep 17 00:00:00 2001 From: Casey Vega Date: Tue, 21 Jul 2020 12:37:47 -0700 Subject: [PATCH 011/135] update dart section - clean up invalid references - modified invalid file names (changed to anaylsis_options.yaml) --- docs/disabling-linters.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/docs/disabling-linters.md b/docs/disabling-linters.md index 858966a0..d625eef1 100644 --- a/docs/disabling-linters.md +++ b/docs/disabling-linters.md @@ -35,6 +35,7 @@ For some linters it is also possible to override rules on a case by case level w - [Dockerfile](#dockerfile) - [Terraform](#terraform) - [CSS](#css) +- [DART](#dart) - [ENV](#dotenv-linter) - [Kotlin](#kotlin) - [OpenAPI](#openapi) @@ -826,7 +827,7 @@ import package.b.* - `.github/linters/.dart-lint.yml` - You can pass multiple rules and overwrite default rules -- File should be located at: `.github/linters/.dart-lint.yml` +- File should be located at: `.github/linters/anaylsis_options.yaml` ### dartanalyzer disable single line @@ -844,7 +845,7 @@ int x = ''; // ignore: invalid_assignment ### dartanalyzer disable entire file -- You can disable entire files with the `analyzer.exclude` property in `.dart-lint.yml` +- You can disable entire files with the `analyzer.exclude` property in `anaylsis_options.yaml` ```dart analyzer: From 71a3cd9093fe63d63f91a38d22ad048d53eaba34 Mon Sep 17 00:00:00 2001 From: Eric Nemchik Date: Tue, 21 Jul 2020 14:39:14 -0500 Subject: [PATCH 012/135] Braces orthodontist --- lib/buildFileList.sh | 4 +- lib/linter.sh | 106 +++++++++++++++++++++---------------------- lib/validation.sh | 6 +-- lib/worker.sh | 8 ++-- 4 files changed, 62 insertions(+), 62 deletions(-) diff --git a/lib/buildFileList.sh b/lib/buildFileList.sh index e01070a0..eef350c6 100755 --- a/lib/buildFileList.sh +++ b/lib/buildFileList.sh @@ -163,11 +163,11 @@ function BuildFileList() { ############################################ # Check if the file is AWS States Language # ############################################ - if DetectAWSStatesFIle "$FILE"; then + if DetectAWSStatesFIle "${FILE}"; then ################################ # Append the file to the array # ################################ - FILE_ARRAY_STATES+=("$FILE") + FILE_ARRAY_STATES+=("${FILE}") fi ########################################################## # Set the READ_ONLY_CHANGE_FLAG since this could be exec # diff --git a/lib/linter.sh b/lib/linter.sh index 3a7d5b76..4727016c 100755 --- a/lib/linter.sh +++ b/lib/linter.sh @@ -29,19 +29,19 @@ ARM_FILE_NAME='.arm-ttk.psd1' # Name o ARM_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${ARM_FILE_NAME}" # Path to the ARM lint rules # Cloudformation Vars CFN_FILE_NAME='.cfnlintrc.yml' # Name of the file -CFN_LINTER_RULES="$DEFAULT_RULES_LOCATION/$CFN_FILE_NAME" # Path to the cloudformation lint rules +CFN_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${CFN_FILE_NAME}" # Path to the cloudformation lint rules # Clojure Vars CLOJURE_FILE_NAME='.clj-kondo/config.edn' # Name of the file -CLOJURE_LINTER_RULES="$DEFAULT_RULES_LOCATION/$CLOJURE_FILE_NAME" # Path to the Clojure lint rules +CLOJURE_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${CLOJURE_FILE_NAME}" # Path to the Clojure lint rules # Coffee Vars -COFFEESCRIPT_LINTER_RULES="$DEFAULT_RULES_LOCATION/$COFFEE_FILE_NAME" # Path to the coffeescript lint rules +COFFEESCRIPT_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${COFFEE_FILE_NAME}" # Path to the coffeescript lint rules COFFEE_FILE_NAME='.coffee-lint.json' # Name of the file # CSS Vars CSS_FILE_NAME='.stylelintrc.json' # Name of the file -CSS_LINTER_RULES="$DEFAULT_RULES_LOCATION/$CSS_FILE_NAME" # Path to the CSS lint rules +CSS_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${CSS_FILE_NAME}" # Path to the CSS lint rules # Dart Vars DART_FILE_NAME='analysis_options.yaml' # Name of the file -DART_LINTER_RULES="$DEFAULT_RULES_LOCATION/$DART_FILE_NAME" # Path to the DART lint rules +DART_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${DART_FILE_NAME}" # Path to the DART lint rules # Default Vars DEFAULT_RULES_LOCATION='/action/lib/.automation' # Default rules files location # Docker Vars @@ -49,44 +49,44 @@ DOCKER_FILE_NAME='.dockerfilelintrc' # Name o DOCKER_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${DOCKER_FILE_NAME}" # Path to the Docker lint rules # Golang Vars 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 # HTML Vars 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 # Javascript Vars JAVASCRIPT_FILE_NAME="${JAVASCRIPT_ES_CONFIG_FILE:-.eslintrc.yml}" # Name of the file -JAVASCRIPT_LINTER_RULES="$DEFAULT_RULES_LOCATION/$JAVASCRIPT_FILE_NAME" # Path to the Javascript lint rules +JAVASCRIPT_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${JAVASCRIPT_FILE_NAME}" # Path to the Javascript lint rules JAVASCRIPT_STANDARD_LINTER_RULES='' # ENV string to pass when running js standard # Default linter path LINTER_RULES_PATH="${LINTER_RULES_PATH:-.github/linters}" # Linter Path Directory # MD Vars MARKDOWN_FILE_NAME='.markdown-lint.yml' # Name of the file -MARKDOWN_LINTER_RULES="$DEFAULT_RULES_LOCATION/$MARKDOWN_FILE_NAME" # Path to the markdown lint rules +MARKDOWN_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${MARKDOWN_FILE_NAME}" # Path to the markdown lint rules # OpenAPI Vars OPENAPI_FILE_NAME='.openapirc.yml' # Name of the file -OPENAPI_LINTER_RULES="$DEFAULT_RULES_LOCATION/$OPENAPI_FILE_NAME" # Path to the OpenAPI lint rules +OPENAPI_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${OPENAPI_FILE_NAME}" # Path to the OpenAPI lint rules # Powershell Vars POWERSHELL_FILE_NAME='.powershell-psscriptanalyzer.psd1' # Name of the file -POWERSHELL_LINTER_RULES="$DEFAULT_RULES_LOCATION/$POWERSHELL_FILE_NAME" # Path to the Powershell lint rules +POWERSHELL_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${POWERSHELL_FILE_NAME}" # Path to the Powershell lint rules # Protocol Buffers Vars PROTOBUF_FILE_NAME='.protolintrc.yml' # Name of the file -PROTOBUF_LINTER_RULES="$DEFAULT_RULES_LOCATION/$PROTOBUF_FILE_NAME" # Path to the Protocol Buffers lint rules +PROTOBUF_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${PROTOBUF_FILE_NAME}" # Path to the Protocol Buffers lint rules # Python Vars PYTHON_FILE_NAME='.python-lint' # Name of the file -PYTHON_LINTER_RULES="$DEFAULT_RULES_LOCATION/$PYTHON_FILE_NAME" # Path to the python lint rules +PYTHON_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${PYTHON_FILE_NAME}" # Path to the python lint rules # Ruby Vars RUBY_FILE_NAME="${RUBY_CONFIG_FILE:-.ruby-lint.yml}" # Name of the file -RUBY_LINTER_RULES="$DEFAULT_RULES_LOCATION/$RUBY_FILE_NAME" # Path to the ruby lint rules +RUBY_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${RUBY_FILE_NAME}" # Path to the ruby lint rules # Terraform Vars 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 # Typescript Vars TYPESCRIPT_FILE_NAME="${TYPESCRIPT_ES_CONFIG_FILE:-.eslintrc.yml}" # Name of the file -TYPESCRIPT_LINTER_RULES="$DEFAULT_RULES_LOCATION/$TYPESCRIPT_FILE_NAME" # Path to the Typescript lint rules +TYPESCRIPT_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${TYPESCRIPT_FILE_NAME}" # Path to the Typescript lint rules TYPESCRIPT_STANDARD_LINTER_RULES='' # ENV string to pass when running js standard # YAML Vars YAML_FILE_NAME='.yaml-lint.yml' # Name of the file -YAML_LINTER_RULES="$DEFAULT_RULES_LOCATION/$YAML_FILE_NAME" # Path to the yaml lint rules +YAML_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${YAML_FILE_NAME}" # Path to the yaml lint rules ####################################### @@ -586,13 +586,13 @@ DetectAWSStatesFIle() { ################ # Pull in Vars # ################ - FILE="$1" # File that we need to validate + FILE="${1}" # File that we need to validate # https://states-language.net/spec.html#example ############################### # check if file has resources # ############################### - if grep '"Resource": *"arn"*' "$FILE"; then + if grep '"Resource": *"arn"*' "${FILE}"; then # Found it return 0 fi @@ -963,39 +963,39 @@ Footer() { ############################### # Exit with 1 if errors found # ############################### - elif [ "$ERRORS_FOUND_ANSIBLE" -ne 0 ] || - [ "$ERRORS_FOUND_ARM" -ne 0 ] || - [ "$ERRORS_FOUND_BASH" -ne 0 ] || - [ "$ERRORS_FOUND_CFN" -ne 0 ] || - [ "$ERRORS_FOUND_CLOJURE" -ne 0 ] || - [ "$ERRORS_FOUND_COFFEESCRIPT" -ne 0 ] || - [ "$ERRORS_FOUND_CSS" -ne 0 ] || - [ "$ERRORS_FOUND_DART" -ne 0 ] || - [ "$ERRORS_FOUND_DOCKER" -ne 0 ] || - [ "$ERRORS_FOUND_ENV" -ne 0 ] || - [ "$ERRORS_FOUND_GO" -ne 0 ] || - [ "$ERRORS_FOUND_HTML" -ne 0 ] || - [ "$ERRORS_FOUND_JAVASCRIPT_ES" -ne 0 ] || - [ "$ERRORS_FOUND_JAVASCRIPT_STANDARD" -ne 0 ] || - [ "$ERRORS_FOUND_JSON" -ne 0 ] || - [ "$ERRORS_FOUND_JSX" -ne 0 ] || - [ "$ERRORS_FOUND_KOTLIN" -ne 0 ] || - [ "$ERRORS_FOUND_MARKDOWN" -ne 0 ] || - [ "$ERRORS_FOUND_OPENAPI" -ne 0 ] || - [ "$ERRORS_FOUND_PERL" -ne 0 ] || - [ "$ERRORS_FOUND_PHP" -ne 0 ] || - [ "$ERRORS_FOUND_POWERSHELL" -ne 0 ] || - [ "$ERRORS_FOUND_PROTOBUF" -ne 0 ] || - [ "$ERRORS_FOUND_PYTHON" -ne 0 ] || - [ "$ERRORS_FOUND_RAKU" -ne 0 ] || - [ "$ERRORS_FOUND_RUBY" -ne 0 ] || - [ "$ERRORS_FOUND_STATES" -ne 0 ] || - [ "$ERRORS_FOUND_TERRAFORM" -ne 0 ] || - [ "$ERRORS_FOUND_TSX" -ne 0 ] || - [ "$ERRORS_FOUND_TYPESCRIPT_ES" -ne 0 ] || - [ "$ERRORS_FOUND_TYPESCRIPT_STANDARD" -ne 0 ] || - [ "$ERRORS_FOUND_XML" -ne 0 ] || - [ "$ERRORS_FOUND_YML" -ne 0 ]; then + elif [ "${ERRORS_FOUND_ANSIBLE}" -ne 0 ] || + [ "${ERRORS_FOUND_ARM}" -ne 0 ] || + [ "${ERRORS_FOUND_BASH}" -ne 0 ] || + [ "${ERRORS_FOUND_CFN}" -ne 0 ] || + [ "${ERRORS_FOUND_CLOJURE}" -ne 0 ] || + [ "${ERRORS_FOUND_COFFEESCRIPT}" -ne 0 ] || + [ "${ERRORS_FOUND_CSS}" -ne 0 ] || + [ "${ERRORS_FOUND_DART}" -ne 0 ] || + [ "${ERRORS_FOUND_DOCKER}" -ne 0 ] || + [ "${ERRORS_FOUND_ENV}" -ne 0 ] || + [ "${ERRORS_FOUND_GO}" -ne 0 ] || + [ "${ERRORS_FOUND_HTML}" -ne 0 ] || + [ "${ERRORS_FOUND_JAVASCRIPT_ES}" -ne 0 ] || + [ "${ERRORS_FOUND_JAVASCRIPT_STANDARD}" -ne 0 ] || + [ "${ERRORS_FOUND_JSON}" -ne 0 ] || + [ "${ERRORS_FOUND_JSX}" -ne 0 ] || + [ "${ERRORS_FOUND_KOTLIN}" -ne 0 ] || + [ "${ERRORS_FOUND_MARKDOWN}" -ne 0 ] || + [ "${ERRORS_FOUND_OPENAPI}" -ne 0 ] || + [ "${ERRORS_FOUND_PERL}" -ne 0 ] || + [ "${ERRORS_FOUND_PHP}" -ne 0 ] || + [ "${ERRORS_FOUND_POWERSHELL}" -ne 0 ] || + [ "${ERRORS_FOUND_PROTOBUF}" -ne 0 ] || + [ "${ERRORS_FOUND_PYTHON}" -ne 0 ] || + [ "${ERRORS_FOUND_RAKU}" -ne 0 ] || + [ "${ERRORS_FOUND_RUBY}" -ne 0 ] || + [ "${ERRORS_FOUND_STATES}" -ne 0 ] || + [ "${ERRORS_FOUND_TERRAFORM}" -ne 0 ] || + [ "${ERRORS_FOUND_TSX}" -ne 0 ] || + [ "${ERRORS_FOUND_TYPESCRIPT_ES}" -ne 0 ] || + [ "${ERRORS_FOUND_TYPESCRIPT_STANDARD}" -ne 0 ] || + [ "${ERRORS_FOUND_XML}" -ne 0 ] || + [ "${ERRORS_FOUND_YML}" -ne 0 ]; then # Failed exit echo -e "${NC}${F[R]}Exiting with errors found!${NC}" exit 1 @@ -1531,7 +1531,7 @@ fi ###################### # AWS STATES LINTING # ###################### -if [ "$VALIDATE_STATES" == "true" ]; then +if [ "${VALIDATE_STATES}" == "true" ]; then ######################### # Lint the STATES files # ######################### diff --git a/lib/validation.sh b/lib/validation.sh index a96cfd1c..4fffb249 100755 --- a/lib/validation.sh +++ b/lib/validation.sh @@ -260,9 +260,9 @@ function GetValidationInfo() { ########################################## # Validate if we should check AWS States # ########################################## - if [[ $ANY_SET == "true" ]]; then + if [[ ${ANY_SET} == "true" ]]; then # Some linter flags were set - only run those set to true - if [[ -z $VALIDATE_STATES ]]; then + if [[ -z ${VALIDATE_STATES} ]]; then # STATES flag was not set - default to false VALIDATE_STATES="false" fi @@ -735,7 +735,7 @@ function GetValidationInfo() { else PRINT_ARRAY+=("- Excluding [HTML] files in code base...") fi - if [[ $VALIDATE_STATES == "true" ]]; then + if [[ ${VALIDATE_STATES} == "true" ]]; then PRINT_ARRAY+=("- Validating [AWS STATES] files in code base...") else PRINT_ARRAY+=("- Excluding [AWS STATES] files in code base...") diff --git a/lib/worker.sh b/lib/worker.sh index cde619c1..a78ec722 100755 --- a/lib/worker.sh +++ b/lib/worker.sh @@ -577,11 +577,11 @@ function RunTestCases() { TestCodebase "PROTOBUF" "protolint" "protolint lint --config_path ${PROTOBUF_LINTER_RULES}" ".*\.\(proto\)\$" "protobuf" TestCodebase "PYTHON" "pylint" "pylint --rcfile ${PYTHON_LINTER_RULES}" ".*\.\(py\)\$" "python" TestCodebase "RAKU" "raku" "raku -c" ".*\.\(raku\|rakumod\|rakutest\|pm6\|pl6\|p6\)\$" "raku" - TestCodebase "RUBY" "rubocop" "rubocop -c $RUBY_LINTER_RULES" ".*\.\(rb\)\$" "ruby" + TestCodebase "RUBY" "rubocop" "rubocop -c ${RUBY_LINTER_RULES}" ".*\.\(rb\)\$" "ruby" TestCodebase "STATES" "asl-validator" "asl-validator --json-path" ".*\.\(json\)\$" "states" - TestCodebase "TERRAFORM" "tflint" "tflint -c $TERRAFORM_LINTER_RULES" ".*\.\(tf\)\$" "terraform" - TestCodebase "TYPESCRIPT_ES" "eslint" "eslint --no-eslintrc -c $TYPESCRIPT_LINTER_RULES" ".*\.\(ts\)\$" "typescript" - TestCodebase "TYPESCRIPT_STANDARD" "standard" "standard --parser @typescript-eslint/parser --plugin @typescript-eslint/eslint-plugin $TYPESCRIPT_STANDARD_LINTER_RULES" ".*\.\(ts\)\$" "typescript" + TestCodebase "TERRAFORM" "tflint" "tflint -c ${TERRAFORM_LINTER_RULES}" ".*\.\(tf\)\$" "terraform" + TestCodebase "TYPESCRIPT_ES" "eslint" "eslint --no-eslintrc -c ${TYPESCRIPT_LINTER_RULES}" ".*\.\(ts\)\$" "typescript" + TestCodebase "TYPESCRIPT_STANDARD" "standard" "standard --parser @typescript-eslint/parser --plugin @typescript-eslint/eslint-plugin ${TYPESCRIPT_STANDARD_LINTER_RULES}" ".*\.\(ts\)\$" "typescript" TestCodebase "XML" "xmllint" "xmllint" ".*\.\(xml\)\$" "xml" TestCodebase "YML" "yamllint" "yamllint -c ${YAML_LINTER_RULES}" ".*\.\(yml\|yaml\)\$" "yml" From c1c3547e293a2fbefd4b33fe57f6afa47c993d9c Mon Sep 17 00:00:00 2001 From: Eric Nemchik Date: Tue, 21 Jul 2020 14:43:22 -0500 Subject: [PATCH 013/135] Markdown getdown --- .automation/test/states/README.md | 8 ++- README.md | 98 +++++++++++++++---------------- 2 files changed, 56 insertions(+), 50 deletions(-) diff --git a/.automation/test/states/README.md b/.automation/test/states/README.md index fd526bb2..f2c3dfc3 100644 --- a/.automation/test/states/README.md +++ b/.automation/test/states/README.md @@ -1,13 +1,19 @@ # AWS States language Test Cases -This folder holds the test cases for **AWS States Language**. + +This folder holds the test cases for **AWS States Language**. ## 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. diff --git a/README.md b/README.md index eab3c9c2..633d3ddb 100644 --- a/README.md +++ b/README.md @@ -165,56 +165,56 @@ This means that if you run the linter "out of the box", all languages will be ch But if you wish to select specific linters, we give you full control to choose which linters are run, and won't run anything unexpected. -| **ENV VAR** | **Default Value** | **Notes** | -| --- | --- | --- | -| **ACTIONS_RUNNER_DEBUG** | `false` | Flag to enable additional information about the linter, versions, and additional output. | -| **ANSIBLE_DIRECTORY** | `/ansible` | Flag to set the root directory for Ansible file location(s). | -| **DEFAULT_BRANCH** | `master` | The name of the repository default branch. | -| **DEFAULT_WORKSPACE** | `/tmp/lint` | The location containing files to lint if you are running locally. | -| **DISABLE_ERRORS** | `false` | Flag to have the linter complete with exit code 0 even if errors were detected. | -| **JAVASCRIPT_ES_CONFIG_FILE** | `.eslintrc.yml` | Filename for [eslint configuration](https://eslint.org/docs/user-guide/configuring#configuration-file-formats) (ex: `.eslintrc.yml`, `.eslintrc.json`)| -| **LINTER_RULES_PATH** | `.github/linters` | Directory for all linter configuration rules. | -| **MULTI_STATUS** | `true` | A status API is made for each language that is linted to make visual parsing easier. | -| **OUTPUT_FORMAT** | `none` | The report format to be generated, besides the stdout one. Output format of tap is currently using v13 of the specification. Supported formats: tap | -| **OUTPUT_FOLDER** | `super-linter.report` | The location where the output reporting will be generated to. Output folder must not previously exist. | -| **OUTPUT_DETAILS** | `simpler` | What level of details to be reported. Supported formats: simpler or detailed. | -| **RUBY_CONFIG_FILE** | `.ruby-lint.yml` | Filename for [rubocop configuration](https://docs.rubocop.org/rubocop/configuration.html) (ex: `.ruby-lint.yml`, `.rubocop.yml`)| -| **TYPESCRIPT_ES_CONFIG_FILE** | `.eslintrc.yml` | Filename for [eslint configuration](https://eslint.org/docs/user-guide/configuring#configuration-file-formats) (ex: `.eslintrc.yml`, `.eslintrc.json`)| +| **ENV VAR** | **Default Value** | **Notes** | +| -------------------------------- | --------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| **ACTIONS_RUNNER_DEBUG** | `false` | Flag to enable additional information about the linter, versions, and additional output. | +| **ANSIBLE_DIRECTORY** | `/ansible` | Flag to set the root directory for Ansible file location(s). | +| **DEFAULT_BRANCH** | `master` | The name of the repository default branch. | +| **DEFAULT_WORKSPACE** | `/tmp/lint` | The location containing files to lint if you are running locally. | +| **DISABLE_ERRORS** | `false` | Flag to have the linter complete with exit code 0 even if errors were detected. | +| **JAVASCRIPT_ES_CONFIG_FILE** | `.eslintrc.yml` | Filename for [eslint configuration](https://eslint.org/docs/user-guide/configuring#configuration-file-formats) (ex: `.eslintrc.yml`, `.eslintrc.json`) | +| **LINTER_RULES_PATH** | `.github/linters` | Directory for all linter configuration rules. | +| **MULTI_STATUS** | `true` | A status API is made for each language that is linted to make visual parsing easier. | +| **OUTPUT_FORMAT** | `none` | The report format to be generated, besides the stdout one. Output format of tap is currently using v13 of the specification. Supported formats: tap | +| **OUTPUT_FOLDER** | `super-linter.report` | The location where the output reporting will be generated to. Output folder must not previously exist. | +| **OUTPUT_DETAILS** | `simpler` | What level of details to be reported. Supported formats: simpler or detailed. | +| **RUBY_CONFIG_FILE** | `.ruby-lint.yml` | Filename for [rubocop configuration](https://docs.rubocop.org/rubocop/configuration.html) (ex: `.ruby-lint.yml`, `.rubocop.yml`) | +| **TYPESCRIPT_ES_CONFIG_FILE** | `.eslintrc.yml` | Filename for [eslint configuration](https://eslint.org/docs/user-guide/configuring#configuration-file-formats) (ex: `.eslintrc.yml`, `.eslintrc.json`) | | **VALIDATE_ALL_CODEBASE** | `true` | Will parse the entire repository and find all files to validate across all types. **NOTE:** When set to `false`, only **new** or **edited** files will be parsed for validation. | -| **VALIDATE_ANSIBLE** | `true` | Flag to enable or disable the linting process of the Ansible language. | -| **VALIDATE_ARM** | `true` | Flag to enable or disable the linting process of the ARM language. | -| **VALIDATE_BASH** | `true` | Flag to enable or disable the linting process of the Bash language. | -| **VALIDATE_CLOJURE** | `true` | Flag to enable or disable the linting process of the Clojure language. | -| **VALIDATE_CLOUDFORMATION** | `true` | Flag to enable or disable the linting process of the AWS Cloud Formation language. | -| **VALIDATE_COFFEE** | `true` | Flag to enable or disable the linting process of the Coffeescript language . | -| **VALIDATE_CSS** | `true` | Flag to enable or disable the linting process of the CSS language. | -| **VALIDATE_DART** | `true` | Flag to enable or disable the linting process of the Dart language. | -| **VALIDATE_DOCKER** | `true` | Flag to enable or disable the linting process of the Docker language. | -| **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_GO** | `true` | Flag to enable or disable the linting process of the Golang 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_STANDARD** | `true` | Flag to enable or disable the linting process of the Javascript language. (Utilizing: standard) | -| **VALIDATE_JSON** | `true` | Flag to enable or disable the linting process of the JSON language. | -| **VALIDATE_JSX** | `true` | Flag to enable or disable the linting process for jsx files (Utilizing: eslint) | -| **VALIDATE_KOTLIN** | `true` | Flag to enable or disable the linting process of the Kotlin language. | -| **VALIDATE_MD** | `true` | Flag to enable or disable the linting process of the Markdown language. | -| **VALIDATE_OPENAPI** | `true` | Flag to enable or disable the linting process of the OpenAPI language. | -| **VALIDATE_PERL** | `true` | Flag to enable or disable the linting process of the Perl language. | -| **VALIDATE_PHP** | `true` | Flag to enable or disable the linting process of the PHP language. | -| **VALIDATE_PROTOBUF** | `true` | Flag to enable or disable the linting process of the Protobuf language. | -| **VALIDATE_PYTHON** | `true` | Flag to enable or disable the linting process of the Python language. | -| **VALIDATE_POWERSHELL** | `true` | Flag to enable or disable the linting process of the Powershell language. | -| **VALIDATE_RAKU** | `true` | Flag to enable or disable the linting process of the Raku language. | -| **VALIDATE_RUBY** | `true` | Flag to enable or disable the linting process of the Ruby language. | -| **VALIDATE_STATES** | `true` | Flag to enable or disable the linting process for AWS States Language. | -| **VALIDATE_TERRAFORM** | `true` | Flag to enable or disable the linting process of the Terraform language. | -| **VALIDATE_TSX** | `true` | Flag to enable or disable the linting process for tsx files (Utilizing: eslint) | -| **VALIDATE_TYPESCRIPT_ES** | `true` | Flag to enable or disable the linting process of the Typescript language. (Utilizing: eslint) | -| **VALIDATE_TYPESCRIPT_STANDARD** | `true` | Flag to enable or disable the linting process of the Typescript language. (Utilizing: standard) | -| **VALIDATE_XML** | `true` | Flag to enable or disable the linting process of the XML language. | -| **VALIDATE_YAML** | `true` |Flag to enable or disable the linting process of the YAML language. | +| **VALIDATE_ANSIBLE** | `true` | Flag to enable or disable the linting process of the Ansible language. | +| **VALIDATE_ARM** | `true` | Flag to enable or disable the linting process of the ARM language. | +| **VALIDATE_BASH** | `true` | Flag to enable or disable the linting process of the Bash language. | +| **VALIDATE_CLOJURE** | `true` | Flag to enable or disable the linting process of the Clojure language. | +| **VALIDATE_CLOUDFORMATION** | `true` | Flag to enable or disable the linting process of the AWS Cloud Formation language. | +| **VALIDATE_COFFEE** | `true` | Flag to enable or disable the linting process of the Coffeescript language . | +| **VALIDATE_CSS** | `true` | Flag to enable or disable the linting process of the CSS language. | +| **VALIDATE_DART** | `true` | Flag to enable or disable the linting process of the Dart language. | +| **VALIDATE_DOCKER** | `true` | Flag to enable or disable the linting process of the Docker language. | +| **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_GO** | `true` | Flag to enable or disable the linting process of the Golang 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_STANDARD** | `true` | Flag to enable or disable the linting process of the Javascript language. (Utilizing: standard) | +| **VALIDATE_JSON** | `true` | Flag to enable or disable the linting process of the JSON language. | +| **VALIDATE_JSX** | `true` | Flag to enable or disable the linting process for jsx files (Utilizing: eslint) | +| **VALIDATE_KOTLIN** | `true` | Flag to enable or disable the linting process of the Kotlin language. | +| **VALIDATE_MD** | `true` | Flag to enable or disable the linting process of the Markdown language. | +| **VALIDATE_OPENAPI** | `true` | Flag to enable or disable the linting process of the OpenAPI language. | +| **VALIDATE_PERL** | `true` | Flag to enable or disable the linting process of the Perl language. | +| **VALIDATE_PHP** | `true` | Flag to enable or disable the linting process of the PHP language. | +| **VALIDATE_PROTOBUF** | `true` | Flag to enable or disable the linting process of the Protobuf language. | +| **VALIDATE_PYTHON** | `true` | Flag to enable or disable the linting process of the Python language. | +| **VALIDATE_POWERSHELL** | `true` | Flag to enable or disable the linting process of the Powershell language. | +| **VALIDATE_RAKU** | `true` | Flag to enable or disable the linting process of the Raku language. | +| **VALIDATE_RUBY** | `true` | Flag to enable or disable the linting process of the Ruby language. | +| **VALIDATE_STATES** | `true` | Flag to enable or disable the linting process for AWS States Language. | +| **VALIDATE_TERRAFORM** | `true` | Flag to enable or disable the linting process of the Terraform language. | +| **VALIDATE_TSX** | `true` | Flag to enable or disable the linting process for tsx files (Utilizing: eslint) | +| **VALIDATE_TYPESCRIPT_ES** | `true` | Flag to enable or disable the linting process of the Typescript language. (Utilizing: eslint) | +| **VALIDATE_TYPESCRIPT_STANDARD** | `true` | Flag to enable or disable the linting process of the Typescript language. (Utilizing: standard) | +| **VALIDATE_XML** | `true` | Flag to enable or disable the linting process of the XML language. | +| **VALIDATE_YAML** | `true` | Flag to enable or disable the linting process of the YAML language. | ### Template rules files From 586677713406488a9085a4a206457432943ca299 Mon Sep 17 00:00:00 2001 From: Lukas Gravley Date: Tue, 21 Jul 2020 14:53:32 -0500 Subject: [PATCH 014/135] Rename expected-COFFEESCRIPT.tap to expected-COFFEESCRIPT.tap.ignored --- ...xpected-COFFEESCRIPT.tap => expected-COFFEESCRIPT.tap.ignored} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename .automation/test/coffeescript/reports/{expected-COFFEESCRIPT.tap => expected-COFFEESCRIPT.tap.ignored} (100%) diff --git a/.automation/test/coffeescript/reports/expected-COFFEESCRIPT.tap b/.automation/test/coffeescript/reports/expected-COFFEESCRIPT.tap.ignored similarity index 100% rename from .automation/test/coffeescript/reports/expected-COFFEESCRIPT.tap rename to .automation/test/coffeescript/reports/expected-COFFEESCRIPT.tap.ignored From b6410c5cba46198ecbd18cd635df56c9044a64c0 Mon Sep 17 00:00:00 2001 From: Lukas Gravley Date: Tue, 21 Jul 2020 15:04:59 -0500 Subject: [PATCH 015/135] Rename expected-STATES.tap to expected-STATES.tap.ignored --- .../reports/{expected-STATES.tap => expected-STATES.tap.ignored} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename .automation/test/states/reports/{expected-STATES.tap => expected-STATES.tap.ignored} (100%) diff --git a/.automation/test/states/reports/expected-STATES.tap b/.automation/test/states/reports/expected-STATES.tap.ignored similarity index 100% rename from .automation/test/states/reports/expected-STATES.tap rename to .automation/test/states/reports/expected-STATES.tap.ignored From c596ef11de805dbe85d0f2c024bd090520703f55 Mon Sep 17 00:00:00 2001 From: Casey Vega Date: Tue, 21 Jul 2020 13:32:34 -0700 Subject: [PATCH 016/135] Update Dockerfile - clean up glibc pkg for dart Noticed `glibc-${GLIBC_VERSION}.apk` was getting purged after and laying around in `/`. --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 4f56d321..8aa3c5b9 100644 --- a/Dockerfile +++ b/Dockerfile @@ -174,7 +174,7 @@ RUN curl -sSLO https://github.com/pinterest/ktlint/releases/latest/download/ktli #################### RUN wget -q -O /etc/apk/keys/sgerrand.rsa.pub https://alpine-pkgs.sgerrand.com/sgerrand.rsa.pub RUN wget https://github.com/sgerrand/alpine-pkg-glibc/releases/download/${GLIBC_VERSION}/glibc-${GLIBC_VERSION}.apk -RUN apk add --no-cache glibc-${GLIBC_VERSION}.apk +RUN apk add --no-cache glibc-${GLIBC_VERSION}.apk && rm glibc-${GLIBC_VERSION}.apk RUN wget https://storage.googleapis.com/dart-archive/channels/stable/release/${DART_VERSION}/sdk/dartsdk-linux-x64-release.zip -O - -q | unzip -q - \ && chmod +x dart-sdk/bin/dart* \ && mv dart-sdk/bin/* /usr/bin/ && mv dart-sdk/lib/* /usr/lib/ && mv dart-sdk/include/* /usr/include/ \ From 1870af5c5f92907c9dd4a11536949edf6f1fe242 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 22 Jul 2020 06:07:25 +0000 Subject: [PATCH 017/135] Update actions/github-script requirement to v2 Updates the requirements on [actions/github-script](https://github.com/actions/github-script) to permit the latest version. - [Release notes](https://github.com/actions/github-script/releases) - [Commits](https://github.com/actions/github-script/commits/6e5ee1dc1cb3740e5e5e76ad668e3f526edbfe45) Signed-off-by: dependabot[bot] --- .github/workflows/automerge-dependabot.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/automerge-dependabot.yml b/.github/workflows/automerge-dependabot.yml index 1e212ebf..10942d09 100644 --- a/.github/workflows/automerge-dependabot.yml +++ b/.github/workflows/automerge-dependabot.yml @@ -30,7 +30,7 @@ jobs: if: github.actor == 'dependabot[bot]' steps: - name: merge - uses: actions/github-script@0.2.0 + uses: actions/github-script@v2 with: script: | github.pullRequests.createReview({ From eaa25456255f28626eb5e8379aa72a0156adba1c Mon Sep 17 00:00:00 2001 From: Lucas Gravley <29484535+admiralAwkbar@users.noreply.github.com> Date: Wed, 22 Jul 2020 08:06:35 -0500 Subject: [PATCH 018/135] adding it --- lib/linter.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/linter.sh b/lib/linter.sh index 4727016c..b3071780 100755 --- a/lib/linter.sh +++ b/lib/linter.sh @@ -312,9 +312,9 @@ GetLinterVersions() { # Go through the array of linters and print version info # ########################################################## for LINTER in "${LINTER_ARRAY[@]}"; do - ################### - # Get the version # - ################### + #################### + # Get the versions # + #################### if [[ "${LINTER}" == "arm-ttk" ]]; then # Need specific command for ARM mapfile -t GET_VERSION_CMD < <(grep -iE 'version' "${ARM_TTK_PSD1}" | xargs 2>&1) From e813af8313b0e60a815ecc5decb9d9cd8b3d8038 Mon Sep 17 00:00:00 2001 From: Lucas Gravley <29484535+admiralAwkbar@users.noreply.github.com> Date: Wed, 22 Jul 2020 09:20:02 -0500 Subject: [PATCH 019/135] Adding better error reporting --- lib/worker.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/worker.sh b/lib/worker.sh index a78ec722..1f461542 100755 --- a/lib/worker.sh +++ b/lib/worker.sh @@ -216,6 +216,7 @@ function LintCodebase() { # Error # ######### echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Found errors in [${LINTER_NAME}] linter!${NC}" + echo -e "${NC}${B[R]}${F[W]}Command run:${NC}[\$${LINT_CMD}]${NC}" echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[${LINT_CMD}]${NC}" # Increment the error count (("ERRORS_FOUND_${FILE_TYPE}++")) @@ -431,6 +432,7 @@ function TestCodebase() { # Error # ######### echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Found errors in [${LINTER_NAME}] linter!${NC}" + echo -e "${NC}${B[R]}${F[W]}Command run:${NC}[\$${LINT_CMD}]${NC}" echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[${LINT_CMD}]${NC}" echo -e "${NC}${B[R]}${F[W]}ERROR:${NC} Linter CMD:[${LINTER_COMMAND} ${FILE}]${NC}" # Increment the error count @@ -460,6 +462,7 @@ function TestCodebase() { ######### echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Found errors in [${LINTER_NAME}] linter!${NC}" echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} This file should have failed test case!${NC}" + echo -e "${NC}${B[R]}${F[W]}Command run:${NC}[\$${LINT_CMD}]${NC}" echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[${LINT_CMD}]${NC}" echo -e "${NC}${B[R]}${F[W]}ERROR:${NC} Linter CMD:[${LINTER_COMMAND} ${FILE}]${NC}" # Increment the error count From 54ee1cdfb43e72903fd40dd0baa5625260d111fa Mon Sep 17 00:00:00 2001 From: Lucas Gravley <29484535+admiralAwkbar@users.noreply.github.com> Date: Wed, 22 Jul 2020 09:35:21 -0500 Subject: [PATCH 020/135] fixed order --- lib/linter.sh | 81 +++++++++++++++++++++++++-------------------------- lib/worker.sh | 3 +- 2 files changed, 41 insertions(+), 43 deletions(-) diff --git a/lib/linter.sh b/lib/linter.sh index b3071780..c489a260 100755 --- a/lib/linter.sh +++ b/lib/linter.sh @@ -21,82 +21,81 @@ source /action/lib/worker.sh # Source the function script(s) ########### # GLOBALS # ########### +# Default Vars +DEFAULT_RULES_LOCATION='/action/lib/.automation' # Default rules files location # Ansible Vars -ANSIBLE_FILE_NAME='.ansible-lint.yml' # Name of the file -ANSIBLE_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${ANSIBLE_FILE_NAME}" # Path to the Ansible lint rules +ANSIBLE_FILE_NAME='.ansible-lint.yml' # Name of the file +ANSIBLE_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${ANSIBLE_FILE_NAME}" # Path to the Ansible lint rules # Azure Resource Manager Vars -ARM_FILE_NAME='.arm-ttk.psd1' # Name of the file -ARM_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${ARM_FILE_NAME}" # Path to the ARM lint rules +ARM_FILE_NAME='.arm-ttk.psd1' # Name of the file +ARM_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${ARM_FILE_NAME}" # Path to the ARM lint rules # Cloudformation Vars -CFN_FILE_NAME='.cfnlintrc.yml' # Name of the file +CFN_FILE_NAME='.cfnlintrc.yml' # Name of the file CFN_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${CFN_FILE_NAME}" # Path to the cloudformation lint rules # Clojure Vars -CLOJURE_FILE_NAME='.clj-kondo/config.edn' # Name of the file +CLOJURE_FILE_NAME='.clj-kondo/config.edn' # Name of the file CLOJURE_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${CLOJURE_FILE_NAME}" # Path to the Clojure lint rules # Coffee Vars +COFFEE_FILE_NAME='.coffee-lint.json' # Name of the file COFFEESCRIPT_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${COFFEE_FILE_NAME}" # Path to the coffeescript lint rules -COFFEE_FILE_NAME='.coffee-lint.json' # Name of the file # CSS Vars -CSS_FILE_NAME='.stylelintrc.json' # Name of the file +CSS_FILE_NAME='.stylelintrc.json' # Name of the file CSS_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${CSS_FILE_NAME}" # Path to the CSS lint rules # Dart Vars -DART_FILE_NAME='analysis_options.yaml' # Name of the file +DART_FILE_NAME='analysis_options.yaml' # Name of the file DART_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${DART_FILE_NAME}" # Path to the DART lint rules -# Default Vars -DEFAULT_RULES_LOCATION='/action/lib/.automation' # Default rules files location # Docker Vars -DOCKER_FILE_NAME='.dockerfilelintrc' # Name of the file +DOCKER_FILE_NAME='.dockerfilelintrc' # Name of the file DOCKER_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${DOCKER_FILE_NAME}" # Path to the Docker lint rules # 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 # 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 # Javascript Vars -JAVASCRIPT_FILE_NAME="${JAVASCRIPT_ES_CONFIG_FILE:-.eslintrc.yml}" # Name of the file +JAVASCRIPT_FILE_NAME="${JAVASCRIPT_ES_CONFIG_FILE:-.eslintrc.yml}" # Name of the file JAVASCRIPT_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${JAVASCRIPT_FILE_NAME}" # Path to the Javascript lint rules -JAVASCRIPT_STANDARD_LINTER_RULES='' # ENV string to pass when running js standard +JAVASCRIPT_STANDARD_LINTER_RULES='' # ENV string to pass when running js standard # Default linter path -LINTER_RULES_PATH="${LINTER_RULES_PATH:-.github/linters}" # Linter Path Directory +LINTER_RULES_PATH="${LINTER_RULES_PATH:-.github/linters}" # Linter Path Directory # MD Vars -MARKDOWN_FILE_NAME='.markdown-lint.yml' # Name of the file +MARKDOWN_FILE_NAME='.markdown-lint.yml' # Name of the file MARKDOWN_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${MARKDOWN_FILE_NAME}" # Path to the markdown lint rules # OpenAPI Vars -OPENAPI_FILE_NAME='.openapirc.yml' # Name of the file +OPENAPI_FILE_NAME='.openapirc.yml' # Name of the file OPENAPI_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${OPENAPI_FILE_NAME}" # Path to the OpenAPI lint rules # Powershell Vars -POWERSHELL_FILE_NAME='.powershell-psscriptanalyzer.psd1' # Name of the file +POWERSHELL_FILE_NAME='.powershell-psscriptanalyzer.psd1' # Name of the file POWERSHELL_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${POWERSHELL_FILE_NAME}" # Path to the Powershell lint rules # Protocol Buffers Vars -PROTOBUF_FILE_NAME='.protolintrc.yml' # Name of the file +PROTOBUF_FILE_NAME='.protolintrc.yml' # Name of the file PROTOBUF_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${PROTOBUF_FILE_NAME}" # Path to the Protocol Buffers lint rules # Python Vars -PYTHON_FILE_NAME='.python-lint' # Name of the file +PYTHON_FILE_NAME='.python-lint' # Name of the file PYTHON_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${PYTHON_FILE_NAME}" # Path to the python lint rules # Ruby Vars -RUBY_FILE_NAME="${RUBY_CONFIG_FILE:-.ruby-lint.yml}" # Name of the file +RUBY_FILE_NAME="${RUBY_CONFIG_FILE:-.ruby-lint.yml}" # Name of the file RUBY_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${RUBY_FILE_NAME}" # Path to the ruby lint rules # 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 # Typescript Vars -TYPESCRIPT_FILE_NAME="${TYPESCRIPT_ES_CONFIG_FILE:-.eslintrc.yml}" # Name of the file +TYPESCRIPT_FILE_NAME="${TYPESCRIPT_ES_CONFIG_FILE:-.eslintrc.yml}" # Name of the file TYPESCRIPT_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${TYPESCRIPT_FILE_NAME}" # Path to the Typescript lint rules -TYPESCRIPT_STANDARD_LINTER_RULES='' # ENV string to pass when running js standard +TYPESCRIPT_STANDARD_LINTER_RULES='' # ENV string to pass when running js standard # YAML Vars -YAML_FILE_NAME='.yaml-lint.yml' # Name of the file +YAML_FILE_NAME='.yaml-lint.yml' # Name of the file YAML_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${YAML_FILE_NAME}" # Path to the yaml lint rules - ####################################### # Linter array for information prints # ####################################### -LINTER_ARRAY=('ansible-lint' 'arm-ttk' 'asl-validator' 'cfn-lint' 'clj-kondo' 'coffeelint' - 'dart' 'dockerfilelint' 'dotenv-linter' 'eslint' 'golangci-lint' 'htmlhint' - 'jsonlint' 'ktlint' 'markdownlint' 'perl' 'protolint' 'pwsh' 'pylint' - 'raku' 'rubocop' 'shellcheck' 'spectral' 'standard' 'stylelint' 'tflint' - 'xmllint' 'yamllint') +LINTER_ARRAY=('ansible-lint' 'arm-ttk' 'asl-validator' 'cfn-lint' 'clj-kondo' + 'coffeelint' 'dart' 'dockerfilelint' 'dotenv-linter' 'eslint' 'golangci-lint' + 'htmlhint' 'jsonlint' 'ktlint' 'markdownlint' 'perl' 'protolint' 'pwsh' + 'pylint' 'raku' 'rubocop' 'shellcheck' 'spectral' 'standard' 'stylelint' + 'tflint' 'xmllint' 'yamllint') ############################# # Language array for prints # @@ -105,8 +104,8 @@ LANGUAGE_ARRAY=('ANSIBLE' 'ARM' 'BASH' 'CFN' 'CLOJURE' 'COFFEESCRIPT' 'CSS' 'DART' 'DOCKER' 'ENV' 'GO' 'HTML' 'JAVASCRIPT_ES' 'JAVASCRIPT_STANDARD' 'JSON' 'JSX' 'KOTLIN' 'MARKDOWN' 'OPENAPI' 'PERL' 'PHP' 'POWERSHELL' 'PROTOBUF' 'PYTHON' - 'RAKU' 'RUBY' 'STATES' 'TERRAFORM' 'TSX' 'TYPESCRIPT_ES' 'TYPESCRIPT_STANDARD' - 'XML' 'YML') + 'RAKU' 'RUBY' 'STATES' 'TERRAFORM' 'TSX' 'TYPESCRIPT_ES' + 'TYPESCRIPT_STANDARD' 'XML' 'YML') ############################################ # Array for all languages that were linted # @@ -171,10 +170,10 @@ ACTIONS_RUNNER_DEBUG="${ACTIONS_RUNNER_DEBUG:-false}" # Boolean to see even more ################ # Default Vars # ################ -DEFAULT_VALIDATE_ALL_CODEBASE='true' # Default value for validate all files -DEFAULT_WORKSPACE="${DEFAULT_WORKSPACE:-/tmp/lint}" # Default workspace if running locally -DEFAULT_RUN_LOCAL='false' # Default value for debugging locally -DEFAULT_TEST_CASE_RUN='false' # Flag to tell code to run only test cases +DEFAULT_VALIDATE_ALL_CODEBASE='true' # Default value for validate all files +DEFAULT_WORKSPACE="${DEFAULT_WORKSPACE:-/tmp/lint}" # Default workspace if running locally +DEFAULT_RUN_LOCAL='false' # Default value for debugging locally +DEFAULT_TEST_CASE_RUN='false' # Flag to tell code to run only test cases DEFAULT_IFS="${IFS}" # Get the Default IFS for updating ############################################################### @@ -188,7 +187,7 @@ READ_ONLY_CHANGE_FLAG=0 # Flag set to 1 if echo "${READ_ONLY_CHANGE_FLAG}" > /dev/null 2>&1 || true # Workaround SC2034 TEST_CASE_FOLDER='.automation/test' # Folder for test cases we should always ignore echo "${TEST_CASE_FOLDER}" > /dev/null 2>&1 || true # Workaround SC2034 -DEFAULT_ANSIBLE_DIRECTORY="${GITHUB_WORKSPACE}/ansible" # Default Ansible Directory +DEFAULT_ANSIBLE_DIRECTORY="${GITHUB_WORKSPACE}/ansible" # Default Ansible Directory echo "${DEFAULT_ANSIBLE_DIRECTORY}" > /dev/null 2>&1 || true # Workaround SC2034 WARNING_ARRAY_TEST=() # Array of warning linters that did not have an expected test result. echo "${WARNING_ARRAY_TEST[*]}" > /dev/null 2>&1 || true # Workaround SC2034 @@ -199,7 +198,7 @@ echo "${WARNING_ARRAY_TEST[*]}" > /dev/null 2>&1 || true # Workaround SC2034 OUTPUT_FORMAT="${OUTPUT_FORMAT}" # Output format to be generated. Default none OUTPUT_FOLDER="${OUTPUT_FOLDER:-super-linter.report}" # Folder where the reports are generated. Default super-linter.report OUTPUT_DETAILS="${OUTPUT_DETAILS:-simpler}" # What level of details. (simpler or detailed). Default simpler -REPORT_OUTPUT_FOLDER="${DEFAULT_WORKSPACE}/${OUTPUT_FOLDER}" +REPORT_OUTPUT_FOLDER="${DEFAULT_WORKSPACE}/${OUTPUT_FOLDER}" # Location for the report folder ########################## # Array of changed files # diff --git a/lib/worker.sh b/lib/worker.sh index 1f461542..f5957f4e 100755 --- a/lib/worker.sh +++ b/lib/worker.sh @@ -216,8 +216,8 @@ function LintCodebase() { # Error # ######### echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Found errors in [${LINTER_NAME}] linter!${NC}" - echo -e "${NC}${B[R]}${F[W]}Command run:${NC}[\$${LINT_CMD}]${NC}" echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[${LINT_CMD}]${NC}" + echo -e "${NC}${B[R]}${F[W]}ERROR:${NC} Linter CMD:[${LINTER_COMMAND} ${FILE}]${NC}" # Increment the error count (("ERRORS_FOUND_${FILE_TYPE}++")) @@ -432,7 +432,6 @@ function TestCodebase() { # Error # ######### echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Found errors in [${LINTER_NAME}] linter!${NC}" - echo -e "${NC}${B[R]}${F[W]}Command run:${NC}[\$${LINT_CMD}]${NC}" echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[${LINT_CMD}]${NC}" echo -e "${NC}${B[R]}${F[W]}ERROR:${NC} Linter CMD:[${LINTER_COMMAND} ${FILE}]${NC}" # Increment the error count From ed4d9111e17cdcf37d99886a40bf4d94f2885f48 Mon Sep 17 00:00:00 2001 From: Victor Martinez Date: Wed, 22 Jul 2020 17:33:19 +0100 Subject: [PATCH 021/135] Revert "Rename expected-COFFEESCRIPT.tap to expected-COFFEESCRIPT.tap.ignored" This reverts commit 586677713406488a9085a4a206457432943ca299. --- ...xpected-COFFEESCRIPT.tap.ignored => expected-COFFEESCRIPT.tap} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename .automation/test/coffeescript/reports/{expected-COFFEESCRIPT.tap.ignored => expected-COFFEESCRIPT.tap} (100%) diff --git a/.automation/test/coffeescript/reports/expected-COFFEESCRIPT.tap.ignored b/.automation/test/coffeescript/reports/expected-COFFEESCRIPT.tap similarity index 100% rename from .automation/test/coffeescript/reports/expected-COFFEESCRIPT.tap.ignored rename to .automation/test/coffeescript/reports/expected-COFFEESCRIPT.tap From 1c1784a8190b1973f83f223d54bbd713c2eeb67f Mon Sep 17 00:00:00 2001 From: Lucas Gravley <29484535+admiralAwkbar@users.noreply.github.com> Date: Wed, 22 Jul 2020 11:48:06 -0500 Subject: [PATCH 022/135] fixed format --- docs/disabling-linters.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/disabling-linters.md b/docs/disabling-linters.md index 3188104b..e1963e56 100644 --- a/docs/disabling-linters.md +++ b/docs/disabling-linters.md @@ -713,7 +713,7 @@ def variable = 1; /* groovylint-disable */ ``` --------------------------------------------------------------------------------- +--- ## Dockerfile From 183a8f0ea3d4aa418df81cbd27edcdd3fb81f8e6 Mon Sep 17 00:00:00 2001 From: Lucas Gravley <29484535+admiralAwkbar@users.noreply.github.com> Date: Wed, 22 Jul 2020 11:59:46 -0500 Subject: [PATCH 023/135] fixed bug --- .../reports/{expected-JSON.tap => expected-JSON.tap.ignored} | 0 lib/linter.sh | 2 +- 2 files changed, 1 insertion(+), 1 deletion(-) rename .automation/test/json/reports/{expected-JSON.tap => expected-JSON.tap.ignored} (100%) diff --git a/.automation/test/json/reports/expected-JSON.tap b/.automation/test/json/reports/expected-JSON.tap.ignored similarity index 100% rename from .automation/test/json/reports/expected-JSON.tap rename to .automation/test/json/reports/expected-JSON.tap.ignored diff --git a/lib/linter.sh b/lib/linter.sh index 41e35bd4..14ca1b0e 100755 --- a/lib/linter.sh +++ b/lib/linter.sh @@ -755,7 +755,7 @@ GetGitHubVars() { ############################ # 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}[${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}" From fd6dea2c1796e19665a3085fa4f6b90d5367031d Mon Sep 17 00:00:00 2001 From: Eric Nemchik Date: Wed, 22 Jul 2020 12:27:45 -0500 Subject: [PATCH 024/135] Simplify extension extraction --- lib/buildFileList.sh | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/buildFileList.sh b/lib/buildFileList.sh index 70dc7c4d..a1e1ebb4 100755 --- a/lib/buildFileList.sh +++ b/lib/buildFileList.sh @@ -84,9 +84,10 @@ function BuildFileList() { ########################### # Get the files extension # ########################### - # Extract just the file and extension, reverse it, cut off extension, - # reverse it back, substitute to lowercase - FILE_TYPE=$(basename "${FILE}" | rev | cut -f1 -d'.' | rev | awk '{print tolower($0)}') + # Extract just the file extension + FILE_TYPE=${FILE##*.} + # To lowercase + FILE_TYPE=${FILE_TYPE,,} ############## # Print file # From 9cb4c33715a74049e63a15df1906b97671b596b2 Mon Sep 17 00:00:00 2001 From: Lucas Gravley <29484535+admiralAwkbar@users.noreply.github.com> Date: Wed, 22 Jul 2020 14:07:08 -0500 Subject: [PATCH 025/135] found the missing link --- .automation/test/cfn/reports/expected-CFN.tap | 22 ---- .../test/{cfn => cloudformation}/README.md | 0 .../cloudformation_bad_1.json} | 0 .../cloudformation_bad_2.yaml} | 0 .../cloudformation_bad_3.json} | 0 .../cloudformation_bad_4.yaml} | 0 .../cloudformation_good_1.json} | 0 .../cloudformation_good_2.yaml} | 0 .../cloudformation_good_3.json} | 0 .../cloudformation_good_4.yaml} | 0 .../reports/expected-CLOUDFORMATION.tap | 22 ++++ Dockerfile | 1 + docs/disabling-linters.md | 2 +- lib/buildFileList.sh | 10 +- lib/linter.sh | 118 +++++++++--------- lib/validation.sh | 21 ++++ lib/worker.sh | 2 +- 17 files changed, 110 insertions(+), 88 deletions(-) delete mode 100644 .automation/test/cfn/reports/expected-CFN.tap rename .automation/test/{cfn => cloudformation}/README.md (100%) rename .automation/test/{cfn/cfn_bad_1.json => cloudformation/cloudformation_bad_1.json} (100%) rename .automation/test/{cfn/cfn_bad_2.yaml => cloudformation/cloudformation_bad_2.yaml} (100%) rename .automation/test/{cfn/cfn_bad_3.json => cloudformation/cloudformation_bad_3.json} (100%) rename .automation/test/{cfn/cfn_bad_4.yaml => cloudformation/cloudformation_bad_4.yaml} (100%) rename .automation/test/{cfn/cfn_good_1.json => cloudformation/cloudformation_good_1.json} (100%) rename .automation/test/{cfn/cfn_good_2.yaml => cloudformation/cloudformation_good_2.yaml} (100%) rename .automation/test/{cfn/cfn_good_3.json => cloudformation/cloudformation_good_3.json} (100%) rename .automation/test/{cfn/cfn_good_4.yaml => cloudformation/cloudformation_good_4.yaml} (100%) create mode 100644 .automation/test/cloudformation/reports/expected-CLOUDFORMATION.tap diff --git a/.automation/test/cfn/reports/expected-CFN.tap b/.automation/test/cfn/reports/expected-CFN.tap deleted file mode 100644 index 98466237..00000000 --- a/.automation/test/cfn/reports/expected-CFN.tap +++ /dev/null @@ -1,22 +0,0 @@ -TAP version 13 -1..8 -not ok 1 - cfn_bad_1.json - --- - message: E3001 Invalid or unsupported Type AWS Route53 HostedZonee for resource DNS in us-east-1\n/tmp/lint/.automation/test/cfn/cfn_bad_1.json 6 10\n - ... -not ok 2 - cfn_bad_2.yaml - --- - message: E3001 Invalid or unsupported Type AWS Route53 HostedZonee for resource DNS in us-east-1\n/tmp/lint/.automation/test/cfn/cfn_bad_2.yaml 5 5\n - ... -not ok 3 - cfn_bad_3.json - --- - message: E3002 Invalid Property Resources/myDNSRecord/Properties/Ttl\n/tmp/lint/.automation/test/cfn/cfn_bad_3.json 11 13\n - ... -not ok 4 - cfn_bad_4.yaml - --- - message: E3002 Invalid Property Resources/myDNSRecord/Properties/Ttl\n/tmp/lint/.automation/test/cfn/cfn_bad_4.yaml 9 7\n - ... -ok 5 - cfn_good_1.json -ok 6 - cfn_good_2.yaml -ok 7 - cfn_good_3.json -ok 8 - cfn_good_4.yaml diff --git a/.automation/test/cfn/README.md b/.automation/test/cloudformation/README.md similarity index 100% rename from .automation/test/cfn/README.md rename to .automation/test/cloudformation/README.md diff --git a/.automation/test/cfn/cfn_bad_1.json b/.automation/test/cloudformation/cloudformation_bad_1.json similarity index 100% rename from .automation/test/cfn/cfn_bad_1.json rename to .automation/test/cloudformation/cloudformation_bad_1.json diff --git a/.automation/test/cfn/cfn_bad_2.yaml b/.automation/test/cloudformation/cloudformation_bad_2.yaml similarity index 100% rename from .automation/test/cfn/cfn_bad_2.yaml rename to .automation/test/cloudformation/cloudformation_bad_2.yaml diff --git a/.automation/test/cfn/cfn_bad_3.json b/.automation/test/cloudformation/cloudformation_bad_3.json similarity index 100% rename from .automation/test/cfn/cfn_bad_3.json rename to .automation/test/cloudformation/cloudformation_bad_3.json diff --git a/.automation/test/cfn/cfn_bad_4.yaml b/.automation/test/cloudformation/cloudformation_bad_4.yaml similarity index 100% rename from .automation/test/cfn/cfn_bad_4.yaml rename to .automation/test/cloudformation/cloudformation_bad_4.yaml diff --git a/.automation/test/cfn/cfn_good_1.json b/.automation/test/cloudformation/cloudformation_good_1.json similarity index 100% rename from .automation/test/cfn/cfn_good_1.json rename to .automation/test/cloudformation/cloudformation_good_1.json diff --git a/.automation/test/cfn/cfn_good_2.yaml b/.automation/test/cloudformation/cloudformation_good_2.yaml similarity index 100% rename from .automation/test/cfn/cfn_good_2.yaml rename to .automation/test/cloudformation/cloudformation_good_2.yaml diff --git a/.automation/test/cfn/cfn_good_3.json b/.automation/test/cloudformation/cloudformation_good_3.json similarity index 100% rename from .automation/test/cfn/cfn_good_3.json rename to .automation/test/cloudformation/cloudformation_good_3.json diff --git a/.automation/test/cfn/cfn_good_4.yaml b/.automation/test/cloudformation/cloudformation_good_4.yaml similarity index 100% rename from .automation/test/cfn/cfn_good_4.yaml rename to .automation/test/cloudformation/cloudformation_good_4.yaml diff --git a/.automation/test/cloudformation/reports/expected-CLOUDFORMATION.tap b/.automation/test/cloudformation/reports/expected-CLOUDFORMATION.tap new file mode 100644 index 00000000..a92e9775 --- /dev/null +++ b/.automation/test/cloudformation/reports/expected-CLOUDFORMATION.tap @@ -0,0 +1,22 @@ +TAP version 13 +1..8 +not ok 1 - cloudformation_bad_1.json + --- + message: E3001 Invalid or unsupported Type AWS Route53 HostedZonee for resource DNS in us-east-1\n/tmp/lint/.automation/test/cloudformation/cloudformation_bad_1.json 6 10\n + ... +not ok 2 - cloudformation_bad_2.yaml + --- + message: E3001 Invalid or unsupported Type AWS Route53 HostedZonee for resource DNS in us-east-1\n/tmp/lint/.automation/test/cloudformation/cloudformation_bad_2.yaml 5 5\n + ... +not ok 3 - cloudformation_bad_3.json + --- + message: E3002 Invalid Property Resources/myDNSRecord/Properties/Ttl\n/tmp/lint/.automation/test/cloudformation/cloudformation_bad_3.json 11 13\n + ... +not ok 4 - cloudformation_bad_4.yaml + --- + message: E3002 Invalid Property Resources/myDNSRecord/Properties/Ttl\n/tmp/lint/.automation/test/cloudformation/cloudformation_bad_4.yaml 9 7\n + ... +ok 5 - cloudformation_good_1.json +ok 6 - cloudformation_good_2.yaml +ok 7 - cloudformation_good_3.json +ok 8 - cloudformation_good_4.yaml diff --git a/Dockerfile b/Dockerfile index 32964e48..cf48d8c7 100644 --- a/Dockerfile +++ b/Dockerfile @@ -209,6 +209,7 @@ ENV ACTIONS_RUNNER_DEBUG=${ACTIONS_RUNNER_DEBUG} \ VALIDATE_ARM=${VALIDATE_ARM} \ VALIDATE_BASH=${VALIDATE_BASH} \ VALIDATE_CLOJURE=${VALIDATE_CLOJURE} \ + VALIDATE_CLOUDFORMATION=${VALIDATE_CLOUDFORMATION} \ VALIDATE_COFFEE=${VALIDATE_COFFEE} \ VALIDATE_CSS=${VALIDATE_CSS} \ VALIDATE_DART=${VALIDATE_DART} \ diff --git a/docs/disabling-linters.md b/docs/disabling-linters.md index 858966a0..fb19256e 100644 --- a/docs/disabling-linters.md +++ b/docs/disabling-linters.md @@ -18,7 +18,7 @@ For some linters it is also possible to override rules on a case by case level w - [Shell](#shell) - [Ansible](#ansible) - [YAML](#yaml) -- [AWS CloudFormation templates](#cfn) +- [AWS CloudFormation templates](#aws-cloud-formation) - [Python](#python3) - [JSON](#json) - [Markdown](#markdown) diff --git a/lib/buildFileList.sh b/lib/buildFileList.sh index 915ddcfa..2627238c 100755 --- a/lib/buildFileList.sh +++ b/lib/buildFileList.sh @@ -99,9 +99,9 @@ function BuildFileList() { ######### #echo "FILE_TYPE:[${FILE_TYPE}]" - ##################### - # Get the CFN files # - ##################### + ################################ + # Get the CLOUDFORMATION files # + ################################ if [ "${FILE_TYPE}" == "yml" ] || [ "${FILE_TYPE}" == "yaml" ]; then ################################ # Append the file to the array # @@ -119,7 +119,7 @@ function BuildFileList() { ################################ # Append the file to the array # ################################ - FILE_ARRAY_CFN+=("${FILE}") + FILE_ARRAY_CLOUDFORMATION+=("${FILE}") ########################################################## # Set the READ_ONLY_CHANGE_FLAG since this could be exec # @@ -159,7 +159,7 @@ function BuildFileList() { ################################ # Append the file to the array # ################################ - FILE_ARRAY_CFN+=("${FILE}") + FILE_ARRAY_CLOUDFORMATION+=("${FILE}") fi ############################################ # Check if the file is AWS States Language # diff --git a/lib/linter.sh b/lib/linter.sh index c489a260..516c9d3c 100755 --- a/lib/linter.sh +++ b/lib/linter.sh @@ -22,71 +22,71 @@ source /action/lib/worker.sh # Source the function script(s) # GLOBALS # ########### # Default Vars -DEFAULT_RULES_LOCATION='/action/lib/.automation' # Default rules files location +DEFAULT_RULES_LOCATION='/action/lib/.automation' # Default rules files location # Ansible Vars -ANSIBLE_FILE_NAME='.ansible-lint.yml' # Name of the file -ANSIBLE_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${ANSIBLE_FILE_NAME}" # Path to the Ansible lint rules +ANSIBLE_FILE_NAME='.ansible-lint.yml' # Name of the file +ANSIBLE_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${ANSIBLE_FILE_NAME}" # Path to the Ansible lint rules # Azure Resource Manager Vars -ARM_FILE_NAME='.arm-ttk.psd1' # Name of the file -ARM_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${ARM_FILE_NAME}" # Path to the ARM lint rules +ARM_FILE_NAME='.arm-ttk.psd1' # Name of the file +ARM_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${ARM_FILE_NAME}" # Path to the ARM lint rules # Cloudformation Vars -CFN_FILE_NAME='.cfnlintrc.yml' # Name of the file -CFN_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${CFN_FILE_NAME}" # Path to the cloudformation lint rules +CLOUDFORMATION_FILE_NAME='.cfnlintrc.yml' # Name of the file +CLOUDFORMATION_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${CLOUDFORMATION_FILE_NAME}" # Path to the cloudformation lint rules # Clojure Vars -CLOJURE_FILE_NAME='.clj-kondo/config.edn' # Name of the file -CLOJURE_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${CLOJURE_FILE_NAME}" # Path to the Clojure lint rules +CLOJURE_FILE_NAME='.clj-kondo/config.edn' # Name of the file +CLOJURE_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${CLOJURE_FILE_NAME}" # Path to the Clojure lint rules # Coffee Vars -COFFEE_FILE_NAME='.coffee-lint.json' # Name of the file -COFFEESCRIPT_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${COFFEE_FILE_NAME}" # Path to the coffeescript lint rules +COFFEE_FILE_NAME='.coffee-lint.json' # Name of the file +COFFEESCRIPT_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${COFFEE_FILE_NAME}" # Path to the coffeescript lint rules # CSS Vars -CSS_FILE_NAME='.stylelintrc.json' # Name of the file -CSS_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${CSS_FILE_NAME}" # Path to the CSS lint rules +CSS_FILE_NAME='.stylelintrc.json' # Name of the file +CSS_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${CSS_FILE_NAME}" # Path to the CSS lint rules # Dart Vars -DART_FILE_NAME='analysis_options.yaml' # Name of the file -DART_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${DART_FILE_NAME}" # Path to the DART lint rules +DART_FILE_NAME='analysis_options.yaml' # Name of the file +DART_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${DART_FILE_NAME}" # Path to the DART lint rules # Docker Vars -DOCKER_FILE_NAME='.dockerfilelintrc' # Name of the file -DOCKER_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${DOCKER_FILE_NAME}" # Path to the Docker lint rules +DOCKER_FILE_NAME='.dockerfilelintrc' # Name of the file +DOCKER_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${DOCKER_FILE_NAME}" # Path to the Docker lint rules # Golang Vars -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_FILE_NAME='.golangci.yml' # Name of the file +GO_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${GO_FILE_NAME}" # Path to the Go lint rules # HTML Vars -HTML_FILE_NAME='.htmlhintrc' # Name of the file -HTML_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${HTML_FILE_NAME}" # Path to the CSS lint rules +HTML_FILE_NAME='.htmlhintrc' # Name of the file +HTML_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${HTML_FILE_NAME}" # Path to the CSS lint rules # Javascript Vars -JAVASCRIPT_FILE_NAME="${JAVASCRIPT_ES_CONFIG_FILE:-.eslintrc.yml}" # Name of the file -JAVASCRIPT_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${JAVASCRIPT_FILE_NAME}" # Path to the Javascript lint rules -JAVASCRIPT_STANDARD_LINTER_RULES='' # ENV string to pass when running js standard +JAVASCRIPT_FILE_NAME="${JAVASCRIPT_ES_CONFIG_FILE:-.eslintrc.yml}" # Name of the file +JAVASCRIPT_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${JAVASCRIPT_FILE_NAME}" # Path to the Javascript lint rules +JAVASCRIPT_STANDARD_LINTER_RULES='' # ENV string to pass when running js standard # Default linter path -LINTER_RULES_PATH="${LINTER_RULES_PATH:-.github/linters}" # Linter Path Directory +LINTER_RULES_PATH="${LINTER_RULES_PATH:-.github/linters}" # Linter Path Directory # MD Vars -MARKDOWN_FILE_NAME='.markdown-lint.yml' # Name of the file -MARKDOWN_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${MARKDOWN_FILE_NAME}" # Path to the markdown lint rules +MARKDOWN_FILE_NAME='.markdown-lint.yml' # Name of the file +MARKDOWN_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${MARKDOWN_FILE_NAME}" # Path to the markdown lint rules # OpenAPI Vars -OPENAPI_FILE_NAME='.openapirc.yml' # Name of the file -OPENAPI_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${OPENAPI_FILE_NAME}" # Path to the OpenAPI lint rules +OPENAPI_FILE_NAME='.openapirc.yml' # Name of the file +OPENAPI_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${OPENAPI_FILE_NAME}" # Path to the OpenAPI lint rules # Powershell Vars -POWERSHELL_FILE_NAME='.powershell-psscriptanalyzer.psd1' # Name of the file -POWERSHELL_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${POWERSHELL_FILE_NAME}" # Path to the Powershell lint rules +POWERSHELL_FILE_NAME='.powershell-psscriptanalyzer.psd1' # Name of the file +POWERSHELL_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${POWERSHELL_FILE_NAME}" # Path to the Powershell lint rules # Protocol Buffers Vars -PROTOBUF_FILE_NAME='.protolintrc.yml' # Name of the file -PROTOBUF_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${PROTOBUF_FILE_NAME}" # Path to the Protocol Buffers lint rules +PROTOBUF_FILE_NAME='.protolintrc.yml' # Name of the file +PROTOBUF_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${PROTOBUF_FILE_NAME}" # Path to the Protocol Buffers lint rules # Python Vars -PYTHON_FILE_NAME='.python-lint' # Name of the file -PYTHON_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${PYTHON_FILE_NAME}" # Path to the python lint rules +PYTHON_FILE_NAME='.python-lint' # Name of the file +PYTHON_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${PYTHON_FILE_NAME}" # Path to the python lint rules # Ruby Vars -RUBY_FILE_NAME="${RUBY_CONFIG_FILE:-.ruby-lint.yml}" # Name of the file -RUBY_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${RUBY_FILE_NAME}" # Path to the ruby lint rules +RUBY_FILE_NAME="${RUBY_CONFIG_FILE:-.ruby-lint.yml}" # Name of the file +RUBY_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${RUBY_FILE_NAME}" # Path to the ruby lint rules # Terraform Vars -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_FILE_NAME='.tflint.hcl' # Name of the file +TERRAFORM_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${TERRAFORM_FILE_NAME}" # Path to the Terraform lint rules # Typescript Vars -TYPESCRIPT_FILE_NAME="${TYPESCRIPT_ES_CONFIG_FILE:-.eslintrc.yml}" # Name of the file -TYPESCRIPT_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${TYPESCRIPT_FILE_NAME}" # Path to the Typescript lint rules -TYPESCRIPT_STANDARD_LINTER_RULES='' # ENV string to pass when running js standard +TYPESCRIPT_FILE_NAME="${TYPESCRIPT_ES_CONFIG_FILE:-.eslintrc.yml}" # Name of the file +TYPESCRIPT_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${TYPESCRIPT_FILE_NAME}" # Path to the Typescript lint rules +TYPESCRIPT_STANDARD_LINTER_RULES='' # ENV string to pass when running js standard # YAML Vars -YAML_FILE_NAME='.yaml-lint.yml' # Name of the file -YAML_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${YAML_FILE_NAME}" # Path to the yaml lint rules +YAML_FILE_NAME='.yaml-lint.yml' # Name of the file +YAML_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${YAML_FILE_NAME}" # Path to the yaml lint rules ####################################### # Linter array for information prints # @@ -100,7 +100,7 @@ LINTER_ARRAY=('ansible-lint' 'arm-ttk' 'asl-validator' 'cfn-lint' 'clj-kondo' ############################# # Language array for prints # ############################# -LANGUAGE_ARRAY=('ANSIBLE' 'ARM' 'BASH' 'CFN' 'CLOJURE' 'COFFEESCRIPT' +LANGUAGE_ARRAY=('ANSIBLE' 'ARM' 'BASH' 'CLOUDFORMATION' 'CLOJURE' 'COFFEESCRIPT' 'CSS' 'DART' 'DOCKER' 'ENV' 'GO' 'HTML' 'JAVASCRIPT_ES' 'JAVASCRIPT_STANDARD' 'JSON' 'JSX' 'KOTLIN' 'MARKDOWN' 'OPENAPI' 'PERL' 'PHP' 'POWERSHELL' 'PROTOBUF' 'PYTHON' @@ -130,7 +130,7 @@ VALIDATE_ALL_CODEBASE="${VALIDATE_ALL_CODEBASE}" # Boolean to vali VALIDATE_ANSIBLE="${VALIDATE_ANSIBLE}" # Boolean to validate language VALIDATE_ARM="${VALIDATE_ARM}" # Boolean to validate language VALIDATE_BASH="${VALIDATE_BASH}" # Boolean to validate language -VALIDATE_CFN="${VALIDATE_CLOUDFORMATION}" # Boolean to validate language +VALIDATE_CLOUDFORMATION="${VALIDATE_CLOUDFORMATION}" # Boolean to validate language VALIDATE_CLOJURE="${VALIDATE_CLOJURE}" # Boolean to validate language VALIDATE_COFFEE="${VALIDATE_COFFEE}" # Boolean to validate language VALIDATE_CSS="${VALIDATE_CSS}" # Boolean to validate language @@ -205,7 +205,7 @@ REPORT_OUTPUT_FOLDER="${DEFAULT_WORKSPACE}/${OUTPUT_FOLDER}" # Location for the ########################## FILE_ARRAY_ARM=() # Array of files to check FILE_ARRAY_BASH=() # Array of files to check -FILE_ARRAY_CFN=() # Array of files to check +FILE_ARRAY_CLOUDFORMATION=() # Array of files to check FILE_ARRAY_CLOJURE=() # Array of files to check FILE_ARRAY_COFFEESCRIPT=() # Array of files to check FILE_ARRAY_CSS=() # Array of files to check @@ -242,7 +242,7 @@ FILE_ARRAY_YML=() # Array of files to check ERRORS_FOUND_ANSIBLE=0 # Count of errors found ERRORS_FOUND_ARM=0 # Count of errors found ERRORS_FOUND_BASH=0 # Count of errors found -ERRORS_FOUND_CFN=0 # Count of errors found +ERRORS_FOUND_CLOUDFORMATION=0 # Count of errors found ERRORS_FOUND_CLOJURE=0 # Count of errors found ERRORS_FOUND_CSS=0 # Count of errors found ERRORS_FOUND_COFFEESCRIPT=0 # Count of errors found @@ -574,9 +574,9 @@ DetectCloudFormationFile() { return 0 fi - ########################################## - # No identifiers of a CFN template found # - ########################################## + ##################################################### + # No identifiers of a CLOUDFORMATION template found # + ##################################################### return 1 } ################################################################################ @@ -965,7 +965,7 @@ Footer() { elif [ "${ERRORS_FOUND_ANSIBLE}" -ne 0 ] || [ "${ERRORS_FOUND_ARM}" -ne 0 ] || [ "${ERRORS_FOUND_BASH}" -ne 0 ] || - [ "${ERRORS_FOUND_CFN}" -ne 0 ] || + [ "${ERRORS_FOUND_CLOUDFORMATION}" -ne 0 ] || [ "${ERRORS_FOUND_CLOJURE}" -ne 0 ] || [ "${ERRORS_FOUND_COFFEESCRIPT}" -ne 0 ] || [ "${ERRORS_FOUND_CSS}" -ne 0 ] || @@ -1074,8 +1074,8 @@ GetLinterRules "POWERSHELL" GetLinterRules "ARM" # Get CSS rules GetLinterRules "CSS" -# Get CFN rules -GetLinterRules "CFN" +# Get CLOUDFORMATION rules +GetLinterRules "CLOUDFORMATION" # Get DART rules GetLinterRules "DART" # Get HTML rules @@ -1184,15 +1184,15 @@ if [ "${VALIDATE_PYTHON}" == "true" ]; then LintCodebase "PYTHON" "pylint" "pylint --rcfile ${PYTHON_LINTER_RULES}" ".*\.\(py\)\$" "${FILE_ARRAY_PYTHON[@]}" fi -############### -# CFN LINTING # -############### -if [ "${VALIDATE_CFN}" == "true" ]; then +########################## +# CLOUDFORMATION LINTING # +########################## +if [ "${VALIDATE_CLOUDFORMATION}" == "true" ]; then ################################# # Lint the CloudFormation files # ################################# # LintCodebase "FILE_TYPE" "LINTER_NAME" "LINTER_CMD" "FILE_TYPES_REGEX" "FILE_ARRAY" - LintCodebase "CFN" "cfn-lint" "cfn-lint --config-file ${CFN_LINTER_RULES}" ".*\.\(json\|yml\|yaml\)\$" "${FILE_ARRAY_CFN[@]}" + LintCodebase "CLOUDFORMATION" "cfn-lint" "cfn-lint --config-file ${CLOUDFORMATION_LINTER_RULES}" ".*\.\(json\|yml\|yaml\)\$" "${FILE_ARRAY_CLOUDFORMATION[@]}" fi ################ diff --git a/lib/validation.sh b/lib/validation.sh index 4fffb249..bf1e7ccb 100755 --- a/lib/validation.sh +++ b/lib/validation.sh @@ -50,6 +50,7 @@ function GetValidationInfo() { VALIDATE_ARM="${VALIDATE_ARM,,}" VALIDATE_BASH="${VALIDATE_BASH,,}" VALIDATE_CLOJURE="${VALIDATE_CLOJURE,,}" + VALIDATE_CLOUDFORMATION="${VALIDATE_CLOUDFORMATION,,}" VALIDATE_COFFEE="${VALIDATE_COFFEE,,}" VALIDATE_CSS="${VALIDATE_CSS,,}" VALIDATE_DART="${VALIDATE_DART,,}" @@ -88,6 +89,7 @@ function GetValidationInfo() { ${VALIDATE_ARM} || -n \ ${VALIDATE_BASH} || -n \ ${VALIDATE_CLOJURE} || -n \ + ${VALIDATE_CLOUDFORMATION} || -n \ ${VALIDATE_COFFEE} || -n \ ${VALIDATE_CSS} || -n \ ${VALIDATE_DART} || -n \ @@ -551,6 +553,20 @@ function GetValidationInfo() { VALIDATE_CLOJURE="true" fi + ############################################## + # Validate if we should check CloudFormation # + ############################################## + if [[ ${ANY_SET} == "true" ]]; then + # Some linter flags were set - only run those set to true + if [[ -z ${VALIDATE_CLOUDFORMATION} ]]; then + # Cloud Formation flag was not set - default to false + VALIDATE_CLOUDFORMATION="false" + fi + else + # No linter flags were set - default all to true + VALIDATE_CLOUDFORMATION="true" + fi + ############################################ # Validate if we should check editorconfig # ############################################ @@ -700,6 +716,11 @@ function GetValidationInfo() { else PRINT_ARRAY+=("- Excluding [CLOJURE] files in code base...") fi + if [[ ${VALIDATE_CLOUDFORMATION} == "true" ]]; then + PRINT_ARRAY+=("- Validating [CLOUDFORMATION] files in code base...") + else + PRINT_ARRAY+=("- Excluding [CLOUDFORMATION] files in code base...") + fi if [[ ${VALIDATE_ENV} == "true" ]]; then PRINT_ARRAY+=("- Validating [ENV] files in code base...") else diff --git a/lib/worker.sh b/lib/worker.sh index f5957f4e..57ee3413 100755 --- a/lib/worker.sh +++ b/lib/worker.sh @@ -557,7 +557,7 @@ function RunTestCases() { TestCodebase "ANSIBLE" "ansible-lint" "ansible-lint -v -c ${ANSIBLE_LINTER_RULES}" ".*\.\(yml\|yaml\)\$" "ansible" TestCodebase "ARM" "arm-ttk" "Import-Module ${ARM_TTK_PSD1} ; \${config} = \$(Import-PowerShellDataFile -Path ${ARM_LINTER_RULES}) ; Test-AzTemplate @config -TemplatePath" ".*\.\(json\)\$" "arm" TestCodebase "BASH" "shellcheck" "shellcheck --color" ".*\.\(sh\|bash\|dash\|ksh\)\$" "shell" - TestCodebase "CFN" "cfn-lint" "cfn-lint --config-file ${CFN_LINTER_RULES}" ".*\.\(json\|yml\|yaml\)\$" "cfn" + TestCodebase "CLOUDFORMATION" "cfn-lint" "cfn-lint --config-file ${CLOUDFORMATION_LINTER_RULES}" ".*\.\(json\|yml\|yaml\)\$" "cloudformation" TestCodebase "CLOJURE" "clj-kondo" "clj-kondo --config ${CLOJURE_LINTER_RULES} --lint" ".*\.\(clj\|cljs\|cljc\|edn\)\$" "clojure" TestCodebase "COFFEESCRIPT" "coffeelint" "coffeelint -f ${COFFEESCRIPT_LINTER_RULES}" ".*\.\(coffee\)\$" "coffeescript" TestCodebase "CSS" "stylelint" "stylelint --config ${CSS_LINTER_RULES}" ".*\.\(css\)\$" "css" From 3c92dcd70b19a83756a723274188cb3c27523cc6 Mon Sep 17 00:00:00 2001 From: Lucas Gravley <29484535+admiralAwkbar@users.noreply.github.com> Date: Wed, 22 Jul 2020 14:26:45 -0500 Subject: [PATCH 026/135] Went sooo hard on this --- lib/validation.sh | 703 +++------------------------------------------- 1 file changed, 37 insertions(+), 666 deletions(-) diff --git a/lib/validation.sh b/lib/validation.sh index bf1e7ccb..d13bb3f4 100755 --- a/lib/validation.sh +++ b/lib/validation.sh @@ -85,682 +85,53 @@ function GetValidationInfo() { # Determine if any linters were explicitly set # ################################################ ANY_SET="false" - if [[ -n ${VALIDATE_ANSIBLE} || -n \ - ${VALIDATE_ARM} || -n \ - ${VALIDATE_BASH} || -n \ - ${VALIDATE_CLOJURE} || -n \ - ${VALIDATE_CLOUDFORMATION} || -n \ - ${VALIDATE_COFFEE} || -n \ - ${VALIDATE_CSS} || -n \ - ${VALIDATE_DART} || -n \ - ${VALIDATE_DOCKER} || -n \ - ${VALIDATE_EDITORCONFIG} || -n \ - ${VALIDATE_ENV} || -n \ - ${VALIDATE_GO} || -n \ - ${VALIDATE_HTML} || -n \ - ${VALIDATE_JAVASCRIPT_ES} || -n \ - ${VALIDATE_JAVASCRIPT_STANDARD} || -n \ - ${VALIDATE_JSON} || -n \ - ${VALIDATE_KOTLIN} || -n \ - ${VALIDATE_MARKDOWN} || -n \ - ${VALIDATE_OPENAPI} || -n \ - ${VALIDATE_PERL} || -n \ - ${VALIDATE_PHP} || -n \ - ${VALIDATE_POWERSHELL} || -n \ - ${VALIDATE_PROTOBUF} || -n \ - ${VALIDATE_PYTHON} || -n \ - ${VALIDATE_RAKU} || -n \ - ${VALIDATE_RUBY} || -n \ - ${VALIDATE_TERRAFORM} || -n \ - ${VALIDATE_TYPESCRIPT_ES} || -n \ - ${VALIDATE_TYPESCRIPT_STANDARD} || -n \ - ${VALIDATE_XML} || -n \ - ${VALIDATE_YAML} ]]; then - ANY_SET="true" - fi - - #################################### - # Validate if we should check YAML # - #################################### - if [[ ${ANY_SET} == "true" ]]; then - # Some linter flags were set - only run those set to true - if [[ -z ${VALIDATE_YAML} ]]; then - # YAML flag was not set - default to false - VALIDATE_YAML="false" + # Loop through all languages + for LANGUAGE in "${LANGUAGE_ARRAY[@]}"; do + # build the variable + VALIDATE_LANGUAGE="VALIDATE_${LANGUAGE}" + # Check to see if the variable was set + if [ -n ${!VALIDATE_LANGUAGE} ]; then + # It was set, need to set flag + ANY_SET="true" fi - else - # No linter flags were set - default all to true - VALIDATE_YAML="true" - fi + done - #################################### - # Validate if we should check JSON # - #################################### - if [[ ${ANY_SET} == "true" ]]; then - # Some linter flags were set - only run those set to true - if [[ -z ${VALIDATE_JSON} ]]; then - # JSON flag was not set - default to false - VALIDATE_JSON="false" - fi - else - # No linter flags were set - default all to true - VALIDATE_JSON="true" - fi - - ################################### - # Validate if we should check XML # - ################################### - if [[ ${ANY_SET} == "true" ]]; then - # Some linter flags were set - only run those set to true - if [[ -z ${VALIDATE_XML} ]]; then - # XML flag was not set - default to false - VALIDATE_XML="false" - fi - else - # No linter flags were set - default all to true - VALIDATE_XML="true" - fi - - ######################################## - # Validate if we should check MARKDOWN # - ######################################## - if [[ ${ANY_SET} == "true" ]]; then - # Some linter flags were set - only run those set to true - if [[ -z ${VALIDATE_MARKDOWN} ]]; then - # MD flag was not set - default to false - VALIDATE_MARKDOWN="false" - fi - else - # No linter flags were set - default all to true - VALIDATE_MARKDOWN="true" - fi - - #################################### - # Validate if we should check BASH # - #################################### - if [[ ${ANY_SET} == "true" ]]; then - # Some linter flags were set - only run those set to true - if [[ -z ${VALIDATE_BASH} ]]; then - # BASH flag was not set - default to false - VALIDATE_BASH="false" - fi - else - # No linter flags were set - default all to true - VALIDATE_BASH="true" - fi - - #################################### - # Validate if we should check PERL # - #################################### - if [[ ${ANY_SET} == "true" ]]; then - # Some linter flags were set - only run those set to true - if [[ -z ${VALIDATE_PERL} ]]; then - # PERL flag was not set - default to false - VALIDATE_PERL="false" - fi - else - # No linter flags were set - default all to true - VALIDATE_PERL="true" - fi - - #################################### - # Validate if we should check RAKU # - #################################### - if [[ ${ANY_SET} == "true" ]]; then - # Some linter flags were set - only run those set to true - if [[ -z ${VALIDATE_RAKU} ]]; then - # RAKU flag was not set - default to false - VALIDATE_RAKU="false" - fi - else - # No linter flags were set - default all to true - VALIDATE_RAKU="true" - 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 # - ###################################### - if [[ ${ANY_SET} == "true" ]]; then - # Some linter flags were set - only run those set to true - if [[ -z ${VALIDATE_PYTHON} ]]; then - # PYTHON flag was not set - default to false - VALIDATE_PYTHON="false" - fi - else - # No linter flags were set - default all to true - VALIDATE_PYTHON="true" - fi - - #################################### - # Validate if we should check RUBY # - #################################### - if [[ ${ANY_SET} == "true" ]]; then - # Some linter flags were set - only run those set to true - if [[ -z ${VALIDATE_RUBY} ]]; then - # RUBY flag was not set - default to false - VALIDATE_RUBY="false" - fi - else - # No linter flags were set - default all to true - VALIDATE_RUBY="true" - fi - - ########################################## - # Validate if we should check AWS States # - ########################################## - if [[ ${ANY_SET} == "true" ]]; then - # Some linter flags were set - only run those set to true - if [[ -z ${VALIDATE_STATES} ]]; then - # STATES flag was not set - default to false - VALIDATE_STATES="false" - fi - else - # No linter flags were set - default all to true - VALIDATE_STATES="true" - fi - - ###################################### - # Validate if we should check COFFEE # - ###################################### - if [[ ${ANY_SET} == "true" ]]; then - # Some linter flags were set - only run those set to true - if [[ -z ${VALIDATE_COFFEE} ]]; then - # COFFEE flag was not set - default to false - VALIDATE_COFFEE="false" - fi - else - # No linter flags were set - default all to true - VALIDATE_COFFEE="true" - fi - - ####################################### - # Validate if we should check ANSIBLE # - ####################################### - if [[ ${ANY_SET} == "true" ]]; then - # Some linter flags were set - only run those set to true - if [[ -z ${VALIDATE_ANSIBLE} ]]; then - # ANSIBLE flag was not set - default to false - VALIDATE_ANSIBLE="false" - fi - else - # No linter flags were set - default all to true - VALIDATE_ANSIBLE="true" - fi - - ############################################# - # Validate if we should check JAVASCRIPT_ES # - ############################################# - if [[ ${ANY_SET} == "true" ]]; then - # Some linter flags were set - only run those set to true - if [[ -z ${VALIDATE_JAVASCRIPT_ES} ]]; then - # JAVASCRIPT_ES flag was not set - default to false - VALIDATE_JAVASCRIPT_ES="false" - fi - else - # No linter flags were set - default all to true - VALIDATE_JAVASCRIPT_ES="true" - fi ################################################### - # Validate if we should check JAVASCRIPT_STANDARD # + # Validate if we should check individual lanuages # ################################################### - if [[ ${ANY_SET} == "true" ]]; then - # Some linter flags were set - only run those set to true - if [[ -z ${VALIDATE_JAVASCRIPT_STANDARD} ]]; then - # JAVASCRIPT_STANDARD flag was not set - default to false - VALIDATE_JAVASCRIPT_STANDARD="false" + # Loop through all languages + for LANGUAGE in "${LANGUAGE_ARRAY[@]}"; do + # build the variable + VALIDATE_LANGUAGE="VALIDATE_${LANGUAGE}" + # Check if ANY_SET was set + if [[ ${ANY_SET} == "true" ]]; then + # Check to see if the variable was set + if [ -z ${!VALIDATE_LANGUAGE} ]; then + # Flag was not set, default to false + eval "${VALIDATE_LANGUAGE}='false'" + fi + else + # No linter flags were set - default all to true + eval "${VALIDATE_LANGUAGE}='true'" fi - else - # No linter flags were set - default all to true - VALIDATE_JAVASCRIPT_STANDARD="true" - fi - - ############################################# - # Validate if we should check JSX # - ############################################# - if [[ ${ANY_SET} == "true" ]]; then - # Some linter flags were set - only run those set to true - if [[ -z ${VALIDATE_JSX} ]]; then - # JSX flag was not set - default to false - VALIDATE_JSX="false" - fi - else - # No linter flags were set - default all to true - VALIDATE_JSX="true" - fi - - ############################################# - # Validate if we should check TSX # - ############################################# - if [[ ${ANY_SET} == "true" ]]; then - # Some linter flags were set - only run those set to true - if [[ -z ${VALIDATE_TSX} ]]; then - # TSX flag was not set - default to false - VALIDATE_TSX="false" - fi - else - # No linter flags were set - default all to true - VALIDATE_TSX="true" - fi - - ############################################# - # Validate if we should check TYPESCRIPT_ES # - ############################################# - if [[ ${ANY_SET} == "true" ]]; then - # Some linter flags were set - only run those set to true - if [[ -z ${VALIDATE_TYPESCRIPT_ES} ]]; then - # TYPESCRIPT_ES flag was not set - default to false - VALIDATE_TYPESCRIPT_ES="false" - fi - else - # No linter flags were set - default all to true - VALIDATE_TYPESCRIPT_ES="true" - fi - - ################################################### - # Validate if we should check TYPESCRIPT_STANDARD # - ################################################### - if [[ ${ANY_SET} == "true" ]]; then - # Some linter flags were set - only run those set to true - if [[ -z ${VALIDATE_TYPESCRIPT_STANDARD} ]]; then - # TYPESCRIPT_STANDARD flag was not set - default to false - VALIDATE_TYPESCRIPT_STANDARD="false" - fi - else - # No linter flags were set - default all to true - VALIDATE_TYPESCRIPT_STANDARD="true" - fi - - ###################################### - # Validate if we should check DOCKER # - ###################################### - if [[ ${ANY_SET} == "true" ]]; then - # Some linter flags were set - only run those set to true - if [[ -z ${VALIDATE_DOCKER} ]]; then - # DOCKER flag was not set - default to false - VALIDATE_DOCKER="false" - fi - else - # No linter flags were set - default all to true - VALIDATE_DOCKER="true" - fi - - ################################## - # Validate if we should check GO # - ################################## - if [[ ${ANY_SET} == "true" ]]; then - # Some linter flags were set - only run those set to true - if [[ -z ${VALIDATE_GO} ]]; then - # GO flag was not set - default to false - VALIDATE_GO="false" - fi - else - # No linter flags were set - default all to true - VALIDATE_GO="true" - fi - - ######################################### - # Validate if we should check TERRAFORM # - ######################################### - if [[ ${ANY_SET} == "true" ]]; then - # Some linter flags were set - only run those set to true - if [[ -z ${VALIDATE_TERRAFORM} ]]; then - # TERRAFORM flag was not set - default to false - VALIDATE_TERRAFORM="false" - fi - else - # No linter flags were set - default all to true - VALIDATE_TERRAFORM="true" - fi - - ######################################### - # Validate if we should check POWERSHELL # - ######################################### - if [[ ${ANY_SET} == "true" ]]; then - # Some linter flags were set - only run those set to true - if [[ -z ${VALIDATE_POWERSHELL} ]]; then - # POWERSHELL flag was not set - default to false - VALIDATE_POWERSHELL="false" - fi - else - # No linter flags were set - default all to true - VALIDATE_POWERSHELL="true" - fi - - ################################### - # Validate if we should check ARM # - ################################### - if [[ "${ANY_SET}" == "true" ]]; then - # Some linter flags were set - only run those set to true - if [[ -z "${VALIDATE_ARM}" ]]; then - # ARM flag was not set - default to false - VALIDATE_ARM="false" - fi - else - # No linter flags were set - default all to true - VALIDATE_ARM="true" - fi - - ################################### - # Validate if we should check CSS # - ################################### - if [[ ${ANY_SET} == "true" ]]; then - # Some linter flags were set - only run those set to true - if [[ -z ${VALIDATE_CSS} ]]; then - # CSS flag was not set - default to false - VALIDATE_CSS="false" - fi - else - # No linter flags were set - default all to true - VALIDATE_CSS="true" - fi - - ################################### - # Validate if we should check ENV # - ################################### - if [[ ${ANY_SET} == "true" ]]; then - # Some linter flags were set - only run those set to true - if [[ -z ${VALIDATE_ENV} ]]; then - # ENV flag was not set - default to false - VALIDATE_ENV="false" - fi - else - # No linter flags were set - default all to true - VALIDATE_ENV="true" - fi - - ###################################### - # Validate if we should check KOTLIN # - ###################################### - if [[ ${ANY_SET} == "true" ]]; then - # Some linter flags were set - only run those set to true - if [[ -z ${VALIDATE_KOTLIN} ]]; then - # ENV flag was not set - default to false - VALIDATE_KOTLIN="false" - fi - else - # No linter flags were set - default all to true - VALIDATE_KOTLIN="true" - fi - - #################################### - # Validate if we should check DART # - #################################### - if [[ ${ANY_SET} == "true" ]]; then - # Some linter flags were set - only run those set to true - if [[ -z ${VALIDATE_DART} ]]; then - # ENV flag was not set - default to false - VALIDATE_DART="false" - fi - else - # No linter flags were set - default all to true - VALIDATE_DART="true" - fi - - ####################################### - # Validate if we should check OPENAPI # - ####################################### - if [[ ${ANY_SET} == "true" ]]; then - # Some linter flags were set - only run those set to true - if [[ -z ${VALIDATE_OPENAPI} ]]; then - # OPENAPI flag was not set - default to false - VALIDATE_OPENAPI="false" - fi - else - # No linter flags were set - default all to true - VALIDATE_OPENAPI="true" - fi - - ####################################### - # Validate if we should check PROTOBUF # - ####################################### - if [[ ${ANY_SET} == "true" ]]; then - # Some linter flags were set - only run those set to true - if [[ -z ${VALIDATE_PROTOBUF} ]]; then - # PROTOBUF flag was not set - default to false - VALIDATE_PROTOBUF="false" - fi - else - # No linter flags were set - default all to true - VALIDATE_PROTOBUF="true" - fi - - ####################################### - # Validate if we should check Clojure # - ####################################### - if [[ ${ANY_SET} == "true" ]]; then - # Some linter flags were set - only run those set to true - if [[ -z ${VALIDATE_CLOJURE} ]]; then - # Clojure flag was not set - default to false - VALIDATE_CLOJURE="false" - fi - else - # No linter flags were set - default all to true - VALIDATE_CLOJURE="true" - fi - - ############################################## - # Validate if we should check CloudFormation # - ############################################## - if [[ ${ANY_SET} == "true" ]]; then - # Some linter flags were set - only run those set to true - if [[ -z ${VALIDATE_CLOUDFORMATION} ]]; then - # Cloud Formation flag was not set - default to false - VALIDATE_CLOUDFORMATION="false" - fi - else - # No linter flags were set - default all to true - VALIDATE_CLOUDFORMATION="true" - fi - - ############################################ - # Validate if we should check editorconfig # - ############################################ - if [[ ${ANY_SET} == "true" ]]; then - # Some linter flags were set - only run those set to true - if [[ -z ${VALIDATE_EDITORCONFIG} ]]; then - # EDITORCONFIG flag was not set - default to false - VALIDATE_EDITORCONFIG="false" - fi - else - # No linter flags were set - # special case checking for .editorconfig - if [ -f "${GITHUB_WORKSPACE}/.editorconfig" ]; then - VALIDATE_EDITORCONFIG="true" - fi - fi - - #################################### - # Validate if we should check HTML # - #################################### - if [[ ${ANY_SET} == "true" ]]; then - # Some linter flags were set - only run those set to true - if [[ -z ${VALIDATE_HTML} ]]; then - # HTML flag was not set - default to false - VALIDATE_HTML="false" - fi - else - # No linter flags were set - default all to true - VALIDATE_HTML="true" - fi + done ####################################### # Print which linters we are enabling # ####################################### - if [[ ${VALIDATE_YAML} == "true" ]]; then - PRINT_ARRAY+=("- Validating [YAML] files in code base...") - else - PRINT_ARRAY+=("- Excluding [YAML] files in code base...") - fi - if [[ ${VALIDATE_JSON} == "true" ]]; then - PRINT_ARRAY+=("- Validating [JSON] files in code base...") - else - PRINT_ARRAY+=("- Excluding [JSON] files in code base...") - fi - if [[ ${VALIDATE_XML} == "true" ]]; then - PRINT_ARRAY+=("- Validating [XML] files in code base...") - else - PRINT_ARRAY+=("- Excluding [XML] files in code base...") - fi - if [[ ${VALIDATE_MARKDOWN} == "true" ]]; then - PRINT_ARRAY+=("- Validating [MARKDOWN] files in code base...") - else - PRINT_ARRAY+=("- Excluding [MARKDOWN] files in code base...") - fi - if [[ ${VALIDATE_BASH} == "true" ]]; then - PRINT_ARRAY+=("- Validating [BASH] files in code base...") - else - PRINT_ARRAY+=("- Excluding [BASH] files in code base...") - fi - if [[ ${VALIDATE_PERL} == "true" ]]; then - PRINT_ARRAY+=("- Validating [PERL] files in code base...") - else - PRINT_ARRAY+=("- Excluding [PERL] files in code base...") - fi - if [[ ${VALIDATE_RAKU} == "true" ]]; then - PRINT_ARRAY+=("- Validating [RAKU] files in code base...") - else - PRINT_ARRAY+=("- Excluding [RAKU] files in code base...") - 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 - PRINT_ARRAY+=("- Validating [PYTHON] files in code base...") - else - PRINT_ARRAY+=("- Excluding [PYTHON] files in code base...") - fi - if [[ ${VALIDATE_RUBY} == "true" ]]; then - PRINT_ARRAY+=("- Validating [RUBY] files in code base...") - else - PRINT_ARRAY+=("- Excluding [RUBY] files in code base...") - fi - if [[ ${VALIDATE_COFFEE} == "true" ]]; then - PRINT_ARRAY+=("- Validating [COFFEE] files in code base...") - else - PRINT_ARRAY+=("- Excluding [COFFEE] files in code base...") - fi - if [[ ${VALIDATE_ANSIBLE} == "true" ]]; then - PRINT_ARRAY+=("- Validating [ANSIBLE] files in code base...") - else - PRINT_ARRAY+=("- Excluding [ANSIBLE] files in code base...") - fi - if [[ ${VALIDATE_JAVASCRIPT_ES} == "true" ]]; then - PRINT_ARRAY+=("- Validating [JAVASCRIPT(eslint)] files in code base...") - else - PRINT_ARRAY+=("- Excluding [JAVASCRIPT(eslint)] files in code base...") - fi - if [[ ${VALIDATE_JAVASCRIPT_STANDARD} == "true" ]]; then - PRINT_ARRAY+=("- Validating [JAVASCRIPT(standard)] files in code base...") - else - PRINT_ARRAY+=("- Excluding [JAVASCRIPT(standard)] files in code base...") - fi - if [[ ${VALIDATE_TYPESCRIPT_ES} == "true" ]]; then - PRINT_ARRAY+=("- Validating [TYPESCRIPT(eslint)] files in code base...") - else - PRINT_ARRAY+=("- Excluding [TYPESCRIPT(eslint)] files in code base...") - fi - if [[ ${VALIDATE_TYPESCRIPT_STANDARD} == "true" ]]; then - PRINT_ARRAY+=("- Validating [TYPESCRIPT(standard)] files in code base...") - else - PRINT_ARRAY+=("- Excluding [TYPESCRIPT(standard)] files in code base...") - fi - if [[ ${VALIDATE_DOCKER} == "true" ]]; then - PRINT_ARRAY+=("- Validating [DOCKER] files in code base...") - else - PRINT_ARRAY+=("- Excluding [DOCKER] files in code base...") - fi - if [[ ${VALIDATE_GO} == "true" ]]; then - PRINT_ARRAY+=("- Validating [GOLANG] files in code base...") - else - PRINT_ARRAY+=("- Excluding [GOLANG] files in code base...") - fi - if [[ ${VALIDATE_TERRAFORM} == "true" ]]; then - PRINT_ARRAY+=("- Validating [TERRAFORM] files in code base...") - else - PRINT_ARRAY+=("- Excluding [TERRAFORM] files in code base...") - fi - if [[ ${VALIDATE_POWERSHELL} == "true" ]]; then - PRINT_ARRAY+=("- Validating [POWERSHELL] files in code base...") - else - PRINT_ARRAY+=("- Excluding [POWERSHELL] files in code base...") - fi - if [[ ${VALIDATE_ARM} == "true" ]]; then - PRINT_ARRAY+=("- Validating [ARM] files in code base...") - else - PRINT_ARRAY+=("- Excluding [ARM] files in code base...") - fi - if [[ ${VALIDATE_CSS} == "true" ]]; then - PRINT_ARRAY+=("- Validating [CSS] files in code base...") - else - PRINT_ARRAY+=("- Excluding [CSS] files in code base...") - fi - if [[ ${VALIDATE_CLOJURE} == "true" ]]; then - PRINT_ARRAY+=("- Validating [CLOJURE] files in code base...") - else - PRINT_ARRAY+=("- Excluding [CLOJURE] files in code base...") - fi - if [[ ${VALIDATE_CLOUDFORMATION} == "true" ]]; then - PRINT_ARRAY+=("- Validating [CLOUDFORMATION] files in code base...") - else - PRINT_ARRAY+=("- Excluding [CLOUDFORMATION] files in code base...") - fi - if [[ ${VALIDATE_ENV} == "true" ]]; then - PRINT_ARRAY+=("- Validating [ENV] files in code base...") - else - PRINT_ARRAY+=("- Excluding [ENV] files in code base...") - fi - if [[ ${VALIDATE_KOTLIN} == "true" ]]; then - PRINT_ARRAY+=("- Validating [KOTLIN] files in code base...") - else - PRINT_ARRAY+=("- Excluding [KOTLIN] files in code base...") - fi - if [[ ${VALIDATE_OPENAPI} == "true" ]]; then - PRINT_ARRAY+=("- Validating [OPENAPI] files in code base...") - else - PRINT_ARRAY+=("- Excluding [OPENAPI] files in code base...") - fi - if [[ ${VALIDATE_PROTOBUF} == "true" ]]; then - PRINT_ARRAY+=("- Validating [PROTOBUF] files in code base...") - else - PRINT_ARRAY+=("- Excluding [PROTOBUF] files in code base...") - fi - if [[ ${VALIDATE_DART} == "true" ]]; then - PRINT_ARRAY+=("- Validating [DART] files in code base...") - else - PRINT_ARRAY+=("- Excluding [DART] files in code base...") - fi - if [[ ${VALIDATE_EDITORCONFIG} == "true" ]]; then - PRINT_ARRAY+=("- Validating [EDITORCONFIG] files in code base...") - else - PRINT_ARRAY+=("- Excluding [EDITORCONFIG] files in code base...") - fi - if [[ ${VALIDATE_HTML} == "true" ]]; then - PRINT_ARRAY+=("- Validating [HTML] files in code base...") - else - PRINT_ARRAY+=("- Excluding [HTML] files in code base...") - fi - if [[ ${VALIDATE_STATES} == "true" ]]; then - PRINT_ARRAY+=("- Validating [AWS STATES] files in code base...") - else - PRINT_ARRAY+=("- Excluding [AWS STATES] files in code base...") - fi + # Loop through all languages + for LANGUAGE in "${LANGUAGE_ARRAY[@]}"; do + # build the variable + VALIDATE_LANGUAGE="VALIDATE_${LANGUAGE}" + if [[ ${!VALIDATE_LANGUAGE} == "true" ]]; then + # We need to validate + PRINT_ARRAY+=("- Validating [$LANGUAGE] files in code base...") + else + # We are skipping the language + PRINT_ARRAY+=("- Excluding [$LANGUAGE] files in code base...") + fi + done ############################## # Validate Ansible Directory # From 5001845b7baf4c018e039cf35a418b7dbb3b7b1a Mon Sep 17 00:00:00 2001 From: Lucas Gravley <29484535+admiralAwkbar@users.noreply.github.com> Date: Wed, 22 Jul 2020 14:31:47 -0500 Subject: [PATCH 027/135] going soooo hard --- lib/validation.sh | 45 +++++++++------------------------------------ 1 file changed, 9 insertions(+), 36 deletions(-) diff --git a/lib/validation.sh b/lib/validation.sh index d13bb3f4..57aad373 100755 --- a/lib/validation.sh +++ b/lib/validation.sh @@ -46,40 +46,13 @@ function GetValidationInfo() { ################################ # Convert strings to lowercase # ################################ - VALIDATE_ANSIBLE="${VALIDATE_ANSIBLE,,}" - VALIDATE_ARM="${VALIDATE_ARM,,}" - VALIDATE_BASH="${VALIDATE_BASH,,}" - VALIDATE_CLOJURE="${VALIDATE_CLOJURE,,}" - VALIDATE_CLOUDFORMATION="${VALIDATE_CLOUDFORMATION,,}" - VALIDATE_COFFEE="${VALIDATE_COFFEE,,}" - VALIDATE_CSS="${VALIDATE_CSS,,}" - VALIDATE_DART="${VALIDATE_DART,,}" - VALIDATE_DOCKER="${VALIDATE_DOCKER,,}" - VALIDATE_EDITORCONFIG="${VALIDATE_EDITORCONFIG,,}" - VALIDATE_ENV="${VALIDATE_ENV,,}" - VALIDATE_GO="${VALIDATE_GO,,}" - VALIDATE_HTML="${VALIDATE_HTML,,}" - VALIDATE_JAVASCRIPT_ES="${VALIDATE_JAVASCRIPT_ES,,}" - VALIDATE_JAVASCRIPT_STANDARD="${VALIDATE_JAVASCRIPT_STANDARD,,}" - VALIDATE_JSON="${VALIDATE_JSON,,}" - VALIDATE_JSX="${VALIDATE_JSX,,}" - VALIDATE_KOTLIN="${VALIDATE_KOTLIN,,}" - VALIDATE_MARKDOWN="${VALIDATE_MARKDOWN,,}" - VALIDATE_OPENAPI="${VALIDATE_OPENAPI,,}" - VALIDATE_PERL="${VALIDATE_PERL,,}" - VALIDATE_PHP="${VALIDATE_PHP,,}" - VALIDATE_POWERSHELL="${VALIDATE_POWERSHELL,,}" - VALIDATE_PROTOBUF="${VALIDATE_PROTOBUF,,}" - VALIDATE_PYTHON="${VALIDATE_PYTHON,,}" - VALIDATE_RAKU="${VALIDATE_RAKU,,}" - VALIDATE_RUBY="${VALIDATE_RUBY,,}" - VALIDATE_STATES="${VALIDATE_STATES,,}" - VALIDATE_TERRAFORM="${VALIDATE_TERRAFORM,,}" - VALIDATE_TSX="${VALIDATE_TSX,,}" - VALIDATE_TYPESCRIPT_ES="${VALIDATE_TYPESCRIPT_ES,,}" - VALIDATE_TYPESCRIPT_STANDARD="${VALIDATE_TYPESCRIPT_STANDARD,,}" - VALIDATE_YAML="${VALIDATE_YAML,,}" - VALIDATE_XML="${VALIDATE_XML,,}" + # Loop through all languages + for LANGUAGE in "${LANGUAGE_ARRAY[@]}"; do + # build the variable + VALIDATE_LANGUAGE="VALIDATE_${LANGUAGE}" + # Set the value of the var to lowercase + eval "${VALIDATE_LANGUAGE}=${!VALIDATE_LANGUAGE,,}" + done ################################################ # Determine if any linters were explicitly set # @@ -90,7 +63,7 @@ function GetValidationInfo() { # build the variable VALIDATE_LANGUAGE="VALIDATE_${LANGUAGE}" # Check to see if the variable was set - if [ -n ${!VALIDATE_LANGUAGE} ]; then + if [ -n "${!VALIDATE_LANGUAGE}" ]; then # It was set, need to set flag ANY_SET="true" fi @@ -107,7 +80,7 @@ function GetValidationInfo() { # Check if ANY_SET was set if [[ ${ANY_SET} == "true" ]]; then # Check to see if the variable was set - if [ -z ${!VALIDATE_LANGUAGE} ]; then + if [ -z "${!VALIDATE_LANGUAGE}" ]; then # Flag was not set, default to false eval "${VALIDATE_LANGUAGE}='false'" fi From f74fa431f4bda7ae562465ea68e7c591095c49a0 Mon Sep 17 00:00:00 2001 From: Lucas Gravley <29484535+admiralAwkbar@users.noreply.github.com> Date: Wed, 22 Jul 2020 14:41:37 -0500 Subject: [PATCH 028/135] Cleanup of errors --- lib/linter.sh | 52 ++++++++++++++------------------------------------- 1 file changed, 14 insertions(+), 38 deletions(-) diff --git a/lib/linter.sh b/lib/linter.sh index 516c9d3c..e9c156d2 100755 --- a/lib/linter.sh +++ b/lib/linter.sh @@ -205,7 +205,7 @@ REPORT_OUTPUT_FOLDER="${DEFAULT_WORKSPACE}/${OUTPUT_FOLDER}" # Location for the ########################## FILE_ARRAY_ARM=() # Array of files to check FILE_ARRAY_BASH=() # Array of files to check -FILE_ARRAY_CLOUDFORMATION=() # Array of files to check +FILE_ARRAY_CLOUDFORMATION=() # Array of files to check FILE_ARRAY_CLOJURE=() # Array of files to check FILE_ARRAY_COFFEESCRIPT=() # Array of files to check FILE_ARRAY_CSS=() # Array of files to check @@ -242,7 +242,7 @@ FILE_ARRAY_YML=() # Array of files to check ERRORS_FOUND_ANSIBLE=0 # Count of errors found ERRORS_FOUND_ARM=0 # Count of errors found ERRORS_FOUND_BASH=0 # Count of errors found -ERRORS_FOUND_CLOUDFORMATION=0 # Count of errors found +ERRORS_FOUND_CLOUDFORMATION=0 # Count of errors found ERRORS_FOUND_CLOJURE=0 # Count of errors found ERRORS_FOUND_CSS=0 # Count of errors found ERRORS_FOUND_COFFEESCRIPT=0 # Count of errors found @@ -962,42 +962,18 @@ Footer() { ############################### # Exit with 1 if errors found # ############################### - elif [ "${ERRORS_FOUND_ANSIBLE}" -ne 0 ] || - [ "${ERRORS_FOUND_ARM}" -ne 0 ] || - [ "${ERRORS_FOUND_BASH}" -ne 0 ] || - [ "${ERRORS_FOUND_CLOUDFORMATION}" -ne 0 ] || - [ "${ERRORS_FOUND_CLOJURE}" -ne 0 ] || - [ "${ERRORS_FOUND_COFFEESCRIPT}" -ne 0 ] || - [ "${ERRORS_FOUND_CSS}" -ne 0 ] || - [ "${ERRORS_FOUND_DART}" -ne 0 ] || - [ "${ERRORS_FOUND_DOCKER}" -ne 0 ] || - [ "${ERRORS_FOUND_ENV}" -ne 0 ] || - [ "${ERRORS_FOUND_GO}" -ne 0 ] || - [ "${ERRORS_FOUND_HTML}" -ne 0 ] || - [ "${ERRORS_FOUND_JAVASCRIPT_ES}" -ne 0 ] || - [ "${ERRORS_FOUND_JAVASCRIPT_STANDARD}" -ne 0 ] || - [ "${ERRORS_FOUND_JSON}" -ne 0 ] || - [ "${ERRORS_FOUND_JSX}" -ne 0 ] || - [ "${ERRORS_FOUND_KOTLIN}" -ne 0 ] || - [ "${ERRORS_FOUND_MARKDOWN}" -ne 0 ] || - [ "${ERRORS_FOUND_OPENAPI}" -ne 0 ] || - [ "${ERRORS_FOUND_PERL}" -ne 0 ] || - [ "${ERRORS_FOUND_PHP}" -ne 0 ] || - [ "${ERRORS_FOUND_POWERSHELL}" -ne 0 ] || - [ "${ERRORS_FOUND_PROTOBUF}" -ne 0 ] || - [ "${ERRORS_FOUND_PYTHON}" -ne 0 ] || - [ "${ERRORS_FOUND_RAKU}" -ne 0 ] || - [ "${ERRORS_FOUND_RUBY}" -ne 0 ] || - [ "${ERRORS_FOUND_STATES}" -ne 0 ] || - [ "${ERRORS_FOUND_TERRAFORM}" -ne 0 ] || - [ "${ERRORS_FOUND_TSX}" -ne 0 ] || - [ "${ERRORS_FOUND_TYPESCRIPT_ES}" -ne 0 ] || - [ "${ERRORS_FOUND_TYPESCRIPT_STANDARD}" -ne 0 ] || - [ "${ERRORS_FOUND_XML}" -ne 0 ] || - [ "${ERRORS_FOUND_YML}" -ne 0 ]; then - # Failed exit - echo -e "${NC}${F[R]}Exiting with errors found!${NC}" - exit 1 + elif + # Loop through all languages + for LANGUAGE in "${LANGUAGE_ARRAY[@]}"; do + # build the variable + ERRORS_FOUND_LANGUAGE="ERRORS_FOUND_${LANGUAGE}" + # Check if error was found + if [ "${!ERRORS_FOUND_LANGUAGE}" -ne 0 ]; then + # Failed exit + echo -e "${NC}${F[R]}Exiting with errors found!${NC}" + exit 1 + fi + done else ################# # Footer prints # From 1249a930b7c283571fa264c5b4420bcb90d469d1 Mon Sep 17 00:00:00 2001 From: Lucas Gravley <29484535+admiralAwkbar@users.noreply.github.com> Date: Wed, 22 Jul 2020 14:49:26 -0500 Subject: [PATCH 029/135] making cool moves --- lib/linter.sh | 83 +++++++++++++++++++++++++++++++-------------------- 1 file changed, 50 insertions(+), 33 deletions(-) diff --git a/lib/linter.sh b/lib/linter.sh index e9c156d2..7346b0ec 100755 --- a/lib/linter.sh +++ b/lib/linter.sh @@ -890,12 +890,12 @@ CallStatusAPI() { fi } ################################################################################ -#### Function Footer ########################################################### -Footer() { +#### Function Reports ########################################################## +Reports() { echo "" echo "----------------------------------------------" echo "----------------------------------------------" - echo "The script has completed" + echo "Generated reports:" echo "----------------------------------------------" echo "----------------------------------------------" echo "" @@ -907,6 +907,25 @@ Footer() { echo "Reports generated in folder ${REPORT_OUTPUT_FOLDER}" fi + ################################ + # Prints for warnings if found # + ################################ + for TEST in "${WARNING_ARRAY_TEST[@]}"; do + echo -e "${NC}${F[Y]}WARN!${NC} Expected file to compare with was not found for ${TEST}${NC}" + done + +} +################################################################################ +#### Function Footer ########################################################### +Footer() { + echo "" + echo "----------------------------------------------" + echo "----------------------------------------------" + echo "The script has completed" + echo "----------------------------------------------" + echo "----------------------------------------------" + echo "" + #################################################### # Need to clean up the lanuage array of duplicates # #################################################### @@ -946,45 +965,38 @@ Footer() { fi done - ################################ - # Prints for warnings if found # - ################################ - for TEST in "${WARNING_ARRAY_TEST[@]}"; do - echo -e "${NC}${F[Y]}WARN!${NC} Expected file to compare with was not found for ${TEST}${NC}" - done - ################################## # Exit with 0 if errors disabled # ################################## if [ "${DISABLE_ERRORS}" == "true" ]; then echo -e "${NC}${F[Y]}WARN!${NC} Exiting with exit code:[0] as:[DISABLE_ERRORS] was set to:[${DISABLE_ERRORS}]${NC}" exit 0 + fi + ############################### # Exit with 1 if errors found # ############################### - elif - # Loop through all languages - for LANGUAGE in "${LANGUAGE_ARRAY[@]}"; do - # build the variable - ERRORS_FOUND_LANGUAGE="ERRORS_FOUND_${LANGUAGE}" - # Check if error was found - if [ "${!ERRORS_FOUND_LANGUAGE}" -ne 0 ]; then - # Failed exit - echo -e "${NC}${F[R]}Exiting with errors found!${NC}" - exit 1 - fi - done - else - ################# - # Footer prints # - ################# - echo "" - echo -e "${NC}${F[G]}All file(s) linted successfully with no errors detected${NC}" - echo "----------------------------------------------" - echo "" - # Successful exit - exit 0 - fi + # Loop through all languages + for LANGUAGE in "${LANGUAGE_ARRAY[@]}"; do + # build the variable + ERRORS_FOUND_LANGUAGE="ERRORS_FOUND_${LANGUAGE}" + # Check if error was found + if [ "${!ERRORS_FOUND_LANGUAGE}" -ne 0 ]; then + # Failed exit + echo -e "${NC}${F[R]}Exiting with errors found!${NC}" + exit 1 + fi + done + + ######################## + # Footer prints Exit 0 # + ######################## + echo "" + echo -e "${NC}${F[G]}All file(s) linted successfully with no errors detected${NC}" + echo "----------------------------------------------" + echo "" + # Successful exit + exit 0 } ################################################################################ @@ -1513,6 +1525,11 @@ if [ "${VALIDATE_STATES}" == "true" ]; then LintCodebase "STATES" "asl-validator" "asl-validator --json-path" ".*\.\(json\)\$" "${FILE_ARRAY_STATES[@]}" fi +########### +# Reports # +########### +Reports + ########## # Footer # ########## From da67a885357540760fcbaec9b76589d3522f81f7 Mon Sep 17 00:00:00 2001 From: Lucas Gravley <29484535+admiralAwkbar@users.noreply.github.com> Date: Wed, 22 Jul 2020 14:59:03 -0500 Subject: [PATCH 030/135] fix fun else --- lib/linter.sh | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/lib/linter.sh b/lib/linter.sh index 7346b0ec..e080cfeb 100755 --- a/lib/linter.sh +++ b/lib/linter.sh @@ -954,14 +954,12 @@ Footer() { # Create status API for Failed language # ######################################### CallStatusAPI "${LANGUAGE}" "error" - else + ###################################### + # Check if we validated the langauge # + ###################################### + elif [ "${!ERROR_COUNTER}" -eq 0 ] && [[ "${UNIQUE_LINTED_ARRAY[*]}" =~ ${LANGUAGE} ]]; then # No errors found when linting the language - ###################################### - # Check if we validated the langauge # - ###################################### - if [[ "${UNIQUE_LINTED_ARRAY[*]}" =~ ${LANGUAGE} ]]; then - CallStatusAPI "${LANGUAGE}" "success" - fi + CallStatusAPI "${LANGUAGE}" "success" fi done From a0ff3df431437a683ccffa149a054cb03aaf407e Mon Sep 17 00:00:00 2001 From: Lucas Gravley <29484535+admiralAwkbar@users.noreply.github.com> Date: Wed, 22 Jul 2020 15:41:08 -0500 Subject: [PATCH 031/135] imports and exports --- lib/linter.sh | 99 ++++++++++++++++++++++++++++++++++----------------- 1 file changed, 66 insertions(+), 33 deletions(-) diff --git a/lib/linter.sh b/lib/linter.sh index e080cfeb..3ac5ea63 100755 --- a/lib/linter.sh +++ b/lib/linter.sh @@ -239,39 +239,72 @@ FILE_ARRAY_YML=() # Array of files to check ############ # Counters # ############ -ERRORS_FOUND_ANSIBLE=0 # Count of errors found -ERRORS_FOUND_ARM=0 # Count of errors found -ERRORS_FOUND_BASH=0 # Count of errors found -ERRORS_FOUND_CLOUDFORMATION=0 # Count of errors found -ERRORS_FOUND_CLOJURE=0 # Count of errors found -ERRORS_FOUND_CSS=0 # Count of errors found -ERRORS_FOUND_COFFEESCRIPT=0 # Count of errors found -ERRORS_FOUND_DART=0 # Count of errors found -ERRORS_FOUND_DOCKER=0 # Count of errors found -ERRORS_FOUND_ENV=0 # Count of errors found -ERRORS_FOUND_GO=0 # Count of errors found -ERRORS_FOUND_HTML=0 # Count of errors found -ERRORS_FOUND_JAVASCRIPT_STANDARD=0 # Count of errors found -ERRORS_FOUND_JAVASCRIPT_ES=0 # Count of errors found -ERRORS_FOUND_JSON=0 # Count of errors found -ERRORS_FOUND_JSX=0 # Count of errors found -ERRORS_FOUND_KOTLIN=0 # Count of errors found -ERRORS_FOUND_MARKDOWN=0 # Count of errors found -ERRORS_FOUND_OPENAPI=0 # Count of errors found -ERRORS_FOUND_PERL=0 # Count of errors found -ERRORS_FOUND_PHP=0 # Count of errors found -ERRORS_FOUND_POWERSHELL=0 # Count of errors found -ERRORS_FOUND_PROTOBUF=0 # Count of errors found -ERRORS_FOUND_PYTHON=0 # Count of errors found -ERRORS_FOUND_RAKU=0 # Count of errors found -ERRORS_FOUND_RUBY=0 # Count of errors found -ERRORS_FOUND_STATES=0 # Count of errors found -ERRORS_FOUND_TERRAFORM=0 # Count of errors found -ERRORS_FOUND_TSX=0 # Count of errors found -ERRORS_FOUND_TYPESCRIPT_STANDARD=0 # Count of errors found -ERRORS_FOUND_TYPESCRIPT_ES=0 # Count of errors found -ERRORS_FOUND_XML=0 # Count of errors found -ERRORS_FOUND_YML=0 # Count of errors found +ERRORS_FOUND_ANSIBLE=0 # Count of errors found +export ERRORS_FOUND_ANSIBLE # Workaround SC2034 +ERRORS_FOUND_ARM=0 # Count of errors found +export ERRORS_FOUND_ARM # Workaround SC2034 +ERRORS_FOUND_BASH=0 # Count of errors found +export ERRORS_FOUND_BASH # Workaround SC2034 +ERRORS_FOUND_CLOUDFORMATION=0 # Count of errors found +export ERRORS_FOUND_CLOUDFORMATION # Workaround SC2034 +ERRORS_FOUND_CLOJURE=0 # Count of errors found +export ERRORS_FOUND_CLOJURE # Workaround SC2034 +ERRORS_FOUND_CSS=0 # Count of errors found +export ERRORS_FOUND_CSS # Workaround SC2034 +ERRORS_FOUND_COFFEESCRIPT=0 # Count of errors found +export ERRORS_FOUND_COFFEESCRIPT # Workaround SC2034 +ERRORS_FOUND_DART=0 # Count of errors found +export ERRORS_FOUND_DART # Workaround SC2034 +ERRORS_FOUND_DOCKER=0 # Count of errors found +export ERRORS_FOUND_DOCKER # Workaround SC2034 +ERRORS_FOUND_ENV=0 # Count of errors found +export ERRORS_FOUND_ENV # Workaround SC2034 +ERRORS_FOUND_GO=0 # Count of errors found +export ERRORS_FOUND_GO # Workaround SC2034 +ERRORS_FOUND_HTML=0 # Count of errors found +export ERRORS_FOUND_HTML # Workaround SC2034 +ERRORS_FOUND_JAVASCRIPT_STANDARD=0 # Count of errors found +export ERRORS_FOUND_JAVASCRIPT_STANDARD # Workaround SC2034 +ERRORS_FOUND_JAVASCRIPT_ES=0 # Count of errors found +export ERRORS_FOUND_JAVASCRIPT_ES # Workaround SC2034 +ERRORS_FOUND_JSON=0 # Count of errors found +export ERRORS_FOUND_JSON # Workaround SC2034 +ERRORS_FOUND_JSX=0 # Count of errors found +export ERRORS_FOUND_JSX # Workaround SC2034 +ERRORS_FOUND_KOTLIN=0 # Count of errors found +export ERRORS_FOUND_KOTLIN # Workaround SC2034 +ERRORS_FOUND_MARKDOWN=0 # Count of errors found +export ERRORS_FOUND_MARKDOWN # Workaround SC2034 +ERRORS_FOUND_OPENAPI=0 # Count of errors found +export ERRORS_FOUND_OPENAPI # Workaround SC2034 +ERRORS_FOUND_PERL=0 # Count of errors found +export ERRORS_FOUND_PERL # Workaround SC2034 +ERRORS_FOUND_PHP=0 # Count of errors found +export ERRORS_FOUND_PHP # Workaround SC2034 +ERRORS_FOUND_POWERSHELL=0 # Count of errors found +export ERRORS_FOUND_POWERSHELL # Workaround SC2034 +ERRORS_FOUND_PROTOBUF=0 # Count of errors found +export ERRORS_FOUND_PROTOBUF # Workaround SC2034 +ERRORS_FOUND_PYTHON=0 # Count of errors found +export ERRORS_FOUND_PYTHON # Workaround SC2034 +ERRORS_FOUND_RAKU=0 # Count of errors found +export ERRORS_FOUND_RAKU # Workaround SC2034 +ERRORS_FOUND_RUBY=0 # Count of errors found +export ERRORS_FOUND_RUBY # Workaround SC2034 +ERRORS_FOUND_STATES=0 # Count of errors found +export ERRORS_FOUND_STATES # Workaround SC2034 +ERRORS_FOUND_TERRAFORM=0 # Count of errors found +export ERRORS_FOUND_TERRAFORM # Workaround SC2034 +ERRORS_FOUND_TSX=0 # Count of errors found +export ERRORS_FOUND_TSX # Workaround SC2034 +ERRORS_FOUND_TYPESCRIPT_STANDARD=0 # Count of errors found +export ERRORS_FOUND_TYPESCRIPT_STANDARD # Workaround SC2034 +ERRORS_FOUND_TYPESCRIPT_ES=0 # Count of errors found +export ERRORS_FOUND_TYPESCRIPT_ES # Workaround SC2034 +ERRORS_FOUND_XML=0 # Count of errors found +export ERRORS_FOUND_XML # Workaround SC2034 +ERRORS_FOUND_YML=0 # Count of errors found +export ERRORS_FOUND_YML # Workaround SC2034 ################################################################################ ########################## FUNCTIONS BELOW ##################################### From b15fa8c738e98c33b5597841e58ed0d453f1d1a4 Mon Sep 17 00:00:00 2001 From: Gabo Date: Thu, 23 Jul 2020 00:30:12 -0500 Subject: [PATCH 032/135] Added case for special types like open api --- lib/linter.sh | 66 ++++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 63 insertions(+), 3 deletions(-) diff --git a/lib/linter.sh b/lib/linter.sh index c489a260..1ade97b7 100755 --- a/lib/linter.sh +++ b/lib/linter.sh @@ -1188,11 +1188,31 @@ fi # CFN LINTING # ############### if [ "${VALIDATE_CFN}" == "true" ]; then + # If we are validating all codebase we need to build file list because not every yml/json file is an CFN 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 DetectCloudFormationFile "${FILE}"; then + FILE_ARRAY_CFN+=("${FILE}") + fi + done + + ########################### + # Set IFS back to default # + ########################### + IFS="${DEFAULT_IFS}" + fi + ################################# # Lint the CloudFormation files # ################################# # LintCodebase "FILE_TYPE" "LINTER_NAME" "LINTER_CMD" "FILE_TYPES_REGEX" "FILE_ARRAY" - LintCodebase "CFN" "cfn-lint" "cfn-lint --config-file ${CFN_LINTER_RULES}" ".*\.\(json\|yml\|yaml\)\$" "${FILE_ARRAY_CFN[@]}" + LintCodebase "CFN" "cfn-lint" "cfn-lint --config-file ${CFN_LINTER_RULES}" "disabledfileext" "${FILE_ARRAY_CFN[@]}" fi ################ @@ -1475,11 +1495,31 @@ 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" ".*\.\(json\)\$" "${FILE_ARRAY_ARM[@]}" + 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 ################### @@ -1531,10 +1571,30 @@ 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" ".*\.\(json\)\$" "${FILE_ARRAY_STATES[@]}" + LintCodebase "STATES" "asl-validator" "asl-validator --json-path" "disabledfileext" "${FILE_ARRAY_STATES[@]}" fi ########## From 386ad69aae07814df731586cd9e8cd8bcf7fd26a Mon Sep 17 00:00:00 2001 From: mil7 <49973666+mil7@users.noreply.github.com> Date: Thu, 23 Jul 2020 14:55:56 +0200 Subject: [PATCH 033/135] fix disabling-linters dokumentation Fix link to #closure Everything after #clojure chapter was not properly defined (anymore) --- docs/disabling-linters.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/docs/disabling-linters.md b/docs/disabling-linters.md index 858966a0..68184302 100644 --- a/docs/disabling-linters.md +++ b/docs/disabling-linters.md @@ -39,6 +39,7 @@ For some linters it is also possible to override rules on a case by case level w - [Kotlin](#kotlin) - [OpenAPI](#openapi) - [Protocol Buffers](#protocol-buffers) +- [Clojure](#clojure) - [EDITORCONFIG-CHECKER](#editorconfig-checker) - [HTML](#html) @@ -946,8 +947,9 @@ lint: ### clj-kondo disable entire file -````clojure +```clojure {:output {:exclude-files ["path/to/file"]}} +``` ## EDITORCONFIG-CHECKER - [editorconfig-checker](https://github.com/editorconfig-checker/editorconfig-checker) @@ -1003,4 +1005,3 @@ lint: ### htmlhint disable entire file - There is currently **No** way to disable rules in an entire file -```` From 677d19fbbf734ad7aaf169fa1fbbf32294c57c7a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tobias=20B=C3=BCschel?= Date: Thu, 23 Jul 2020 21:18:49 +0800 Subject: [PATCH 034/135] chore: remove redundant package-lock.json --- .gitignore | 1 + package-lock.json | 545 ---------------------------------------------- 2 files changed, 1 insertion(+), 545 deletions(-) delete mode 100644 package-lock.json diff --git a/.gitignore b/.gitignore index df2846f3..5ab6c13d 100644 --- a/.gitignore +++ b/.gitignore @@ -4,6 +4,7 @@ logs npm-debug.log* yarn-debug.log* yarn-error.log* +/package-lock.json # Runtime data pids diff --git a/package-lock.json b/package-lock.json deleted file mode 100644 index 33b3caa3..00000000 --- a/package-lock.json +++ /dev/null @@ -1,545 +0,0 @@ -{ - "requires": true, - "lockfileVersion": 1, - "dependencies": { - "@types/color-name": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/@types/color-name/-/color-name-1.1.1.tgz", - "integrity": "sha512-rr+OQyAjxze7GgWrSaJwydHStIhHq2lvY3BOC2Mj7KnzI7XK0Uw1TOOdI9lDoajEbSWLiYgoo4f1R51erQfhPQ==" - }, - "ajv": { - "version": "6.12.3", - "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.12.3.tgz", - "integrity": "sha512-4K0cK3L1hsqk9xIb2z9vs/XU+PGJZ9PNpJRDS9YLzmNdX6jmVPfamLvTJr0aDAusnHyCHO6MjzlkAsgtqp9teA==", - "requires": { - "fast-deep-equal": "^3.1.1", - "fast-json-stable-stringify": "^2.0.0", - "json-schema-traverse": "^0.4.1", - "uri-js": "^4.2.2" - } - }, - "ansi-styles": { - "version": "4.2.1", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.2.1.tgz", - "integrity": "sha512-9VGjrMsG1vePxcSweQsN20KY/c4zN0h9fLjqAbwbPfahM3t+NL+M9HC8xeXG2I8pX5NoamTGNuomEUFI7fcUjA==", - "requires": { - "@types/color-name": "^1.1.1", - "color-convert": "^2.0.1" - } - }, - "asn1": { - "version": "0.2.4", - "resolved": "https://registry.npmjs.org/asn1/-/asn1-0.2.4.tgz", - "integrity": "sha512-jxwzQpLQjSmWXgwaCZE9Nz+glAG01yF1QnWgbhGwHI5A6FRIEY6IVqtHhIepHqI7/kyEyQEagBC5mBEFlIYvdg==", - "requires": { - "safer-buffer": "~2.1.0" - } - }, - "assert-plus": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/assert-plus/-/assert-plus-1.0.0.tgz", - "integrity": "sha1-8S4PPF13sLHN2RRpQuTpbB5N1SU=" - }, - "async": { - "version": "3.2.0", - "resolved": "https://registry.npmjs.org/async/-/async-3.2.0.tgz", - "integrity": "sha512-TR2mEZFVOj2pLStYxLht7TyfuRzaydfpxr3k9RpHIzMgw7A64dzsdqCxH1WJyQdoe8T10nDXd9wnEigmiuHIZw==" - }, - "asynckit": { - "version": "0.4.0", - "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz", - "integrity": "sha1-x57Zf380y48robyXkLzDZkdLS3k=" - }, - "aws-sign2": { - "version": "0.7.0", - "resolved": "https://registry.npmjs.org/aws-sign2/-/aws-sign2-0.7.0.tgz", - "integrity": "sha1-tG6JCTSpWR8tL2+G1+ap8bP+dqg=" - }, - "aws4": { - "version": "1.10.0", - "resolved": "https://registry.npmjs.org/aws4/-/aws4-1.10.0.tgz", - "integrity": "sha512-3YDiu347mtVtjpyV3u5kVqQLP242c06zwDOgpeRnybmXlYYsLbtTrUBUm8i8srONt+FWobl5aibnU1030PeeuA==" - }, - "balanced-match": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz", - "integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=" - }, - "bcrypt-pbkdf": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/bcrypt-pbkdf/-/bcrypt-pbkdf-1.0.2.tgz", - "integrity": "sha1-pDAdOJtqQ/m2f/PKEaP2Y342Dp4=", - "requires": { - "tweetnacl": "^0.14.3" - } - }, - "brace-expansion": { - "version": "1.1.11", - "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", - "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", - "requires": { - "balanced-match": "^1.0.0", - "concat-map": "0.0.1" - } - }, - "caseless": { - "version": "0.12.0", - "resolved": "https://registry.npmjs.org/caseless/-/caseless-0.12.0.tgz", - "integrity": "sha1-G2gcIf+EAzyCZUMJBolCDRhxUdw=" - }, - "chalk": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.0.0.tgz", - "integrity": "sha512-N9oWFcegS0sFr9oh1oz2d7Npos6vNoWW9HvtCg5N1KRFpUhaAhvTv5Y58g880fZaEYSNm3qDz8SU1UrGvp+n7A==", - "requires": { - "ansi-styles": "^4.1.0", - "supports-color": "^7.1.0" - } - }, - "color-convert": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", - "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", - "requires": { - "color-name": "~1.1.4" - } - }, - "color-name": { - "version": "1.1.4", - "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", - "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==" - }, - "combined-stream": { - "version": "1.0.8", - "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.8.tgz", - "integrity": "sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==", - "requires": { - "delayed-stream": "~1.0.0" - } - }, - "commander": { - "version": "5.1.0", - "resolved": "https://registry.npmjs.org/commander/-/commander-5.1.0.tgz", - "integrity": "sha512-P0CysNDQ7rtVw4QIQtm+MRxV66vKFSvlsQvGYXZWR3qFU0jlMKHZZZgw8e+8DSah4UDKMqnknRDQz+xuQXQ/Zg==" - }, - "concat-map": { - "version": "0.0.1", - "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", - "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=" - }, - "core-util-is": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz", - "integrity": "sha1-tf1UIgqivFq1eqtxQMlAdUUDwac=" - }, - "dashdash": { - "version": "1.14.1", - "resolved": "https://registry.npmjs.org/dashdash/-/dashdash-1.14.1.tgz", - "integrity": "sha1-hTz6D3y+L+1d4gMmuN1YEDX24vA=", - "requires": { - "assert-plus": "^1.0.0" - } - }, - "delayed-stream": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz", - "integrity": "sha1-3zrhmayt+31ECqrgsp4icrJOxhk=" - }, - "ecc-jsbn": { - "version": "0.1.2", - "resolved": "https://registry.npmjs.org/ecc-jsbn/-/ecc-jsbn-0.1.2.tgz", - "integrity": "sha1-OoOpBOVDUyh4dMVkt1SThoSamMk=", - "requires": { - "jsbn": "~0.1.0", - "safer-buffer": "^2.1.0" - } - }, - "extend": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/extend/-/extend-3.0.2.tgz", - "integrity": "sha512-fjquC59cD7CyW6urNXK0FBufkZcoiGG80wTuPujX590cB5Ttln20E2UB4S/WARVqhXffZl2LNgS+gQdPIIim/g==" - }, - "extsprintf": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/extsprintf/-/extsprintf-1.3.0.tgz", - "integrity": "sha1-lpGEQOMEGnpBT4xS48V06zw+HgU=" - }, - "fast-deep-equal": { - "version": "3.1.3", - "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz", - "integrity": "sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==" - }, - "fast-json-stable-stringify": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/fast-json-stable-stringify/-/fast-json-stable-stringify-2.1.0.tgz", - "integrity": "sha512-lhd/wF+Lk98HZoTCtlVraHtfh5XYijIjalXck7saUtuanSDyLMxnHhSXEDJqHxD7msR8D0uCmqlkwjCV8xvwHw==" - }, - "forever-agent": { - "version": "0.6.1", - "resolved": "https://registry.npmjs.org/forever-agent/-/forever-agent-0.6.1.tgz", - "integrity": "sha1-+8cfDEGt6zf5bFd60e1C2P2sypE=" - }, - "form-data": { - "version": "2.3.3", - "resolved": "https://registry.npmjs.org/form-data/-/form-data-2.3.3.tgz", - "integrity": "sha512-1lLKB2Mu3aGP1Q/2eCOx0fNbRMe7XdwktwOruhfqqd0rIJWwN4Dh+E3hrPSlDCXnSR7UtZ1N38rVXm+6+MEhJQ==", - "requires": { - "asynckit": "^0.4.0", - "combined-stream": "^1.0.6", - "mime-types": "^2.1.12" - } - }, - "fs.realpath": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", - "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=" - }, - "getpass": { - "version": "0.1.7", - "resolved": "https://registry.npmjs.org/getpass/-/getpass-0.1.7.tgz", - "integrity": "sha1-Xv+OPmhNVprkyysSgmBOi6YhSfo=", - "requires": { - "assert-plus": "^1.0.0" - } - }, - "glob": { - "version": "7.1.6", - "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.6.tgz", - "integrity": "sha512-LwaxwyZ72Lk7vZINtNNrywX0ZuLyStrdDtabefZKAY5ZGJhVtgdznluResxNmPitE0SAO+O26sWTHeKSI2wMBA==", - "requires": { - "fs.realpath": "^1.0.0", - "inflight": "^1.0.4", - "inherits": "2", - "minimatch": "^3.0.4", - "once": "^1.3.0", - "path-is-absolute": "^1.0.0" - } - }, - "glob-base": { - "version": "0.3.0", - "resolved": "https://registry.npmjs.org/glob-base/-/glob-base-0.3.0.tgz", - "integrity": "sha1-27Fk9iIbHAscz4Kuoyi0l98Oo8Q=", - "requires": { - "glob-parent": "^2.0.0", - "is-glob": "^2.0.0" - } - }, - "glob-parent": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-2.0.0.tgz", - "integrity": "sha1-gTg9ctsFT8zPUzbaqQLxgvbtuyg=", - "requires": { - "is-glob": "^2.0.0" - } - }, - "har-schema": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/har-schema/-/har-schema-2.0.0.tgz", - "integrity": "sha1-qUwiJOvKwEeCoNkDVSHyRzW37JI=" - }, - "har-validator": { - "version": "5.1.3", - "resolved": "https://registry.npmjs.org/har-validator/-/har-validator-5.1.3.tgz", - "integrity": "sha512-sNvOCzEQNr/qrvJgc3UG/kD4QtlHycrzwS+6mfTrrSq97BvaYcPZZI1ZSqGSPR73Cxn4LKTD4PttRwfU7jWq5g==", - "requires": { - "ajv": "^6.5.5", - "har-schema": "^2.0.0" - } - }, - "has-flag": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", - "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==" - }, - "htmlhint": { - "version": "0.14.1", - "resolved": "https://registry.npmjs.org/htmlhint/-/htmlhint-0.14.1.tgz", - "integrity": "sha512-VWKrljlwF8tEKH48YPfC30zYKhrsMqm70d7vXswivEqd3DSva8ZlIzfeCa3YWFEFRIIhiXKgKurlqEpCtYMCAA==", - "dev": true, - "requires": { - "async": "3.2.0", - "chalk": "4.0.0", - "commander": "5.1.0", - "glob": "7.1.6", - "parse-glob": "3.0.4", - "request": "2.88.2", - "strip-json-comments": "3.1.0", - "xml": "1.0.1" - } - }, - "http-signature": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/http-signature/-/http-signature-1.2.0.tgz", - "integrity": "sha1-muzZJRFHcvPZW2WmCruPfBj7rOE=", - "requires": { - "assert-plus": "^1.0.0", - "jsprim": "^1.2.2", - "sshpk": "^1.7.0" - } - }, - "inflight": { - "version": "1.0.6", - "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", - "integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=", - "requires": { - "once": "^1.3.0", - "wrappy": "1" - } - }, - "inherits": { - "version": "2.0.4", - "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", - "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==" - }, - "is-dotfile": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/is-dotfile/-/is-dotfile-1.0.3.tgz", - "integrity": "sha1-pqLzL/0t+wT1yiXs0Pa4PPeYoeE=" - }, - "is-extglob": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-1.0.0.tgz", - "integrity": "sha1-rEaBd8SUNAWgkvyPKXYMb/xiBsA=" - }, - "is-glob": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-2.0.1.tgz", - "integrity": "sha1-0Jb5JqPe1WAPP9/ZEZjLCIjC2GM=", - "requires": { - "is-extglob": "^1.0.0" - } - }, - "is-typedarray": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/is-typedarray/-/is-typedarray-1.0.0.tgz", - "integrity": "sha1-5HnICFjfDBsR3dppQPlgEfzaSpo=" - }, - "isstream": { - "version": "0.1.2", - "resolved": "https://registry.npmjs.org/isstream/-/isstream-0.1.2.tgz", - "integrity": "sha1-R+Y/evVa+m+S4VAOaQ64uFKcCZo=" - }, - "jsbn": { - "version": "0.1.1", - "resolved": "https://registry.npmjs.org/jsbn/-/jsbn-0.1.1.tgz", - "integrity": "sha1-peZUwuWi3rXyAdls77yoDA7y9RM=" - }, - "json-schema": { - "version": "0.2.3", - "resolved": "https://registry.npmjs.org/json-schema/-/json-schema-0.2.3.tgz", - "integrity": "sha1-tIDIkuWaLwWVTOcnvT8qTogvnhM=" - }, - "json-schema-traverse": { - "version": "0.4.1", - "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz", - "integrity": "sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg==" - }, - "json-stringify-safe": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/json-stringify-safe/-/json-stringify-safe-5.0.1.tgz", - "integrity": "sha1-Epai1Y/UXxmg9s4B1lcB4sc1tus=" - }, - "jsprim": { - "version": "1.4.1", - "resolved": "https://registry.npmjs.org/jsprim/-/jsprim-1.4.1.tgz", - "integrity": "sha1-MT5mvB5cwG5Di8G3SZwuXFastqI=", - "requires": { - "assert-plus": "1.0.0", - "extsprintf": "1.3.0", - "json-schema": "0.2.3", - "verror": "1.10.0" - } - }, - "mime-db": { - "version": "1.44.0", - "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.44.0.tgz", - "integrity": "sha512-/NOTfLrsPBVeH7YtFPgsVWveuL+4SjjYxaQ1xtM1KMFj7HdxlBlxeyNLzhyJVx7r4rZGJAZ/6lkKCitSc/Nmpg==" - }, - "mime-types": { - "version": "2.1.27", - "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.27.tgz", - "integrity": "sha512-JIhqnCasI9yD+SsmkquHBxTSEuZdQX5BuQnS2Vc7puQQQ+8yiP5AY5uWhpdv4YL4VM5c6iliiYWPgJ/nJQLp7w==", - "requires": { - "mime-db": "1.44.0" - } - }, - "minimatch": { - "version": "3.0.4", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", - "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", - "requires": { - "brace-expansion": "^1.1.7" - } - }, - "oauth-sign": { - "version": "0.9.0", - "resolved": "https://registry.npmjs.org/oauth-sign/-/oauth-sign-0.9.0.tgz", - "integrity": "sha512-fexhUFFPTGV8ybAtSIGbV6gOkSv8UtRbDBnAyLQw4QPKkgNlsH2ByPGtMUqdWkos6YCRmAqViwgZrJc/mRDzZQ==" - }, - "once": { - "version": "1.4.0", - "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", - "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=", - "requires": { - "wrappy": "1" - } - }, - "parse-glob": { - "version": "3.0.4", - "resolved": "https://registry.npmjs.org/parse-glob/-/parse-glob-3.0.4.tgz", - "integrity": "sha1-ssN2z7EfNVE7rdFz7wu246OIORw=", - "requires": { - "glob-base": "^0.3.0", - "is-dotfile": "^1.0.0", - "is-extglob": "^1.0.0", - "is-glob": "^2.0.0" - } - }, - "path-is-absolute": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", - "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=" - }, - "performance-now": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/performance-now/-/performance-now-2.1.0.tgz", - "integrity": "sha1-Ywn04OX6kT7BxpMHrjZLSzd8nns=" - }, - "psl": { - "version": "1.8.0", - "resolved": "https://registry.npmjs.org/psl/-/psl-1.8.0.tgz", - "integrity": "sha512-RIdOzyoavK+hA18OGGWDqUTsCLhtA7IcZ/6NCs4fFJaHBDab+pDDmDIByWFRQJq2Cd7r1OoQxBGKOaztq+hjIQ==" - }, - "punycode": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.1.1.tgz", - "integrity": "sha512-XRsRjdf+j5ml+y/6GKHPZbrF/8p2Yga0JPtdqTIY2Xe5ohJPD9saDJJLPvp9+NSBprVvevdXZybnj2cv8OEd0A==" - }, - "qs": { - "version": "6.5.2", - "resolved": "https://registry.npmjs.org/qs/-/qs-6.5.2.tgz", - "integrity": "sha512-N5ZAX4/LxJmF+7wN74pUD6qAh9/wnvdQcjq9TZjevvXzSUo7bfmw91saqMjzGS2xq91/odN2dW/WOl7qQHNDGA==" - }, - "request": { - "version": "2.88.2", - "resolved": "https://registry.npmjs.org/request/-/request-2.88.2.tgz", - "integrity": "sha512-MsvtOrfG9ZcrOwAW+Qi+F6HbD0CWXEh9ou77uOb7FM2WPhwT7smM833PzanhJLsgXjN89Ir6V2PczXNnMpwKhw==", - "requires": { - "aws-sign2": "~0.7.0", - "aws4": "^1.8.0", - "caseless": "~0.12.0", - "combined-stream": "~1.0.6", - "extend": "~3.0.2", - "forever-agent": "~0.6.1", - "form-data": "~2.3.2", - "har-validator": "~5.1.3", - "http-signature": "~1.2.0", - "is-typedarray": "~1.0.0", - "isstream": "~0.1.2", - "json-stringify-safe": "~5.0.1", - "mime-types": "~2.1.19", - "oauth-sign": "~0.9.0", - "performance-now": "^2.1.0", - "qs": "~6.5.2", - "safe-buffer": "^5.1.2", - "tough-cookie": "~2.5.0", - "tunnel-agent": "^0.6.0", - "uuid": "^3.3.2" - } - }, - "safe-buffer": { - "version": "5.2.1", - "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz", - "integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==" - }, - "safer-buffer": { - "version": "2.1.2", - "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz", - "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==" - }, - "sshpk": { - "version": "1.16.1", - "resolved": "https://registry.npmjs.org/sshpk/-/sshpk-1.16.1.tgz", - "integrity": "sha512-HXXqVUq7+pcKeLqqZj6mHFUMvXtOJt1uoUx09pFW6011inTMxqI8BA8PM95myrIyyKwdnzjdFjLiE6KBPVtJIg==", - "requires": { - "asn1": "~0.2.3", - "assert-plus": "^1.0.0", - "bcrypt-pbkdf": "^1.0.0", - "dashdash": "^1.12.0", - "ecc-jsbn": "~0.1.1", - "getpass": "^0.1.1", - "jsbn": "~0.1.0", - "safer-buffer": "^2.0.2", - "tweetnacl": "~0.14.0" - } - }, - "strip-json-comments": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-3.1.0.tgz", - "integrity": "sha512-e6/d0eBu7gHtdCqFt0xJr642LdToM5/cN4Qb9DbHjVx1CP5RyeM+zH7pbecEmDv/lBqb0QH+6Uqq75rxFPkM0w==" - }, - "supports-color": { - "version": "7.1.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.1.0.tgz", - "integrity": "sha512-oRSIpR8pxT1Wr2FquTNnGet79b3BWljqOuoW/h4oBhxJ/HUbX5nX6JSruTkvXDCFMwDPvsaTTbvMLKZWSy0R5g==", - "requires": { - "has-flag": "^4.0.0" - } - }, - "tough-cookie": { - "version": "2.5.0", - "resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-2.5.0.tgz", - "integrity": "sha512-nlLsUzgm1kfLXSXfRZMc1KLAugd4hqJHDTvc2hDIwS3mZAfMEuMbc03SujMF+GEcpaX/qboeycw6iO8JwVv2+g==", - "requires": { - "psl": "^1.1.28", - "punycode": "^2.1.1" - } - }, - "tunnel-agent": { - "version": "0.6.0", - "resolved": "https://registry.npmjs.org/tunnel-agent/-/tunnel-agent-0.6.0.tgz", - "integrity": "sha1-J6XeoGs2sEoKmWZ3SykIaPD8QP0=", - "requires": { - "safe-buffer": "^5.0.1" - } - }, - "tweetnacl": { - "version": "0.14.5", - "resolved": "https://registry.npmjs.org/tweetnacl/-/tweetnacl-0.14.5.tgz", - "integrity": "sha1-WuaBd/GS1EViadEIr6k/+HQ/T2Q=" - }, - "uri-js": { - "version": "4.2.2", - "resolved": "https://registry.npmjs.org/uri-js/-/uri-js-4.2.2.tgz", - "integrity": "sha512-KY9Frmirql91X2Qgjry0Wd4Y+YTdrdZheS8TFwvkbLWf/G5KNJDCh6pKL5OZctEW4+0Baa5idK2ZQuELRwPznQ==", - "requires": { - "punycode": "^2.1.0" - } - }, - "uuid": { - "version": "3.4.0", - "resolved": "https://registry.npmjs.org/uuid/-/uuid-3.4.0.tgz", - "integrity": "sha512-HjSDRw6gZE5JMggctHBcjVak08+KEVhSIiDzFnT9S9aegmp85S/bReBVTb4QTFaRNptJ9kuYaNhnbNEOkbKb/A==" - }, - "verror": { - "version": "1.10.0", - "resolved": "https://registry.npmjs.org/verror/-/verror-1.10.0.tgz", - "integrity": "sha1-OhBcoXBTr1XW4nDB+CiGguGNpAA=", - "requires": { - "assert-plus": "^1.0.0", - "core-util-is": "1.0.2", - "extsprintf": "^1.2.0" - } - }, - "wrappy": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", - "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=" - }, - "xml": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/xml/-/xml-1.0.1.tgz", - "integrity": "sha1-eLpyAgApxbyHuKgaPPzXS0ovweU=" - } - } -} From 4a5adc95485b9b656a9b0a2ddd5015cdcf59bb25 Mon Sep 17 00:00:00 2001 From: Lucas Gravley <29484535+admiralAwkbar@users.noreply.github.com> Date: Thu, 23 Jul 2020 08:22:30 -0500 Subject: [PATCH 035/135] forgot that gradle action --- lib/buildFileList.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/buildFileList.sh b/lib/buildFileList.sh index d06b3678..2f0df142 100755 --- a/lib/buildFileList.sh +++ b/lib/buildFileList.sh @@ -439,7 +439,7 @@ function BuildFileList() { # Set the READ_ONLY_CHANGE_FLAG since this could be exec # ########################################################## READ_ONLY_CHANGE_FLAG=1 - elif [ "$FILE_TYPE" == "groovy" ] || [ "$FILE_TYPE" == "jenkinsfile" ]; then + elif [ "$FILE_TYPE" == "groovy" ] || [ "$FILE_TYPE" == "jenkinsfile" ] || [ "$FILE_TYPE" == "gradle" ]; then ################################ # Append the file to the array # ################################ From 5c0da604bf9f49167a10a9d61ecb1405466b6118 Mon Sep 17 00:00:00 2001 From: Lucas Gravley <29484535+admiralAwkbar@users.noreply.github.com> Date: Thu, 23 Jul 2020 09:16:40 -0500 Subject: [PATCH 036/135] Adding LFS --- Dockerfile | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/Dockerfile b/Dockerfile index b4134227..ce9cf959 100644 --- a/Dockerfile +++ b/Dockerfile @@ -54,23 +54,19 @@ RUN apk add --update --no-cache \ bash \ curl \ gcc \ - git \ + git git-lfs\ go \ icu-libs \ jq \ libxml2-utils \ make \ musl-dev \ - npm \ - nodejs \ + npm nodejs \ openjdk8-jre \ perl \ php7 \ py3-setuptools \ - ruby \ - ruby-dev \ - ruby-bundler \ - ruby-rdoc + ruby ruby-dev ruby-bundler ruby-rdoc ######################################## # Copy dependencies files to container # From dd20279eae2528af80ebeca0567e21de45544ecb Mon Sep 17 00:00:00 2001 From: mil7 <49973666+mil7@users.noreply.github.com> Date: Thu, 23 Jul 2020 16:25:23 +0200 Subject: [PATCH 037/135] Fix horizontal line --- docs/disabling-linters.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/disabling-linters.md b/docs/disabling-linters.md index 68184302..31864c8b 100644 --- a/docs/disabling-linters.md +++ b/docs/disabling-linters.md @@ -954,7 +954,7 @@ lint: ## EDITORCONFIG-CHECKER - [editorconfig-checker](https://github.com/editorconfig-checker/editorconfig-checker) --------------------------------------------------------------------------------- +--- ### editorconfig-checker Config file - `.github/linters/.ecrc` From 7d07c7e2b2dd3ccbe44be6a5de03ea9a195d46f9 Mon Sep 17 00:00:00 2001 From: mil7 <49973666+mil7@users.noreply.github.com> Date: Thu, 23 Jul 2020 16:26:48 +0200 Subject: [PATCH 038/135] Delete surplus horizonal line --- docs/disabling-linters.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/docs/disabling-linters.md b/docs/disabling-linters.md index 31864c8b..491f76bc 100644 --- a/docs/disabling-linters.md +++ b/docs/disabling-linters.md @@ -954,8 +954,6 @@ lint: ## EDITORCONFIG-CHECKER - [editorconfig-checker](https://github.com/editorconfig-checker/editorconfig-checker) ---- - ### editorconfig-checker Config file - `.github/linters/.ecrc` - This linter will also use the [`.editorconfig`](https://editorconfig.org/) of your project From c41b2aef29536655567cd34501fe46f37f2a60d9 Mon Sep 17 00:00:00 2001 From: Lucas Gravley <29484535+admiralAwkbar@users.noreply.github.com> Date: Thu, 23 Jul 2020 10:15:18 -0500 Subject: [PATCH 039/135] fix shyaml --- dependencies/Pipfile.lock | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/dependencies/Pipfile.lock b/dependencies/Pipfile.lock index 9ddf4df3..4e90e85d 100644 --- a/dependencies/Pipfile.lock +++ b/dependencies/Pipfile.lock @@ -28,6 +28,7 @@ "sha256:2f4078c2a41bf377eea06d71c9d2ba4eb8f6b1af2135bec27bbbb7d8f12bb703", "sha256:bc58d83eb610252fd8de6363e39d4f1d0619c894b0ed24603b881c02e64c7386" ], + "markers": "python_version >= '3.5'", "version": "==2.4.2" }, "attrs": { @@ -35,6 +36,7 @@ "sha256:08a96c641c3a74e44eb59afb61a24f2cb9f4d7188748e76ba4bb5edfa3cb7d1c", "sha256:f7b7ce16570fe9965acd6d30101a28f62fb4a7f9e926b3bbc9b61f8b04247e72" ], + "markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3'", "version": "==19.3.0" }, "aws-sam-translator": { @@ -47,16 +49,17 @@ }, "boto3": { "hashes": [ - "sha256:07bd0872e9178b637baefb82aff8abb76197770c9fc60c4d6575564ba878e3e4" + "sha256:4735fdf490094537ea0cb93ba4237db442195c37f974ea4ad44b9a5af98e6d7b", + "sha256:838cea329851e11b9a9dae1c00cd5ef2f3b29ac83c061733b2e93b64c333750f" ], - "version": "==1.14.22" + "version": "==1.14.26" }, "botocore": { "hashes": [ - "sha256:4d084dfcfcdf21ac2df17d017607ca53d53ac6c2fa17484cdd87ef78daba06b8", - "sha256:f491d3c29d7dda8c8907c520bc96d77a67a8953dfed7f55c250799849e213640" + "sha256:0c4ed6349e8ef6bfe9648757f3ff66c33a8f37d9cbadd9c17987138184990cbd", + "sha256:28832be365204f00d5c7d2c2a0538d9d082dbfc39ed984fdc9556770470b7487" ], - "version": "==1.17.22" + "version": "==1.17.26" }, "cfn-lint": { "hashes": [ @@ -79,6 +82,7 @@ "sha256:9e4d7ecfc600058e07ba661411a2b7de2fd0fafa17d1a7f7361cd47b1175c827", "sha256:a2aeea129088da402665e92e0b25b04b073c04b2dce4ab65caaa38b7ce2e1a99" ], + "markers": "python_version >= '2.6' and python_version not in '3.0, 3.1, 3.2'", "version": "==0.15.2" }, "isort": { @@ -86,6 +90,7 @@ "sha256:54da7e92468955c4fceacd0c86bd0ec997b0e1ee80d97f67c35a78b719dccab1", "sha256:6e811fcb295968434526407adb8796944f1988c5b65e8139058f2014cbe100fd" ], + "markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3'", "version": "==4.3.21" }, "jmespath": { @@ -93,6 +98,7 @@ "sha256:b85d0567b8666149a93172712e68920734333c0ce7e89b78b3e987f71e5ed4f9", "sha256:cdf6525904cc597730141d61b36f2e4b8ecc257c420fa2f4549bac2c2d0cb72f" ], + "markers": "python_version >= '2.6' and python_version not in '3.0, 3.1, 3.2'", "version": "==0.10.0" }, "jsonpatch": { @@ -108,6 +114,7 @@ "sha256:c192ba86648e05fdae4f08a17ec25180a9aef5008d973407b581798a83975362", "sha256:ff379fa021d1b81ab539f5ec467c7745beb1a5671463f9dcc2b2d458bd361c1e" ], + "markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3'", "version": "==2.0" }, "jsonschema": { @@ -147,6 +154,7 @@ "sha256:efa1909120ce98bbb3777e8b6f92237f5d5c8ea6758efea36a473e1d38f7d3e4", "sha256:f3900e8a5de27447acbf900b4750b0ddfd7ec1ea7fbaf11dfa911141bc522af0" ], + "markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3'", "version": "==1.4.3" }, "mccabe": { @@ -190,6 +198,7 @@ "sha256:73ebfe9dbf22e832286dafa60473e4cd239f8592f699aa5adaf10050e6e1823c", "sha256:75bb3f31ea686f1197762692a9ee6a7550b59fc6ca3a1f4b5d7e32fb98e2da2a" ], + "markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2'", "version": "==2.8.1" }, "pyyaml": { @@ -229,6 +238,7 @@ "sha256:30639c035cdb23534cd4aa2dd52c3bf48f06e5f4a941509c8bafd8ce11080259", "sha256:8b74bedcbbbaca38ff6d7491d76f2b06b3592611af620f8426e82dddb04a5ced" ], + "markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2'", "version": "==1.15.0" }, "toml": { @@ -240,11 +250,11 @@ }, "urllib3": { "hashes": [ - "sha256:3018294ebefce6572a474f0604c2021e33b3fd8006ecd11d62107a5d2a963527", - "sha256:88206b0eb87e6d677d424843ac5209e3fb9d0190d0ee169599165ec25e9d9115" + "sha256:91056c15fa70756691db97756772bb1eb9678fa585d9184f24534b100dc60f4a", + "sha256:e7983572181f5e1522d9c98453462384ee92a0be7fac5f1413a1e35c56cc0461" ], "markers": "python_version != '3.4'", - "version": "==1.25.9" + "version": "==1.25.10" }, "wrapt": { "hashes": [ From 1102675a6d9da39739985968e51d9a9b2b810dc9 Mon Sep 17 00:00:00 2001 From: Lucas Gravley <29484535+admiralAwkbar@users.noreply.github.com> Date: Thu, 23 Jul 2020 10:18:54 -0500 Subject: [PATCH 040/135] adding the rest --- lib/linter.sh | 29 +++++------------------------ 1 file changed, 5 insertions(+), 24 deletions(-) diff --git a/lib/linter.sh b/lib/linter.sh index 46902f57..7c5fabc1 100755 --- a/lib/linter.sh +++ b/lib/linter.sh @@ -575,34 +575,15 @@ DetectCloudFormationFile() { ####################################### # Check if file has AWS Template info # ####################################### - if grep 'AWSTemplateFormatVersion' "${FILE}" > /dev/null; then + if grep -q 'AWSTemplateFormatVersion' "${FILE}" > /dev/null; then # Found it return 0 fi - ################################################### - # Check if file has AWSTemplateFormatVersion info # - ################################################### - if shyaml --quiet get-type AWSTemplateFormatVersion > /dev/null < "${FILE}"; then - # Found it - return 0 - fi - - ############################### - # check if file has resources # - ############################### - if jq -e 'has("Resources")' > /dev/null 2>&1 < "${FILE}"; then - # Check if AWS Alexa or custom - if jq ".Resources[].Type" 2> /dev/null | grep -q -E "(AWS|Alexa|Custom)" < "${FILE}"; then - # Found it - return 0 - fi - fi - - ################################ - # See if it contains resources # - ################################ - if shyaml values-0 Resources 2> /dev/null | grep -q -E "Type: (AWS|Alexa|Custom)" < "${FILE}"; then + ##################################### + # See if it contains AWS References # + ##################################### + if grep -q -E '(AWS|Alexa|Custom)::' "${FILE}" > /dev/null; then # Found it return 0 fi From b6096044cfa3cf72fe7f9ab72cade44979d63e49 Mon Sep 17 00:00:00 2001 From: Lucas Gravley <29484535+admiralAwkbar@users.noreply.github.com> Date: Thu, 23 Jul 2020 10:19:58 -0500 Subject: [PATCH 041/135] now with changes --- dependencies/Pipfile | 1 - dependencies/Pipfile.lock | 10 +--------- 2 files changed, 1 insertion(+), 10 deletions(-) diff --git a/dependencies/Pipfile b/dependencies/Pipfile index 2fce4271..b9df418b 100644 --- a/dependencies/Pipfile +++ b/dependencies/Pipfile @@ -10,7 +10,6 @@ yamllint = "*" pylint = "*" yq = "*" cfn-lint = "*" -shyaml = "*" [requires] python_version = "3.8" diff --git a/dependencies/Pipfile.lock b/dependencies/Pipfile.lock index 4e90e85d..356eeda1 100644 --- a/dependencies/Pipfile.lock +++ b/dependencies/Pipfile.lock @@ -1,7 +1,7 @@ { "_meta": { "hash": { - "sha256": "f8d7f08c1efbacea7c92868babd54bc040413f865e3cd7ea8d4bebab310b3da3" + "sha256": "1ccc4fd5c20ba56f1cca85abdd09b24798c3ad68b921cb42c501177598d986c9" }, "pipfile-spec": 6, "requires": { @@ -225,14 +225,6 @@ ], "version": "==0.3.3" }, - "shyaml": { - "hashes": [ - "sha256:3a57e380f66043c661d417106a0f101f8068c80caa2afef57c90447b88526c3d", - "sha256:ac9066eed5b8445de1f83a99106ca96a77900b6873de327fd50d3e3102084752" - ], - "index": "pypi", - "version": "==0.6.1" - }, "six": { "hashes": [ "sha256:30639c035cdb23534cd4aa2dd52c3bf48f06e5f4a941509c8bafd8ce11080259", From 264157912578ba8eca991b77d08ecafd4a7e4488 Mon Sep 17 00:00:00 2001 From: Lucas Gravley <29484535+admiralAwkbar@users.noreply.github.com> Date: Thu, 23 Jul 2020 12:52:43 -0500 Subject: [PATCH 042/135] Adding it --- lib/linter.sh | 706 +++++++++++++++++++++++++------------------------- lib/worker.sh | 32 ++- 2 files changed, 381 insertions(+), 357 deletions(-) diff --git a/lib/linter.sh b/lib/linter.sh index c9150aeb..06bb4884 100755 --- a/lib/linter.sh +++ b/lib/linter.sh @@ -1055,42 +1055,42 @@ GetValidationInfo ######################## # Get the linter rules # ######################## -# Get YML rules -GetLinterRules "YAML" -# Get Markdown rules -GetLinterRules "MARKDOWN" -# Get Python rules -GetLinterRules "PYTHON" -# Get Ruby rules -GetLinterRules "RUBY" -# Get Coffeescript rules -GetLinterRules "COFFEESCRIPT" # Get Ansible rules GetLinterRules "ANSIBLE" -# Get JavaScript rules -GetLinterRules "JAVASCRIPT" -# Get TypeScript rules -GetLinterRules "TYPESCRIPT" +# 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 Docker rules -GetLinterRules "DOCKER" -# Get Terraform rules -GetLinterRules "TERRAFORM" -# Get PowerShell rules -GetLinterRules "POWERSHELL" -# Get ARM rules -GetLinterRules "ARM" -# Get CSS rules -GetLinterRules "CSS" -# Get CLOUDFORMATION rules -GetLinterRules "CLOUDFORMATION" -# Get DART rules -GetLinterRules "DART" # Get HTML rules GetLinterRules "HTML" +# Get JavaScript rules +GetLinterRules "JAVASCRIPT" +# Get Markdown rules +GetLinterRules "MARKDOWN" +# Get PowerShell rules +GetLinterRules "POWERSHELL" +# Get Python rules +GetLinterRules "PYTHON" +# Get Ruby rules +GetLinterRules "RUBY" +# Get Terraform rules +GetLinterRules "TERRAFORM" +# Get TypeScript rules +GetLinterRules "TYPESCRIPT" +# Get YML rules +GetLinterRules "YAML" ################################# # Check if were in verbose mode # @@ -1129,48 +1129,48 @@ if [ "${VALIDATE_ALL_CODEBASE}" == "false" ]; then BuildFileList fi -############### -# YML LINTING # -############### -if [ "${VALIDATE_YAML}" == "true" ]; then - ###################### - # Lint the Yml Files # - ###################### - # LintCodebase "FILE_TYPE" "LINTER_NAME" "LINTER_CMD" "FILE_TYPES_REGEX" "FILE_ARRAY" - LintCodebase "YML" "yamllint" "yamllint -c ${YAML_LINTER_RULES}" ".*\.\(yml\|yaml\)\$" "${FILE_ARRAY_YML[@]}" +################### +# ANSIBLE LINTING # +################### +if [ "${VALIDATE_ANSIBLE}" == "true" ]; then + ########################## + # Lint the Ansible files # + ########################## + # Due to the nature of how we want to validate Ansible, we cannot use the + # 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 -################ -# 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 +######################## +# 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' -############### -# XML LINTING # -############### -if [ "${VALIDATE_XML}" == "true" ]; then - ###################### - # Lint the XML Files # - ###################### - # LintCodebase "FILE_TYPE" "LINTER_NAME" "LINTER_CMD" "FILE_TYPES_REGEX" "FILE_ARRAY" - LintCodebase "XML" "xmllint" "xmllint" ".*\.\(xml\)\$" "${FILE_ARRAY_XML[@]}" -fi + 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 -#################### -# 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 "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 ################ @@ -1184,17 +1184,6 @@ if [ "${VALIDATE_BASH}" == "true" ]; then LintCodebase "BASH" "shellcheck" "shellcheck --color" ".*\.\(sh\|bash\|dash\|ksh\)\$" "${FILE_ARRAY_BASH[@]}" 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 # ########################## @@ -1226,52 +1215,18 @@ if [ "${VALIDATE_CLOUDFORMATION}" == "true" ]; then LintCodebase "CLOUDFORMATION" "cfn-lint" "cfn-lint --config-file ${CLOUDFORMATION_LINTER_RULES}" "disabledfileext" "${FILE_ARRAY_CLOUDFORMATION[@]}" 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 - -################ -# 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[@]}" +################### +# 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 ######################## @@ -1285,6 +1240,65 @@ if [ "${VALIDATE_COFFEE}" == "true" ]; then LintCodebase "COFFEESCRIPT" "coffeelint" "coffeelint -f ${COFFEESCRIPT_LINTER_RULES}" ".*\.\(coffee\)\$" "${FILE_ARRAY_COFFEESCRIPT[@]}" 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 # ################## @@ -1304,31 +1318,21 @@ if [ "$VALIDATE_GROOVY" == "true" ]; then # Lint the groovy files # ######################### # LintCodebase "FILE_TYPE" "LINTER_NAME" "LINTER_CMD" "FILE_TYPES_REGEX" "FILE_ARRAY" - LintCodebase "GROOVY" "npm-groovy-lint" "npm-groovy-lint -c $GROOVY_LINTER_RULES -s" ".*\.\(groovy\|jenkinsfile\|gradle\)\$" "${FILE_ARRAY_GROOVY[@]}" + LintCodebase "GROOVY" "npm-groovy-lint" "npm-groovy-lint -c $GROOVY_LINTER_RULES --failon error" ".*\.\(groovy\|jenkinsfile\|gradle\)\$" "${FILE_ARRAY_GROOVY[@]}" 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 - -################### -# ANSIBLE LINTING # -################### -if [ "${VALIDATE_ANSIBLE}" == "true" ]; then - ########################## - # Lint the Ansible files # - ########################## - # Due to the nature of how we want to validate Ansible, we cannot use the - # 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 +################ +# 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 ###################### @@ -1357,6 +1361,17 @@ if [ "${VALIDATE_JAVASCRIPT_STANDARD}" == "true" ]; then LintCodebase "JAVASCRIPT_STANDARD" "standard" "standard ${JAVASCRIPT_STANDARD_LINTER_RULES}" ".*\.\(js\)\$" "${FILE_ARRAY_JAVASCRIPT_STANDARD[@]}" 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 # ###################### @@ -1368,6 +1383,186 @@ if [ "${VALIDATE_JSX}" == "true" ]; then LintCodebase "JSX" "eslint" "eslint --no-eslintrc -c ${JAVASCRIPT_LINTER_RULES}" ".*\.\(jsx\)\$" "${FILE_ARRAY_JSX[@]}" 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 # ###################### @@ -1403,220 +1598,25 @@ if [ "${VALIDATE_TYPESCRIPT_STANDARD}" == "true" ]; then fi ############### -# CSS LINTING # +# XML 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[@]}" +if [ "${VALIDATE_XML}" == "true" ]; then + ###################### + # Lint the XML Files # + ###################### + # LintCodebase "FILE_TYPE" "LINTER_NAME" "LINTER_CMD" "FILE_TYPES_REGEX" "FILE_ARRAY" + LintCodebase "XML" "xmllint" "xmllint" ".*\.\(xml\)\$" "${FILE_ARRAY_XML[@]}" fi ############### -# ENV LINTING # +# YML LINTING # ############### -if [ "${VALIDATE_ENV}" == "true" ]; then - ####################### - # Lint the env files # - ####################### +if [ "${VALIDATE_YAML}" == "true" ]; then + ###################### + # Lint the Yml Files # + ###################### # LintCodebase "FILE_TYPE" "LINTER_NAME" "LINTER_CMD" "FILE_TYPES_REGEX" "FILE_ARRAY" - LintCodebase "ENV" "dotenv-linter" "dotenv-linter" ".*\.\(env\).*\$" "${FILE_ARRAY_ENV[@]}" -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[@]}" + LintCodebase "YML" "yamllint" "yamllint -c ${YAML_LINTER_RULES}" ".*\.\(yml\|yaml\)\$" "${FILE_ARRAY_YML[@]}" fi ########### diff --git a/lib/worker.sh b/lib/worker.sh index f6bb3808..607c3fd6 100755 --- a/lib/worker.sh +++ b/lib/worker.sh @@ -138,10 +138,11 @@ function LintCodebase() { # Lint the files # ################## for FILE in "${LIST_FILES[@]}"; do - ##################### - # Get the file name # - ##################### + ################################### + # Get the file name and directory # + ################################### FILE_NAME=$(basename "${FILE}" 2>&1) + DIR_NAME=$(dirname "${FILE}" 2>&1) ##################################################### # 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 }" 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 ################################ # Lint the file with the rules # @@ -326,6 +338,7 @@ function TestCodebase() { # Get the file name # ##################### FILE_NAME=$(basename "${FILE}" 2>&1) + DIR_NAME=$(dirname "${FILE}" 2>&1) ############################ # Get the file pass status # @@ -400,6 +413,17 @@ function TestCodebase() { pwsh -NoProfile -NoLogo -Command "${LINTER_COMMAND} ${FILE}; if (\${Error}.Count) { exit 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 ################################ # Lint the file with the rules # @@ -566,7 +590,7 @@ function RunTestCases() { TestCodebase "EDITORCONFIG" "editorconfig-checker" "editorconfig-checker" ".*\.ext$" "editorconfig-checker" TestCodebase "ENV" "dotenv-linter" "dotenv-linter" ".*\.\(env\)\$" "env" 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 -s" ".*\.\(groovy\|jenkinsfile\|gradle\)\$" "groovy" + 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 "JAVASCRIPT_ES" "eslint" "eslint --no-eslintrc -c ${JAVASCRIPT_LINTER_RULES}" ".*\.\(js\)\$" "javascript" TestCodebase "JAVASCRIPT_STANDARD" "standard" "standard ${JAVASCRIPT_STANDARD_LINTER_RULES}" ".*\.\(js\)\$" "javascript" From d2bb1dd6c1c0f32bb792cd6c13a6a0c776cae2af Mon Sep 17 00:00:00 2001 From: Lucas Gravley <29484535+admiralAwkbar@users.noreply.github.com> Date: Thu, 23 Jul 2020 13:01:04 -0500 Subject: [PATCH 043/135] Fix spacing --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 25612c63..aa163769 100644 --- a/README.md +++ b/README.md @@ -54,7 +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) | | **ENV** | [dotenv-linter](https://github.com/dotenv-linter/dotenv-linter) | | **Golang** | [golangci-lint](https://github.com/golangci/golangci-lint) | -| **Groovy** | [npm-groovy-lint](https://github.com/nvuillam/npm-groovy-lint) | +| **Groovy** | [npm-groovy-lint](https://github.com/nvuillam/npm-groovy-lint) | | **HTMLHint** | [HTMLHint](https://github.com/htmlhint/HTMLHint) | | **JavaScript** | [eslint](https://eslint.org/) [standard js](https://standardjs.com/) | | **JSON** | [jsonlint](https://github.com/zaach/jsonlint) | From a1e4dccdd54190986c2056dc39796e6e23740249 Mon Sep 17 00:00:00 2001 From: Cesar Rodriguez Date: Wed, 22 Jul 2020 16:55:15 -0400 Subject: [PATCH 044/135] adds Terrascan --- dependencies/Pipfile | 1 + 1 file changed, 1 insertion(+) diff --git a/dependencies/Pipfile b/dependencies/Pipfile index b9df418b..dbc906c9 100644 --- a/dependencies/Pipfile +++ b/dependencies/Pipfile @@ -10,6 +10,7 @@ yamllint = "*" pylint = "*" yq = "*" cfn-lint = "*" +terrascan = "*" [requires] python_version = "3.8" From 7c4f96b5b74c4c211814b07787bc40228b92688f Mon Sep 17 00:00:00 2001 From: Cesar Rodriguez Date: Wed, 22 Jul 2020 16:55:44 -0400 Subject: [PATCH 045/135] adds Terrascan and bumps urllib and boto3 to latest --- dependencies/Pipfile.lock | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/dependencies/Pipfile.lock b/dependencies/Pipfile.lock index 356eeda1..e36ac249 100644 --- a/dependencies/Pipfile.lock +++ b/dependencies/Pipfile.lock @@ -179,6 +179,12 @@ ], "version": "==0.8.0" }, + "pyhcl": { + "hashes": [ + "sha256:2d9b9dcdf1023d812bfed561ba72c99104c5b3f52e558d595130a44ce081b003" + ], + "version": "==0.4.4" + }, "pylint": { "hashes": [ "sha256:7dd78437f2d8d019717dbf287772d0b2dbdfd13fc016aa7faa08d67bccc46adc", @@ -233,6 +239,14 @@ "markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2'", "version": "==1.15.0" }, + "terrascan": { + "hashes": [ + "sha256:b58c926e5c04d161d00c4563a1c9e688a1cf10c1283c6964c2c642a0fb5041bc", + "sha256:ce41ee1297259dad7b409cac49e26a196b1e86788e87de7166b61f407ad3da91" + ], + "index": "pypi", + "version": "==0.2.2" + }, "toml": { "hashes": [ "sha256:926b612be1e5ce0634a2ca03470f95169cf16f939018233a670519cb4ac58b0f", From de8574565dfb2a0d30e3f5c425c24fe68ee90d36 Mon Sep 17 00:00:00 2001 From: Cesar Rodriguez Date: Wed, 22 Jul 2020 21:40:20 -0400 Subject: [PATCH 046/135] Adds the VALIDATE_TERRAFORM_TERRASCAN variable --- Dockerfile | 1 + README.md | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 02452f59..2d143824 100644 --- a/Dockerfile +++ b/Dockerfile @@ -229,6 +229,7 @@ ENV ACTIONS_RUNNER_DEBUG=${ACTIONS_RUNNER_DEBUG} \ VALIDATE_RUBY=${VALIDATE_RUBY} \ VALIDATE_STATES=${VALIDATE_STATES} \ VALIDATE_TERRAFORM=${VALIDATE_TERRAFORM} \ + VALIDATE_TERRAFORM_TERRASCAN=${VALIDATE_TERRAFORM_TERRASCAN} \ VALIDATE_TYPESCRIPT_ES=${VALIDATE_TYPESCRIPT_ES} \ VALIDATE_TYPESCRIPT_STANDARD=${VALIDATE_TYPESCRIPT_STANDARD} \ VALIDATE_XML=${VALIDATE_XML} \ diff --git a/README.md b/README.md index aa163769..e9dd76be 100644 --- a/README.md +++ b/README.md @@ -69,7 +69,7 @@ Developers on **GitHub** can call the **GitHub Action** to lint their code base | **Raku** | [raku](https://raku.org) | | **Ruby** | [RuboCop](https://github.com/rubocop-hq/rubocop) | | **Shell** | [Shellcheck](https://github.com/koalaman/shellcheck) | -| **Terraform** | [tflint](https://github.com/terraform-linters/tflint) | +| **Terraform** | [tflint](https://github.com/terraform-linters/tflint) [terrascan](https://github.com/accurics/terrascan) | | **TypeScript** | [eslint](https://eslint.org/) [standard js](https://standardjs.com/) | | **XML** | [LibXML](http://xmlsoft.org/) | | **YAML** | [YamlLint](https://github.com/adrienverge/yamllint) | @@ -212,6 +212,7 @@ and won't run anything unexpected. | **VALIDATE_RUBY** | `true` | Flag to enable or disable the linting process of the Ruby language. | | **VALIDATE_STATES** | `true` | Flag to enable or disable the linting process for AWS States Language. | | **VALIDATE_TERRAFORM** | `true` | Flag to enable or disable the linting process of the Terraform language. | +| **VALIDATE_TERRAFORM_TERRASCAN** | `false` | Flag to enable or disable the linting process of the Terraform language for security related issues. | | **VALIDATE_TSX** | `true` | Flag to enable or disable the linting process for tsx files (Utilizing: eslint) | | **VALIDATE_TYPESCRIPT_ES** | `true` | Flag to enable or disable the linting process of the Typescript language. (Utilizing: eslint) | | **VALIDATE_TYPESCRIPT_STANDARD** | `true` | Flag to enable or disable the linting process of the Typescript language. (Utilizing: standard) | From 2b7a78dd9615851ae924c5aa6f96fd0788bd586c Mon Sep 17 00:00:00 2001 From: Cesar Rodriguez Date: Wed, 22 Jul 2020 21:40:43 -0400 Subject: [PATCH 047/135] Including Terrascan linting command --- lib/linter.sh | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/lib/linter.sh b/lib/linter.sh index 06bb4884..9c9e3864 100755 --- a/lib/linter.sh +++ b/lib/linter.sh @@ -98,7 +98,7 @@ LINTER_ARRAY=('ansible-lint' 'arm-ttk' 'asl-validator' 'cfn-lint' 'clj-kondo' 'coffeelint' 'dart' 'dockerfilelint' 'dotenv-linter' 'eslint' 'golangci-lint' 'htmlhint' 'jsonlint' 'ktlint' 'markdownlint' 'npm-groovy-lint' 'perl' 'protolint' 'pwsh' 'pylint' 'raku' 'rubocop' 'shellcheck' 'spectral' - 'standard' 'stylelint' 'tflint' 'xmllint' 'yamllint') + 'standard' 'stylelint' 'terrascan' 'tflint' 'xmllint' 'yamllint') ############################# @@ -108,7 +108,7 @@ LANGUAGE_ARRAY=('ANSIBLE' 'ARM' 'BASH' 'CLOUDFORMATION' 'CLOJURE' 'COFFEESCRIPT' 'CSS' 'DART' 'DOCKER' 'ENV' 'GO' 'GROOVY' 'HTML' 'JAVASCRIPT_ES' 'JAVASCRIPT_STANDARD' 'JSON' 'JSX' 'KOTLIN' 'MARKDOWN' 'OPENAPI' 'PERL' 'PHP' 'POWERSHELL' 'PROTOBUF' 'PYTHON' - 'RAKU' 'RUBY' 'STATES' 'TERRAFORM' 'TSX' 'TYPESCRIPT_ES' + 'RAKU' 'RUBY' 'STATES' 'TERRAFORM' 'TERRAFORM_TERRASCAN' 'TSX' 'TYPESCRIPT_ES' 'TYPESCRIPT_STANDARD' 'XML' 'YML') ############################################ @@ -161,6 +161,7 @@ VALIDATE_RAKU="${VALIDATE_RAKU}" # Boolean to vali VALIDATE_RUBY="${VALIDATE_RUBY}" # Boolean to validate language VALIDATE_STATES="${VALIDATE_STATES}" # Boolean to validate language VALIDATE_TERRAFORM="${VALIDATE_TERRAFORM}" # Boolean to validate language +VALIDATE_TERRAFORM_TERRASCAN="${VALIDATE_TERRAFORM_TERRASCAN}" # Boolean to validate language VALIDATE_TSX="${VALIDATE_TSX}" # Boolean to validate language VALIDATE_TYPESCRIPT_ES="${VALIDATE_TYPESCRIPT_ES}" # Boolean to validate language VALIDATE_TYPESCRIPT_STANDARD="${VALIDATE_TYPESCRIPT_STANDARD}" # Boolean to validate language @@ -304,6 +305,8 @@ ERRORS_FOUND_STATES=0 # Count of errors found export ERRORS_FOUND_STATES # Workaround SC2034 ERRORS_FOUND_TERRAFORM=0 # Count of errors found export ERRORS_FOUND_TERRAFORM # Workaround SC2034 +ERRORS_FOUND_TERRAFORM_TERRASCAN=0 # Count of errors found +export ERRORS_FOUND_TERRAFORM_TERRASCAN # Workaround SC2034 ERRORS_FOUND_TSX=0 # Count of errors found export ERRORS_FOUND_TSX # Workaround SC2034 ERRORS_FOUND_TYPESCRIPT_STANDARD=0 # Count of errors found @@ -1563,6 +1566,17 @@ if [ "${VALIDATE_TERRAFORM}" == "true" ]; then LintCodebase "TERRAFORM" "tflint" "tflint -c ${TERRAFORM_LINTER_RULES}" ".*\.\(tf\)\$" "${FILE_ARRAY_TERRAFORM[@]}" fi +##################### +# TERRAFORM TERRASCAN LINTING # +##################### +if [ "${VALIDATE_TERRAFORM_TERRASCAN}" == "true" ]; then + ############################ + # Lint the Terraform files # + ############################ + # LintCodebase "FILE_TYPE" "LINTER_NAME" "LINTER_CMD" "FILE_TYPES_REGEX" "FILE_ARRAY" + LintCodebase "TERRAFORM_TERRASCAN" "terrascan" "terrascan -l" ".*\.\(tf\)\$" "${FILE_ARRAY_TERRAFORM[@]}" +fi + ###################### # TSX LINTING # ###################### From ea9ad2c3fbd5c8d7eebb589efb3dd02f5f49ff14 Mon Sep 17 00:00:00 2001 From: Cesar Rodriguez Date: Wed, 22 Jul 2020 22:01:53 -0400 Subject: [PATCH 048/135] Adds Terrascan testing --- lib/worker.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/worker.sh b/lib/worker.sh index 607c3fd6..1874a49f 100755 --- a/lib/worker.sh +++ b/lib/worker.sh @@ -607,6 +607,7 @@ function RunTestCases() { TestCodebase "RUBY" "rubocop" "rubocop -c ${RUBY_LINTER_RULES}" ".*\.\(rb\)\$" "ruby" TestCodebase "STATES" "asl-validator" "asl-validator --json-path" ".*\.\(json\)\$" "states" TestCodebase "TERRAFORM" "tflint" "tflint -c ${TERRAFORM_LINTER_RULES}" ".*\.\(tf\)\$" "terraform" + TestCodebase "TERRAFORM" "terrascan" "terrascan -l " ".*\.\(tf\)\$" "terraform" TestCodebase "TYPESCRIPT_ES" "eslint" "eslint --no-eslintrc -c ${TYPESCRIPT_LINTER_RULES}" ".*\.\(ts\)\$" "typescript" TestCodebase "TYPESCRIPT_STANDARD" "standard" "standard --parser @typescript-eslint/parser --plugin @typescript-eslint/eslint-plugin ${TYPESCRIPT_STANDARD_LINTER_RULES}" ".*\.\(ts\)\$" "typescript" TestCodebase "XML" "xmllint" "xmllint" ".*\.\(xml\)\$" "xml" From 3f6a75e9ac5f81aed5bc6205238cc3f5b43f0060 Mon Sep 17 00:00:00 2001 From: Cesar Rodriguez Date: Wed, 22 Jul 2020 22:36:59 -0400 Subject: [PATCH 049/135] adds terrascan tests --- .automation/test/terraform_terrascan/README.md | 0 .../test/terraform_terrascan/bad/terraform_bad_1.tf | 9 +++++++++ .../test/terraform_terrascan/good/terraform_good_1.tf | 9 +++++++++ .../terraform_terrascan/reports/expected-TERRAFORM.tap | 7 +++++++ 4 files changed, 25 insertions(+) create mode 100644 .automation/test/terraform_terrascan/README.md create mode 100644 .automation/test/terraform_terrascan/bad/terraform_bad_1.tf create mode 100644 .automation/test/terraform_terrascan/good/terraform_good_1.tf create mode 100644 .automation/test/terraform_terrascan/reports/expected-TERRAFORM.tap diff --git a/.automation/test/terraform_terrascan/README.md b/.automation/test/terraform_terrascan/README.md new file mode 100644 index 00000000..e69de29b diff --git a/.automation/test/terraform_terrascan/bad/terraform_bad_1.tf b/.automation/test/terraform_terrascan/bad/terraform_bad_1.tf new file mode 100644 index 00000000..f2f87778 --- /dev/null +++ b/.automation/test/terraform_terrascan/bad/terraform_bad_1.tf @@ -0,0 +1,9 @@ +resource "aws_instance" "bad" { + ami = "ami-0ff8a91507f77f867" + instance_type = "t2.small" + associate_public_ip_address = true + + ebs_block_device { + encrypted = false + } +} diff --git a/.automation/test/terraform_terrascan/good/terraform_good_1.tf b/.automation/test/terraform_terrascan/good/terraform_good_1.tf new file mode 100644 index 00000000..59d24f7e --- /dev/null +++ b/.automation/test/terraform_terrascan/good/terraform_good_1.tf @@ -0,0 +1,9 @@ +resource "aws_instance" "good" { + ami = "ami-0ff8a91507f77f867" + instance_type = "t2.small" + associate_public_ip_address = false + + ebs_block_device { + encrypted = true + } +} diff --git a/.automation/test/terraform_terrascan/reports/expected-TERRAFORM.tap b/.automation/test/terraform_terrascan/reports/expected-TERRAFORM.tap new file mode 100644 index 00000000..3434675d --- /dev/null +++ b/.automation/test/terraform_terrascan/reports/expected-TERRAFORM.tap @@ -0,0 +1,7 @@ +TAP version 13 +1..2 +not ok 1 - terraform_bad_1.tf + --- + message: Failed to load configurations. 1 error(s) occurred \n\nError Invalid expression\n\n on /tmp/lint/.automation/test/terraform/bad/terraform_bad_1.tf line 3, in resource "aws_instance" "bad" \n 3 instance_type = # invalid type!\n 4 }\n\nExpected the start of an expression, but found an invalid expression token.\n + ... +ok 2 - terraform_good_1.tf From d16206da815da606893c3d28adfa8b8106ee6b43 Mon Sep 17 00:00:00 2001 From: Cesar Rodriguez Date: Thu, 23 Jul 2020 23:08:27 -0400 Subject: [PATCH 050/135] Bumps Terrascan to 0.2.3 and boto3 --- dependencies/Pipfile.lock | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/dependencies/Pipfile.lock b/dependencies/Pipfile.lock index e36ac249..cb152dbc 100644 --- a/dependencies/Pipfile.lock +++ b/dependencies/Pipfile.lock @@ -49,17 +49,17 @@ }, "boto3": { "hashes": [ - "sha256:4735fdf490094537ea0cb93ba4237db442195c37f974ea4ad44b9a5af98e6d7b", - "sha256:838cea329851e11b9a9dae1c00cd5ef2f3b29ac83c061733b2e93b64c333750f" + "sha256:65c131b72c2a75e3cc6044e5fd6426719051b9b1f28bd026b4a5490648d13019", + "sha256:e1e09587763671cc07c9e6d349d93bf53a140f83947cb6cf1ec4cb9f07b0ff95" ], - "version": "==1.14.26" + "version": "==1.14.27" }, "botocore": { "hashes": [ - "sha256:0c4ed6349e8ef6bfe9648757f3ff66c33a8f37d9cbadd9c17987138184990cbd", - "sha256:28832be365204f00d5c7d2c2a0538d9d082dbfc39ed984fdc9556770470b7487" + "sha256:994a9f50e0e770c0f9ea74659f501848f7d12b22186026c219cde8a481ede298", + "sha256:acd955f0315b5d17e3e8ddc2ef74d7f03c4ef37f0ceb042058637f7edfbbad4e" ], - "version": "==1.17.26" + "version": "==1.17.27" }, "cfn-lint": { "hashes": [ @@ -241,11 +241,11 @@ }, "terrascan": { "hashes": [ - "sha256:b58c926e5c04d161d00c4563a1c9e688a1cf10c1283c6964c2c642a0fb5041bc", - "sha256:ce41ee1297259dad7b409cac49e26a196b1e86788e87de7166b61f407ad3da91" + "sha256:2003638e2e38feba9215df3add2ee99565731b86dbd5c43fd8982b1a4ddac927", + "sha256:b44d8c7eac96aa8094865061783ab0e8e849690b8187b75778caf5dd34002d18" ], "index": "pypi", - "version": "==0.2.2" + "version": "==0.2.3" }, "toml": { "hashes": [ From 6327cc5205388fd481f1862bfc9615b3d2db7412 Mon Sep 17 00:00:00 2001 From: Cesar Rodriguez Date: Thu, 23 Jul 2020 23:17:13 -0400 Subject: [PATCH 051/135] Updates Terrascan linting flag --- lib/worker.sh | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/worker.sh b/lib/worker.sh index 1874a49f..d28515e4 100755 --- a/lib/worker.sh +++ b/lib/worker.sh @@ -214,7 +214,6 @@ function LintCodebase() { ${LINTER_COMMAND} "${FILE}" 2>&1 ) fi - ####################### # Load the error code # ####################### @@ -607,7 +606,7 @@ function RunTestCases() { TestCodebase "RUBY" "rubocop" "rubocop -c ${RUBY_LINTER_RULES}" ".*\.\(rb\)\$" "ruby" TestCodebase "STATES" "asl-validator" "asl-validator --json-path" ".*\.\(json\)\$" "states" TestCodebase "TERRAFORM" "tflint" "tflint -c ${TERRAFORM_LINTER_RULES}" ".*\.\(tf\)\$" "terraform" - TestCodebase "TERRAFORM" "terrascan" "terrascan -l " ".*\.\(tf\)\$" "terraform" + TestCodebase "TERRAFORM" "terrascan" "terrascan -f " ".*\.\(tf\)\$" "terraform" TestCodebase "TYPESCRIPT_ES" "eslint" "eslint --no-eslintrc -c ${TYPESCRIPT_LINTER_RULES}" ".*\.\(ts\)\$" "typescript" TestCodebase "TYPESCRIPT_STANDARD" "standard" "standard --parser @typescript-eslint/parser --plugin @typescript-eslint/eslint-plugin ${TYPESCRIPT_STANDARD_LINTER_RULES}" ".*\.\(ts\)\$" "typescript" TestCodebase "XML" "xmllint" "xmllint" ".*\.\(xml\)\$" "xml" From dcc97ab0b96f9cf045ea52da8b7e5407028945e3 Mon Sep 17 00:00:00 2001 From: Cesar Rodriguez Date: Thu, 23 Jul 2020 23:33:17 -0400 Subject: [PATCH 052/135] Simplify test --- .../bad/terraform_bad_1.tf | 2 +- .../reports/expected-TERRAFORM.tap | 21 ++++++++++++++++--- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/.automation/test/terraform_terrascan/bad/terraform_bad_1.tf b/.automation/test/terraform_terrascan/bad/terraform_bad_1.tf index f2f87778..57b891dc 100644 --- a/.automation/test/terraform_terrascan/bad/terraform_bad_1.tf +++ b/.automation/test/terraform_terrascan/bad/terraform_bad_1.tf @@ -4,6 +4,6 @@ resource "aws_instance" "bad" { associate_public_ip_address = true ebs_block_device { - encrypted = false + encrypted = true } } diff --git a/.automation/test/terraform_terrascan/reports/expected-TERRAFORM.tap b/.automation/test/terraform_terrascan/reports/expected-TERRAFORM.tap index 3434675d..6fcc7cb9 100644 --- a/.automation/test/terraform_terrascan/reports/expected-TERRAFORM.tap +++ b/.automation/test/terraform_terrascan/reports/expected-TERRAFORM.tap @@ -1,7 +1,22 @@ TAP version 13 1..2 not ok 1 - terraform_bad_1.tf - --- - message: Failed to load configurations. 1 error(s) occurred \n\nError Invalid expression\n\n on /tmp/lint/.automation/test/terraform/bad/terraform_bad_1.tf line 3, in resource "aws_instance" "bad" \n 3 instance_type = # invalid type!\n 4 }\n\nExpected the start of an expression, but found an invalid expression token.\n - ... + terrascan version 0.2.3 + Logging level set to error. + ........................................................................ + ---------------------------------------------------------------------- + Ran 72 tests in 0.008s + + OK + + Processed 1 files in /tmp/lint/.terrascan + + + Processed on 07/24/2020 at 03:22 + Results (took 0.42 seconds): + + Failures: (1) + [high] [aws_instance.bad.associate_public_ip_address] should not be 'True'. Is: 'True' in module .terrascan, file /tmp/lint/.terrascan/terraform_bad_1.tf + + Errors: (0) ok 2 - terraform_good_1.tf From 43192d2d1f882a399a48682e06b8ab2bbbff23a5 Mon Sep 17 00:00:00 2001 From: Cesar Rodriguez Date: Fri, 24 Jul 2020 00:04:11 -0400 Subject: [PATCH 053/135] Locks dependencies --- dependencies/Pipfile.lock | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/dependencies/Pipfile.lock b/dependencies/Pipfile.lock index cb152dbc..32180e96 100644 --- a/dependencies/Pipfile.lock +++ b/dependencies/Pipfile.lock @@ -1,7 +1,7 @@ { "_meta": { "hash": { - "sha256": "1ccc4fd5c20ba56f1cca85abdd09b24798c3ad68b921cb42c501177598d986c9" + "sha256": "c62b95247cb67b10711da0012966cc031d5a9ec08885a45736c0ee77bba3a844" }, "pipfile-spec": 6, "requires": { @@ -28,7 +28,6 @@ "sha256:2f4078c2a41bf377eea06d71c9d2ba4eb8f6b1af2135bec27bbbb7d8f12bb703", "sha256:bc58d83eb610252fd8de6363e39d4f1d0619c894b0ed24603b881c02e64c7386" ], - "markers": "python_version >= '3.5'", "version": "==2.4.2" }, "attrs": { @@ -36,7 +35,6 @@ "sha256:08a96c641c3a74e44eb59afb61a24f2cb9f4d7188748e76ba4bb5edfa3cb7d1c", "sha256:f7b7ce16570fe9965acd6d30101a28f62fb4a7f9e926b3bbc9b61f8b04247e72" ], - "markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3'", "version": "==19.3.0" }, "aws-sam-translator": { @@ -82,7 +80,6 @@ "sha256:9e4d7ecfc600058e07ba661411a2b7de2fd0fafa17d1a7f7361cd47b1175c827", "sha256:a2aeea129088da402665e92e0b25b04b073c04b2dce4ab65caaa38b7ce2e1a99" ], - "markers": "python_version >= '2.6' and python_version not in '3.0, 3.1, 3.2'", "version": "==0.15.2" }, "isort": { @@ -90,7 +87,6 @@ "sha256:54da7e92468955c4fceacd0c86bd0ec997b0e1ee80d97f67c35a78b719dccab1", "sha256:6e811fcb295968434526407adb8796944f1988c5b65e8139058f2014cbe100fd" ], - "markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3'", "version": "==4.3.21" }, "jmespath": { @@ -98,7 +94,6 @@ "sha256:b85d0567b8666149a93172712e68920734333c0ce7e89b78b3e987f71e5ed4f9", "sha256:cdf6525904cc597730141d61b36f2e4b8ecc257c420fa2f4549bac2c2d0cb72f" ], - "markers": "python_version >= '2.6' and python_version not in '3.0, 3.1, 3.2'", "version": "==0.10.0" }, "jsonpatch": { @@ -114,7 +109,6 @@ "sha256:c192ba86648e05fdae4f08a17ec25180a9aef5008d973407b581798a83975362", "sha256:ff379fa021d1b81ab539f5ec467c7745beb1a5671463f9dcc2b2d458bd361c1e" ], - "markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3'", "version": "==2.0" }, "jsonschema": { @@ -154,7 +148,6 @@ "sha256:efa1909120ce98bbb3777e8b6f92237f5d5c8ea6758efea36a473e1d38f7d3e4", "sha256:f3900e8a5de27447acbf900b4750b0ddfd7ec1ea7fbaf11dfa911141bc522af0" ], - "markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3'", "version": "==1.4.3" }, "mccabe": { @@ -204,7 +197,6 @@ "sha256:73ebfe9dbf22e832286dafa60473e4cd239f8592f699aa5adaf10050e6e1823c", "sha256:75bb3f31ea686f1197762692a9ee6a7550b59fc6ca3a1f4b5d7e32fb98e2da2a" ], - "markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2'", "version": "==2.8.1" }, "pyyaml": { @@ -236,7 +228,6 @@ "sha256:30639c035cdb23534cd4aa2dd52c3bf48f06e5f4a941509c8bafd8ce11080259", "sha256:8b74bedcbbbaca38ff6d7491d76f2b06b3592611af620f8426e82dddb04a5ced" ], - "markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2'", "version": "==1.15.0" }, "terrascan": { From d423b1c36ac854928f733f4aa3129f8432b30ce1 Mon Sep 17 00:00:00 2001 From: Cesar Rodriguez Date: Fri, 24 Jul 2020 00:19:49 -0400 Subject: [PATCH 054/135] Fixes Terrascan command --- lib/linter.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/linter.sh b/lib/linter.sh index 9c9e3864..5e5aa6da 100755 --- a/lib/linter.sh +++ b/lib/linter.sh @@ -1574,7 +1574,7 @@ if [ "${VALIDATE_TERRAFORM_TERRASCAN}" == "true" ]; then # Lint the Terraform files # ############################ # LintCodebase "FILE_TYPE" "LINTER_NAME" "LINTER_CMD" "FILE_TYPES_REGEX" "FILE_ARRAY" - LintCodebase "TERRAFORM_TERRASCAN" "terrascan" "terrascan -l" ".*\.\(tf\)\$" "${FILE_ARRAY_TERRAFORM[@]}" + LintCodebase "TERRAFORM_TERRASCAN" "terrascan" "terrascan -f " ".*\.\(tf\)\$" "${FILE_ARRAY_TERRAFORM_TERRASCAN[@]}" fi ###################### From 20a91b5de5a369a73fd9716385b536c48b1dcf6a Mon Sep 17 00:00:00 2001 From: Cesar Rodriguez Date: Fri, 24 Jul 2020 00:20:08 -0400 Subject: [PATCH 055/135] Adds file array variable for Terrascan --- lib/buildFileList.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/buildFileList.sh b/lib/buildFileList.sh index 468e0360..00aebf1f 100755 --- a/lib/buildFileList.sh +++ b/lib/buildFileList.sh @@ -353,6 +353,7 @@ function BuildFileList() { # Append the file to the array # ################################ FILE_ARRAY_TERRAFORM+=("${FILE}") + FILE_ARRAY_TERRAFORM_TERRASCAN+=("${FILE}") ########################################################## # Set the READ_ONLY_CHANGE_FLAG since this could be exec # ########################################################## From 7a48eb4e9a174461e403395b40602f52d2be6ebe Mon Sep 17 00:00:00 2001 From: Cesar Rodriguez Date: Fri, 24 Jul 2020 00:30:37 -0400 Subject: [PATCH 056/135] Default to not use Terrascan --- lib/validation.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/validation.sh b/lib/validation.sh index 39618a3e..5e78307c 100755 --- a/lib/validation.sh +++ b/lib/validation.sh @@ -89,6 +89,8 @@ function GetValidationInfo() { else # No linter flags were set - default all to true eval "${VALIDATE_LANGUAGE}='true'" + # Default Terrascan to false + VALIDATE_TERRAFORM_TERRASCAN="false" fi done From 85d4c8954489fd64553159b56a88733610b25721 Mon Sep 17 00:00:00 2001 From: Cesar Rodriguez Date: Fri, 24 Jul 2020 00:37:40 -0400 Subject: [PATCH 057/135] Fixing bash linting issue --- lib/validation.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/validation.sh b/lib/validation.sh index 5e78307c..082e8066 100755 --- a/lib/validation.sh +++ b/lib/validation.sh @@ -90,7 +90,7 @@ function GetValidationInfo() { # No linter flags were set - default all to true eval "${VALIDATE_LANGUAGE}='true'" # Default Terrascan to false - VALIDATE_TERRAFORM_TERRASCAN="false" + export VALIDATE_TERRAFORM_TERRASCAN="false" fi done From 9cbcacb5295d8b3933adb3f60e3fd8f539933b09 Mon Sep 17 00:00:00 2001 From: Cesar Rodriguez Date: Fri, 24 Jul 2020 00:55:31 -0400 Subject: [PATCH 058/135] Fixes Terrascan tests --- lib/worker.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/worker.sh b/lib/worker.sh index d28515e4..a7da7f04 100755 --- a/lib/worker.sh +++ b/lib/worker.sh @@ -606,7 +606,7 @@ function RunTestCases() { TestCodebase "RUBY" "rubocop" "rubocop -c ${RUBY_LINTER_RULES}" ".*\.\(rb\)\$" "ruby" TestCodebase "STATES" "asl-validator" "asl-validator --json-path" ".*\.\(json\)\$" "states" TestCodebase "TERRAFORM" "tflint" "tflint -c ${TERRAFORM_LINTER_RULES}" ".*\.\(tf\)\$" "terraform" - TestCodebase "TERRAFORM" "terrascan" "terrascan -f " ".*\.\(tf\)\$" "terraform" + TestCodebase "TERRAFORM_TERRASCAN" "terrascan" "terrascan -f " ".*\.\(tf\)\$" "terraform_terrascan" TestCodebase "TYPESCRIPT_ES" "eslint" "eslint --no-eslintrc -c ${TYPESCRIPT_LINTER_RULES}" ".*\.\(ts\)\$" "typescript" TestCodebase "TYPESCRIPT_STANDARD" "standard" "standard --parser @typescript-eslint/parser --plugin @typescript-eslint/eslint-plugin ${TYPESCRIPT_STANDARD_LINTER_RULES}" ".*\.\(ts\)\$" "typescript" TestCodebase "XML" "xmllint" "xmllint" ".*\.\(xml\)\$" "xml" From 03ae51501825cee008981ec302314fb8511bf24f Mon Sep 17 00:00:00 2001 From: Lucas Gravley <29484535+admiralAwkbar@users.noreply.github.com> Date: Fri, 24 Jul 2020 08:14:01 -0500 Subject: [PATCH 059/135] remove dead loop, set terrascan to default true --- lib/validation.sh | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/lib/validation.sh b/lib/validation.sh index 082e8066..07387fd5 100755 --- a/lib/validation.sh +++ b/lib/validation.sh @@ -89,25 +89,9 @@ function GetValidationInfo() { else # No linter flags were set - default all to true eval "${VALIDATE_LANGUAGE}='true'" - # Default Terrascan to false - export VALIDATE_TERRAFORM_TERRASCAN="false" fi 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 # ####################################### From 4c7f32ef9ab3f89dcc75be35488443e3b809fd8a Mon Sep 17 00:00:00 2001 From: Lucas Gravley <29484535+admiralAwkbar@users.noreply.github.com> Date: Fri, 24 Jul 2020 08:20:41 -0500 Subject: [PATCH 060/135] small cleanup --- .automation/test/terraform/README.md | 19 +++++++++++++ .../test/terraform_terrascan/README.md | 19 +++++++++++++ lib/linter.sh | 28 +++++++++---------- 3 files changed, 52 insertions(+), 14 deletions(-) diff --git a/.automation/test/terraform/README.md b/.automation/test/terraform/README.md index e69de29b..6cb4f692 100644 --- a/.automation/test/terraform/README.md +++ b/.automation/test/terraform/README.md @@ -0,0 +1,19 @@ +# AWS States language Test Cases + +This folder holds the test cases for **Terraform**. + +## 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. diff --git a/.automation/test/terraform_terrascan/README.md b/.automation/test/terraform_terrascan/README.md index e69de29b..036699d9 100644 --- a/.automation/test/terraform_terrascan/README.md +++ b/.automation/test/terraform_terrascan/README.md @@ -0,0 +1,19 @@ +# AWS States language Test Cases + +This folder holds the test cases for **Terraform terrascan**. + +## 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. diff --git a/lib/linter.sh b/lib/linter.sh index 5e5aa6da..d712ab4b 100755 --- a/lib/linter.sh +++ b/lib/linter.sh @@ -1375,13 +1375,13 @@ if [ "${VALIDATE_JSON}" == "true" ]; then LintCodebase "JSON" "jsonlint" "jsonlint" ".*\.\(json\)\$" "${FILE_ARRAY_JSON[@]}" fi -###################### -# JSX LINTING # -###################### +############### +# JSX LINTING # +############### if [ "${VALIDATE_JSX}" == "true" ]; then - ############################# - # Lint the JSX files # - ############################# + ###################### + # Lint the JSX files # + ###################### # LintCodebase "FILE_TYPE" "LINTER_NAME" "LINTER_CMD" "FILE_TYPES_REGEX" "FILE_ARRAY" LintCodebase "JSX" "eslint" "eslint --no-eslintrc -c ${JAVASCRIPT_LINTER_RULES}" ".*\.\(jsx\)\$" "${FILE_ARRAY_JSX[@]}" fi @@ -1566,9 +1566,9 @@ if [ "${VALIDATE_TERRAFORM}" == "true" ]; then LintCodebase "TERRAFORM" "tflint" "tflint -c ${TERRAFORM_LINTER_RULES}" ".*\.\(tf\)\$" "${FILE_ARRAY_TERRAFORM[@]}" fi -##################### +############################### # TERRAFORM TERRASCAN LINTING # -##################### +############################### if [ "${VALIDATE_TERRAFORM_TERRASCAN}" == "true" ]; then ############################ # Lint the Terraform files # @@ -1577,13 +1577,13 @@ if [ "${VALIDATE_TERRAFORM_TERRASCAN}" == "true" ]; then LintCodebase "TERRAFORM_TERRASCAN" "terrascan" "terrascan -f " ".*\.\(tf\)\$" "${FILE_ARRAY_TERRAFORM_TERRASCAN[@]}" fi -###################### -# TSX LINTING # -###################### +############### +# TSX LINTING # +############### if [ "${VALIDATE_TSX}" == "true" ]; then - ############################# - # Lint the TSX files # - ############################# + ###################### + # Lint the TSX files # + ###################### LintCodebase "TSX" "eslint" "eslint --no-eslintrc -c ${TYPESCRIPT_LINTER_RULES}" ".*\.\(tsx\)\$" "${FILE_ARRAY_TSX[@]}" fi From f2045eb49664d5801e2357f01a84bb2e7ff5d6ae Mon Sep 17 00:00:00 2001 From: Gabo Date: Fri, 24 Jul 2020 11:20:22 -0500 Subject: [PATCH 061/135] Fix YAML --- lib/buildFileList.sh | 2 +- lib/linter.sh | 14 +++++++------- lib/worker.sh | 2 +- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/lib/buildFileList.sh b/lib/buildFileList.sh index 00aebf1f..2efc0fb3 100755 --- a/lib/buildFileList.sh +++ b/lib/buildFileList.sh @@ -106,7 +106,7 @@ function BuildFileList() { ################################ # Append the file to the array # ################################ - FILE_ARRAY_YML+=("${FILE}") + FILE_ARRAY_YAML+=("${FILE}") ########################################################## # Set the READ_ONLY_CHANGE_FLAG since this could be exec # ########################################################## diff --git a/lib/linter.sh b/lib/linter.sh index d712ab4b..6b2c8028 100755 --- a/lib/linter.sh +++ b/lib/linter.sh @@ -109,7 +109,7 @@ LANGUAGE_ARRAY=('ANSIBLE' 'ARM' 'BASH' 'CLOUDFORMATION' 'CLOJURE' 'COFFEESCRIPT' 'JAVASCRIPT_STANDARD' 'JSON' 'JSX' 'KOTLIN' 'MARKDOWN' 'OPENAPI' 'PERL' 'PHP' 'POWERSHELL' 'PROTOBUF' 'PYTHON' 'RAKU' 'RUBY' 'STATES' 'TERRAFORM' 'TERRAFORM_TERRASCAN' 'TSX' 'TYPESCRIPT_ES' - 'TYPESCRIPT_STANDARD' 'XML' 'YML') + 'TYPESCRIPT_STANDARD' 'XML' 'YAML') ############################################ # Array for all languages that were linted # @@ -242,7 +242,7 @@ FILE_ARRAY_TSX=() # Array of files to check FILE_ARRAY_TYPESCRIPT_ES=() # Array of files to check FILE_ARRAY_TYPESCRIPT_STANDARD=() # Array of files to check FILE_ARRAY_XML=() # Array of files to check -FILE_ARRAY_YML=() # Array of files to check +FILE_ARRAY_YAML=() # Array of files to check ############ # Counters # @@ -315,8 +315,8 @@ ERRORS_FOUND_TYPESCRIPT_ES=0 # Count of errors found export ERRORS_FOUND_TYPESCRIPT_ES # Workaround SC2034 ERRORS_FOUND_XML=0 # Count of errors found export ERRORS_FOUND_XML # Workaround SC2034 -ERRORS_FOUND_YML=0 # Count of errors found -export ERRORS_FOUND_YML # Workaround SC2034 +ERRORS_FOUND_YAML=0 # Count of errors found +export ERRORS_FOUND_YAML # Workaround SC2034 ################################################################################ ########################## FUNCTIONS BELOW ##################################### @@ -1092,7 +1092,7 @@ GetLinterRules "RUBY" GetLinterRules "TERRAFORM" # Get TypeScript rules GetLinterRules "TYPESCRIPT" -# Get YML rules +# Get YAML rules GetLinterRules "YAML" ################################# @@ -1623,14 +1623,14 @@ if [ "${VALIDATE_XML}" == "true" ]; then fi ############### -# YML LINTING # +# YAML LINTING # ############### if [ "${VALIDATE_YAML}" == "true" ]; then ###################### # Lint the Yml Files # ###################### # LintCodebase "FILE_TYPE" "LINTER_NAME" "LINTER_CMD" "FILE_TYPES_REGEX" "FILE_ARRAY" - LintCodebase "YML" "yamllint" "yamllint -c ${YAML_LINTER_RULES}" ".*\.\(yml\|yaml\)\$" "${FILE_ARRAY_YML[@]}" + LintCodebase "YAML" "yamllint" "yamllint -c ${YAML_LINTER_RULES}" ".*\.\(yml\|yaml\)\$" "${FILE_ARRAY_YAML[@]}" fi ########### diff --git a/lib/worker.sh b/lib/worker.sh index a7da7f04..70141d10 100755 --- a/lib/worker.sh +++ b/lib/worker.sh @@ -610,7 +610,7 @@ function RunTestCases() { TestCodebase "TYPESCRIPT_ES" "eslint" "eslint --no-eslintrc -c ${TYPESCRIPT_LINTER_RULES}" ".*\.\(ts\)\$" "typescript" TestCodebase "TYPESCRIPT_STANDARD" "standard" "standard --parser @typescript-eslint/parser --plugin @typescript-eslint/eslint-plugin ${TYPESCRIPT_STANDARD_LINTER_RULES}" ".*\.\(ts\)\$" "typescript" TestCodebase "XML" "xmllint" "xmllint" ".*\.\(xml\)\$" "xml" - TestCodebase "YML" "yamllint" "yamllint -c ${YAML_LINTER_RULES}" ".*\.\(yml\|yaml\)\$" "yml" + TestCodebase "YAML" "yamllint" "yamllint -c ${YAML_LINTER_RULES}" ".*\.\(yml\|yaml\)\$" "yml" ################# # Footer prints # From 5fa6aca5c266e61a486a6d681b61a9cc7cd07f0f Mon Sep 17 00:00:00 2001 From: Casey Vega Date: Fri, 24 Jul 2020 10:27:54 -0700 Subject: [PATCH 062/135] add lua to super-linter --- .automation/test/lua/README.md | 13 +++++++++ .automation/test/lua/lua_bad_1.lua | 9 +++++++ .automation/test/lua/lua_good_1.lua | 12 +++++++++ .github/linters/.luacheckrc | 1 + Dockerfile | 22 ++++++++++++++++ README.md | 2 ++ TEMPLATES/.luacheckrc | 1 + docs/disabling-linters.md | 41 +++++++++++++++++++++++++++++ lib/buildFileList.sh | 9 +++++++ lib/linter.sh | 24 +++++++++++++++-- lib/worker.sh | 1 + 11 files changed, 133 insertions(+), 2 deletions(-) create mode 100644 .automation/test/lua/README.md create mode 100644 .automation/test/lua/lua_bad_1.lua create mode 100644 .automation/test/lua/lua_good_1.lua create mode 100644 .github/linters/.luacheckrc create mode 100644 TEMPLATES/.luacheckrc diff --git a/.automation/test/lua/README.md b/.automation/test/lua/README.md new file mode 100644 index 00000000..db695378 --- /dev/null +++ b/.automation/test/lua/README.md @@ -0,0 +1,13 @@ +# Lua Test Cases +This folder holds the test cases for **Lua**. + +## 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. \ No newline at end of file diff --git a/.automation/test/lua/lua_bad_1.lua b/.automation/test/lua/lua_bad_1.lua new file mode 100644 index 00000000..2c31e39d --- /dev/null +++ b/.automation/test/lua/lua_bad_1.lua @@ -0,0 +1,9 @@ +package.loaded[...] = {} + +local function helper(...) + -- NYI +end + +function embrace(opt) + local opt = opt or "default" + return hepler(opt.."?") diff --git a/.automation/test/lua/lua_good_1.lua b/.automation/test/lua/lua_good_1.lua new file mode 100644 index 00000000..f7ade80b --- /dev/null +++ b/.automation/test/lua/lua_good_1.lua @@ -0,0 +1,12 @@ +local embracer = {} + +local function helper() + -- NYI wontfix +end + +function embracer.embrace(opt) + opt = opt or "default" + return helper(opt.."?") +end + +return embracer diff --git a/.github/linters/.luacheckrc b/.github/linters/.luacheckrc new file mode 100644 index 00000000..00aa308f --- /dev/null +++ b/.github/linters/.luacheckrc @@ -0,0 +1 @@ +--std max diff --git a/Dockerfile b/Dockerfile index 2d143824..57540fce 100644 --- a/Dockerfile +++ b/Dockerfile @@ -52,12 +52,14 @@ ARG GLIBC_VERSION='2.31-r0' RUN apk add --update --no-cache \ ansible-lint \ bash \ + coreutils \ curl \ gcc \ git git-lfs\ go \ icu-libs \ jq \ + libc-dev \ libxml2-utils \ make \ musl-dev \ @@ -66,6 +68,7 @@ RUN apk add --update --no-cache \ perl \ php7 \ py3-setuptools \ + readline-dev \ ruby ruby-dev ruby-bundler ruby-rdoc ######################################## @@ -183,6 +186,24 @@ RUN wget https://storage.googleapis.com/dart-archive/channels/stable/release/${D RUN echo "http://dl-cdn.alpinelinux.org/alpine/edge/testing/" >> /etc/apk/repositories \ && apk add --update --no-cache rakudo zef +#################### +# Install luacheck # +#################### +RUN wget https://www.lua.org/ftp/lua-5.3.5.tar.gz -O - -q | tar -xzf - \ + && cd lua-5.3.5 \ + && make linux \ + && make install \ + && cd .. && rm -r lua-5.3.5/ + +RUN wget https://github.com/cvega/luarocks/archive/v3.3.1-super-linter.tar.gz -O - -q | tar -xzf - \ + && cd luarocks-3.3.1-super-linter \ + && ./configure --with-lua-include=/usr/local/include \ + && make \ + && make -b install \ + && cd .. && rm -r luarocks-3.3.1-super-linter/ + +RUN luarocks install luacheck + ########################################### # Load GitHub Env Vars for GitHub Actions # ########################################### @@ -218,6 +239,7 @@ ENV ACTIONS_RUNNER_DEBUG=${ACTIONS_RUNNER_DEBUG} \ VALIDATE_JAVASCRIPT_STANDARD=${VALIDATE_JAVASCRIPT_STANDARD} \ VALIDATE_JSON=${VALIDATE_JSON} \ VALIDATE_KOTLIN=${VALIDATE_KOTLIN} \ + VALIDATE_LUA=${VALIDATE_LUA} \ VALIDATE_MD=${VALIDATE_MD} \ VALIDATE_OPENAPI=${VALIDATE_OPENAPI} \ VALIDATE_PERL=${VALIDATE_PERL} \ diff --git a/README.md b/README.md index e9dd76be..10aa67be 100644 --- a/README.md +++ b/README.md @@ -59,6 +59,7 @@ Developers on **GitHub** can call the **GitHub Action** to lint their code base | **JavaScript** | [eslint](https://eslint.org/) [standard js](https://standardjs.com/) | | **JSON** | [jsonlint](https://github.com/zaach/jsonlint) | | **Kotlin** | [ktlint](https://github.com/pinterest/ktlint) | +| **Lua** | [luacheck](https://github.com/luarocks/luacheck) | | **Markdown** | [markdownlint](https://github.com/igorshubovych/markdownlint-cli#readme) | | **OpenAPI** | [spectral](https://github.com/stoplightio/spectral) | | **Perl** | [perl](https://pkgs.alpinelinux.org/package/edge/main/x86/perl) | @@ -201,6 +202,7 @@ and won't run anything unexpected. | **VALIDATE_JSON** | `true` | Flag to enable or disable the linting process of the JSON language. | | **VALIDATE_JSX** | `true` | Flag to enable or disable the linting process for jsx files (Utilizing: eslint) | | **VALIDATE_KOTLIN** | `true` | Flag to enable or disable the linting process of the Kotlin language. | +| **VALIDATE_LUA** | `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 Markdown language. | | **VALIDATE_OPENAPI** | `true` | Flag to enable or disable the linting process of the OpenAPI language. | | **VALIDATE_PERL** | `true` | Flag to enable or disable the linting process of the Perl language. | diff --git a/TEMPLATES/.luacheckrc b/TEMPLATES/.luacheckrc new file mode 100644 index 00000000..00aa308f --- /dev/null +++ b/TEMPLATES/.luacheckrc @@ -0,0 +1 @@ +--std max diff --git a/docs/disabling-linters.md b/docs/disabling-linters.md index 2d3632d4..fbdb578e 100644 --- a/docs/disabling-linters.md +++ b/docs/disabling-linters.md @@ -44,6 +44,7 @@ For some linters it is also possible to override rules on a case by case level w - [Clojure](#clojure) - [EDITORCONFIG-CHECKER](#editorconfig-checker) - [HTML](#html) +- [LUA](#lua) @@ -859,6 +860,46 @@ import package.b.* --- +## Lua +- [luarocks](https://github.com/luarocks/luacheck) + +### luacheck standard Config file +- `.github/linters/.luacheckrc` +- You can pass multiple rules and overwrite default rules +- File should be located at: `.github/linters/.luacheckrc` +- See [luacheck](https://luacheck.readthedocs.io/en/stable/config.html) docs for additional + behaviors + +### luacheck disable single line +```lua +-- luacheck: globals g1 g2, ignore foo +local foo = g1(g2) -- No warnings emitted. +``` + +### luacheck disable code block +```lua +-- The following unused function is not reported. +local function f() -- luacheck: ignore + -- luacheck: globals g3 + g3() -- No warning. +end +``` + +### luacheck include/exclude files (via .luacheckrc) +```lua +include_files = {"src", "spec/*.lua", "scripts/*.lua", "*.rockspec", "*.luacheckrc"} +exclude_files = {"src/luacheck/vendor"} +``` + +### luacheck push/pop +```lua +-- luacheck: push ignore foo +foo() -- No warning. +-- luacheck: pop +foo() -- Warning is emitted. +``` +--- + ## Dart - [dartanalyzer](https://dart.dev/tools/dartanalyzer) diff --git a/lib/buildFileList.sh b/lib/buildFileList.sh index 00aebf1f..9d51364d 100755 --- a/lib/buildFileList.sh +++ b/lib/buildFileList.sh @@ -393,6 +393,15 @@ function BuildFileList() { # Set the READ_ONLY_CHANGE_FLAG since this could be exec # ########################################################## READ_ONLY_CHANGE_FLAG=1 + elif [ "$FILE_TYPE" == "lua" ]; then + ################################ + # Append the file to the array # + ################################ + FILE_ARRAY_LUA+=("$FILE") + ########################################################## + # Set the READ_ONLY_CHANGE_FLAG since this could be exec # + ########################################################## + READ_ONLY_CHANGE_FLAG=1 ############################ # Get the Protocol Buffers files # ############################ diff --git a/lib/linter.sh b/lib/linter.sh index d712ab4b..ff2d8303 100755 --- a/lib/linter.sh +++ b/lib/linter.sh @@ -62,6 +62,9 @@ JAVASCRIPT_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${JAVASCRIPT_FILE_NAME}" JAVASCRIPT_STANDARD_LINTER_RULES='' # ENV string to pass when running js standard # Default linter path LINTER_RULES_PATH="${LINTER_RULES_PATH:-.github/linters}" # Linter Path Directory +# Lua Vars +LUA_FILE_NAME='.luacheckrc' # Name of the file +LUA_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${LUA_FILE_NAME}" # Path to the Lua lint rules # MD Vars MARKDOWN_FILE_NAME='.markdown-lint.yml' # Name of the file MARKDOWN_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${MARKDOWN_FILE_NAME}" # Path to the markdown lint rules @@ -96,7 +99,7 @@ YAML_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${YAML_FILE_NAME}" ####################################### LINTER_ARRAY=('ansible-lint' 'arm-ttk' 'asl-validator' 'cfn-lint' 'clj-kondo' 'coffeelint' 'dart' 'dockerfilelint' 'dotenv-linter' 'eslint' 'golangci-lint' - 'htmlhint' 'jsonlint' 'ktlint' 'markdownlint' 'npm-groovy-lint' 'perl' + 'htmlhint' 'jsonlint' 'ktlint' 'lua' 'markdownlint' 'npm-groovy-lint' 'perl' 'protolint' 'pwsh' 'pylint' 'raku' 'rubocop' 'shellcheck' 'spectral' 'standard' 'stylelint' 'terrascan' 'tflint' 'xmllint' 'yamllint') @@ -106,7 +109,7 @@ LINTER_ARRAY=('ansible-lint' 'arm-ttk' 'asl-validator' 'cfn-lint' 'clj-kondo' ############################# LANGUAGE_ARRAY=('ANSIBLE' 'ARM' 'BASH' 'CLOUDFORMATION' 'CLOJURE' 'COFFEESCRIPT' 'CSS' 'DART' 'DOCKER' 'ENV' 'GO' 'GROOVY' 'HTML' 'JAVASCRIPT_ES' - 'JAVASCRIPT_STANDARD' 'JSON' 'JSX' 'KOTLIN' 'MARKDOWN' 'OPENAPI' + 'JAVASCRIPT_STANDARD' 'JSON' 'JSX' 'KOTLIN' 'LUA' 'MARKDOWN' 'OPENAPI' 'PERL' 'PHP' 'POWERSHELL' 'PROTOBUF' 'PYTHON' 'RAKU' 'RUBY' 'STATES' 'TERRAFORM' 'TERRAFORM_TERRASCAN' 'TSX' 'TYPESCRIPT_ES' 'TYPESCRIPT_STANDARD' 'XML' 'YML') @@ -151,6 +154,7 @@ VALIDATE_JAVASCRIPT_STANDARD="${VALIDATE_JAVASCRIPT_STANDARD}" # Boolean to vali VALIDATE_JSON="${VALIDATE_JSON}" # Boolean to validate language VALIDATE_JSX="${VALIDATE_JSX}" # Boolean to validate language VALIDATE_KOTLIN="${VALIDATE_KOTLIN}" # Boolean to validate language +VALIDATE_LUA="${VALIDATE_LUA}" # Boolean to validate language VALIDATE_MARKDOWN="${VALIDATE_MD:-}" # Boolean to validate language VALIDATE_OPENAPI="${VALIDATE_OPENAPI}" # Boolean to validate language VALIDATE_PERL="${VALIDATE_PERL}" # Boolean to validate language @@ -227,6 +231,7 @@ FILE_ARRAY_JAVASCRIPT_STANDARD=() # Array of files to check FILE_ARRAY_JSON=() # Array of files to check FILE_ARRAY_JSX=() # Array of files to check FILE_ARRAY_KOTLIN=() # Array of files to check +FILE_ARRAY_LUA=() # Array of files to check FILE_ARRAY_MARKDOWN=() # Array of files to check FILE_ARRAY_OPENAPI=() # Array of files to check FILE_ARRAY_PERL=() # Array of files to check @@ -283,6 +288,8 @@ ERRORS_FOUND_JSX=0 # Count of errors found export ERRORS_FOUND_JSX # Workaround SC2034 ERRORS_FOUND_KOTLIN=0 # Count of errors found export ERRORS_FOUND_KOTLIN # Workaround SC2034 +ERRORS_FOUND_LUA=0 # Count of errors found +export ERRORS_FOUND_LUA=0 # Workaround SC2034 ERRORS_FOUND_MARKDOWN=0 # Count of errors found export ERRORS_FOUND_MARKDOWN # Workaround SC2034 ERRORS_FOUND_OPENAPI=0 # Count of errors found @@ -1080,6 +1087,8 @@ GetLinterRules "GROOVY" GetLinterRules "HTML" # Get JavaScript rules GetLinterRules "JAVASCRIPT" +# Get LUA rules +GetLinterRules "LUA" # Get Markdown rules GetLinterRules "MARKDOWN" # Get PowerShell rules @@ -1397,6 +1406,17 @@ if [ "${VALIDATE_KOTLIN}" == "true" ]; then LintCodebase "KOTLIN" "ktlint" "ktlint" ".*\.\(kt\|kts\)\$" "${FILE_ARRAY_KOTLIN[@]}" fi +############### +# LUA LINTING # +############### +if [ "${VALIDATE_LUA}" == "true" ]; then + ###################### + # Lint the Lua files # + ###################### + # LintCodebase "FILE_TYPE" "LINTER_NAME" "LINTER_CMD" "FILE_TYPES_REGEX" "FILE_ARRAY" + LintCodebase "LUA" "lua" "luacheck --config ${LUA_LINTER_RULES}" ".*\.\(lua\)\$" "${FILE_ARRAY_LUA[@]}" +fi + #################### # MARKDOWN LINTING # #################### diff --git a/lib/worker.sh b/lib/worker.sh index a7da7f04..4a2c0b1a 100755 --- a/lib/worker.sh +++ b/lib/worker.sh @@ -595,6 +595,7 @@ function RunTestCases() { TestCodebase "JAVASCRIPT_STANDARD" "standard" "standard ${JAVASCRIPT_STANDARD_LINTER_RULES}" ".*\.\(js\)\$" "javascript" TestCodebase "JSON" "jsonlint" "jsonlint" ".*\.\(json\)\$" "json" TestCodebase "KOTLIN" "ktlint" "ktlint" ".*\.\(kt\|kts\)\$" "kotlin" + TestCodebase "LUA" "lua" "luacheck" ".*\.\(lua\)\$" "lua" TestCodebase "MARKDOWN" "markdownlint" "markdownlint -c ${MARKDOWN_LINTER_RULES}" ".*\.\(md\)\$" "markdown" TestCodebase "PERL" "perl" "perl -Mstrict -cw" ".*\.\(pl\)\$" "perl" TestCodebase "PHP" "php" "php -l" ".*\.\(php\)\$" "php" From 1c11a23fd36b632c9a82ce0a089e947661961ca3 Mon Sep 17 00:00:00 2001 From: Gabo Date: Fri, 24 Jul 2020 14:03:26 -0500 Subject: [PATCH 063/135] Allo to pass yamllint config file --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index e9dd76be..f9c77028 100644 --- a/README.md +++ b/README.md @@ -218,6 +218,8 @@ and won't run anything unexpected. | **VALIDATE_TYPESCRIPT_STANDARD** | `true` | Flag to enable or disable the linting process of the Typescript language. (Utilizing: standard) | | **VALIDATE_XML** | `true` | Flag to enable or disable the linting process of the XML language. | | **VALIDATE_YAML** | `true` | Flag to enable or disable the linting process of the YAML language. | +| **YAML_CONFIG_FILE** | `.yaml-lint.yml` | Filename for [Yamllint configuration](https://yamllint.readthedocs.io/en/stable/configuration.html) (ex: `.yaml-lint.yml`, `.yamllint.yml`) | + ### Template rules files From eafc73332b71f997f8d0569cdb56022f300835c4 Mon Sep 17 00:00:00 2001 From: Gabo Date: Fri, 24 Jul 2020 14:05:03 -0500 Subject: [PATCH 064/135] Allow to pass yamllint config file --- lib/linter.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/linter.sh b/lib/linter.sh index 6b2c8028..9e51f010 100755 --- a/lib/linter.sh +++ b/lib/linter.sh @@ -88,7 +88,7 @@ TYPESCRIPT_FILE_NAME="${TYPESCRIPT_ES_CONFIG_FILE:-.eslintrc.yml}" TYPESCRIPT_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${TYPESCRIPT_FILE_NAME}" # Path to the Typescript lint rules TYPESCRIPT_STANDARD_LINTER_RULES='' # ENV string to pass when running js standard # YAML Vars -YAML_FILE_NAME='.yaml-lint.yml' # Name of the file +YAML_FILE_NAME="${YAML_CONFIG_FILE:-.yaml-lint.yml}" # Name of the file YAML_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${YAML_FILE_NAME}" # Path to the yaml lint rules ####################################### From 49243625fe71a055e54421a21e43c815c2871df7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Filip=20=C5=A0?= Date: Sun, 26 Jul 2020 21:01:29 +0200 Subject: [PATCH 065/135] Basic support for PHPCS and Psalm --- Dockerfile | 25 +++++++++++++++++++++++- dependencies/phive.xml | 6 ++++++ lib/linter.sh | 44 ++++++++++++++++++++++++++++++++---------- 3 files changed, 64 insertions(+), 11 deletions(-) create mode 100755 dependencies/phive.xml diff --git a/Dockerfile b/Dockerfile index 2d143824..f8574be7 100644 --- a/Dockerfile +++ b/Dockerfile @@ -65,8 +65,18 @@ RUN apk add --update --no-cache \ openjdk8-jre \ perl \ php7 \ + php7-phar \ + php7-json \ + php7-simplexml \ + php7-xmlwriter \ + php7-mbstring \ + php7-tokenizer \ + php7-ctype \ + php7-curl \ + php7-dom \ py3-setuptools \ - ruby ruby-dev ruby-bundler ruby-rdoc + ruby ruby-dev ruby-bundler ruby-rdoc \ + gnupg ######################################## # Copy dependencies files to container # @@ -96,6 +106,19 @@ ENV PATH="/node_modules/.bin:${PATH}" ############################## RUN bundle install +############################## +# Install Phive dependencies # +############################## +RUN wget -O phive.phar https://phar.io/releases/phive.phar \ + && wget -O phive.phar.asc https://phar.io/releases/phive.phar.asc \ + && gpg --keyserver pool.sks-keyservers.net --recv-keys 0x9D8A98B29B2D5D79 \ + && gpg --verify phive.phar.asc phive.phar \ + && chmod +x phive.phar \ + && mv phive.phar /usr/local/bin/phive \ + && rm phive.phar.asc \ + && phive install --trust-gpg-keys 31C7E470E2138192,8A03EA3B385DBAA1 +# Trusted GPG keys for PHP linters: phpcs, psalm + ######################################### # Install Powershell + PSScriptAnalyzer # ######################################### diff --git a/dependencies/phive.xml b/dependencies/phive.xml new file mode 100755 index 00000000..af2d5187 --- /dev/null +++ b/dependencies/phive.xml @@ -0,0 +1,6 @@ + + + + + + diff --git a/lib/linter.sh b/lib/linter.sh index d712ab4b..17aa4e98 100755 --- a/lib/linter.sh +++ b/lib/linter.sh @@ -107,7 +107,7 @@ LINTER_ARRAY=('ansible-lint' 'arm-ttk' 'asl-validator' 'cfn-lint' 'clj-kondo' LANGUAGE_ARRAY=('ANSIBLE' 'ARM' 'BASH' 'CLOUDFORMATION' 'CLOJURE' 'COFFEESCRIPT' 'CSS' 'DART' 'DOCKER' 'ENV' 'GO' 'GROOVY' 'HTML' 'JAVASCRIPT_ES' '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' 'TYPESCRIPT_STANDARD' 'XML' 'YML') @@ -154,7 +154,9 @@ VALIDATE_KOTLIN="${VALIDATE_KOTLIN}" # Boolean to vali VALIDATE_MARKDOWN="${VALIDATE_MD:-}" # Boolean to validate language VALIDATE_OPENAPI="${VALIDATE_OPENAPI}" # Boolean to validate language VALIDATE_PERL="${VALIDATE_PERL}" # Boolean to validate language -VALIDATE_PHP="${VALIDATE_PHP}" # Boolean to validate language +VALIDATE_PHP_BUILTIN="${VALIDATE_PHP_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_PYTHON="${VALIDATE_PYTHON}" # 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_OPENAPI=() # Array of files to check FILE_ARRAY_PERL=() # Array of files to check -FILE_ARRAY_PHP=() # Array of files to check +FILE_ARRAY_PHP_BUILTIN=() # Array of files to check +FILE_ARRAY_PHP_PHPCS=() # Array of files to check +FILE_ARRAY_PHP_PSALM=() # Array of files to check FILE_ARRAY_POWERSHELL=() # Array of files to check FILE_ARRAY_PROTOBUF=() # Array of files to check FILE_ARRAY_PYTHON=() # Array of files to check @@ -289,8 +293,12 @@ ERRORS_FOUND_OPENAPI=0 # Count of errors found export ERRORS_FOUND_OPENAPI # Workaround SC2034 ERRORS_FOUND_PERL=0 # Count of errors found export ERRORS_FOUND_PERL # Workaround SC2034 -ERRORS_FOUND_PHP=0 # Count of errors found -export ERRORS_FOUND_PHP # Workaround SC2034 +ERRORS_FOUND_PHP_BUILTIN=0 # Count of errors found +export ERRORS_FOUND_PHP_BUILTIN # Workaround SC2034 +ERRORS_FOUND_PHP_PHPCS=0 # Count of errors found +export ERRORS_FOUND_PHP_PHPCS # Workaround SC2034 +ERRORS_FOUND_PHP_PSALM=0 # Count of errors found +export ERRORS_FOUND_PHP_PSALM # Workaround SC2034 ERRORS_FOUND_POWERSHELL=0 # Count of errors found export ERRORS_FOUND_POWERSHELL # Workaround SC2034 ERRORS_FOUND_PROTOBUF=0 # Count of errors found @@ -1453,12 +1461,28 @@ fi ################ # PHP LINTING # ################ -if [ "${VALIDATE_PHP}" == "true" ]; then - ####################### - # Lint the PHP files # - ####################### +if [ "${VALIDATE_PHP_BUILTIN}" == "true" ]; then + ################################################ + # Lint the PHP files using built-in PHP linter # + ################################################ # LintCodebase "FILE_TYPE" "LINTER_NAME" "LINTER_CMD" "FILE_TYPES_REGEX" "FILE_ARRAY" - LintCodebase "PHP" "php" "php -l" ".*\.\(php\)\$" "${FILE_ARRAY_PHP[@]}" + LintCodebase "PHP_BUILTIN" "php" "php -l" ".*\.\(php\)\$" "${FILE_ARRAY_PHP_BUILTIN[@]}" +fi + +if [ "${VALIDATE_PHP_PHPCS}" == "true" ]; then + ############################################ + # Lint the PHP files using PHP CodeSniffer # + ############################################ + # LintCodebase "FILE_TYPE" "LINTER_NAME" "LINTER_CMD" "FILE_TYPES_REGEX" "FILE_ARRAY" + LintCodebase "PHP_PHPCS" "phpcs" "phpcs" ".*\.\(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 ###################### From 67cde9602e2aab954b0c1ac9dd0e221a889ca62f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Filip=20=C5=A0?= Date: Sun, 26 Jul 2020 21:30:45 +0200 Subject: [PATCH 066/135] Add support for PHPCS and Psalm config files --- TEMPLATES/phpcs.xml | 6 ++++++ TEMPLATES/psalm.xml | 4 ++++ lib/linter.sh | 10 ++++++++-- 3 files changed, 18 insertions(+), 2 deletions(-) create mode 100755 TEMPLATES/phpcs.xml create mode 100755 TEMPLATES/psalm.xml diff --git a/TEMPLATES/phpcs.xml b/TEMPLATES/phpcs.xml new file mode 100755 index 00000000..b319d759 --- /dev/null +++ b/TEMPLATES/phpcs.xml @@ -0,0 +1,6 @@ + + + + The default coding standard for usage with super-linter. Just includes PSR12. + + diff --git a/TEMPLATES/psalm.xml b/TEMPLATES/psalm.xml new file mode 100755 index 00000000..0eb2e126 --- /dev/null +++ b/TEMPLATES/psalm.xml @@ -0,0 +1,4 @@ + + + + diff --git a/lib/linter.sh b/lib/linter.sh index 17aa4e98..c5a829fa 100755 --- a/lib/linter.sh +++ b/lib/linter.sh @@ -68,6 +68,12 @@ MARKDOWN_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${MARKDOWN_FILE_NAME}" # OpenAPI Vars OPENAPI_FILE_NAME='.openapirc.yml' # Name of the file OPENAPI_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${OPENAPI_FILE_NAME}" # Path to the OpenAPI lint rules +# PHPCS Vars +PHP_PHPCS_FILE_NAME='phpcs.xml' # Name of the file +PHP_PHPCS_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${PHP_PHPCS_FILE_NAME}" # Path to the PHP CodeSniffer lint rules +# Psalm Vars +PHP_PSALM_FILE_NAME='psalm.xml' # Name of the file +PHP_PSALM_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${PHP_PSALM_FILE_NAME}" # Path to the Psalm lint rules # Powershell Vars POWERSHELL_FILE_NAME='.powershell-psscriptanalyzer.psd1' # Name of the file POWERSHELL_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${POWERSHELL_FILE_NAME}" # Path to the Powershell lint rules @@ -1474,7 +1480,7 @@ 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[@]}" + LintCodebase "PHP_PHPCS" "phpcs" "phpcs --standard=${PHP_PHPCS_LINTER_RULES}" ".*\.\(php\)\$" "${FILE_ARRAY_PHP_PHPCS[@]}" fi if [ "${VALIDATE_PHP_PSALM}" == "true" ]; then @@ -1482,7 +1488,7 @@ 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[@]}" + LintCodebase "PHP_PSALM" "psalm" "psalm --config=${PHP_PSALM_LINTER_RULES}" ".*\.\(php\)\$" "${FILE_ARRAY_PHP_PSALM[@]}" fi ###################### From a8802c1fa602d0c5d708ae228b0bdf8d0947ef91 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 27 Jul 2020 05:43:15 +0000 Subject: [PATCH 067/135] Bump actions/stale from v3.0.8 to v3.0.9 Bumps [actions/stale](https://github.com/actions/stale) from v3.0.8 to v3.0.9. - [Release notes](https://github.com/actions/stale/releases) - [Commits](https://github.com/actions/stale/compare/v3.0.8...1e5e734da7bd7ea04daf52d9f1c6540e83867b73) Signed-off-by: dependabot[bot] --- .github/workflows/stale.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/stale.yml b/.github/workflows/stale.yml index 4aecddcb..aac6767a 100644 --- a/.github/workflows/stale.yml +++ b/.github/workflows/stale.yml @@ -29,7 +29,7 @@ jobs: if: "github.event_name == 'schedule'" steps: - name: Mark issue stale - uses: actions/stale@v3.0.8 + uses: actions/stale@v3.0.9 with: repo-token: ${{ secrets.GITHUB_TOKEN }} stale-issue-message: "This issue has been automatically marked as stale because it has not had recent activity.\nIt will be closed in 14 days if no further activity occurs.\nThank you for your contributions.\n\nIf you think this issue should stay open, please remove the `O: stale 🤖` label or comment on the issue." From 8495208874e5e5a728493c2842390edcad30a169 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 27 Jul 2020 05:44:27 +0000 Subject: [PATCH 068/135] Bump borkdude/clj-kondo from 2020.06.21 to 2020.07.26 Bumps borkdude/clj-kondo from 2020.06.21 to 2020.07.26. Signed-off-by: dependabot[bot] --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 2d143824..b5bbefca 100644 --- a/Dockerfile +++ b/Dockerfile @@ -7,7 +7,7 @@ ######################################### # Get dependency images as build stages # ######################################### -FROM borkdude/clj-kondo:2020.06.21 as clj-kondo +FROM borkdude/clj-kondo:2020.07.26 as clj-kondo FROM dotenvlinter/dotenv-linter:2.1.0 as dotenv-linter FROM mstruebing/editorconfig-checker:2.1.0 as editorconfig-checker FROM golangci/golangci-lint:v1.29.0 as golangci-lint From cc7b68f98557202f4b957a0087f0d33aeef24b65 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 27 Jul 2020 05:44:37 +0000 Subject: [PATCH 069/135] Bump yoheimuta/protolint from v0.25.1 to v0.26.0 Bumps yoheimuta/protolint from v0.25.1 to v0.26.0. Signed-off-by: dependabot[bot] --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 2d143824..d842c658 100644 --- a/Dockerfile +++ b/Dockerfile @@ -11,7 +11,7 @@ FROM borkdude/clj-kondo:2020.06.21 as clj-kondo FROM dotenvlinter/dotenv-linter:2.1.0 as dotenv-linter FROM mstruebing/editorconfig-checker:2.1.0 as editorconfig-checker FROM golangci/golangci-lint:v1.29.0 as golangci-lint -FROM yoheimuta/protolint:v0.25.1 as protolint +FROM yoheimuta/protolint:v0.26.0 as protolint FROM koalaman/shellcheck:v0.7.1 as shellcheck FROM wata727/tflint:0.18.0 as tflint From 99cb8a7ef5dd807d67a91cc70a966308a6156839 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 27 Jul 2020 05:46:58 +0000 Subject: [PATCH 070/135] Bump eslint-plugin-jest from 23.18.0 to 23.18.2 in /dependencies Bumps [eslint-plugin-jest](https://github.com/jest-community/eslint-plugin-jest) from 23.18.0 to 23.18.2. - [Release notes](https://github.com/jest-community/eslint-plugin-jest/releases) - [Changelog](https://github.com/jest-community/eslint-plugin-jest/blob/master/CHANGELOG.md) - [Commits](https://github.com/jest-community/eslint-plugin-jest/compare/v23.18.0...v23.18.2) Signed-off-by: dependabot[bot] --- dependencies/package-lock.json | 164 ++++++++++++++++++++++++++++++++- dependencies/package.json | 2 +- 2 files changed, 162 insertions(+), 4 deletions(-) diff --git a/dependencies/package-lock.json b/dependencies/package-lock.json index 06703cc7..31315d49 100644 --- a/dependencies/package-lock.json +++ b/dependencies/package-lock.json @@ -3,6 +3,20 @@ "requires": true, "lockfileVersion": 1, "dependencies": { + "@amplitude/node": { + "version": "0.3.3", + "resolved": "https://registry.npmjs.org/@amplitude/node/-/node-0.3.3.tgz", + "integrity": "sha512-Uzg4MRAuD053Ex67Iu2lm2GovnVte1uKI3q7CXlMCYZ9ylZmAkPbTnjg9OVyD4f+IiUfgK4p3bE7r9p7jqSDLA==", + "requires": { + "@amplitude/types": "^0.3.2", + "tslib": "^1.9.3" + } + }, + "@amplitude/types": { + "version": "0.3.2", + "resolved": "https://registry.npmjs.org/@amplitude/types/-/types-0.3.2.tgz", + "integrity": "sha512-7+m7nhJMFGbpsppOUsCH8f4FOFyAxgKFuXkKknU/LP2CMYVjWEIoLTKKgaJPc2c8wXaK5KPXVetb8VeiGbuaGg==" + }, "@babel/code-frame": { "version": "7.10.4", "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.10.4.tgz", @@ -742,6 +756,14 @@ "resolved": "https://registry.npmjs.org/aws4/-/aws4-1.10.0.tgz", "integrity": "sha512-3YDiu347mtVtjpyV3u5kVqQLP242c06zwDOgpeRnybmXlYYsLbtTrUBUm8i8srONt+FWobl5aibnU1030PeeuA==" }, + "axios": { + "version": "0.19.2", + "resolved": "https://registry.npmjs.org/axios/-/axios-0.19.2.tgz", + "integrity": "sha512-fjgm5MvRHLhx+osE2xoekY70AhARk3a6hkN+3Io1jc00jtquGvxYlKlsFUhmUET0V5te6CcZI7lcv2Ym61mjHA==", + "requires": { + "follow-redirects": "1.5.10" + } + }, "babel-eslint": { "version": "10.1.0", "resolved": "https://registry.npmjs.org/babel-eslint/-/babel-eslint-10.1.0.tgz", @@ -950,6 +972,15 @@ "restore-cursor": "^3.1.0" } }, + "cli-progress": { + "version": "3.8.2", + "resolved": "https://registry.npmjs.org/cli-progress/-/cli-progress-3.8.2.tgz", + "integrity": "sha512-qRwBxLldMSfxB+YGFgNRaj5vyyHe1yMpVeDL79c+7puGujdKJHQHydgqXDcrkvQgJ5U/d3lpf6vffSoVVUftVQ==", + "requires": { + "colors": "^1.1.2", + "string-width": "^4.2.0" + } + }, "cli-width": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/cli-width/-/cli-width-3.0.0.tgz", @@ -1159,6 +1190,11 @@ "resolved": "https://registry.npmjs.org/decimal.js/-/decimal.js-10.2.0.tgz", "integrity": "sha512-vDPw+rDgn3bZe1+F/pyEwb1oMG2XTlRVgAa6B4KccTEpYgF8w6eQllVbQcfIJnZyvzFtFpxnpGtx8dd7DJp/Rw==" }, + "decode-html": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/decode-html/-/decode-html-2.0.0.tgz", + "integrity": "sha1-fQqIfORCgOYJeKcH67f4CB/WHqo=" + }, "deep-extend": { "version": "0.5.1", "resolved": "https://registry.npmjs.org/deep-extend/-/deep-extend-0.5.1.tgz", @@ -1847,9 +1883,9 @@ } }, "eslint-plugin-jest": { - "version": "23.18.0", - "resolved": "https://registry.npmjs.org/eslint-plugin-jest/-/eslint-plugin-jest-23.18.0.tgz", - "integrity": "sha512-wLPM/Rm1SGhxrFQ2TKM/BYsYPhn7ch6ZEK92S2o/vGkAAnDXM0I4nTIo745RIX+VlCRMFgBuJEax6XfTHMdeKg==", + "version": "23.18.2", + "resolved": "https://registry.npmjs.org/eslint-plugin-jest/-/eslint-plugin-jest-23.18.2.tgz", + "integrity": "sha512-afVOE47F0PENnRlnePUHgrDbv1tsDlTAVrjL051oUETB2ImzBwa5GfmUAUhDjAEuxH+xkE6DsmEpZ8obXzUMqQ==", "requires": { "@typescript-eslint/experimental-utils": "^2.5.0" }, @@ -2117,6 +2153,27 @@ "to-regex-range": "^5.0.1" } }, + "find-java-home": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/find-java-home/-/find-java-home-1.1.0.tgz", + "integrity": "sha512-bSTCKNZ193UM/+ZZoNDzICAEHcVywovkhsWCkZALjCvRXQ+zXTe/XATrrP4CpxkaP6YFhQJOpyRpH0P2U/woDA==", + "requires": { + "which": "~1.0.5", + "winreg": "~1.2.2" + }, + "dependencies": { + "which": { + "version": "1.0.9", + "resolved": "https://registry.npmjs.org/which/-/which-1.0.9.tgz", + "integrity": "sha1-RgwdoPgQED0DIam2M6+eV15kSG8=" + } + } + }, + "find-package-json": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/find-package-json/-/find-package-json-1.2.0.tgz", + "integrity": "sha512-+SOGcLGYDJHtyqHd87ysBhmaeQ95oWspDKnMXBrnQ9Eq4OkLNqejgoaD8xVWu6GPa0B6roa6KinCMEMcVeqONw==" + }, "find-root": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/find-root/-/find-root-1.1.0.tgz", @@ -2146,6 +2203,29 @@ "resolved": "https://registry.npmjs.org/flatted/-/flatted-2.0.2.tgz", "integrity": "sha512-r5wGx7YeOwNWNlCA0wQ86zKyDLMQr+/RB8xy74M4hTphfmjlijTSSXGuH8rnvKZnfT9i+75zmd8jcKdMR4O6jA==" }, + "follow-redirects": { + "version": "1.5.10", + "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.5.10.tgz", + "integrity": "sha512-0V5l4Cizzvqt5D44aTXbFZz+FtyXV1vrDN6qrelxtfYQKW0KO0W2T/hkE8xvGa/540LkZlkaUjO4ailYTFtHVQ==", + "requires": { + "debug": "=3.1.0" + }, + "dependencies": { + "debug": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/debug/-/debug-3.1.0.tgz", + "integrity": "sha512-OX8XqP7/1a9cqkxYw2yXss15f26NKWBpDXQd0/uK/KPqdQhxbPa994hnzjcE2VqQpDslf55723cKPUOGSmMY3g==", + "requires": { + "ms": "2.0.0" + } + }, + "ms": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", + "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=" + } + } + }, "forever-agent": { "version": "0.6.1", "resolved": "https://registry.npmjs.org/forever-agent/-/forever-agent-0.6.1.tgz", @@ -2161,6 +2241,16 @@ "mime-types": "^2.1.12" } }, + "fs-extra": { + "version": "8.1.0", + "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-8.1.0.tgz", + "integrity": "sha512-yhlQgA6mnOJUKOsRUFsgJdQCvkKhcz8tlZG5HBQfReYZy46OwLcY+Zia0mtdHsOo9y/hP+CxMN0TU9QxoOtG4g==", + "requires": { + "graceful-fs": "^4.2.0", + "jsonfile": "^4.0.0", + "universalify": "^0.1.0" + } + }, "fs.realpath": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", @@ -2934,6 +3024,14 @@ "resolved": "https://registry.npmjs.org/jsonc-parser/-/jsonc-parser-2.2.1.tgz", "integrity": "sha512-o6/yDBYccGvTz1+QFevz6l6OBZ2+fMVu2JZ9CIhzsYRX4mjaK5IyX9eldUdCmga16zlgQxyrj5pt9kzuj2C02w==" }, + "jsonfile": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-4.0.0.tgz", + "integrity": "sha1-h3Gq4HmbZAdrdmQPygWPnBDjPss=", + "requires": { + "graceful-fs": "^4.1.6" + } + }, "jsonlint": { "version": "1.6.3", "resolved": "https://registry.npmjs.org/jsonlint/-/jsonlint-1.6.3.tgz", @@ -3472,6 +3570,37 @@ "resolved": "https://registry.npmjs.org/normalize-selector/-/normalize-selector-0.2.0.tgz", "integrity": "sha1-0LFF62kRicY6eNIB3E/bEpPvDAM=" }, + "npm-groovy-lint": { + "version": "5.7.0", + "resolved": "https://registry.npmjs.org/npm-groovy-lint/-/npm-groovy-lint-5.7.0.tgz", + "integrity": "sha512-Cq/ncgmNMI6USeazp2gingZj73ia6M+rpR5LfBK8ATSEdRZuIsnKTIGTuqMc/hrZyU4oMN0C/PYQj4DTO+TRFQ==", + "requires": { + "@amplitude/node": "^0.3.3", + "ansi-colors": "^4.1.1", + "axios": "^0.19.2", + "cli-progress": "^3.6.0", + "debug": "^4.1.1", + "decode-html": "^2.0.0", + "find-java-home": "^1.1.0", + "find-package-json": "^1.2.0", + "fs-extra": "^8.1.0", + "glob": "^7.1.6", + "import-fresh": "^3.2.1", + "ip": "^1.1.5", + "optionator": "^0.8.3", + "semver": "^7.1.3", + "strip-json-comments": "^3.0.1", + "uuid": "^8.2.0", + "xml2js": "^0.4.23" + }, + "dependencies": { + "uuid": { + "version": "8.2.0", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-8.2.0.tgz", + "integrity": "sha512-CYpGiFTUrmI6OBMkAdjSDM0k5h8SkkiTP4WAjQgDgNB1S3Ou9VBEvr6q0Kv2H1mMk7IWfxYGpMH5sd5AvcIV2Q==" + } + } + }, "num2fraction": { "version": "1.2.2", "resolved": "https://registry.npmjs.org/num2fraction/-/num2fraction-1.2.2.tgz", @@ -4445,6 +4574,11 @@ "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz", "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==" }, + "sax": { + "version": "1.2.4", + "resolved": "https://registry.npmjs.org/sax/-/sax-1.2.4.tgz", + "integrity": "sha512-NqVDv9TpANUjFm0N8uM5GxL36UgKi9/atZw+x7YFnQ8ckwFGKrl4xX4yWtrey3UJm5nP1kUbnYgLopqWNSRhWw==" + }, "semver": { "version": "7.3.2", "resolved": "https://registry.npmjs.org/semver/-/semver-7.3.2.tgz", @@ -5301,6 +5435,11 @@ "unist-util-is": "^4.0.0" } }, + "universalify": { + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/universalify/-/universalify-0.1.2.tgz", + "integrity": "sha512-rBJeI5CXAlmy1pV+617WB9J63U6XcazHHF2f2dbJix4XzpUF0RS3Zbj0FGIOCAva5P/d/GBOYaACQ1w+0azUkg==" + }, "unpipe": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/unpipe/-/unpipe-1.0.0.tgz", @@ -5397,6 +5536,11 @@ "resolved": "https://registry.npmjs.org/which-module/-/which-module-2.0.0.tgz", "integrity": "sha1-2e8H3Od7mQK4o6j6SzHD4/fm6Ho=" }, + "winreg": { + "version": "1.2.4", + "resolved": "https://registry.npmjs.org/winreg/-/winreg-1.2.4.tgz", + "integrity": "sha1-ugZWKbepJRMOFXeRCM9UCZDpjRs=" + }, "wolfy87-eventemitter": { "version": "5.2.9", "resolved": "https://registry.npmjs.org/wolfy87-eventemitter/-/wolfy87-eventemitter-5.2.9.tgz", @@ -5446,6 +5590,20 @@ "resolved": "https://registry.npmjs.org/xml/-/xml-1.0.1.tgz", "integrity": "sha1-eLpyAgApxbyHuKgaPPzXS0ovweU=" }, + "xml2js": { + "version": "0.4.23", + "resolved": "https://registry.npmjs.org/xml2js/-/xml2js-0.4.23.tgz", + "integrity": "sha512-ySPiMjM0+pLDftHgXY4By0uswI3SPKLDw/i3UXbnO8M/p28zqexCUoPmQFrYD+/1BzhGJSs2i1ERWKJAtiLrug==", + "requires": { + "sax": ">=0.6.0", + "xmlbuilder": "~11.0.0" + } + }, + "xmlbuilder": { + "version": "11.0.1", + "resolved": "https://registry.npmjs.org/xmlbuilder/-/xmlbuilder-11.0.1.tgz", + "integrity": "sha512-fDlsI/kFEx7gLvbecc0/ohLG50fugQp8ryHzMTuW9vSa1GJ0XYWKnhsUx7oie3G98+r56aTQIUB4kht42R3JvA==" + }, "xregexp": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/xregexp/-/xregexp-2.0.0.tgz", diff --git a/dependencies/package.json b/dependencies/package.json index 6e1d4695..b493cb56 100644 --- a/dependencies/package.json +++ b/dependencies/package.json @@ -9,7 +9,7 @@ "dockerfilelint": "^1.5.0", "eslint": "^7.5.0", "eslint-config-prettier": "^6.11.0", - "eslint-plugin-jest": "^23.18.0", + "eslint-plugin-jest": "^23.18.2", "htmlhint": "^0.14.1", "jsonlint": "^1.6.3", "markdownlint-cli": "^0.23.2", From 9fc054ab16f36f5cd74979912bf7e9ab16cbfc73 Mon Sep 17 00:00:00 2001 From: Eric Nemchik Date: Mon, 27 Jul 2020 16:11:33 -0500 Subject: [PATCH 071/135] Add log functions --- lib/linter.sh | 15 ++++++++++++++- lib/log.sh | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 67 insertions(+), 1 deletion(-) create mode 100644 lib/log.sh diff --git a/lib/linter.sh b/lib/linter.sh index 5ccbafaf..f613ec16 100755 --- a/lib/linter.sh +++ b/lib/linter.sh @@ -10,7 +10,7 @@ # Source Function Files # ######################### # shellcheck source=/dev/null -source /action/lib/termColors.sh # Source the function script(s) +source /action/lib/log.sh # Source the function script(s) # shellcheck source=/dev/null source /action/lib/buildFileList.sh # Source the function script(s) # shellcheck source=/dev/null @@ -1030,6 +1030,19 @@ Footer() { exit 0 } + +################################################################################ +#### Function Cleanup ########################################################## +cleanup() { + local -ri EXIT_CODE=$? + + sudo sh -c "cat ${LOG_TEMP} >> ${GITHUB_WORKSPACE}/super-linter.log" || true + + exit ${EXIT_CODE} + trap - 0 1 2 3 6 14 15 +} +trap 'cleanup' 0 1 2 3 6 14 15 + ################################################################################ ############################### MAIN ########################################### ################################################################################ diff --git a/lib/log.sh b/lib/log.sh new file mode 100644 index 00000000..532a60a5 --- /dev/null +++ b/lib/log.sh @@ -0,0 +1,53 @@ +#!/usr/bin/env bash + +declare -Agr B=( + [B]=$(echo -e "\e[44m") + [C]=$(echo -e "\e[46m") + [G]=$(echo -e "\e[42m") + [K]=$(echo -e "\e[40m") + [M]=$(echo -e "\e[45m") + [R]=$(echo -e "\e[41m") + [W]=$(echo -e "\e[47m") + [Y]=$(echo -e "\e[43m") +) +declare -Agr F=( + [B]=$(echo -e "\e[0;34m") + [C]=$(echo -e "\e[0;36m") + [G]=$(echo -e "\e[0;32m") + [K]=$(echo -e "\e[0;30m") + [M]=$(echo -e "\e[0;35m") + [R]=$(echo -e "\e[0;31m") + [W]=$(echo -e "\e[0;37m") + [Y]=$(echo -e "\e[0;33m") +) +readonly NC=$(echo -e "\e[0m") + +export B +export F +export NC + +# Log Functions +LOG_TEMP=$(mktemp) || echo "Failed to create temporary log file." +export LOG_TEMP +echo "super-linter Log" > "${LOG_TEMP}" +log() { + local TOTERM=${1:-} + local MESSAGE=${2:-} + echo -e "${MESSAGE:-}" | ( + if [[ -n ${TOTERM} ]]; then + tee -a "${LOG_TEMP}" >&2 + else + cat >> "${LOG_TEMP}" 2>&1 + fi + ) +} +trace() { log "${TRACE:-}" "${NC}$(date +"%F %T") ${F[B]}[TRACE ]${NC} $*${NC}"; } +debug() { log "${DEBUG:-}" "${NC}$(date +"%F %T") ${F[B]}[DEBUG ]${NC} $*${NC}"; } +info() { log "${VERBOSE:-}" "${NC}$(date +"%F %T") ${F[B]}[INFO ]${NC} $*${NC}"; } +notice() { log "true" "${NC}$(date +"%F %T") ${F[G]}[NOTICE]${NC} $*${NC}"; } +warn() { log "true" "${NC}$(date +"%F %T") ${F[Y]}[WARN ]${NC} $*${NC}"; } +error() { log "true" "${NC}$(date +"%F %T") ${F[R]}[ERROR ]${NC} $*${NC}"; } +fatal() { + log "true" "${NC}$(date +"%F %T") ${B[R]}${F[W]}[FATAL ]${NC} $*${NC}" + exit 1 +} From af13245484c01c5deca66a936a6d19c3de50b2c6 Mon Sep 17 00:00:00 2001 From: Eric Nemchik Date: Mon, 27 Jul 2020 16:20:06 -0500 Subject: [PATCH 072/135] First pass at log functions --- .automation/cleanup-docker.sh | 49 +++----- .../templates/ghe-config-apply.sh | 15 ++- .automation/upload-docker.sh | 116 ++++++++---------- lib/buildFileList.sh | 21 ++-- lib/linter.sh | 100 +++++++-------- lib/worker.sh | 68 +++++----- 6 files changed, 160 insertions(+), 209 deletions(-) diff --git a/.automation/cleanup-docker.sh b/.automation/cleanup-docker.sh index 889c4d65..7910f17b 100755 --- a/.automation/cleanup-docker.sh +++ b/.automation/cleanup-docker.sh @@ -52,9 +52,8 @@ ValidateInput() { # Validate GITHUB_WORKSPACE # ############################ if [ -z "${GITHUB_WORKSPACE}" ]; then - echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Failed to get [GITHUB_WORKSPACE]!${NC}" - echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[${GITHUB_WORKSPACE}]${NC}" - exit 1 + error "Failed to get [GITHUB_WORKSPACE]!${NC}" + fatal "[${GITHUB_WORKSPACE}]${NC}" else echo "Successfully found:[GITHUB_WORKSPACE], value:[${GITHUB_WORKSPACE}]" fi @@ -64,15 +63,14 @@ ValidateInput() { ####################### if [ -z "${IMAGE_REPO}" ]; then # No repo was pulled - echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Failed to get [IMAGE_REPO]!${NC}" - echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[${IMAGE_REPO}]${NC}" - exit 1 + error "Failed to get [IMAGE_REPO]!${NC}" + fatal "[${IMAGE_REPO}]${NC}" elif [[ ${IMAGE_REPO} == "github/super-linter" ]]; then # Found our main repo echo "Successfully found:[IMAGE_REPO], value:[${IMAGE_REPO}]" else # This is a fork and we cant pull vars or any info - echo -e "${NC}${F[Y]}WARN!${NC} No image to cleanup as this is a forked branch, and not being built with current automation!${NC}" + warn "No image to cleanup as this is a forked branch, and not being built with current automation!${NC}" exit 0 fi @@ -80,9 +78,8 @@ ValidateInput() { # Validate IMAGE_VERSION # ########################## if [ -z "${IMAGE_VERSION}" ]; then - echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Failed to get [IMAGE_VERSION]!${NC}" - echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[${IMAGE_VERSION}]${NC}" - exit 1 + error "Failed to get [IMAGE_VERSION]!${NC}" + fatal "[${IMAGE_VERSION}]${NC}" else echo "Successfully found:[IMAGE_VERSION], value:[${IMAGE_VERSION}]" fi @@ -91,9 +88,8 @@ ValidateInput() { # Validate DOCKER_USERNAME # ############################ if [ -z "${DOCKER_USERNAME}" ]; then - echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Failed to get [DOCKER_USERNAME]!${NC}" - echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[${DOCKER_USERNAME}]${NC}" - exit 1 + error "Failed to get [DOCKER_USERNAME]!${NC}" + fatal "[${DOCKER_USERNAME}]${NC}" else echo "Successfully found:[DOCKER_USERNAME], value:[${DOCKER_USERNAME}]" fi @@ -102,9 +98,8 @@ ValidateInput() { # Validate DOCKER_PASSWORD # ############################ if [ -z "${DOCKER_PASSWORD}" ]; then - echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Failed to get [DOCKER_PASSWORD]!${NC}" - echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[${DOCKER_PASSWORD}]${NC}" - exit 1 + error "Failed to get [DOCKER_PASSWORD]!${NC}" + fatal "[${DOCKER_PASSWORD}]${NC}" else echo "Successfully found:[DOCKER_PASSWORD], value:[********]" fi @@ -121,10 +116,9 @@ ValidateInput() { ############################################# # Image is 'latest' and we will not destroy # ############################################# - echo "Image Tag is set to:[latest]..." - echo "We will never destroy latest..." - echo "Bye!" - exit 1 + error "Image Tag is set to:[latest]..." + error "We will never destroy latest..." + fatal "Bye!" fi } ################################################################################ @@ -154,9 +148,8 @@ LoginToDocker() { ############################## if [ ${ERROR_CODE} -ne 0 ]; then # ERROR - echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Failed to authenticate to DockerHub!${NC}" - echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[${LOGIN_CMD}]${NC}" - exit 1 + error "Failed to authenticate to DockerHub!${NC}" + fatal "[${LOGIN_CMD}]${NC}" else # SUCCESS echo "Successfully authenticated to DockerHub!" @@ -193,9 +186,8 @@ RemoveImage() { ############################## if [ ${ERROR_CODE} -ne 0 ]; then # ERROR - echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Failed to gain token from DockerHub!${NC}" - echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[${TOKEN}]${NC}" - exit 1 + error "Failed to gain token from DockerHub!${NC}" + fatal "[${TOKEN}]${NC}" else # SUCCESS echo "Successfully gained auth token from DockerHub!" @@ -218,9 +210,8 @@ RemoveImage() { ############################## if [ ${ERROR_CODE} -ne 0 ]; then # ERROR - echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Failed to remove tag from DockerHub!${NC}" - echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[${REMOVE_CMD}]${NC}" - exit 1 + error "Failed to remove tag from DockerHub!${NC}" + fatal "[${REMOVE_CMD}]${NC}" else # SUCCESS echo "Successfully [removed] Docker image tag:[${IMAGE_VERSION}] from DockerHub!" diff --git a/.automation/test/ansible/ghe-initialize/templates/ghe-config-apply.sh b/.automation/test/ansible/ghe-initialize/templates/ghe-config-apply.sh index 2d4b0eec..227caabc 100644 --- a/.automation/test/ansible/ghe-initialize/templates/ghe-config-apply.sh +++ b/.automation/test/ansible/ghe-initialize/templates/ghe-config-apply.sh @@ -53,8 +53,8 @@ CheckGHEPid() # Check the shell for errors # ############################## if [ ${ERROR_CODE} -ne 0 ]; then - echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Failed to sleep!${NC}" - echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[${SLEEP_CMD}]${NC}" + error "Failed to sleep!${NC}" + error "[${SLEEP_CMD}]${NC}" echo "Will try to call apply as last effort..." #################################### # Call config apply as last effort # @@ -117,8 +117,8 @@ CheckGHEProcess() # Check the shell for errors # ############################## if [ ${ERROR_CODE} -ne 0 ]; then - echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Failed to sleep!${NC}" - echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[${SLEEP_CMD}]${NC}" + error "Failed to sleep!${NC}" + error "[${SLEEP_CMD}]${NC}" echo "Will try to call apply as last effort..." #################################### # Call config apply as last effort # @@ -161,12 +161,11 @@ RunConfigApply() ############################## if [ ${ERROR_CODE} -ne 0 ]; then # Errors - echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Failed to run config apply command!${NC}" - echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[${APPLY_CMD}]${NC}" - exit 1 + error "Failed to run config apply command!${NC}" + fatal "[${APPLY_CMD}]${NC}" else # Success - echo -e "${NC}${F[B]}Successfully ran ${F[C]}${GHE_APPLY_COMMAND}${NC}" + notice "Successfully ran ${F[C]}${GHE_APPLY_COMMAND}${NC}" fi } ################################################################################ diff --git a/.automation/upload-docker.sh b/.automation/upload-docker.sh index 42ea1c65..d4fccdf8 100755 --- a/.automation/upload-docker.sh +++ b/.automation/upload-docker.sh @@ -58,22 +58,20 @@ ValidateInput() { # Validate GITHUB_WORKSPACE # ############################# if [ -z "${GITHUB_WORKSPACE}" ]; then - echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Failed to get [GITHUB_WORKSPACE]!${NC}" - echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[${GITHUB_WORKSPACE}]${NC}" - exit 1 + error "Failed to get [GITHUB_WORKSPACE]!${NC}" + fatal "[${GITHUB_WORKSPACE}]${NC}" else - echo -e "${NC}${F[B]}Successfully found:${F[W]}[GITHUB_WORKSPACE]${F[B]}, value:${F[W]}[${GITHUB_WORKSPACE}]${NC}" + notice "Successfully found:${F[W]}[GITHUB_WORKSPACE]${F[B]}, value:${F[W]}[${GITHUB_WORKSPACE}]${NC}" fi ##################### # Validate REGISTRY # ##################### if [ -z "${REGISTRY}" ]; then - echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Failed to get [REGISTRY]!${NC}" - echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[${REGISTRY}]${NC}" - exit 1 + error "Failed to get [REGISTRY]!${NC}" + fatal "[${REGISTRY}]${NC}" else - echo -e "${NC}${F[B]}Successfully found:${F[W]}[REGISTRY]${F[B]}, value:${F[W]}[${REGISTRY}]${NC}" + notice "Successfully found:${F[W]}[REGISTRY]${F[B]}, value:${F[W]}[${REGISTRY}]${NC}" fi ##################################################### @@ -84,22 +82,20 @@ ValidateInput() { # Validate GPR_USERNAME # ######################### if [ -z "${GPR_USERNAME}" ]; then - echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Failed to get [GPR_USERNAME]!${NC}" - echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[${GPR_USERNAME}]${NC}" - exit 1 + error "Failed to get [GPR_USERNAME]!${NC}" + fatal "[${GPR_USERNAME}]${NC}" else - echo -e "${NC}${F[B]}Successfully found:${F[W]}[GPR_USERNAME]${F[B]}, value:${F[W]}[${GPR_USERNAME}]${NC}" + notice "Successfully found:${F[W]}[GPR_USERNAME]${F[B]}, value:${F[W]}[${GPR_USERNAME}]${NC}" fi ###################### # Validate GPR_TOKEN # ###################### if [ -z "${GPR_TOKEN}" ]; then - echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Failed to get [GPR_TOKEN]!${NC}" - echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[${GPR_TOKEN}]${NC}" - exit 1 + error "Failed to get [GPR_TOKEN]!${NC}" + fatal "[${GPR_TOKEN}]${NC}" else - echo -e "${NC}${F[B]}Successfully found:${F[W]}[GPR_TOKEN]${F[B]}, value:${F[W]}[********]${NC}" + notice "Successfully found:${F[W]}[GPR_TOKEN]${F[B]}, value:${F[W]}[********]${NC}" fi ######################################## # See if we need values for Ducker hub # @@ -109,41 +105,37 @@ ValidateInput() { # Validate DOCKER_USERNAME # ############################ if [ -z "${DOCKER_USERNAME}" ]; then - echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Failed to get [DOCKER_USERNAME]!${NC}" - echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[${DOCKER_USERNAME}]${NC}" - exit 1 + error "Failed to get [DOCKER_USERNAME]!${NC}" + fatal "[${DOCKER_USERNAME}]${NC}" else - echo -e "${NC}${F[B]}Successfully found:${F[W]}[DOCKER_USERNAME]${F[B]}, value:${F[W]}[${DOCKER_USERNAME}]${NC}" + notice "Successfully found:${F[W]}[DOCKER_USERNAME]${F[B]}, value:${F[W]}[${DOCKER_USERNAME}]${NC}" fi ############################ # Validate DOCKER_PASSWORD # ############################ if [ -z "${DOCKER_PASSWORD}" ]; then - echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Failed to get [DOCKER_PASSWORD]!${NC}" - echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[${DOCKER_PASSWORD}]${NC}" - exit 1 + error "Failed to get [DOCKER_PASSWORD]!${NC}" + fatal "[${DOCKER_PASSWORD}]${NC}" else - echo -e "${NC}${F[B]}Successfully found:${F[W]}[DOCKER_PASSWORD]${F[B]}, value:${F[B]}[********]${NC}" + notice "Successfully found:${F[W]}[DOCKER_PASSWORD]${F[B]}, value:${F[B]}[********]${NC}" fi ########################################### # We were not passed a registry to update # ########################################### else - echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Failed to find a valid registry!${NC}" - echo "Registry:[${REGISTRY}]" - exit 1 + error "Failed to find a valid registry!${NC}" + fatal "Registry:[${REGISTRY}]" fi ####################### # Validate IMAGE_REPO # ####################### if [ -z "${IMAGE_REPO}" ]; then - echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Failed to get [IMAGE_REPO]!${NC}" - echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[${IMAGE_REPO}]${NC}" - exit 1 + error "Failed to get [IMAGE_REPO]!${NC}" + fatal "[${IMAGE_REPO}]${NC}" else - echo -e "${NC}${F[B]}Successfully found:${F[W]}[IMAGE_REPO]${F[B]}, value:${F[W]}[${IMAGE_REPO}]${NC}" + notice "Successfully found:${F[W]}[IMAGE_REPO]${F[B]}, value:${F[W]}[${IMAGE_REPO}]${NC}" ############################################### # Need to see if GPR registry and update name # ############################################### @@ -158,7 +150,7 @@ ValidateInput() { # Validate IMAGE_VERSION # ########################## if [ -z "${IMAGE_VERSION}" ]; then - echo -e "${NC}${F[Y]}WARN!${NC} Failed to get [IMAGE_VERSION]!${NC}" + warn "Failed to get [IMAGE_VERSION]!${NC}" echo "Pulling from Branch Name..." ############################## # Get the name of the branch # @@ -174,9 +166,8 @@ ValidateInput() { # Check the shell for errors # ############################## if [ ${ERROR_CODE} -ne 0 ]; then - echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Failed to get branch name!${NC}" - echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[${BRANCH_NAME}]${NC}" - exit 1 + error "Failed to get branch name!${NC}" + fatal "[${BRANCH_NAME}]${NC}" fi ################################## @@ -190,7 +181,7 @@ ValidateInput() { IMAGE_VERSION="${BRANCH_NAME}" echo "Tag:[${IMAGE_VERSION}]" else - echo -e "${NC}${F[B]}Successfully found:${F[W]}[IMAGE_VERSION]${F[B]}, value:${F[W]}[${IMAGE_VERSION}]${NC}" + notice "Successfully found:${F[W]}[IMAGE_VERSION]${F[B]}, value:${F[W]}[${IMAGE_VERSION}]${NC}" fi ################################## @@ -221,11 +212,10 @@ ValidateInput() { # Validate DOCKERFILE_PATH # ############################ if [ -z "${DOCKERFILE_PATH}" ]; then - echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Failed to get [DOCKERFILE_PATH]!${NC}" - echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[${DOCKERFILE_PATH}]${NC}" - exit 1 + error "Failed to get [DOCKERFILE_PATH]!${NC}" + fatal "[${DOCKERFILE_PATH}]${NC}" else - echo -e "${NC}${F[B]}Successfully found:${F[W]}[DOCKERFILE_PATH]${F[B]}, value:${F[W]}[${DOCKERFILE_PATH}]${NC}" + notice "Successfully found:${F[W]}[DOCKERFILE_PATH]${F[B]}, value:${F[W]}[${DOCKERFILE_PATH}]${NC}" fi } ################################################################################ @@ -263,12 +253,11 @@ Authenticate() { ############################## if [ ${ERROR_CODE} -ne 0 ]; then # ERROR - echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Failed to authenticate to ${NAME}!${NC}" - echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[${LOGIN_CMD}]${NC}" - exit 1 - else + error "Failed to authenticate to ${NAME}!${NC}" + fatal "[${LOGIN_CMD}]${NC}" +fatal else # SUCCESS - echo -e "${NC}${F[B]}Successfully authenticated to ${F[C]}${NAME}${F[B]}!${NC}" + notice "Successfully authenticated to ${F[C]}${NAME}${F[B]}!${NC}" fi } ################################################################################ @@ -288,10 +277,9 @@ BuildImage() { ################################ if [ ! -f "${DOCKERFILE_PATH}" ]; then # No file found - echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} failed to find Dockerfile at:[${DOCKERFILE_PATH}]${NC}" - echo "Please make sure you give full path!" - echo "Example:[/configs/Dockerfile] or [Dockerfile] if at root directory" - exit 1 + error "failed to find Dockerfile at:[${DOCKERFILE_PATH}]${NC}" + error "Please make sure you give full path!" + fatal "Example:[/configs/Dockerfile] or [Dockerfile] if at root directory" fi ################### @@ -309,11 +297,10 @@ BuildImage() { ############################## if [ ${ERROR_CODE} -ne 0 ]; then # ERROR - echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} failed to [build] Dockerfile!${NC}" - exit 1 + fatal "failed to [build] Dockerfile!${NC}" else # SUCCESS - echo -e "${NC}${F[B]}Successfully Built image!${NC}" + notice "Successfully Built image!${NC}" fi ######################################################## @@ -333,11 +320,10 @@ BuildImage() { ############################## if [ ${ERROR_CODE} -ne 0 ]; then # ERROR - echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} failed to [tag] Dockerfile!${NC}" - exit 1 + fatal "failed to [tag] Dockerfile!${NC}" else # SUCCESS - echo -e "${NC}${F[B]}Successfully tagged image!${NC}" + notice "Successfully tagged image!${NC}" fi fi } @@ -368,11 +354,10 @@ UploadImage() { ############################## if [ ${ERROR_CODE} -ne 0 ]; then # ERROR - echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} failed to [upload] Dockerfile!${NC}" - exit 1 + fatal "failed to [upload] Dockerfile!${NC}" else # SUCCESS - echo -e "${NC}${F[B]}Successfully Uploaded Docker image:${F[W]}[${IMAGE_VERSION}]${F[B]} to ${F[C]}${REGISTRY}${F[B]}!${NC}" + notice "Successfully Uploaded Docker image:${F[W]}[${IMAGE_VERSION}]${F[B]} to ${F[C]}${REGISTRY}${F[B]}!${NC}" fi ######################### @@ -391,9 +376,8 @@ UploadImage() { ############################## if [ ${ERROR_CODE} -ne 0 ]; then # ERROR - echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Failed to get information about built Image!${NC}" - echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[${GET_INFO_CMD}]${NC}" - exit 1 + error "Failed to get information about built Image!${NC}" + fatal "[${GET_INFO_CMD}]${NC}" else ################ # Get the data # @@ -434,11 +418,10 @@ UploadImage() { ############################## if [ ${ERROR_CODE} -ne 0 ]; then # ERROR - echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} failed to [upload] MAJOR_TAG:[${MAJOR_TAG}] Dockerfile!${NC}" - exit 1 + fatal "failed to [upload] MAJOR_TAG:[${MAJOR_TAG}] Dockerfile!${NC}" else # SUCCESS - echo -e "${NC}${F[B]}Successfully Uploaded TAG:${F[W]}[${MAJOR_TAG}]${F[B]} of Docker image to ${F[C]}${REGISTRY}${F[B]}!${NC}" + notice "Successfully Uploaded TAG:${F[W]}[${MAJOR_TAG}]${F[B]} of Docker image to ${F[C]}${REGISTRY}${F[B]}!${NC}" fi fi } @@ -488,9 +471,8 @@ else ######### # ERROR # ######### - echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Registry not set correctly!${NC}" - echo "Registry:[${REGISTRY}]" - exit 1 + error "Registry not set correctly!${NC}" + fatal "Registry:[${REGISTRY}]" fi #################### diff --git a/lib/buildFileList.sh b/lib/buildFileList.sh index 05cdf29f..75d18b4c 100755 --- a/lib/buildFileList.sh +++ b/lib/buildFileList.sh @@ -41,8 +41,7 @@ function BuildFileList() { if [ ${ERROR_CODE} -ne 0 ]; then # Error echo "Failed to switch to ${DEFAULT_BRANCH} branch to get files changed!" - echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[${SWITCH_CMD}]${NC}" - exit 1 + fatal "[${SWITCH_CMD}]${NC}" fi ################ @@ -69,9 +68,8 @@ function BuildFileList() { ############################## if [ ${ERROR_CODE} -ne 0 ]; then # Error - echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Failed to gain a list of all files changed!${NC}" - echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[${RAW_FILE_ARRAY[*]}]${NC}" - exit 1 + error "Failed to gain a list of all files changed!${NC}" + fatal "[${RAW_FILE_ARRAY[*]}]${NC}" fi ################################################ @@ -472,7 +470,7 @@ function BuildFileList() { ####################### # It is a bash script # ####################### - echo -e "${NC}${F[Y]}WARN!${NC} Found bash script without extension:[.sh]${NC}" + warn "Found bash script without extension:[.sh]${NC}" echo "Please update file with proper extensions." ################################ # Append the file to the array # @@ -486,7 +484,7 @@ function BuildFileList() { ####################### # It is a Ruby script # ####################### - echo -e "${NC}${F[Y]}WARN!${NC} Found ruby script without extension:[.rb]${NC}" + warn "Found ruby script without extension:[.rb]${NC}" echo "Please update file with proper extensions." ################################ # Append the file to the array # @@ -500,7 +498,7 @@ function BuildFileList() { ############################ # Extension was not found! # ############################ - echo -e "${NC}${F[Y]} - WARN!${NC} Failed to get filetype for:[${FILE}]!${NC}" + warn "Failed to get filetype for:[${FILE}]!${NC}" ########################################################## # Set the READ_ONLY_CHANGE_FLAG since this could be exec # ########################################################## @@ -526,9 +524,8 @@ function BuildFileList() { ############################## if [ ${ERROR_CODE} -ne 0 ]; then # Error - echo "Failed to switch back to branch!" - echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[${SWITCH2_CMD}]${NC}" - exit 1 + error "Failed to switch back to branch!" + fatal "[${SWITCH2_CMD}]${NC}" fi ################ @@ -536,5 +533,5 @@ function BuildFileList() { ################ echo "" echo "----------------------------------------------" - echo -e "${NC}${F[B]}Successfully gathered list of files...${NC}" + notice "Successfully gathered list of files...${NC}" } diff --git a/lib/linter.sh b/lib/linter.sh index f613ec16..9811ef5a 100755 --- a/lib/linter.sh +++ b/lib/linter.sh @@ -386,12 +386,12 @@ GetLinterVersions() { # Check the shell for errors # ############################## if [ ${ERROR_CODE} -ne 0 ] || [ -z "${GET_VERSION_CMD[*]}" ]; then - echo -e "${NC}[${LINTER}]: ${F[Y]}WARN!${NC} Failed to get version info for:${NC}" + warn "[${LINTER}]: Failed to get version info for:${NC}" else ########################## # Print the version info # ########################## - echo -e "${NC}${F[B]}Successfully found version for ${F[W]}[${LINTER}]${F[B]}: ${F[W]}${GET_VERSION_CMD[*]}${NC}" + notice "Successfully found version for ${F[W]}[${LINTER}]${F[B]}: ${F[W]}${GET_VERSION_CMD[*]}${NC}" fi done @@ -474,9 +474,8 @@ GetStandardRules() { ############################## if [ ${ERROR_CODE} -ne 0 ]; then # ERROR - echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Failed to gain list of ENV vars to load!${NC}" - echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[${GET_ENV_ARRAY[*]}]${NC}" - exit 1 + error "Failed to gain list of ENV vars to load!${NC}" + fatal "[${GET_ENV_ARRAY[*]}]${NC}" fi ########################## @@ -691,8 +690,7 @@ GetGitHubVars() { fi if [ ! -d "${GITHUB_WORKSPACE}" ]; then - echo -e "${NC}${B[R]}${F[W]}ERROR:${NC} Provided volume is not a directory!${NC}" - exit 1 + fatal "Provided volume is not a directory!${NC}" fi echo "Linting all files in mapped directory:[${DEFAULT_WORKSPACE}]" @@ -711,33 +709,30 @@ GetGitHubVars() { # Validate we have a value # ############################ if [ -z "${GITHUB_SHA}" ]; then - echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Failed to get [GITHUB_SHA]!${NC}" - echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[${GITHUB_SHA}]${NC}" - exit 1 + error "Failed to get [GITHUB_SHA]!${NC}" + fatal "[${GITHUB_SHA}]${NC}" else - echo -e "${NC}${F[B]}Successfully found:${F[W]}[GITHUB_SHA]${F[B]}, value:${F[W]}[${GITHUB_SHA}]${NC}" + notice "Successfully found:${F[W]}[GITHUB_SHA]${F[B]}, value:${F[W]}[${GITHUB_SHA}]${NC}" fi ############################ # Validate we have a value # ############################ if [ -z "${GITHUB_WORKSPACE}" ]; then - echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Failed to get [GITHUB_WORKSPACE]!${NC}" - echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[${GITHUB_WORKSPACE}]${NC}" - exit 1 + error "Failed to get [GITHUB_WORKSPACE]!${NC}" + fatal "[${GITHUB_WORKSPACE}]${NC}" else - echo -e "${NC}${F[B]}Successfully found:${F[W]}[GITHUB_WORKSPACE]${F[B]}, value:${F[W]}[${GITHUB_WORKSPACE}]${NC}" + notice "Successfully found:${F[W]}[GITHUB_WORKSPACE]${F[B]}, value:${F[W]}[${GITHUB_WORKSPACE}]${NC}" fi ############################ # Validate we have a value # ############################ if [ -z "${GITHUB_EVENT_PATH}" ]; then - echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Failed to get [GITHUB_EVENT_PATH]!${NC}" - echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[${GITHUB_EVENT_PATH}]${NC}" - exit 1 + error "Failed to get [GITHUB_EVENT_PATH]!${NC}" + fatal "[${GITHUB_EVENT_PATH}]${NC}" else - echo -e "${NC}${F[B]}Successfully found:${F[W]}[GITHUB_EVENT_PATH]${F[B]}, value:${F[W]}[${GITHUB_EVENT_PATH}]${F[B]}${NC}" + notice "Successfully found:${F[W]}[GITHUB_EVENT_PATH]${F[B]}, value:${F[W]}[${GITHUB_EVENT_PATH}]${F[B]}${NC}" fi ################################################## @@ -753,11 +748,10 @@ GetGitHubVars() { # Validate we have a value # ############################ if [ -z "${GITHUB_ORG}" ]; then - echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Failed to get [GITHUB_ORG]!${NC}" - echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[${GITHUB_ORG}]${NC}" - exit 1 + error "Failed to get [GITHUB_ORG]!${NC}" + fatal "[${GITHUB_ORG}]${NC}" else - echo -e "${NC}${F[B]}Successfully found:${F[W]}[GITHUB_ORG]${F[B]}, value:${F[W]}[${GITHUB_ORG}]${NC}" + notice "Successfully found:${F[W]}[GITHUB_ORG]${F[B]}, value:${F[W]}[${GITHUB_ORG}]${NC}" fi ####################### @@ -769,11 +763,10 @@ GetGitHubVars() { # Validate we have a value # ############################ if [ -z "${GITHUB_REPO}" ]; then - echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Failed to get [GITHUB_REPO]!${NC}" - echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[${GITHUB_REPO}]${NC}" - exit 1 + error "Failed to get [GITHUB_REPO]!${NC}" + fatal "[${GITHUB_REPO}]${NC}" else - echo -e "${NC}${F[B]}Successfully found:${F[W]}[GITHUB_REPO]${F[B]}, value:${F[W]}[${GITHUB_REPO}]${NC}" + notice "Successfully found:${F[W]}[GITHUB_REPO]${F[B]}, value:${F[W]}[${GITHUB_REPO}]${NC}" fi fi @@ -781,16 +774,16 @@ GetGitHubVars() { # Validate we have a value # ############################ 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}[${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}" + error "Failed to get [GITHUB_TOKEN]!${NC}" + error "[${GITHUB_TOKEN}]${NC}" + error "Please set a [GITHUB_TOKEN] from the main workflow environment to take advantage of multiple status reports!${NC}" ################################################################################ # Need to set MULTI_STATUS to false as we cant hit API endpoints without token # ################################################################################ MULTI_STATUS='false' else - echo -e "${NC}${F[B]}Successfully found:${F[W]}[GITHUB_TOKEN]${NC}" + notice "Successfully found:${F[W]}[GITHUB_TOKEN]${NC}" fi ############################### @@ -806,22 +799,20 @@ GetGitHubVars() { # Validate we have a value # ############################ if [ -z "${GITHUB_REPOSITORY}" ]; then - echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Failed to get [GITHUB_REPOSITORY]!${NC}" - echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[${GITHUB_REPOSITORY}]${NC}" - exit 1 + error "Failed to get [GITHUB_REPOSITORY]!${NC}" + fatal "[${GITHUB_REPOSITORY}]${NC}" else - echo -e "${NC}${F[B]}Successfully found:${F[W]}[GITHUB_REPOSITORY]${F[B]}, value:${F[W]}[${GITHUB_REPOSITORY}]${NC}" + notice "Successfully found:${F[W]}[GITHUB_REPOSITORY]${F[B]}, value:${F[W]}[${GITHUB_REPOSITORY}]${NC}" fi ############################ # Validate we have a value # ############################ if [ -z "${GITHUB_RUN_ID}" ]; then - echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Failed to get [GITHUB_RUN_ID]!${NC}" - echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[${GITHUB_RUN_ID}]${NC}" - exit 1 + error "Failed to get [GITHUB_RUN_ID]!${NC}" + fatal "[${GITHUB_RUN_ID}]${NC}" else - echo -e "${NC}${F[B]}Successfully found:${F[W]}[GITHUB_RUN_ID]${F[B]}, value:${F[W]}[${GITHUB_RUN_ID}]${NC}" + notice "Successfully found:${F[W]}[GITHUB_RUN_ID]${F[B]}, value:${F[W]}[${GITHUB_RUN_ID}]${NC}" fi fi } @@ -833,16 +824,14 @@ function ValidatePowershellModules() { if [[ ${VALIDATE_PSSA_MODULE} == "PSScriptAnalyzer" ]]; then VALIDATE_PSSA_CMD=$(pwsh -c "(Get-Command Invoke-ScriptAnalyzer | Select-Object -First 1).Name" 2>&1) else - # Failed to find module - exit 1 + fatal "Failed to find module." fi ######################################### # validate we found the script analyzer # ######################################### if [[ ${VALIDATE_PSSA_CMD} != "Invoke-ScriptAnalyzer" ]]; then - # Failed to find module - exit 1 + fatal "Failed to find module." fi ####################### @@ -855,14 +844,13 @@ function ValidatePowershellModules() { ############################## if [ ${ERROR_CODE} -ne 0 ]; then # Failed - echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Failed find module [PSScriptAnalyzer] for [${LINTER_NAME}] in system!${NC}" - echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[PSSA_MODULE ${VALIDATE_PSSA_MODULE}] [PSSA_CMD ${VALIDATE_PSSA_CMD}]${NC}" - exit 1 + error "Failed find module [PSScriptAnalyzer] for [${LINTER_NAME}] in system!${NC}" + fatal "[PSSA_MODULE ${VALIDATE_PSSA_MODULE}] [PSSA_CMD ${VALIDATE_PSSA_CMD}]${NC}" else # Success if [[ ${ACTIONS_RUNNER_DEBUG} == "true" ]]; then - echo -e "${NC}${F[B]}Successfully found module ${F[W]}[${VALIDATE_PSSA_MODULE}]${F[B]} in system${NC}" - echo -e "${NC}${F[B]}Successfully found command ${F[W]}[${VALIDATE_PSSA_CMD}]${F[B]} in system${NC}" + notice "Successfully found module ${F[W]}[${VALIDATE_PSSA_MODULE}]${F[B]} in system${NC}" + notice "Successfully found command ${F[W]}[${VALIDATE_PSSA_CMD}]${F[B]} in system${NC}" fi fi } @@ -944,7 +932,7 @@ Reports() { # Prints for warnings if found # ################################ for TEST in "${WARNING_ARRAY_TEST[@]}"; do - echo -e "${NC}${F[Y]}WARN!${NC} Expected file to compare with was not found for ${TEST}${NC}" + warn "Expected file to compare with was not found for ${TEST}${NC}" done } @@ -981,7 +969,7 @@ Footer() { ################### # Print the goods # ################### - echo -e "${NC}${B[R]}${F[W]}ERRORS FOUND${NC} in ${LANGUAGE}:[${!ERROR_COUNTER}]${NC}" + error "ERRORS FOUND${NC} in ${LANGUAGE}:[${!ERROR_COUNTER}]${NC}" ######################################### # Create status API for Failed language # @@ -1000,7 +988,7 @@ Footer() { # Exit with 0 if errors disabled # ################################## if [ "${DISABLE_ERRORS}" == "true" ]; then - echo -e "${NC}${F[Y]}WARN!${NC} Exiting with exit code:[0] as:[DISABLE_ERRORS] was set to:[${DISABLE_ERRORS}]${NC}" + warn "Exiting with exit code:[0] as:[DISABLE_ERRORS] was set to:[${DISABLE_ERRORS}]${NC}" exit 0 fi @@ -1014,8 +1002,7 @@ Footer() { # Check if error was found if [ "${!ERRORS_FOUND_LANGUAGE}" -ne 0 ]; then # Failed exit - echo -e "${NC}${F[R]}Exiting with errors found!${NC}" - exit 1 + fatal "Exiting with errors found!${NC}" fi done @@ -1023,7 +1010,7 @@ Footer() { # Footer prints Exit 0 # ######################## echo "" - echo -e "${NC}${F[G]}All file(s) linted successfully with no errors detected${NC}" + notice "All file(s) linted successfully with no errors detected${NC}" echo "----------------------------------------------" echo "" # Successful exit @@ -1057,9 +1044,8 @@ Header ############################################################## if [ -n "${OUTPUT_FORMAT}" ]; then if [ -d "${REPORT_OUTPUT_FOLDER}" ] ; then - echo "ERROR! Found ${REPORT_OUTPUT_FOLDER}" - echo "Please remove the folder and try again." - exit 1 + error "ERROR! Found ${REPORT_OUTPUT_FOLDER}" + fatal "Please remove the folder and try again." fi fi diff --git a/lib/worker.sh b/lib/worker.sh index ab23e60f..94fd2add 100755 --- a/lib/worker.sh +++ b/lib/worker.sh @@ -49,13 +49,12 @@ function LintCodebase() { ############################## if [ ${ERROR_CODE} -ne 0 ]; then # Failed - echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Failed to find [${LINTER_NAME}] in system!${NC}" - echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[${VALIDATE_INSTALL_CMD}]${NC}" - exit 1 + error "Failed to find [${LINTER_NAME}] in system!${NC}" + fatal "[${VALIDATE_INSTALL_CMD}]${NC}" else # Success if [[ ${ACTIONS_RUNNER_DEBUG} == "true" ]]; then - echo -e "${NC}${F[B]}Successfully found binary for ${F[W]}[${LINTER_NAME}]${F[B]} in system location: ${F[W]}[${VALIDATE_INSTALL_CMD}]${NC}" + notice "Successfully found binary for ${F[W]}[${LINTER_NAME}]${F[B]} in system location: ${F[W]}[${VALIDATE_INSTALL_CMD}]${NC}" fi fi @@ -226,9 +225,9 @@ function LintCodebase() { ######### # Error # ######### - echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Found errors in [${LINTER_NAME}] linter!${NC}" - echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[${LINT_CMD}]${NC}" - echo -e "${NC}${B[R]}${F[W]}ERROR:${NC} Linter CMD:[${LINTER_COMMAND} ${FILE}]${NC}" + error "Found errors in [${LINTER_NAME}] linter!${NC}" + error "[${LINT_CMD}]${NC}" + error "Linter CMD:[${LINTER_COMMAND} ${FILE}]${NC}" # Increment the error count (("ERRORS_FOUND_${FILE_TYPE}++")) @@ -243,7 +242,7 @@ function LintCodebase() { ########### # Success # ########### - echo -e "${NC}${F[B]} - File:${F[W]}[${FILE_NAME}]${F[B]} was linted with ${F[W]}[${LINTER_NAME}]${F[B]} successfully${NC}" + notice " - File:${F[W]}[${FILE_NAME}]${F[B]} was linted with ${F[W]}[${LINTER_NAME}]${F[B]} successfully${NC}" ####################################################### # Store the linting as a temporary file in TAP format # @@ -302,12 +301,11 @@ function TestCodebase() { ############################## if [ ${ERROR_CODE} -ne 0 ]; then # Failed - echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Failed to find [${LINTER_NAME}] in system!${NC}" - echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[${VALIDATE_INSTALL_CMD}]${NC}" - exit 1 + error "Failed to find [${LINTER_NAME}] in system!${NC}" + fatal "[${VALIDATE_INSTALL_CMD}]${NC}" else # Success - echo -e "${NC}${F[B]}Successfully found binary for ${F[W]}[${LINTER_NAME}]${F[B]} in system location: ${F[W]}[${VALIDATE_INSTALL_CMD}]${NC}" + notice "Successfully found binary for ${F[W]}[${LINTER_NAME}]${F[B]} in system location: ${F[W]}[${VALIDATE_INSTALL_CMD}]${NC}" fi ########################## @@ -454,16 +452,16 @@ function TestCodebase() { ######### # Error # ######### - echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Found errors in [${LINTER_NAME}] linter!${NC}" - echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[${LINT_CMD}]${NC}" - echo -e "${NC}${B[R]}${F[W]}ERROR:${NC} Linter CMD:[${LINTER_COMMAND} ${FILE}]${NC}" + error "Found errors in [${LINTER_NAME}] linter!${NC}" + error "[${LINT_CMD}]${NC}" + error "Linter CMD:[${LINTER_COMMAND} ${FILE}]${NC}" # Increment the error count (("ERRORS_FOUND_${FILE_TYPE}++")) else ########### # Success # ########### - echo -e "${NC}${F[B]} - File:${F[W]}[${FILE_NAME}]${F[B]} was linted with ${F[W]}[${LINTER_NAME}]${F[B]} successfully${NC}" + notice " - File:${F[W]}[${FILE_NAME}]${F[B]} was linted with ${F[W]}[${LINTER_NAME}]${F[B]} successfully${NC}" fi ####################################################### # Store the linting as a temporary file in TAP format # @@ -482,18 +480,18 @@ function TestCodebase() { ######### # Error # ######### - echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Found errors in [${LINTER_NAME}] linter!${NC}" - echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} This file should have failed test case!${NC}" - echo -e "${NC}${B[R]}${F[W]}Command run:${NC}[\$${LINT_CMD}]${NC}" - echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[${LINT_CMD}]${NC}" - echo -e "${NC}${B[R]}${F[W]}ERROR:${NC} Linter CMD:[${LINTER_COMMAND} ${FILE}]${NC}" + error "Found errors in [${LINTER_NAME}] linter!${NC}" + error "This file should have failed test case!${NC}" + error "Command run:${NC}[\$${LINT_CMD}]${NC}" + error "[${LINT_CMD}]${NC}" + error "Linter CMD:[${LINTER_COMMAND} ${FILE}]${NC}" # Increment the error count (("ERRORS_FOUND_${FILE_TYPE}++")) else ########### # Success # ########### - echo -e "${NC}${F[B]} - File:${F[W]}[${FILE_NAME}]${F[B]} failed test case with ${F[W]}[${LINTER_NAME}]${F[B]} successfully${NC}" + notice " - File:${F[W]}[${FILE_NAME}]${F[B]} failed test case with ${F[W]}[${LINTER_NAME}]${F[B]} successfully${NC}" fi ####################################################### # Store the linting as a temporary file in TAP format # @@ -523,16 +521,16 @@ function TestCodebase() { ############################################# # We failed to compare the reporting output # ############################################# - echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Failed to assert TAP output:[${LINTER_NAME}]${NC}"! + error "Failed to assert TAP output:[${LINTER_NAME}]${NC}"! echo "Please validate the asserts!" cat "${TMPFILE}" exit 1 else # Success - echo -e "${NC}${F[B]}Successfully validation in the expected TAP format for ${F[W]}[${LINTER_NAME}]${NC}" + notice "Successfully validation in the expected TAP format for ${F[W]}[${LINTER_NAME}]${NC}" fi else - echo -e "${NC}${F[Y]}WARN!${NC} No TAP expected file found at:[${EXPECTED_FILE}]${NC}" + warn "No TAP expected file found at:[${EXPECTED_FILE}]${NC}" echo "skipping report assertions" ##################################### # Append the file type to the array # @@ -548,9 +546,8 @@ function TestCodebase() { ################################################# # We failed to find files and no tests were ran # ################################################# - echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Failed to find any tests ran for the Linter:[${LINTER_NAME}]${NC}"! - echo "Please validate logic or that tests exist!" - exit 1 + error "Failed to find any tests ran for the Linter:[${LINTER_NAME}]${NC}"! + fatal "Please validate logic or that tests exist!" fi } ################################################################################ @@ -658,14 +655,13 @@ function LintAnsibleFiles() { ############################## if [ ${ERROR_CODE} -ne 0 ]; then # Failed - echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Failed to find ${LINTER_NAME} in system!${NC}" - echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[${VALIDATE_INSTALL_CMD}]${NC}" - exit 1 + error "Failed to find ${LINTER_NAME} in system!${NC}" + fatal "[${VALIDATE_INSTALL_CMD}]${NC}" else # Success if [[ ${ACTIONS_RUNNER_DEBUG} == "true" ]]; then # Success - echo -e "${NC}${F[B]}Successfully found binary in system${NC}" + notice "Successfully found binary in system${NC}" echo "Location:[${VALIDATE_INSTALL_CMD}]" fi fi @@ -777,8 +773,8 @@ function LintAnsibleFiles() { ######### # Error # ######### - echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Found errors in [${LINTER_NAME}] linter!${NC}" - echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[${LINT_CMD}]${NC}" + error "Found errors in [${LINTER_NAME}] linter!${NC}" + error "[${LINT_CMD}]${NC}" # Increment error count ((ERRORS_FOUND_ANSIBLE++)) @@ -794,7 +790,7 @@ function LintAnsibleFiles() { ########### # Success # ########### - echo -e "${NC}${F[B]} - File:${F[W]}[${FILE_NAME}]${F[B]} was linted with ${F[W]}[${LINTER_NAME}]${F[B]} successfully${NC}" + notice " - File:${F[W]}[${FILE_NAME}]${F[B]} was linted with ${F[W]}[${LINTER_NAME}]${F[B]} successfully${NC}" ####################################################### # Store the linting as a temporary file in TAP format # @@ -820,7 +816,7 @@ function LintAnsibleFiles() { ######################## # No Ansible dir found # ######################## - echo -e "${NC}${F[Y]}WARN!${NC} No Ansible base directory found at:[${ANSIBLE_DIRECTORY}]${NC}" + warn "No Ansible base directory found at:[${ANSIBLE_DIRECTORY}]${NC}" echo "skipping ansible lint" fi fi From 008a3057c9c68c5d2305840f25d5cac5bdd42377 Mon Sep 17 00:00:00 2001 From: Eric Nemchik Date: Mon, 27 Jul 2020 16:35:53 -0500 Subject: [PATCH 073/135] Remove trailing NC on log functions --- .automation/cleanup-docker.sh | 32 +++++----- .../templates/ghe-config-apply.sh | 12 ++-- .automation/upload-docker.sh | 58 +++++++++---------- lib/buildFileList.sh | 8 +-- lib/linter.sh | 48 +++++++-------- lib/worker.sh | 38 ++++++------ 6 files changed, 98 insertions(+), 98 deletions(-) diff --git a/.automation/cleanup-docker.sh b/.automation/cleanup-docker.sh index 7910f17b..028a8aa6 100755 --- a/.automation/cleanup-docker.sh +++ b/.automation/cleanup-docker.sh @@ -52,8 +52,8 @@ ValidateInput() { # Validate GITHUB_WORKSPACE # ############################ if [ -z "${GITHUB_WORKSPACE}" ]; then - error "Failed to get [GITHUB_WORKSPACE]!${NC}" - fatal "[${GITHUB_WORKSPACE}]${NC}" + error "Failed to get [GITHUB_WORKSPACE]!" + fatal "[${GITHUB_WORKSPACE}]" else echo "Successfully found:[GITHUB_WORKSPACE], value:[${GITHUB_WORKSPACE}]" fi @@ -63,8 +63,8 @@ ValidateInput() { ####################### if [ -z "${IMAGE_REPO}" ]; then # No repo was pulled - error "Failed to get [IMAGE_REPO]!${NC}" - fatal "[${IMAGE_REPO}]${NC}" + error "Failed to get [IMAGE_REPO]!" + fatal "[${IMAGE_REPO}]" elif [[ ${IMAGE_REPO} == "github/super-linter" ]]; then # Found our main repo echo "Successfully found:[IMAGE_REPO], value:[${IMAGE_REPO}]" @@ -78,8 +78,8 @@ ValidateInput() { # Validate IMAGE_VERSION # ########################## if [ -z "${IMAGE_VERSION}" ]; then - error "Failed to get [IMAGE_VERSION]!${NC}" - fatal "[${IMAGE_VERSION}]${NC}" + error "Failed to get [IMAGE_VERSION]!" + fatal "[${IMAGE_VERSION}]" else echo "Successfully found:[IMAGE_VERSION], value:[${IMAGE_VERSION}]" fi @@ -88,8 +88,8 @@ ValidateInput() { # Validate DOCKER_USERNAME # ############################ if [ -z "${DOCKER_USERNAME}" ]; then - error "Failed to get [DOCKER_USERNAME]!${NC}" - fatal "[${DOCKER_USERNAME}]${NC}" + error "Failed to get [DOCKER_USERNAME]!" + fatal "[${DOCKER_USERNAME}]" else echo "Successfully found:[DOCKER_USERNAME], value:[${DOCKER_USERNAME}]" fi @@ -98,8 +98,8 @@ ValidateInput() { # Validate DOCKER_PASSWORD # ############################ if [ -z "${DOCKER_PASSWORD}" ]; then - error "Failed to get [DOCKER_PASSWORD]!${NC}" - fatal "[${DOCKER_PASSWORD}]${NC}" + error "Failed to get [DOCKER_PASSWORD]!" + fatal "[${DOCKER_PASSWORD}]" else echo "Successfully found:[DOCKER_PASSWORD], value:[********]" fi @@ -148,8 +148,8 @@ LoginToDocker() { ############################## if [ ${ERROR_CODE} -ne 0 ]; then # ERROR - error "Failed to authenticate to DockerHub!${NC}" - fatal "[${LOGIN_CMD}]${NC}" + error "Failed to authenticate to DockerHub!" + fatal "[${LOGIN_CMD}]" else # SUCCESS echo "Successfully authenticated to DockerHub!" @@ -186,8 +186,8 @@ RemoveImage() { ############################## if [ ${ERROR_CODE} -ne 0 ]; then # ERROR - error "Failed to gain token from DockerHub!${NC}" - fatal "[${TOKEN}]${NC}" + error "Failed to gain token from DockerHub!" + fatal "[${TOKEN}]" else # SUCCESS echo "Successfully gained auth token from DockerHub!" @@ -210,8 +210,8 @@ RemoveImage() { ############################## if [ ${ERROR_CODE} -ne 0 ]; then # ERROR - error "Failed to remove tag from DockerHub!${NC}" - fatal "[${REMOVE_CMD}]${NC}" + error "Failed to remove tag from DockerHub!" + fatal "[${REMOVE_CMD}]" else # SUCCESS echo "Successfully [removed] Docker image tag:[${IMAGE_VERSION}] from DockerHub!" diff --git a/.automation/test/ansible/ghe-initialize/templates/ghe-config-apply.sh b/.automation/test/ansible/ghe-initialize/templates/ghe-config-apply.sh index 227caabc..9258978b 100644 --- a/.automation/test/ansible/ghe-initialize/templates/ghe-config-apply.sh +++ b/.automation/test/ansible/ghe-initialize/templates/ghe-config-apply.sh @@ -53,8 +53,8 @@ CheckGHEPid() # Check the shell for errors # ############################## if [ ${ERROR_CODE} -ne 0 ]; then - error "Failed to sleep!${NC}" - error "[${SLEEP_CMD}]${NC}" + error "Failed to sleep!" + error "[${SLEEP_CMD}]" echo "Will try to call apply as last effort..." #################################### # Call config apply as last effort # @@ -117,8 +117,8 @@ CheckGHEProcess() # Check the shell for errors # ############################## if [ ${ERROR_CODE} -ne 0 ]; then - error "Failed to sleep!${NC}" - error "[${SLEEP_CMD}]${NC}" + error "Failed to sleep!" + error "[${SLEEP_CMD}]" echo "Will try to call apply as last effort..." #################################### # Call config apply as last effort # @@ -161,8 +161,8 @@ RunConfigApply() ############################## if [ ${ERROR_CODE} -ne 0 ]; then # Errors - error "Failed to run config apply command!${NC}" - fatal "[${APPLY_CMD}]${NC}" + error "Failed to run config apply command!" + fatal "[${APPLY_CMD}]" else # Success notice "Successfully ran ${F[C]}${GHE_APPLY_COMMAND}${NC}" diff --git a/.automation/upload-docker.sh b/.automation/upload-docker.sh index d4fccdf8..bbb1bae7 100755 --- a/.automation/upload-docker.sh +++ b/.automation/upload-docker.sh @@ -58,8 +58,8 @@ ValidateInput() { # Validate GITHUB_WORKSPACE # ############################# if [ -z "${GITHUB_WORKSPACE}" ]; then - error "Failed to get [GITHUB_WORKSPACE]!${NC}" - fatal "[${GITHUB_WORKSPACE}]${NC}" + error "Failed to get [GITHUB_WORKSPACE]!" + fatal "[${GITHUB_WORKSPACE}]" else notice "Successfully found:${F[W]}[GITHUB_WORKSPACE]${F[B]}, value:${F[W]}[${GITHUB_WORKSPACE}]${NC}" fi @@ -68,8 +68,8 @@ ValidateInput() { # Validate REGISTRY # ##################### if [ -z "${REGISTRY}" ]; then - error "Failed to get [REGISTRY]!${NC}" - fatal "[${REGISTRY}]${NC}" + error "Failed to get [REGISTRY]!" + fatal "[${REGISTRY}]" else notice "Successfully found:${F[W]}[REGISTRY]${F[B]}, value:${F[W]}[${REGISTRY}]${NC}" fi @@ -82,8 +82,8 @@ ValidateInput() { # Validate GPR_USERNAME # ######################### if [ -z "${GPR_USERNAME}" ]; then - error "Failed to get [GPR_USERNAME]!${NC}" - fatal "[${GPR_USERNAME}]${NC}" + error "Failed to get [GPR_USERNAME]!" + fatal "[${GPR_USERNAME}]" else notice "Successfully found:${F[W]}[GPR_USERNAME]${F[B]}, value:${F[W]}[${GPR_USERNAME}]${NC}" fi @@ -92,8 +92,8 @@ ValidateInput() { # Validate GPR_TOKEN # ###################### if [ -z "${GPR_TOKEN}" ]; then - error "Failed to get [GPR_TOKEN]!${NC}" - fatal "[${GPR_TOKEN}]${NC}" + error "Failed to get [GPR_TOKEN]!" + fatal "[${GPR_TOKEN}]" else notice "Successfully found:${F[W]}[GPR_TOKEN]${F[B]}, value:${F[W]}[********]${NC}" fi @@ -105,8 +105,8 @@ ValidateInput() { # Validate DOCKER_USERNAME # ############################ if [ -z "${DOCKER_USERNAME}" ]; then - error "Failed to get [DOCKER_USERNAME]!${NC}" - fatal "[${DOCKER_USERNAME}]${NC}" + error "Failed to get [DOCKER_USERNAME]!" + fatal "[${DOCKER_USERNAME}]" else notice "Successfully found:${F[W]}[DOCKER_USERNAME]${F[B]}, value:${F[W]}[${DOCKER_USERNAME}]${NC}" fi @@ -115,8 +115,8 @@ ValidateInput() { # Validate DOCKER_PASSWORD # ############################ if [ -z "${DOCKER_PASSWORD}" ]; then - error "Failed to get [DOCKER_PASSWORD]!${NC}" - fatal "[${DOCKER_PASSWORD}]${NC}" + error "Failed to get [DOCKER_PASSWORD]!" + fatal "[${DOCKER_PASSWORD}]" else notice "Successfully found:${F[W]}[DOCKER_PASSWORD]${F[B]}, value:${F[B]}[********]${NC}" fi @@ -124,7 +124,7 @@ ValidateInput() { # We were not passed a registry to update # ########################################### else - error "Failed to find a valid registry!${NC}" + error "Failed to find a valid registry!" fatal "Registry:[${REGISTRY}]" fi @@ -132,8 +132,8 @@ ValidateInput() { # Validate IMAGE_REPO # ####################### if [ -z "${IMAGE_REPO}" ]; then - error "Failed to get [IMAGE_REPO]!${NC}" - fatal "[${IMAGE_REPO}]${NC}" + error "Failed to get [IMAGE_REPO]!" + fatal "[${IMAGE_REPO}]" else notice "Successfully found:${F[W]}[IMAGE_REPO]${F[B]}, value:${F[W]}[${IMAGE_REPO}]${NC}" ############################################### @@ -166,8 +166,8 @@ ValidateInput() { # Check the shell for errors # ############################## if [ ${ERROR_CODE} -ne 0 ]; then - error "Failed to get branch name!${NC}" - fatal "[${BRANCH_NAME}]${NC}" + error "Failed to get branch name!" + fatal "[${BRANCH_NAME}]" fi ################################## @@ -212,8 +212,8 @@ ValidateInput() { # Validate DOCKERFILE_PATH # ############################ if [ -z "${DOCKERFILE_PATH}" ]; then - error "Failed to get [DOCKERFILE_PATH]!${NC}" - fatal "[${DOCKERFILE_PATH}]${NC}" + error "Failed to get [DOCKERFILE_PATH]!" + fatal "[${DOCKERFILE_PATH}]" else notice "Successfully found:${F[W]}[DOCKERFILE_PATH]${F[B]}, value:${F[W]}[${DOCKERFILE_PATH}]${NC}" fi @@ -253,8 +253,8 @@ Authenticate() { ############################## if [ ${ERROR_CODE} -ne 0 ]; then # ERROR - error "Failed to authenticate to ${NAME}!${NC}" - fatal "[${LOGIN_CMD}]${NC}" + error "Failed to authenticate to ${NAME}!" + fatal "[${LOGIN_CMD}]" fatal else # SUCCESS notice "Successfully authenticated to ${F[C]}${NAME}${F[B]}!${NC}" @@ -277,7 +277,7 @@ BuildImage() { ################################ if [ ! -f "${DOCKERFILE_PATH}" ]; then # No file found - error "failed to find Dockerfile at:[${DOCKERFILE_PATH}]${NC}" + error "failed to find Dockerfile at:[${DOCKERFILE_PATH}]" error "Please make sure you give full path!" fatal "Example:[/configs/Dockerfile] or [Dockerfile] if at root directory" fi @@ -297,7 +297,7 @@ BuildImage() { ############################## if [ ${ERROR_CODE} -ne 0 ]; then # ERROR - fatal "failed to [build] Dockerfile!${NC}" + fatal "failed to [build] Dockerfile!" else # SUCCESS notice "Successfully Built image!${NC}" @@ -320,7 +320,7 @@ BuildImage() { ############################## if [ ${ERROR_CODE} -ne 0 ]; then # ERROR - fatal "failed to [tag] Dockerfile!${NC}" + fatal "failed to [tag] Dockerfile!" else # SUCCESS notice "Successfully tagged image!${NC}" @@ -354,7 +354,7 @@ UploadImage() { ############################## if [ ${ERROR_CODE} -ne 0 ]; then # ERROR - fatal "failed to [upload] Dockerfile!${NC}" + fatal "failed to [upload] Dockerfile!" else # SUCCESS notice "Successfully Uploaded Docker image:${F[W]}[${IMAGE_VERSION}]${F[B]} to ${F[C]}${REGISTRY}${F[B]}!${NC}" @@ -376,8 +376,8 @@ UploadImage() { ############################## if [ ${ERROR_CODE} -ne 0 ]; then # ERROR - error "Failed to get information about built Image!${NC}" - fatal "[${GET_INFO_CMD}]${NC}" + error "Failed to get information about built Image!" + fatal "[${GET_INFO_CMD}]" else ################ # Get the data # @@ -418,7 +418,7 @@ UploadImage() { ############################## if [ ${ERROR_CODE} -ne 0 ]; then # ERROR - fatal "failed to [upload] MAJOR_TAG:[${MAJOR_TAG}] Dockerfile!${NC}" + fatal "failed to [upload] MAJOR_TAG:[${MAJOR_TAG}] Dockerfile!" else # SUCCESS notice "Successfully Uploaded TAG:${F[W]}[${MAJOR_TAG}]${F[B]} of Docker image to ${F[C]}${REGISTRY}${F[B]}!${NC}" @@ -471,7 +471,7 @@ else ######### # ERROR # ######### - error "Registry not set correctly!${NC}" + error "Registry not set correctly!" fatal "Registry:[${REGISTRY}]" fi diff --git a/lib/buildFileList.sh b/lib/buildFileList.sh index 75d18b4c..71851b2e 100755 --- a/lib/buildFileList.sh +++ b/lib/buildFileList.sh @@ -41,7 +41,7 @@ function BuildFileList() { if [ ${ERROR_CODE} -ne 0 ]; then # Error echo "Failed to switch to ${DEFAULT_BRANCH} branch to get files changed!" - fatal "[${SWITCH_CMD}]${NC}" + fatal "[${SWITCH_CMD}]" fi ################ @@ -68,8 +68,8 @@ function BuildFileList() { ############################## if [ ${ERROR_CODE} -ne 0 ]; then # Error - error "Failed to gain a list of all files changed!${NC}" - fatal "[${RAW_FILE_ARRAY[*]}]${NC}" + error "Failed to gain a list of all files changed!" + fatal "[${RAW_FILE_ARRAY[*]}]" fi ################################################ @@ -525,7 +525,7 @@ function BuildFileList() { if [ ${ERROR_CODE} -ne 0 ]; then # Error error "Failed to switch back to branch!" - fatal "[${SWITCH2_CMD}]${NC}" + fatal "[${SWITCH2_CMD}]" fi ################ diff --git a/lib/linter.sh b/lib/linter.sh index 9811ef5a..7bb5ec81 100755 --- a/lib/linter.sh +++ b/lib/linter.sh @@ -474,8 +474,8 @@ GetStandardRules() { ############################## if [ ${ERROR_CODE} -ne 0 ]; then # ERROR - error "Failed to gain list of ENV vars to load!${NC}" - fatal "[${GET_ENV_ARRAY[*]}]${NC}" + error "Failed to gain list of ENV vars to load!" + fatal "[${GET_ENV_ARRAY[*]}]" fi ########################## @@ -690,7 +690,7 @@ GetGitHubVars() { fi if [ ! -d "${GITHUB_WORKSPACE}" ]; then - fatal "Provided volume is not a directory!${NC}" + fatal "Provided volume is not a directory!" fi echo "Linting all files in mapped directory:[${DEFAULT_WORKSPACE}]" @@ -709,8 +709,8 @@ GetGitHubVars() { # Validate we have a value # ############################ if [ -z "${GITHUB_SHA}" ]; then - error "Failed to get [GITHUB_SHA]!${NC}" - fatal "[${GITHUB_SHA}]${NC}" + error "Failed to get [GITHUB_SHA]!" + fatal "[${GITHUB_SHA}]" else notice "Successfully found:${F[W]}[GITHUB_SHA]${F[B]}, value:${F[W]}[${GITHUB_SHA}]${NC}" fi @@ -719,8 +719,8 @@ GetGitHubVars() { # Validate we have a value # ############################ if [ -z "${GITHUB_WORKSPACE}" ]; then - error "Failed to get [GITHUB_WORKSPACE]!${NC}" - fatal "[${GITHUB_WORKSPACE}]${NC}" + error "Failed to get [GITHUB_WORKSPACE]!" + fatal "[${GITHUB_WORKSPACE}]" else notice "Successfully found:${F[W]}[GITHUB_WORKSPACE]${F[B]}, value:${F[W]}[${GITHUB_WORKSPACE}]${NC}" fi @@ -729,8 +729,8 @@ GetGitHubVars() { # Validate we have a value # ############################ if [ -z "${GITHUB_EVENT_PATH}" ]; then - error "Failed to get [GITHUB_EVENT_PATH]!${NC}" - fatal "[${GITHUB_EVENT_PATH}]${NC}" + error "Failed to get [GITHUB_EVENT_PATH]!" + fatal "[${GITHUB_EVENT_PATH}]" else notice "Successfully found:${F[W]}[GITHUB_EVENT_PATH]${F[B]}, value:${F[W]}[${GITHUB_EVENT_PATH}]${F[B]}${NC}" fi @@ -748,8 +748,8 @@ GetGitHubVars() { # Validate we have a value # ############################ if [ -z "${GITHUB_ORG}" ]; then - error "Failed to get [GITHUB_ORG]!${NC}" - fatal "[${GITHUB_ORG}]${NC}" + error "Failed to get [GITHUB_ORG]!" + fatal "[${GITHUB_ORG}]" else notice "Successfully found:${F[W]}[GITHUB_ORG]${F[B]}, value:${F[W]}[${GITHUB_ORG}]${NC}" fi @@ -763,8 +763,8 @@ GetGitHubVars() { # Validate we have a value # ############################ if [ -z "${GITHUB_REPO}" ]; then - error "Failed to get [GITHUB_REPO]!${NC}" - fatal "[${GITHUB_REPO}]${NC}" + error "Failed to get [GITHUB_REPO]!" + fatal "[${GITHUB_REPO}]" else notice "Successfully found:${F[W]}[GITHUB_REPO]${F[B]}, value:${F[W]}[${GITHUB_REPO}]${NC}" fi @@ -774,9 +774,9 @@ GetGitHubVars() { # Validate we have a value # ############################ if [ -z "${GITHUB_TOKEN}" ] && [[ ${RUN_LOCAL} == "false" ]]; then - error "Failed to get [GITHUB_TOKEN]!${NC}" - error "[${GITHUB_TOKEN}]${NC}" - error "Please set a [GITHUB_TOKEN] from the main workflow environment to take advantage of multiple status reports!${NC}" + error "Failed to get [GITHUB_TOKEN]!" + error "[${GITHUB_TOKEN}]" + error "Please set a [GITHUB_TOKEN] from the main workflow environment to take advantage of multiple status reports!" ################################################################################ # Need to set MULTI_STATUS to false as we cant hit API endpoints without token # @@ -799,8 +799,8 @@ GetGitHubVars() { # Validate we have a value # ############################ if [ -z "${GITHUB_REPOSITORY}" ]; then - error "Failed to get [GITHUB_REPOSITORY]!${NC}" - fatal "[${GITHUB_REPOSITORY}]${NC}" + error "Failed to get [GITHUB_REPOSITORY]!" + fatal "[${GITHUB_REPOSITORY}]" else notice "Successfully found:${F[W]}[GITHUB_REPOSITORY]${F[B]}, value:${F[W]}[${GITHUB_REPOSITORY}]${NC}" fi @@ -809,8 +809,8 @@ GetGitHubVars() { # Validate we have a value # ############################ if [ -z "${GITHUB_RUN_ID}" ]; then - error "Failed to get [GITHUB_RUN_ID]!${NC}" - fatal "[${GITHUB_RUN_ID}]${NC}" + error "Failed to get [GITHUB_RUN_ID]!" + fatal "[${GITHUB_RUN_ID}]" else notice "Successfully found:${F[W]}[GITHUB_RUN_ID]${F[B]}, value:${F[W]}[${GITHUB_RUN_ID}]${NC}" fi @@ -844,8 +844,8 @@ function ValidatePowershellModules() { ############################## if [ ${ERROR_CODE} -ne 0 ]; then # Failed - error "Failed find module [PSScriptAnalyzer] for [${LINTER_NAME}] in system!${NC}" - fatal "[PSSA_MODULE ${VALIDATE_PSSA_MODULE}] [PSSA_CMD ${VALIDATE_PSSA_CMD}]${NC}" + error "Failed find module [PSScriptAnalyzer] for [${LINTER_NAME}] in system!" + fatal "[PSSA_MODULE ${VALIDATE_PSSA_MODULE}] [PSSA_CMD ${VALIDATE_PSSA_CMD}]" else # Success if [[ ${ACTIONS_RUNNER_DEBUG} == "true" ]]; then @@ -969,7 +969,7 @@ Footer() { ################### # Print the goods # ################### - error "ERRORS FOUND${NC} in ${LANGUAGE}:[${!ERROR_COUNTER}]${NC}" + error "ERRORS FOUND${NC} in ${LANGUAGE}:[${!ERROR_COUNTER}]" ######################################### # Create status API for Failed language # @@ -1002,7 +1002,7 @@ Footer() { # Check if error was found if [ "${!ERRORS_FOUND_LANGUAGE}" -ne 0 ]; then # Failed exit - fatal "Exiting with errors found!${NC}" + fatal "Exiting with errors found!" fi done diff --git a/lib/worker.sh b/lib/worker.sh index 94fd2add..6d79ffc8 100755 --- a/lib/worker.sh +++ b/lib/worker.sh @@ -49,8 +49,8 @@ function LintCodebase() { ############################## if [ ${ERROR_CODE} -ne 0 ]; then # Failed - error "Failed to find [${LINTER_NAME}] in system!${NC}" - fatal "[${VALIDATE_INSTALL_CMD}]${NC}" + error "Failed to find [${LINTER_NAME}] in system!" + fatal "[${VALIDATE_INSTALL_CMD}]" else # Success if [[ ${ACTIONS_RUNNER_DEBUG} == "true" ]]; then @@ -225,9 +225,9 @@ function LintCodebase() { ######### # Error # ######### - error "Found errors in [${LINTER_NAME}] linter!${NC}" - error "[${LINT_CMD}]${NC}" - error "Linter CMD:[${LINTER_COMMAND} ${FILE}]${NC}" + error "Found errors in [${LINTER_NAME}] linter!" + error "[${LINT_CMD}]" + error "Linter CMD:[${LINTER_COMMAND} ${FILE}]" # Increment the error count (("ERRORS_FOUND_${FILE_TYPE}++")) @@ -301,8 +301,8 @@ function TestCodebase() { ############################## if [ ${ERROR_CODE} -ne 0 ]; then # Failed - error "Failed to find [${LINTER_NAME}] in system!${NC}" - fatal "[${VALIDATE_INSTALL_CMD}]${NC}" + error "Failed to find [${LINTER_NAME}] in system!" + fatal "[${VALIDATE_INSTALL_CMD}]" else # Success notice "Successfully found binary for ${F[W]}[${LINTER_NAME}]${F[B]} in system location: ${F[W]}[${VALIDATE_INSTALL_CMD}]${NC}" @@ -452,9 +452,9 @@ function TestCodebase() { ######### # Error # ######### - error "Found errors in [${LINTER_NAME}] linter!${NC}" - error "[${LINT_CMD}]${NC}" - error "Linter CMD:[${LINTER_COMMAND} ${FILE}]${NC}" + error "Found errors in [${LINTER_NAME}] linter!" + error "[${LINT_CMD}]" + error "Linter CMD:[${LINTER_COMMAND} ${FILE}]" # Increment the error count (("ERRORS_FOUND_${FILE_TYPE}++")) else @@ -480,11 +480,11 @@ function TestCodebase() { ######### # Error # ######### - error "Found errors in [${LINTER_NAME}] linter!${NC}" - error "This file should have failed test case!${NC}" - error "Command run:${NC}[\$${LINT_CMD}]${NC}" - error "[${LINT_CMD}]${NC}" - error "Linter CMD:[${LINTER_COMMAND} ${FILE}]${NC}" + error "Found errors in [${LINTER_NAME}] linter!" + error "This file should have failed test case!" + error "Command run:${NC}[\$${LINT_CMD}]" + error "[${LINT_CMD}]" + error "Linter CMD:[${LINTER_COMMAND} ${FILE}]" # Increment the error count (("ERRORS_FOUND_${FILE_TYPE}++")) else @@ -655,8 +655,8 @@ function LintAnsibleFiles() { ############################## if [ ${ERROR_CODE} -ne 0 ]; then # Failed - error "Failed to find ${LINTER_NAME} in system!${NC}" - fatal "[${VALIDATE_INSTALL_CMD}]${NC}" + error "Failed to find ${LINTER_NAME} in system!" + fatal "[${VALIDATE_INSTALL_CMD}]" else # Success if [[ ${ACTIONS_RUNNER_DEBUG} == "true" ]]; then @@ -773,8 +773,8 @@ function LintAnsibleFiles() { ######### # Error # ######### - error "Found errors in [${LINTER_NAME}] linter!${NC}" - error "[${LINT_CMD}]${NC}" + error "Found errors in [${LINTER_NAME}] linter!" + error "[${LINT_CMD}]" # Increment error count ((ERRORS_FOUND_ANSIBLE++)) From 4362d5cd9f352b1049bebc182c55a8a5008ba63c Mon Sep 17 00:00:00 2001 From: Gabo Date: Tue, 21 Jul 2020 19:55:39 -0500 Subject: [PATCH 074/135] Add python vars and sort alphabetically --- Dockerfile | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Dockerfile b/Dockerfile index 2aa7dec9..a3f331d3 100644 --- a/Dockerfile +++ b/Dockerfile @@ -247,6 +247,8 @@ ENV ACTIONS_RUNNER_DEBUG=${ACTIONS_RUNNER_DEBUG} \ VALIDATE_POWERSHELL=${VALIDATE_POWERSHELL} \ VALIDATE_PROTOBUF=${VALIDATE_PROTOBUF} \ VALIDATE_PYTHON=${VALIDATE_PYTHON} \ + VALIDATE_PYTHON_PYLINT=${VALIDATE_PYTHON_PYLINT} \ + VALIDATE_PYTHON_FLAKE8=${VALIDATE_PYTHON_FLAKE8} \ VALIDATE_RAKU=${VALIDATE_RAKU} \ VALIDATE_RUBY=${VALIDATE_RUBY} \ VALIDATE_STATES=${VALIDATE_STATES} \ @@ -257,6 +259,7 @@ ENV ACTIONS_RUNNER_DEBUG=${ACTIONS_RUNNER_DEBUG} \ VALIDATE_XML=${VALIDATE_XML} \ VALIDATE_YAML=${VALIDATE_YAML} + ############################# # Copy scripts to container # ############################# From 0ca744a9c70568603a44a2939cf2f0fd3d301cf6 Mon Sep 17 00:00:00 2001 From: Gabo Date: Tue, 21 Jul 2020 19:55:56 -0500 Subject: [PATCH 075/135] Add flake8 dependency --- dependencies/Pipfile | 1 + dependencies/Pipfile.lock | 35 ++++++++++++++++++++++++++++++++++- 2 files changed, 35 insertions(+), 1 deletion(-) diff --git a/dependencies/Pipfile b/dependencies/Pipfile index dbc906c9..0fcce921 100644 --- a/dependencies/Pipfile +++ b/dependencies/Pipfile @@ -11,6 +11,7 @@ pylint = "*" yq = "*" cfn-lint = "*" terrascan = "*" +flake8 = "*" [requires] python_version = "3.8" diff --git a/dependencies/Pipfile.lock b/dependencies/Pipfile.lock index 32180e96..962c1041 100644 --- a/dependencies/Pipfile.lock +++ b/dependencies/Pipfile.lock @@ -1,7 +1,7 @@ { "_meta": { "hash": { - "sha256": "c62b95247cb67b10711da0012966cc031d5a9ec08885a45736c0ee77bba3a844" + "sha256": "f8ea3853c4bb4533103043533d08982436551678c827f59809c94bf0ee54a187" }, "pipfile-spec": 6, "requires": { @@ -28,6 +28,7 @@ "sha256:2f4078c2a41bf377eea06d71c9d2ba4eb8f6b1af2135bec27bbbb7d8f12bb703", "sha256:bc58d83eb610252fd8de6363e39d4f1d0619c894b0ed24603b881c02e64c7386" ], + "markers": "python_version >= '3.5'", "version": "==2.4.2" }, "attrs": { @@ -35,6 +36,7 @@ "sha256:08a96c641c3a74e44eb59afb61a24f2cb9f4d7188748e76ba4bb5edfa3cb7d1c", "sha256:f7b7ce16570fe9965acd6d30101a28f62fb4a7f9e926b3bbc9b61f8b04247e72" ], + "markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3'", "version": "==19.3.0" }, "aws-sam-translator": { @@ -80,13 +82,23 @@ "sha256:9e4d7ecfc600058e07ba661411a2b7de2fd0fafa17d1a7f7361cd47b1175c827", "sha256:a2aeea129088da402665e92e0b25b04b073c04b2dce4ab65caaa38b7ce2e1a99" ], + "markers": "python_version >= '2.6' and python_version not in '3.0, 3.1, 3.2'", "version": "==0.15.2" }, + "flake8": { + "hashes": [ + "sha256:15e351d19611c887e482fb960eae4d44845013cc142d42896e9862f775d8cf5c", + "sha256:f04b9fcbac03b0a3e58c0ab3a0ecc462e023a9faf046d57794184028123aa208" + ], + "index": "pypi", + "version": "==3.8.3" + }, "isort": { "hashes": [ "sha256:54da7e92468955c4fceacd0c86bd0ec997b0e1ee80d97f67c35a78b719dccab1", "sha256:6e811fcb295968434526407adb8796944f1988c5b65e8139058f2014cbe100fd" ], + "markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3'", "version": "==4.3.21" }, "jmespath": { @@ -94,6 +106,7 @@ "sha256:b85d0567b8666149a93172712e68920734333c0ce7e89b78b3e987f71e5ed4f9", "sha256:cdf6525904cc597730141d61b36f2e4b8ecc257c420fa2f4549bac2c2d0cb72f" ], + "markers": "python_version >= '2.6' and python_version not in '3.0, 3.1, 3.2'", "version": "==0.10.0" }, "jsonpatch": { @@ -109,6 +122,7 @@ "sha256:c192ba86648e05fdae4f08a17ec25180a9aef5008d973407b581798a83975362", "sha256:ff379fa021d1b81ab539f5ec467c7745beb1a5671463f9dcc2b2d458bd361c1e" ], + "markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3'", "version": "==2.0" }, "jsonschema": { @@ -148,6 +162,7 @@ "sha256:efa1909120ce98bbb3777e8b6f92237f5d5c8ea6758efea36a473e1d38f7d3e4", "sha256:f3900e8a5de27447acbf900b4750b0ddfd7ec1ea7fbaf11dfa911141bc522af0" ], + "markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3'", "version": "==1.4.3" }, "mccabe": { @@ -172,6 +187,22 @@ ], "version": "==0.8.0" }, + "pycodestyle": { + "hashes": [ + "sha256:2295e7b2f6b5bd100585ebcb1f616591b652db8a741695b3d8f5d28bdc934367", + "sha256:c58a7d2815e0e8d7972bf1803331fb0152f867bd89adf8a01dfd55085434192e" + ], + "markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3'", + "version": "==2.6.0" + }, + "pyflakes": { + "hashes": [ + "sha256:0d94e0e05a19e57a99444b6ddcf9a6eb2e5c68d3ca1e98e90707af8152c90a92", + "sha256:35b2d75ee967ea93b55750aa9edbbf72813e06a66ba54438df2cfac9e3c27fc8" + ], + "markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3'", + "version": "==2.2.0" + }, "pyhcl": { "hashes": [ "sha256:2d9b9dcdf1023d812bfed561ba72c99104c5b3f52e558d595130a44ce081b003" @@ -197,6 +228,7 @@ "sha256:73ebfe9dbf22e832286dafa60473e4cd239f8592f699aa5adaf10050e6e1823c", "sha256:75bb3f31ea686f1197762692a9ee6a7550b59fc6ca3a1f4b5d7e32fb98e2da2a" ], + "markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2'", "version": "==2.8.1" }, "pyyaml": { @@ -228,6 +260,7 @@ "sha256:30639c035cdb23534cd4aa2dd52c3bf48f06e5f4a941509c8bafd8ce11080259", "sha256:8b74bedcbbbaca38ff6d7491d76f2b06b3592611af620f8426e82dddb04a5ced" ], + "markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2'", "version": "==1.15.0" }, "terrascan": { From 794c61483616d73766a3bd5528d8d666d10a9d6f Mon Sep 17 00:00:00 2001 From: Gabo Date: Tue, 21 Jul 2020 19:57:21 -0500 Subject: [PATCH 076/135] Add python vars --- lib/buildFileList.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/buildFileList.sh b/lib/buildFileList.sh index 05cdf29f..7e1ad63e 100755 --- a/lib/buildFileList.sh +++ b/lib/buildFileList.sh @@ -263,7 +263,8 @@ function BuildFileList() { ################################ # Append the file to the array # ################################ - FILE_ARRAY_PYTHON+=("${FILE}") + FILE_ARRAY_PYTHON_PYLINT+=("${FILE}") + FILE_ARRAY_PYTHON_FLAKE8+=("${FILE}") ########################################################## # Set the READ_ONLY_CHANGE_FLAG since this could be exec # ########################################################## From 1fce9458ce6f78f201f12d42f92e4be95c6fef7f Mon Sep 17 00:00:00 2001 From: Gabo Date: Tue, 21 Jul 2020 19:58:23 -0500 Subject: [PATCH 077/135] Sort alphabetically and configs for python flake8 --- lib/linter.sh | 55 ++++++++++++++++++++++++++++++++------------------- 1 file changed, 35 insertions(+), 20 deletions(-) diff --git a/lib/linter.sh b/lib/linter.sh index 5ccbafaf..4a10072b 100755 --- a/lib/linter.sh +++ b/lib/linter.sh @@ -78,8 +78,10 @@ POWERSHELL_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${POWERSHELL_FILE_NAME}" PROTOBUF_FILE_NAME='.protolintrc.yml' # Name of the file PROTOBUF_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${PROTOBUF_FILE_NAME}" # Path to the Protocol Buffers lint rules # Python Vars -PYTHON_FILE_NAME='.python-lint' # Name of the file -PYTHON_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${PYTHON_FILE_NAME}" # Path to the python lint rules +PYTHON_PYLINT_FILE_NAME="${PYTHON_PYLINT_CONFIG_FILE:-.python-lint}" # Name of the file +PYTHON_PYLINT_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${PYTHON_PYLINT_FILE_NAME}" # Path to the python lint rules +PYTHON_FLAKE8_FILE_NAME="${PYTHON_FLAKE8_CONFIG_FILE:-.flake8}" # Name of the file +PYTHON_FLAKE8_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${PYTHON_FLAKE8_FILE_NAME}" # Path to the python lint rules # Ruby Vars RUBY_FILE_NAME="${RUBY_CONFIG_FILE:-.ruby-lint.yml}" # Name of the file RUBY_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${RUBY_FILE_NAME}" # Path to the ruby lint rules @@ -97,22 +99,20 @@ YAML_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${YAML_FILE_NAME}" ####################################### # Linter array for information prints # ####################################### -LINTER_ARRAY=('ansible-lint' 'arm-ttk' 'asl-validator' 'cfn-lint' 'clj-kondo' - 'coffeelint' 'dart' 'dockerfilelint' 'dotenv-linter' 'eslint' 'golangci-lint' - 'htmlhint' 'jsonlint' 'ktlint' 'lua' 'markdownlint' 'npm-groovy-lint' 'perl' - 'protolint' 'pwsh' 'pylint' 'raku' 'rubocop' 'shellcheck' 'spectral' - 'standard' 'stylelint' 'terrascan' 'tflint' 'xmllint' 'yamllint') - +LINTER_ARRAY=('ansible-lint' 'arm-ttk' 'asl-validator' 'cfn-lint' 'clj-kondo' 'coffeelint' + 'dart' 'dockerfilelint' 'dotenv-linter' 'eslint' 'flake8' 'golangci-lint' 'htmlhint' + 'jsonlint' 'ktlint' 'lua' 'markdownlint' 'npm-groovy-lint' 'perl' 'protolint' 'pwsh' + 'pylint' 'raku' 'rubocop' 'shellcheck' 'spectral' 'standard' 'stylelint' 'terrascan' + 'tflint' 'xmllint' 'yamllint') ############################# # Language array for prints # ############################# -LANGUAGE_ARRAY=('ANSIBLE' 'ARM' 'BASH' 'CLOUDFORMATION' 'CLOJURE' 'COFFEESCRIPT' - 'CSS' 'DART' 'DOCKER' 'ENV' 'GO' 'GROOVY' 'HTML' 'JAVASCRIPT_ES' - 'JAVASCRIPT_STANDARD' 'JSON' 'JSX' 'KOTLIN' 'LUA' 'MARKDOWN' 'OPENAPI' - 'PERL' 'PHP' 'POWERSHELL' 'PROTOBUF' 'PYTHON' - 'RAKU' 'RUBY' 'STATES' 'TERRAFORM' 'TERRAFORM_TERRASCAN' 'TSX' 'TYPESCRIPT_ES' - 'TYPESCRIPT_STANDARD' 'XML' 'YAML') +LANGUAGE_ARRAY=('ANSIBLE' 'ARM' 'BASH' 'CLOUDFORMATION' 'CLOJURE' 'COFFEESCRIPT' 'CSS' + 'DART' 'DOCKER' 'ENV' 'GO' 'GROOVY' 'HTML' 'JAVASCRIPT_ES' 'JAVASCRIPT_STANDARD' + 'JSON' 'JSX' 'KOTLIN' 'LUA' 'MARKDOWN' 'OPENAPI' 'PERL' 'PHP' 'POWERSHELL' + 'PROTOBUF' 'PYTHON_PYLINT' 'PYTHON_FLAKE8' 'RAKU' 'RUBY' 'STATES' 'TERRAFORM' + 'TERRAFORM_TERRASCAN' 'TSX' 'TYPESCRIPT_ES' 'TYPESCRIPT_STANDARD' 'XML' 'YML') ############################################ # Array for all languages that were linted # @@ -160,7 +160,8 @@ VALIDATE_OPENAPI="${VALIDATE_OPENAPI}" # Boolean to vali VALIDATE_PERL="${VALIDATE_PERL}" # Boolean to validate language VALIDATE_PHP="${VALIDATE_PHP}" # Boolean to validate language VALIDATE_POWERSHELL="${VALIDATE_POWERSHELL}" # Boolean to validate language -VALIDATE_PYTHON="${VALIDATE_PYTHON}" # Boolean to validate language +VALIDATE_PYTHON_PYLINT="${VALIDATE_PYTHON:-}" # Boolean to validate language +VALIDATE_PYTHON_FLAKE8="${VALIDATE_PYTHON_FLAKE8}" # Boolean to validate language VALIDATE_RAKU="${VALIDATE_RAKU}" # Boolean to validate language VALIDATE_RUBY="${VALIDATE_RUBY}" # Boolean to validate language VALIDATE_STATES="${VALIDATE_STATES}" # Boolean to validate language @@ -238,7 +239,8 @@ FILE_ARRAY_PERL=() # Array of files to check FILE_ARRAY_PHP=() # Array of files to check FILE_ARRAY_POWERSHELL=() # Array of files to check FILE_ARRAY_PROTOBUF=() # Array of files to check -FILE_ARRAY_PYTHON=() # Array of files to check +FILE_ARRAY_PYTHON_PYLINT=() # Array of files to check +FILE_ARRAY_PYTHON_FLAKE8=() # Array of files to check FILE_ARRAY_RAKU=() # Array of files to check FILE_ARRAY_RUBY=() # Array of files to check FILE_ARRAY_STATES=() # Array of files to check @@ -302,8 +304,10 @@ ERRORS_FOUND_POWERSHELL=0 # Count of errors found export ERRORS_FOUND_POWERSHELL # Workaround SC2034 ERRORS_FOUND_PROTOBUF=0 # Count of errors found export ERRORS_FOUND_PROTOBUF # Workaround SC2034 -ERRORS_FOUND_PYTHON=0 # Count of errors found -export ERRORS_FOUND_PYTHON # Workaround SC2034 +ERRORS_FOUND_PYTHON_PYLINT=0 # Count of errors found +export ERRORS_FOUND_PYTHON_PYLINT # Workaround SC2034 +ERRORS_FOUND_PYTHON_FLAKE8=0 # Count of errors found +export ERRORS_FOUND_PYTHON_FLAKE8 # Workaround SC2034 ERRORS_FOUND_RAKU=0 # Count of errors found export ERRORS_FOUND_RAKU # Workaround SC2034 ERRORS_FOUND_RUBY=0 # Count of errors found @@ -1511,12 +1515,23 @@ fi ################## # PYTHON LINTING # ################## -if [ "${VALIDATE_PYTHON}" == "true" ]; then +if [ "${VALIDATE_PYTHON_PYLINT}" == "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[@]}" + LintCodebase "PYTHON" "pylint" "pylint --rcfile ${PYTHON_PYLINT_LINTER_RULES}" ".*\.\(py\)\$" "${FILE_ARRAY_PYTHON_PYLINT[@]}" +fi + +################## +# PYTHON LINTING # +################## +if [ "${VALIDATE_PYTHON_FLAKE8}" == "true" ]; then + ######################### + # Lint the python files # + ######################### + # LintCodebase "FILE_TYPE" "LINTER_NAME" "LINTER_CMD" "FILE_TYPES_REGEX" "FILE_ARRAY" + LintCodebase "PYTHON" "flake8" "flake8 --config=${PYTHON_FLAKE8_LINTER_RULES}" ".*\.\(py\)\$" "${FILE_ARRAY_PYTHON_FLAKE8[@]}" fi ################ From f372e4668b7a661eff017d44c62c26faa83176f5 Mon Sep 17 00:00:00 2001 From: Gabo Date: Tue, 21 Jul 2020 19:59:05 -0500 Subject: [PATCH 078/135] Add python flake8 worker --- lib/worker.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/worker.sh b/lib/worker.sh index ab23e60f..7a9ddc59 100755 --- a/lib/worker.sh +++ b/lib/worker.sh @@ -602,7 +602,8 @@ function RunTestCases() { TestCodebase "OPENAPI" "spectral" "spectral lint -r ${OPENAPI_LINTER_RULES}" ".*\.\(ymlopenapi\|jsonopenapi\)\$" "openapi" TestCodebase "POWERSHELL" "pwsh" "Invoke-ScriptAnalyzer -EnableExit -Settings ${POWERSHELL_LINTER_RULES} -Path" ".*\.\(ps1\|psm1\|psd1\|ps1xml\|pssc\|psrc\|cdxml\)\$" "powershell" TestCodebase "PROTOBUF" "protolint" "protolint lint --config_path ${PROTOBUF_LINTER_RULES}" ".*\.\(proto\)\$" "protobuf" - TestCodebase "PYTHON" "pylint" "pylint --rcfile ${PYTHON_LINTER_RULES}" ".*\.\(py\)\$" "python" + TestCodebase "PYTHON_PYLINT" "pylint" "pylint --rcfile ${PYTHON_PYLINT_LINTER_RULES}" ".*\.\(py\)\$" "python" + TestCodebase "PYTHON_FLAKE8" "flake8" "flake8 --config ${PYTHON_FLAKE8_LINTER_RULES}" ".*\.\(py\)\$" "python" TestCodebase "RAKU" "raku" "raku -c" ".*\.\(raku\|rakumod\|rakutest\|pm6\|pl6\|p6\)\$" "raku" TestCodebase "RUBY" "rubocop" "rubocop -c ${RUBY_LINTER_RULES}" ".*\.\(rb\)\$" "ruby" TestCodebase "STATES" "asl-validator" "asl-validator --json-path" ".*\.\(json\)\$" "states" From 6c2e32ce14c7334f48637dfe46745d534bd7f99e Mon Sep 17 00:00:00 2001 From: Gabo Date: Tue, 21 Jul 2020 19:54:30 -0500 Subject: [PATCH 079/135] Fix python test for flake8 --- .automation/test/python/python_good_1.py | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/.automation/test/python/python_good_1.py b/.automation/test/python/python_good_1.py index e894c36f..a2f7c3e6 100644 --- a/.automation/test/python/python_good_1.py +++ b/.automation/test/python/python_good_1.py @@ -3,9 +3,9 @@ from os import getenv, path from pprint import pprint import sys -import click # pylint: disable=import-error -from dotenv import load_dotenv # pylint: disable=import-error -import requests # pylint: disable=import-error +import click # pylint: disable=import-error +from dotenv import load_dotenv # pylint: disable=import-error +import requests # pylint: disable=import-error env = load_dotenv() api_url = getenv('API_URL', default='https://api.github.com/graphql') @@ -13,8 +13,8 @@ github_token = getenv("GITHUB_TOKEN", default=None) if github_token is None: sys.exit("GitHub Token is not set." + - "Please set the GITHUB_TOKEN env variable in your system or " + - "the .env file of your project.") + "Please set the GITHUB_TOKEN env variable in your system or " + + "the .env file of your project.") client_id = getenv('CLIENT_ID', default='copy_labels.py') headers = { @@ -23,6 +23,7 @@ headers = { 'Content-Type': 'application/json' } + def create_label(repo_id, label): """ Create label in the supplied repo. @@ -52,6 +53,7 @@ def create_label(repo_id, label): return response + def get_labels(owner, repo): """ Gets a list of labels from the supplied repo. @@ -62,7 +64,7 @@ def get_labels(owner, repo): :return: A tuple with the GitHub id for the repository and a list of labels defined in the repository """ - query_variables = { "owner": owner, "name": repo, } + query_variables = {"owner": owner, "name": repo, } with open(path.join(path.dirname(__file__), 'queries/get_repo_data.gql'), 'r') as query_file: query = "".join(query_file.readlines()) @@ -83,6 +85,7 @@ def get_labels(owner, repo): '[ERROR] getting issue labels. Status Code: {status_code} - Message: {result}'.format( status_code=status_code, result=result["message"])) + def delete_label(label_id): """ Delete the specified label @@ -106,6 +109,7 @@ def delete_label(label_id): return result + @click.command() @click.option('--dry', is_flag=True) @click.argument('source_repo') @@ -149,7 +153,8 @@ def copy_labels(source_repo, target_repo, dry): print('Done') + if __name__ == "__main__": # Pylint doesn't know that @click.command takes care of injecting the # function parameters. Disabling Pylint error. - copy_labels() # pylint: disable=no-value-for-parameter + copy_labels() # pylint: disable=no-value-for-parameter From 3f5c87705974efa02f04c94960e4bf3db0fe00f4 Mon Sep 17 00:00:00 2001 From: Gabo Date: Tue, 21 Jul 2020 21:47:48 -0500 Subject: [PATCH 080/135] Add flake template --- TEMPLATES/.flake8 | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 TEMPLATES/.flake8 diff --git a/TEMPLATES/.flake8 b/TEMPLATES/.flake8 new file mode 100644 index 00000000..79a16af7 --- /dev/null +++ b/TEMPLATES/.flake8 @@ -0,0 +1,2 @@ +[flake8] +max-line-length = 120 \ No newline at end of file From 925f12a67866ae4a99d1352df7e29a24d3a7e244 Mon Sep 17 00:00:00 2001 From: Gabo Date: Wed, 22 Jul 2020 13:24:37 -0500 Subject: [PATCH 081/135] Add line at EOF --- TEMPLATES/.flake8 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/TEMPLATES/.flake8 b/TEMPLATES/.flake8 index 79a16af7..6deafc26 100644 --- a/TEMPLATES/.flake8 +++ b/TEMPLATES/.flake8 @@ -1,2 +1,2 @@ [flake8] -max-line-length = 120 \ No newline at end of file +max-line-length = 120 From 675b42880e2c4d6cbb8f00db7218ccbd59b43b45 Mon Sep 17 00:00:00 2001 From: Gabo Date: Wed, 22 Jul 2020 13:30:40 -0500 Subject: [PATCH 082/135] Add glake8 to .github/linters --- .github/linters/.flake8 | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 .github/linters/.flake8 diff --git a/.github/linters/.flake8 b/.github/linters/.flake8 new file mode 100644 index 00000000..6deafc26 --- /dev/null +++ b/.github/linters/.flake8 @@ -0,0 +1,2 @@ +[flake8] +max-line-length = 120 From 107bd8eea4a6dd54ebef14af563f1a3a7dd20b9c Mon Sep 17 00:00:00 2001 From: Gabo Date: Wed, 22 Jul 2020 14:04:55 -0500 Subject: [PATCH 083/135] Update docs --- README.md | 5 +- docs/disabling-linters.md | 1778 +++++++++++++++++++------------------ 2 files changed, 910 insertions(+), 873 deletions(-) diff --git a/README.md b/README.md index 4c09d542..d90ac812 100644 --- a/README.md +++ b/README.md @@ -66,7 +66,7 @@ Developers on **GitHub** can call the **GitHub Action** to lint their code base | **PHP** | [PHP](https://www.php.net/) | | **PowerShell** | [PSScriptAnalyzer](https://github.com/PowerShell/Psscriptanalyzer) | | **Protocol Buffers** | [protolint](https://github.com/yoheimuta/protolint) | -| **Python3** | [pylint](https://www.pylint.org/) | +| **Python3** | [pylint](https://www.pylint.org/) [flake8](https://flake8.pycqa.org/en/latest/) | | **Raku** | [raku](https://raku.org) | | **Ruby** | [RuboCop](https://github.com/rubocop-hq/rubocop) | | **Shell** | [Shellcheck](https://github.com/koalaman/shellcheck) | @@ -208,7 +208,8 @@ and won't run anything unexpected. | **VALIDATE_PERL** | `true` | Flag to enable or disable the linting process of the Perl language. | | **VALIDATE_PHP** | `true` | Flag to enable or disable the linting process of the PHP language. | | **VALIDATE_PROTOBUF** | `true` | Flag to enable or disable the linting process of the Protobuf language. | -| **VALIDATE_PYTHON** | `true` | Flag to enable or disable the linting process of the Python language. | +| **VALIDATE_PYTHON_PYLINT** | `true` | Flag to enable or disable the linting process of the Python language. (Utilizing: pylint) | +| **VALIDATE_PYTHON_FLAKE8** | `true` | Flag to enable or disable the linting process of the Python language. (Utilizing: flake8) | | **VALIDATE_POWERSHELL** | `true` | Flag to enable or disable the linting process of the Powershell language. | | **VALIDATE_RAKU** | `true` | Flag to enable or disable the linting process of the Raku language. | | **VALIDATE_RUBY** | `true` | Flag to enable or disable the linting process of the Ruby language. | diff --git a/docs/disabling-linters.md b/docs/disabling-linters.md index fbdb578e..599bf126 100644 --- a/docs/disabling-linters.md +++ b/docs/disabling-linters.md @@ -14,40 +14,862 @@ For some linters it is also possible to override rules on a case by case level w ## Table of Linters -- [Ruby](#ruby) -- [Shell](#shell) -- [Ansible](#ansible) -- [YAML](#yaml) -- [AWS CloudFormation templates](#aws-cloud-formation) -- [Python](#python3) -- [JSON](#json) -- [Markdown](#markdown) -- [Perl](#perl) -- [Raku](#raku) -- [PHP](#php) -- [XML](#xml) -- [Coffeescript](#coffeescript) -- [Javascript Eslint](#javascript-eslint) -- [Javascript Standard](#javascript-standard) -- [Typescript Eslint](#typescript-eslint) -- [Typescript Standard](#typescript-standard) -- [Golang](#golang) -- [Groovy](#groovy) -- [Dockerfile](#dockerfile) -- [Terraform](#terraform) -- [CSS](#css) -- [DART](#dart) -- [ENV](#dotenv-linter) -- [Kotlin](#kotlin) -- [OpenAPI](#openapi) -- [Protocol Buffers](#protocol-buffers) -- [Clojure](#clojure) -- [EDITORCONFIG-CHECKER](#editorconfig-checker) -- [HTML](#html) -- [LUA](#lua) +- [Disabling linters and Rules](#disabling-linters-and-rules) + - [Table of Linters](#table-of-linters) + - [Ansible](#ansible) + - [AWS CloudFormation templates](#aws-cloudformation-templates) + - [Clojure](#clojure) + - [Coffeescript](#coffeescript) + - [CSS](#css) + - [Dart](#dart) + - [Dockerfile](#dockerfile) + - [EDITORCONFIG-CHECKER](#editorconfig-checker) + - [ENV](#env) + - [Golang](#golang) + - [Groovy](#groovy) + - [HTML](#html) + - [Javascript eslint](#javascript-eslint) + - [Javascript standard](#javascript-standard) + - [JSON](#json) + - [Kotlin](#kotlin) + - [Lua](#lua) + - [Markdown](#markdown) + - [OpenAPI](#openapi) + - [Perl](#perl) + - [PHP](#php) + - [Protocol Buffers](#protocol-buffers) + - [Python3 pylint](#python3-pylint) + - [Python3 flake8](#python3-flake8) + - [Raku](#raku) + - [Ruby](#ruby) + - [Shell](#shell) + - [Terraform](#terraform) + - [Typescript eslint](#typescript-eslint) + - [Typescript standard](#typescript-standard) + - [XML](#xml) + - [YAML](#yaml) +--- + +## Ansible + +- [ansible-lint](https://github.com/ansible/ansible-lint) + +### Ansible-lint Config file + +- `.github/linters/.ansible-lint.yml` +- You can pass multiple rules and overwrite default rules +- File should be located at: `.github/linters/.ansible-lint.yml` + +### Ansible-lint disable single line + +```yml +- name: this would typically fire GitHasVersionRule 401 and BecomeUserWithoutBecomeRule 501 + become_user: alice # noqa 401 501 + git: src=/path/to/git/repo dest=checkout +``` + +### Ansible-lint disable code block + +```yml +- name: this would typically fire GitHasVersionRule 401 + git: src=/path/to/git/repo dest=checkout + tags: + - skip_ansible_lint +``` + +### Ansible-lint disable entire file + +```yml +- name: this would typically fire GitHasVersionRule 401 + git: src=/path/to/git/repo dest=checkout + tags: + - skip_ansible_lint +``` + +--- + +## AWS CloudFormation templates + +- [cfn-lint](https://github.com/aws-cloudformation/cfn-python-lint/) + +### cfn-lint Config file + +- `.github/linters/.cfnlintrc.yml` +- You can pass multiple rules and overwrite default rules +- File should be located at: `.github/linters/.cfnlintrc.yml` + +### cfn-lint disable single line + +- There is currently **No** way to disable rules inline of the file(s) + +### cfn-lint disable code block + +You can disable both [template](https://github.com/aws-cloudformation/cfn-python-lint/#template-based-metadata) or [resource](https://github.com/aws-cloudformation/cfn-python-lint/#resource-based-metadata) via [metadata](https://github.com/aws-cloudformation/cfn-python-lint/#metadata): + +```yaml +Resources: + myInstance: + Type: AWS::EC2::Instance + Metadata: + cfn-lint: + config: + ignore_checks: + - E3030 + Properties: + InstanceType: nt.x4superlarge + ImageId: ami-abc1234 +``` + +### cfn-lint disable entire file + +If you need to ignore an entire file, you can update the `.github/linters/.cfnlintrc.yml` to ignore certain files and locations + +```yaml +ignore_templates: + - codebuild.yaml +``` + +--- + +## Clojure + +- [clj-kondo](https://github.com/borkdude/clj-kondo) +- Since clj-kondo approaches static analysis in a very Clojure way, it is advised to read the [configuration docs](https://github.com/borkdude/clj-kondo/blob/master/doc/config.md) + +### clj-kondo standard Config file + +- `.github/linters/.clj-kondo/config.edn` + +### clj-kondo disable single line + +- There is currently **No** way to disable rules in a single line + +### clj-kondo disable code block + +- There is currently **No** way to disable rules in a code block + +### clj-kondo disable entire file + +```clojure +{:output {:exclude-files ["path/to/file"]}} +``` + +--- + +## Coffeescript + +- [coffeelint](https://coffeelint.github.io/) + +### coffeelint Config file + +- `.github/linters/.coffee-lint.yml` +- You can pass multiple rules and overwrite default rules +- File should be located at: `.github/linters/.coffee.yml` + +### coffeelint disable single line + +```Coffeescript +# coffeelint: disable=max_line_length +foo = "some/huge/line/string/with/embed/#{values}.that/surpasses/the/max/column/width" +# coffeelint: enable=max_line_length +``` + +### coffeelint disable code block + +```Coffeescript +# coffeelint: disable +foo = "some/huge/line/string/with/embed/#{values}.that/surpasses/the/max/column/width" +bar = "some/huge/line/string/with/embed/#{values}.that/surpasses/the/max/column/width" +baz = "some/huge/line/string/with/embed/#{values}.that/surpasses/the/max/column/width" +taz = "some/huge/line/string/with/embed/#{values}.that/surpasses/the/max/column/width" +# coffeelint: enable +``` + +### coffeelint disable entire file + +- You can encapsulate the entire file with the _code block format_ to disable an entire file from being parsed + +--- + +## CSS + +- [stylelint](https://stylelint.io/) + +### stylelint standard Config file + +- `.github/linters/.stylelintrc.json` + +### stylelint disable single line + +```css +#id { + /* stylelint-disable-next-line declaration-no-important */ + color: pink !important; +} +``` + +### stylelint disable code block + +```css +/* stylelint-disable */ +a { +} +/* stylelint-enable */ +``` + +### stylelint disable entire file + +- You can disable entire files with the `ignoreFiles` property in `.stylelintrc.json` + +```json +{ + "ignoreFiles": [ + "styles/ignored/wildcards/*.css", + "styles/ignored/specific-file.css" + ] +} +``` + +--- + +## Dart + +- [dartanalyzer](https://dart.dev/tools/dartanalyzer) + +### dartanalyzer standard Config file + +- `.github/linters/.dart-lint.yml` +- You can pass multiple rules and overwrite default rules +- File should be located at: `.github/linters/anaylsis_options.yaml` + +### dartanalyzer disable single line + +```dart +int x = ''; // ignore: invalid_assignment +``` + +### dartanalyzer disable code block + +- You can make [rule exceptions](https://dart.dev/guides/language/analysis-options#excluding-code-from-analysis) for the entire file. + +```dart +// ignore_for_file: unused_import, unused_local_variable +``` + +### dartanalyzer disable entire file + +- You can disable entire files with the `analyzer.exclude` property in `anaylsis_options.yaml` + +```dart +analyzer: + exclude: + - file +``` + +--- + +## Dockerfile + +- [dockerfilelint](https://github.com/replicatedhq/dockerfilelint.git) + +### Dockerfilelint standard Config file + +- `.github/linters/.dockerfilelintrc` +- You can pass multiple rules and overwrite default rules +- File should be located at: `.github/linters/.dockerfilelintrc` + +### Dockerfilelint disable single line + +- There is currently **No** way to disable rules inline of the file(s) + +### Dockerfilelint disable code block + +- There is currently **No** way to disable rules inline of the file(s) + +### Dockerfilelint disable entire file + +- There is currently **No** way to disable rules inline of the file(s) + +--- + +## EDITORCONFIG-CHECKER +- [editorconfig-checker](https://github.com/editorconfig-checker/editorconfig-checker) + +### editorconfig-checker Config file +- `.github/linters/.ecrc` +- This linter will also use the [`.editorconfig`](https://editorconfig.org/) of your project + +### editorconfig-checker disable single line + +```js + // editorconfig-checker-disable-line +``` + +### editorconfig-checker disable code block + +- There is currently **No** way to disable rules inline of the file(s) + +### editorconfig-checker disable entire file + +```js +// editorconfig-checker-disable-file +``` + +- You can disable entire files with the `Exclude` property in `.ecrc` + +```json +{ + "Exclude": ["path/to/file", "^regular\\/expression\\.ext$"] +} +``` + +--- + +## ENV + +- [dotenv-linter](https://github.com/dotenv-linter/dotenv-linter) + +### dotenv-linter Config file + +- There is no top level _configuration file_ available at this time + +### dotenv-linter disable single line + +```env +# Comment line will be ignored +``` + +### dotenv-linter disable code block + +- There is currently **No** way to disable rules inline of the file(s) + +### dotenv-linter disable entire file + +- There is currently **No** way to disable rules inline of the file(s) + +--- + +## Golang + +- [golangci-lint](https://github.com/golangci/golangci-lint) + +### golangci-lint standard Config file + +- `.github/linters/.golangci.yml` +- You can pass multiple rules and overwrite default rules +- File should be located at: `.github/linters/.golangci.yml` + +### golangci-lint disable single line + +- There is currently **No** way to disable rules inline of the file(s) + +### golangci-lint disable code block + +- There is currently **No** way to disable rules inline of the file(s) + +### golangci-lint disable entire file + +- There is currently **No** way to disable rules inline of the file(s) + +--- + +## 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 */ +``` + +--- + +## HTML + +- [htmlhint](https://htmlhint.com/) + +### htmlhint standard Config file + +- `.github/linters/.htmlhintrc` + +### htmlhint disable single line + +- There is currently **No** way to disable rules in a single line + +### htmlhint disable code block + +- There is currently **No** way to disable rules in a code block + +### htmlhint disable entire file + +- There is currently **No** way to disable rules in an entire file + +--- + +## Javascript eslint + +- [eslint](https://eslint.org/) + +### Javascript eslint Config file + +- `.github/linters/.eslintrc.yml` +- You can pass multiple rules and overwrite default rules +- File should be located at: `.github/linters/.eslintrc.yml` + +### Javascript eslint disable single line + +```javascript +var thing = new Thing(); // eslint-disable-line no-use-before-define +thing.sayHello(); + +function Thing() { + this.sayHello = function () { + console.log("hello"); + }; +} +``` + +### Javascript eslint disable code block + +```javascript +/*eslint-disable */ + +//suppress all warnings between comments +alert("foo"); + +/*eslint-enable */ +``` + +### Javascript eslint disable entire file + +- Place at the top of the file: + +```javascript +/* eslint-disable */ +``` + +--- + +## Javascript standard + +- [standard js](https://standardjs.com/) + +### Javascript standard Config file + +- There is no top level _configuration file_ available at this time + +### Javascript standard disable single line + +- There is currently **No** way to disable rules inline of the file(s) + +### Javascript standard disable code block + +- There is currently **No** way to disable rules inline of the file(s) + +### Javascript standard disable entire file + +- There is currently **No** way to disable rules inline of the file(s) + +--- + +## JSON + +- [jsonlint](https://github.com/zaach/jsonlint) + +### JsonLint Config file + +- There is no top level _configuration file_ available at this time + +### JsonLint disable single line + +- There is currently **No** way to disable rules inline of the file(s) + +### JsonLint disable code block + +- There is currently **No** way to disable rules inline of the file(s) + +### JsonLint disable entire file + +- There is currently **No** way to disable rules inline of the file(s) + +--- + +## Kotlin + +- [ktlint](https://github.com/pinterest/ktlint) + +### ktlint Config file + +- There is no top level _configuration file_ available at this time + +### ktlint disable single line + +```kotlin +import package.* // ktlint-disable no-wildcard-imports +``` + +### ktlint disable code block + +```kotlin +/* ktlint-disable no-wildcard-imports */ +import package.a.* +import package.b.* +/* ktlint-enable no-wildcard-imports */ +``` + +### ktlint disable entire file + +- There is currently **No** way to disable rules inline of the file(s) + +--- + +## Lua + +- [luarocks](https://github.com/luarocks/luacheck) + +### luacheck standard Config file +- `.github/linters/.luacheckrc` +- You can pass multiple rules and overwrite default rules +- File should be located at: `.github/linters/.luacheckrc` +- See [luacheck](https://luacheck.readthedocs.io/en/stable/config.html) docs for additional + behaviors + +### luacheck disable single line +```lua +-- luacheck: globals g1 g2, ignore foo +local foo = g1(g2) -- No warnings emitted. +``` + +### luacheck disable code block +```lua +-- The following unused function is not reported. +local function f() -- luacheck: ignore + -- luacheck: globals g3 + g3() -- No warning. +end +``` + +### luacheck include/exclude files (via .luacheckrc) +```lua +include_files = {"src", "spec/*.lua", "scripts/*.lua", "*.rockspec", "*.luacheckrc"} +exclude_files = {"src/luacheck/vendor"} +``` + +### luacheck push/pop +```lua +-- luacheck: push ignore foo +foo() -- No warning. +-- luacheck: pop +foo() -- Warning is emitted. +``` + +--- + +## Markdown + +- [markdownlint-cli](https://github.com/igorshubovych/markdownlint-cli#readme) +- [markdownlint rule documentation](https://github.com/DavidAnson/markdownlint/blob/main/doc/Rules.md) +- [markdownlint inline comment syntax](https://github.com/DavidAnson/markdownlint#configuration) + +### markdownlint Config file + +- You can pass multiple rules and overwrite default rules +- File should be located at: `.github/linters/.markdown-lint.yml` + +### markdownlint disable single line + +```markdown +## Here is some document + +Here is some random data + + + +any violation you want + + + +Here is more data + +``` + +### markdownlint disable code block + +```markdown +## Here is some document + +Here is some random data + + + +any violations you want + + + +Here is more data +``` + +### markdownlint disable entire file + +- You can encapsulate the entire file with the _code block format_ to disable an entire file from being parsed + +--- + +## OpenAPI + +- [spectral](https://github.com/stoplightio/spectral) + +### OpenAPI Config file + +- `.github/linters/.openapirc.yml` +- You can add, extend, and disable rules +- Documentation at [Spectral Custom Rulesets](https://stoplight.io/p/docs/gh/stoplightio/spectral/docs/guides/4-custom-rulesets.md) +- File should be located at: `.github/linters/.openapirc.yml` + +### OpenAPI disable single line + +- There is currently **No** way to disable rules inline of the file(s) + +### OpenAPI disable code block + +- There is currently **No** way to disable rules inline of the file(s) + +### OpenAPI disable entire file + +- There is currently **No** way to disable rules inline of the file(s) +- However, you can make [rule exceptions](https://stoplight.io/p/docs/gh/stoplightio/spectral/docs/guides/6-exceptions.md?srn=gh/stoplightio/spectral/docs/guides/6-exceptions.md) in the config for individual file(s). + +--- + +## Perl + +- [perl](https://pkgs.alpinelinux.org/package/edge/main/x86/perl) + +### Perl Config file + +- There is no top level _configuration file_ available at this time + +### Perl disable single line + +- There is currently **No** way to disable rules inline of the file(s) + +### Perl disable code block + +- There is currently **No** way to disable rules inline of the file(s) + +### Perl disable entire file + +- There is currently **No** way to disable rules inline of the file(s) + +--- + +## 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) + +--- + +## Protocol Buffers + +- [protolint](https://github.com/yoheimuta/protolint) + +### protolint Config file + +- `.github/linters/.protolintrc.yml` +- You can add, extend, and disable rules +- Documentation at [Rules](https://github.com/yoheimuta/protolint#rules) and [Configuring](https://github.com/yoheimuta/protolint#configuring) + +### protolint disable single line + +```protobuf +enum Foo { + // protolint:disable:next ENUM_FIELD_NAMES_UPPER_SNAKE_CASE + firstValue = 0; + second_value = 1; // protolint:disable:this ENUM_FIELD_NAMES_UPPER_SNAKE_CASE + THIRD_VALUE = 2; +} +``` + +### protolint disable code block + +```protobuf +// protolint:disable ENUM_FIELD_NAMES_UPPER_SNAKE_CASE +enum Foo { + firstValue = 0; + second_value = 1; + THIRD_VALUE = 2; +} +// protolint:enable ENUM_FIELD_NAMES_UPPER_SNAKE_CASE +``` + +### protolint disable entire file + +- You can disable entire files with the `lint.files.exclude` property in `.protolintrc.yml` + +```yaml +# Lint directives. +lint: + # Linter files to walk. + files: + # The specific files to exclude. + exclude: + - path/to/file +``` + +--- + +## Python3 pylint + +- [pylint](https://www.pylint.org/) + +### Pylint Config file + +- `.github/linters/.python-lint` +- You can pass multiple rules and overwrite default rules +- File should be located at: `.github/linters/.python-lint` + +### Pylint disable single line + +```python +global VAR # pylint: disable=global-statement +``` + +### Pylint disable code block + +```python +"""pylint option block-disable""" + +__revision__ = None + +class Foo(object): + """block-disable test""" + + def __init__(self): + pass + + def meth1(self, arg): + """this issues a message""" + print(self) + + def meth2(self, arg): + """and this one not""" + # pylint: disable=unused-argument + print(self\ + + "foo") + + def meth3(self): + """test one line disabling""" + # no error + print(self.baz) # pylint: disable=no-member + # error + print(self.baz) +``` + +### Pylint disable entire file + +```python +#!/bin/python3 +# pylint: skip-file + +var = "terrible code down here..." +``` + +--- + +## Python3 flake8 + +- [flake8](https://flake8.pycqa.org/en/latest/) + +### flake8 Config file + +- `.github/linters/.flake8` +- You can pass multiple rules and overwrite default rules +- File should be located at: `.github/linters/.flake8` + +### flake8 disable single line + +```python +example = lambda: 'example' # noqa: E731 +``` + +### flake8 disable entire file + +```python +#!/bin/python3 +# flake8: noqa + +var = "terrible code down here..." +``` + +--- + +## Raku + +- [raku](https://raku.org) + +### Raku Config file + +- There is no top level _configuration file_ available at this time + +### Raku disable single line + +- There is currently **No** way to disable rules inline of the file(s) + +### Raku disable code block + +- There is currently **No** way to disable rules inline of the file(s) + +### Raku disable entire file + +- There is currently **No** way to disable rules inline of the file(s) + + --- ## Ruby @@ -141,452 +963,25 @@ moreThings() --- -## Ansible +## Terraform -- [ansible-lint](https://github.com/ansible/ansible-lint) +- [tflint](https://github.com/terraform-linters/tflint) -### Ansible-lint Config file +### tflint standard Config file -- `.github/linters/.ansible-lint.yml` +- `.github/linters/.tflint.hcl` - You can pass multiple rules and overwrite default rules -- File should be located at: `.github/linters/.ansible-lint.yml` +- File should be located at: `.github/linters/.tflint.hcl` -### Ansible-lint disable single line - -```yml -- name: this would typically fire GitHasVersionRule 401 and BecomeUserWithoutBecomeRule 501 - become_user: alice # noqa 401 501 - git: src=/path/to/git/repo dest=checkout -``` - -### Ansible-lint disable code block - -```yml -- name: this would typically fire GitHasVersionRule 401 - git: src=/path/to/git/repo dest=checkout - tags: - - skip_ansible_lint -``` - -### Ansible-lint disable entire file - -```yml -- name: this would typically fire GitHasVersionRule 401 - git: src=/path/to/git/repo dest=checkout - tags: - - skip_ansible_lint -``` - ---- - -## YAML - -- [YamlLint](https://github.com/adrienverge/yamllint) - -### Yamllint Config file - -- `.github/linters/.yaml-lint.yml` -- You can pass multiple rules and overwrite default rules -- File should be located at: `.github/linters/.yaml-lint.yml` - -### Yamllint disable single line - -```yml -This line is waaaaaaaaaay too long # yamllint disable-line -``` - -### Yamllint disable code block - -```yml -# yamllint disable rule:colons -- Key: value - dolor: sit, - foo: bar -# yamllint enable -``` - -### Yamllint disable entire file - -If you need to ignore an entire file, you can update the `.github/linters/.yaml-lint.yml` to ignore certain files and locations - -```yml -# For all rules -ignore: | - *.dont-lint-me.yaml - /bin/ - !/bin/*.lint-me-anyway.yaml - -rules: - key-duplicates: - ignore: | - generated - *.template.yaml - trailing-spaces: - ignore: | - *.ignore-trailing-spaces.yaml - /ascii-art/* -``` - ---- - -## Python3 - -- [pylint](https://www.pylint.org/) - -### Pylint Config file - -- `.github/linters/.python-lint` -- You can pass multiple rules and overwrite default rules -- File should be located at: `.github/linters/.python-lint` - -### Pylint disable single line - -```python -global VAR # pylint: disable=global-statement -``` - -### Pylint disable code block - -```python -"""pylint option block-disable""" - -__revision__ = None - -class Foo(object): - """block-disable test""" - - def __init__(self): - pass - - def meth1(self, arg): - """this issues a message""" - print(self) - - def meth2(self, arg): - """and this one not""" - # pylint: disable=unused-argument - print(self\ - + "foo") - - def meth3(self): - """test one line disabling""" - # no error - print(self.baz) # pylint: disable=no-member - # error - print(self.baz) -``` - -### Pylint disable entire file - -```python -#!/bin/python3 -# pylint: skip-file - -var = "terrible code down here..." -``` - ---- - -## AWS CloudFormation templates - -- [cfn-lint](https://github.com/aws-cloudformation/cfn-python-lint/) - -### cfn-lint Config file - -- `.github/linters/.cfnlintrc.yml` -- You can pass multiple rules and overwrite default rules -- File should be located at: `.github/linters/.cfnlintrc.yml` - -### cfn-lint disable single line +### tflint disable single line - There is currently **No** way to disable rules inline of the file(s) -### cfn-lint disable code block - -You can disable both [template](https://github.com/aws-cloudformation/cfn-python-lint/#template-based-metadata) or [resource](https://github.com/aws-cloudformation/cfn-python-lint/#resource-based-metadata) via [metadata](https://github.com/aws-cloudformation/cfn-python-lint/#metadata): - -```yaml -Resources: - myInstance: - Type: AWS::EC2::Instance - Metadata: - cfn-lint: - config: - ignore_checks: - - E3030 - Properties: - InstanceType: nt.x4superlarge - ImageId: ami-abc1234 -``` - -### cfn-lint disable entire file - -If you need to ignore an entire file, you can update the `.github/linters/.cfnlintrc.yml` to ignore certain files and locations - -```yaml -ignore_templates: - - codebuild.yaml -``` - ---- - -## JSON - -- [jsonlint](https://github.com/zaach/jsonlint) - -### JsonLint Config file - -- There is no top level _configuration file_ available at this time - -### JsonLint disable single line +### tflint disable code block - There is currently **No** way to disable rules inline of the file(s) -### JsonLint disable code block - -- There is currently **No** way to disable rules inline of the file(s) - -### JsonLint disable entire file - -- There is currently **No** way to disable rules inline of the file(s) - ---- - -## Markdown - -- [markdownlint-cli](https://github.com/igorshubovych/markdownlint-cli#readme) -- [markdownlint rule documentation](https://github.com/DavidAnson/markdownlint/blob/main/doc/Rules.md) -- [markdownlint inline comment syntax](https://github.com/DavidAnson/markdownlint#configuration) - -### markdownlint Config file - -- You can pass multiple rules and overwrite default rules -- File should be located at: `.github/linters/.markdown-lint.yml` - -### markdownlint disable single line - -```markdown -## Here is some document - -Here is some random data - - - -any violation you want - - - -Here is more data -``` - -### markdownlint disable code block - -```markdown -## Here is some document - -Here is some random data - - - -any violations you want - - - -Here is more data -``` - -### markdownlint disable entire file - -- You can encapsulate the entire file with the _code block format_ to disable an entire file from being parsed - ---- - -## Perl - -- [perl](https://pkgs.alpinelinux.org/package/edge/main/x86/perl) - -### Perl Config file - -- There is no top level _configuration file_ available at this time - -### Perl disable single line - -- There is currently **No** way to disable rules inline of the file(s) - -### Perl disable code block - -- There is currently **No** way to disable rules inline of the file(s) - -### Perl disable entire file - -- There is currently **No** way to disable rules inline of the file(s) - ---- - -## Raku - -- [raku](https://raku.org) - -### Raku Config file - -- There is no top level _configuration file_ available at this time - -### Raku disable single line - -- There is currently **No** way to disable rules inline of the file(s) - -### Raku disable code block - -- There is currently **No** way to disable rules inline of the file(s) - -### Raku disable entire file - -- There is currently **No** way to disable rules inline of the file(s) - ---- - ---- - -## 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](http://xmlsoft.org/) - -### LibXML Config file - -- There is no top level _configuration file_ available at this time - -### LibXML disable single line - -- There is currently **No** way to disable rules inline of the file(s) - -### LibXML disable code block - -- There is currently **No** way to disable rules inline of the file(s) - -### LibXML disable entire file - -- There is currently **No** way to disable rules inline of the file(s) - ---- - -## Coffeescript - -- [coffeelint](https://coffeelint.github.io/) - -### coffeelint Config file - -- `.github/linters/.coffee-lint.yml` -- You can pass multiple rules and overwrite default rules -- File should be located at: `.github/linters/.coffee.yml` - -### coffeelint disable single line - -```Coffeescript -# coffeelint: disable=max_line_length -foo = "some/huge/line/string/with/embed/#{values}.that/surpasses/the/max/column/width" -# coffeelint: enable=max_line_length -``` - -### coffeelint disable code block - -```Coffeescript -# coffeelint: disable -foo = "some/huge/line/string/with/embed/#{values}.that/surpasses/the/max/column/width" -bar = "some/huge/line/string/with/embed/#{values}.that/surpasses/the/max/column/width" -baz = "some/huge/line/string/with/embed/#{values}.that/surpasses/the/max/column/width" -taz = "some/huge/line/string/with/embed/#{values}.that/surpasses/the/max/column/width" -# coffeelint: enable -``` - -### coffeelint disable entire file - -- You can encapsulate the entire file with the _code block format_ to disable an entire file from being parsed - ---- - -## Javascript eslint - -- [eslint](https://eslint.org/) - -### Javascript eslint Config file - -- `.github/linters/.eslintrc.yml` -- You can pass multiple rules and overwrite default rules -- File should be located at: `.github/linters/.eslintrc.yml` - -### Javascript eslint disable single line - -```javascript -var thing = new Thing(); // eslint-disable-line no-use-before-define -thing.sayHello(); - -function Thing() { - this.sayHello = function () { - console.log("hello"); - }; -} -``` - -### Javascript eslint disable code block - -```javascript -/*eslint-disable */ - -//suppress all warnings between comments -alert("foo"); - -/*eslint-enable */ -``` - -### Javascript eslint disable entire file - -- Place at the top of the file: - -```javascript -/* eslint-disable */ -``` - ---- - -## Javascript standard - -- [standard js](https://standardjs.com/) - -### Javascript standard Config file - -- There is no top level _configuration file_ available at this time - -### Javascript standard disable single line - -- There is currently **No** way to disable rules inline of the file(s) - -### Javascript standard disable code block - -- There is currently **No** way to disable rules inline of the file(s) - -### Javascript standard disable entire file +### tflint disable entire file - There is currently **No** way to disable rules inline of the file(s) @@ -656,431 +1051,72 @@ alert("foo"); --- -## Golang +## XML -- [golangci-lint](https://github.com/golangci/golangci-lint) +- [XML](http://xmlsoft.org/) -### golangci-lint standard Config file - -- `.github/linters/.golangci.yml` -- You can pass multiple rules and overwrite default rules -- File should be located at: `.github/linters/.golangci.yml` - -### golangci-lint disable single line - -- There is currently **No** way to disable rules inline of the file(s) - -### golangci-lint disable code block - -- There is currently **No** way to disable rules inline of the file(s) - -### golangci-lint disable entire file - -- There is currently **No** way to disable rules inline of the file(s) - ---- - -## 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 - -- [dockerfilelint](https://github.com/replicatedhq/dockerfilelint.git) - -### Dockerfilelint standard Config file - -- `.github/linters/.dockerfilelintrc` -- You can pass multiple rules and overwrite default rules -- File should be located at: `.github/linters/.dockerfilelintrc` - -### Dockerfilelint disable single line - -- There is currently **No** way to disable rules inline of the file(s) - -### Dockerfilelint disable code block - -- There is currently **No** way to disable rules inline of the file(s) - -### Dockerfilelint disable entire file - -- There is currently **No** way to disable rules inline of the file(s) - ---- - -## Terraform - -- [tflint](https://github.com/terraform-linters/tflint) - -### tflint standard Config file - -- `.github/linters/.tflint.hcl` -- You can pass multiple rules and overwrite default rules -- File should be located at: `.github/linters/.tflint.hcl` - -### tflint disable single line - -- There is currently **No** way to disable rules inline of the file(s) - -### tflint disable code block - -- There is currently **No** way to disable rules inline of the file(s) - -### tflint disable entire file - -- There is currently **No** way to disable rules inline of the file(s) - ---- - -## CSS - -- [stylelint](https://stylelint.io/) - -### stylelint standard Config file - -- `.github/linters/.stylelintrc.json` - -### stylelint disable single line - -```css -#id { - /* stylelint-disable-next-line declaration-no-important */ - color: pink !important; -} -``` - -### stylelint disable code block - -```css -/* stylelint-disable */ -a { -} -/* stylelint-enable */ -``` - -### stylelint disable entire file - -- You can disable entire files with the `ignoreFiles` property in `.stylelintrc.json` - -```json -{ - "ignoreFiles": [ - "styles/ignored/wildcards/*.css", - "styles/ignored/specific-file.css" - ] -} -``` - ---- - -## ENV - -- [dotenv-linter](https://github.com/dotenv-linter/dotenv-linter) - -### dotenv-linter Config file +### LibXML Config file - There is no top level _configuration file_ available at this time -### dotenv-linter disable single line - -```env -# Comment line will be ignored -``` - -### dotenv-linter disable code block +### LibXML disable single line - There is currently **No** way to disable rules inline of the file(s) -### dotenv-linter disable entire file +### LibXML disable code block + +- There is currently **No** way to disable rules inline of the file(s) + +### LibXML disable entire file - There is currently **No** way to disable rules inline of the file(s) --- -## Kotlin +## YAML -- [ktlint](https://github.com/pinterest/ktlint) +- [YamlLint](https://github.com/adrienverge/yamllint) -### ktlint Config file +### Yamllint Config file -- There is no top level _configuration file_ available at this time - -### ktlint disable single line - -```kotlin -import package.* // ktlint-disable no-wildcard-imports -``` - -### ktlint disable code block - -```kotlin -/* ktlint-disable no-wildcard-imports */ -import package.a.* -import package.b.* -/* ktlint-enable no-wildcard-imports */ -``` - -### ktlint disable entire file - -- There is currently **No** way to disable rules inline of the file(s) - ---- - -## Lua -- [luarocks](https://github.com/luarocks/luacheck) - -### luacheck standard Config file -- `.github/linters/.luacheckrc` +- `.github/linters/.yaml-lint.yml` - You can pass multiple rules and overwrite default rules -- File should be located at: `.github/linters/.luacheckrc` -- See [luacheck](https://luacheck.readthedocs.io/en/stable/config.html) docs for additional - behaviors +- File should be located at: `.github/linters/.yaml-lint.yml` -### luacheck disable single line -```lua --- luacheck: globals g1 g2, ignore foo -local foo = g1(g2) -- No warnings emitted. +### Yamllint disable single line + +```yml +This line is waaaaaaaaaay too long # yamllint disable-line ``` -### luacheck disable code block -```lua --- The following unused function is not reported. -local function f() -- luacheck: ignore - -- luacheck: globals g3 - g3() -- No warning. -end +### Yamllint disable code block + +```yml +# yamllint disable rule:colons +- Key: value + dolor: sit, + foo: bar +# yamllint enable ``` -### luacheck include/exclude files (via .luacheckrc) -```lua -include_files = {"src", "spec/*.lua", "scripts/*.lua", "*.rockspec", "*.luacheckrc"} -exclude_files = {"src/luacheck/vendor"} +### Yamllint disable entire file + +If you need to ignore an entire file, you can update the `.github/linters/.yaml-lint.yml` to ignore certain files and locations + +```yml +# For all rules +ignore: | + *.dont-lint-me.yaml + /bin/ + !/bin/*.lint-me-anyway.yaml + +rules: + key-duplicates: + ignore: | + generated + *.template.yaml + trailing-spaces: + ignore: | + *.ignore-trailing-spaces.yaml + /ascii-art/* ``` - -### luacheck push/pop -```lua --- luacheck: push ignore foo -foo() -- No warning. --- luacheck: pop -foo() -- Warning is emitted. -``` ---- - -## Dart - -- [dartanalyzer](https://dart.dev/tools/dartanalyzer) - -### dartanalyzer standard Config file - -- `.github/linters/.dart-lint.yml` -- You can pass multiple rules and overwrite default rules -- File should be located at: `.github/linters/anaylsis_options.yaml` - -### dartanalyzer disable single line - -```dart -int x = ''; // ignore: invalid_assignment -``` - -### dartanalyzer disable code block - -- You can make [rule exceptions](https://dart.dev/guides/language/analysis-options#excluding-code-from-analysis) for the entire file. - -```dart -// ignore_for_file: unused_import, unused_local_variable -``` - -### dartanalyzer disable entire file - -- You can disable entire files with the `analyzer.exclude` property in `anaylsis_options.yaml` - -```dart -analyzer: - exclude: - - file -``` - ---- - -## OpenAPI - -- [spectral](https://github.com/stoplightio/spectral) - -### OpenAPI Config file - -- `.github/linters/.openapirc.yml` -- You can add, extend, and disable rules -- Documentation at [Spectral Custom Rulesets](https://stoplight.io/p/docs/gh/stoplightio/spectral/docs/guides/4-custom-rulesets.md) -- File should be located at: `.github/linters/.openapirc.yml` - -### OpenAPI disable single line - -- There is currently **No** way to disable rules inline of the file(s) - -### OpenAPI disable code block - -- There is currently **No** way to disable rules inline of the file(s) - -### OpenAPI disable entire file - -- There is currently **No** way to disable rules inline of the file(s) -- However, you can make [rule exceptions](https://stoplight.io/p/docs/gh/stoplightio/spectral/docs/guides/6-exceptions.md?srn=gh/stoplightio/spectral/docs/guides/6-exceptions.md) in the config for individual file(s). - ---- - -## Protocol Buffers - -- [protolint](https://github.com/yoheimuta/protolint) - -### protolint Config file - -- `.github/linters/.protolintrc.yml` -- You can add, extend, and disable rules -- Documentation at [Rules](https://github.com/yoheimuta/protolint#rules) and [Configuring](https://github.com/yoheimuta/protolint#configuring) - -### protolint disable single line - -```protobuf -enum Foo { - // protolint:disable:next ENUM_FIELD_NAMES_UPPER_SNAKE_CASE - firstValue = 0; - second_value = 1; // protolint:disable:this ENUM_FIELD_NAMES_UPPER_SNAKE_CASE - THIRD_VALUE = 2; -} -``` - -### protolint disable code block - -```protobuf -// protolint:disable ENUM_FIELD_NAMES_UPPER_SNAKE_CASE -enum Foo { - firstValue = 0; - second_value = 1; - THIRD_VALUE = 2; -} -// protolint:enable ENUM_FIELD_NAMES_UPPER_SNAKE_CASE -``` - -### protolint disable entire file - -- You can disable entire files with the `lint.files.exclude` property in `.protolintrc.yml` - -```yaml -# Lint directives. -lint: - # Linter files to walk. - files: - # The specific files to exclude. - exclude: - - path/to/file -``` - -## Clojure - -- [clj-kondo](https://github.com/borkdude/clj-kondo) -- Since clj-kondo approaches static analysis in a very Clojure way, it is advised to read the [configuration docs](https://github.com/borkdude/clj-kondo/blob/master/doc/config.md) - -### clj-kondo standard Config file - -- `.github/linters/.clj-kondo/config.edn` - -### clj-kondo disable single line - -- There is currently **No** way to disable rules in a single line - -### clj-kondo disable code block - -- There is currently **No** way to disable rules in a code block - -### clj-kondo disable entire file - -```clojure -{:output {:exclude-files ["path/to/file"]}} -``` - -## EDITORCONFIG-CHECKER -- [editorconfig-checker](https://github.com/editorconfig-checker/editorconfig-checker) - -### editorconfig-checker Config file -- `.github/linters/.ecrc` -- This linter will also use the [`.editorconfig`](https://editorconfig.org/) of your project - -### editorconfig-checker disable single line -- -```js - // editorconfig-checker-disable-line -``` - -### editorconfig-checker disable code block - -- There is currently **No** way to disable rules inline of the file(s) - -### editorconfig-checker disable entire file - -- - -```js -// editorconfig-checker-disable-file -``` - -- You can disable entire files with the `Exclude` property in `.ecrc` - -```json -{ - "Exclude": ["path/to/file", "^regular\\/expression\\.ext$"] -} -``` - -## HTML - -- [htmlhint](https://htmlhint.com/) - -### htmlhint standard Config file - -- `.github/linters/.htmlhintrc` - -### htmlhint disable single line - -- There is currently **No** way to disable rules in a single line - -### htmlhint disable code block - -- There is currently **No** way to disable rules in a code block - -### htmlhint disable entire file - -- There is currently **No** way to disable rules in an entire file From a593a5c9add8153c1bb490e2dae0b61953db500c Mon Sep 17 00:00:00 2001 From: Gabo Date: Thu, 23 Jul 2020 09:37:58 -0500 Subject: [PATCH 084/135] Fix rebase --- Dockerfile | 1 - lib/validation.sh | 3 --- 2 files changed, 4 deletions(-) diff --git a/Dockerfile b/Dockerfile index a3f331d3..884c1c4f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -259,7 +259,6 @@ ENV ACTIONS_RUNNER_DEBUG=${ACTIONS_RUNNER_DEBUG} \ VALIDATE_XML=${VALIDATE_XML} \ VALIDATE_YAML=${VALIDATE_YAML} - ############################# # Copy scripts to container # ############################# diff --git a/lib/validation.sh b/lib/validation.sh index 07387fd5..178ffbae 100755 --- a/lib/validation.sh +++ b/lib/validation.sh @@ -46,7 +46,6 @@ function GetValidationInfo() { ################################ # Convert strings to lowercase # ################################ - # Loop through all languages for LANGUAGE in "${LANGUAGE_ARRAY[@]}"; do # build the variable @@ -55,7 +54,6 @@ function GetValidationInfo() { eval "${VALIDATE_LANGUAGE}=${!VALIDATE_LANGUAGE,,}" done - ################################################ # Determine if any linters were explicitly set # ################################################ @@ -71,7 +69,6 @@ function GetValidationInfo() { fi done - ################################################### # Validate if we should check individual lanuages # ################################################### From b2569d37350e0ea38d563925fbcfe82ea0b43dfd Mon Sep 17 00:00:00 2001 From: Gabo Date: Thu, 23 Jul 2020 10:40:29 -0500 Subject: [PATCH 085/135] Add python config file vars in readme --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index d90ac812..98d2c186 100644 --- a/README.md +++ b/README.md @@ -180,6 +180,8 @@ and won't run anything unexpected. | **OUTPUT_FORMAT** | `none` | The report format to be generated, besides the stdout one. Output format of tap is currently using v13 of the specification. Supported formats: tap | | **OUTPUT_FOLDER** | `super-linter.report` | The location where the output reporting will be generated to. Output folder must not previously exist. | | **OUTPUT_DETAILS** | `simpler` | What level of details to be reported. Supported formats: simpler or detailed. | +| **PYTHON_PYLINT_CONFIG_FILE** | `.python-lint` | Filename for [pylint configuration](http://pylint.pycqa.org/en/latest/user_guide/run.html?highlight=rcfile#command-line-options) (ex: `.python-lint`, `.pylintrc`) | +| **PYTHON_FLAKE8_CONFIG_FILE** | `.flake8` | Filename for [flake8 configuration](https://flake8.pycqa.org/en/latest/user/configuration.html) (ex: `.flake8`, `tox.ini`) | | **RUBY_CONFIG_FILE** | `.ruby-lint.yml` | Filename for [rubocop configuration](https://docs.rubocop.org/rubocop/configuration.html) (ex: `.ruby-lint.yml`, `.rubocop.yml`) | | **TYPESCRIPT_ES_CONFIG_FILE** | `.eslintrc.yml` | Filename for [eslint configuration](https://eslint.org/docs/user-guide/configuring#configuration-file-formats) (ex: `.eslintrc.yml`, `.eslintrc.json`) | | **VALIDATE_ALL_CODEBASE** | `true` | Will parse the entire repository and find all files to validate across all types. **NOTE:** When set to `false`, only **new** or **edited** files will be parsed for validation. | From 26c05d5e418f0af716d78ac074bbcce89c1904ee Mon Sep 17 00:00:00 2001 From: Gabo Date: Thu, 23 Jul 2020 10:41:17 -0500 Subject: [PATCH 086/135] Fix python var and rules --- lib/linter.sh | 104 +++++++++++++++++++++++++------------------------- 1 file changed, 53 insertions(+), 51 deletions(-) diff --git a/lib/linter.sh b/lib/linter.sh index 4a10072b..b8eb086c 100755 --- a/lib/linter.sh +++ b/lib/linter.sh @@ -123,55 +123,55 @@ LINTED_LANGUAGES_ARRAY=() # Will be filled at run time with all languages that w ################### # GitHub ENV Vars # ################### -ANSIBLE_DIRECTORY="${ANSIBLE_DIRECTORY}" # Ansible Directory -DEFAULT_BRANCH="${DEFAULT_BRANCH:-master}" # Default Git Branch to use (master by default) -DISABLE_ERRORS="${DISABLE_ERRORS}" # Boolean to enable warning-only output without throwing errors -GITHUB_EVENT_PATH="${GITHUB_EVENT_PATH}" # Github Event Path -GITHUB_REPOSITORY="${GITHUB_REPOSITORY}" # GitHub Org/Repo passed from system -GITHUB_RUN_ID="${GITHUB_RUN_ID}" # GitHub RUn ID to point to logs -GITHUB_SHA="${GITHUB_SHA}" # GitHub sha from the commit -GITHUB_TOKEN="${GITHUB_TOKEN}" # GitHub Token passed from environment -GITHUB_WORKSPACE="${GITHUB_WORKSPACE}" # Github Workspace -MULTI_STATUS="${MULTI_STATUS:-true}" # Multiple status are created for each check ran -TEST_CASE_RUN="${TEST_CASE_RUN}" # Boolean to validate only test cases -VALIDATE_ALL_CODEBASE="${VALIDATE_ALL_CODEBASE}" # Boolean to validate all files -VALIDATE_ANSIBLE="${VALIDATE_ANSIBLE}" # Boolean to validate language -VALIDATE_ARM="${VALIDATE_ARM}" # Boolean to validate language -VALIDATE_BASH="${VALIDATE_BASH}" # Boolean to validate language -VALIDATE_CLOUDFORMATION="${VALIDATE_CLOUDFORMATION}" # Boolean to validate language -VALIDATE_CLOJURE="${VALIDATE_CLOJURE}" # Boolean to validate language -VALIDATE_COFFEE="${VALIDATE_COFFEE}" # Boolean to validate language -VALIDATE_CSS="${VALIDATE_CSS}" # Boolean to validate language -VALIDATE_DART="${VALIDATE_DART}" # Boolean to validate language -VALIDATE_DOCKER="${VALIDATE_DOCKER}" # Boolean to validate language -VALIDATE_EDITORCONFIG="${VALIDATE_EDITORCONFIG}" # Boolean to validate files with editorconfig -VALIDATE_ENV="${VALIDATE_ENV}" # 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_JAVASCRIPT_ES="${VALIDATE_JAVASCRIPT_ES}" # Boolean to validate language -VALIDATE_JAVASCRIPT_STANDARD="${VALIDATE_JAVASCRIPT_STANDARD}" # Boolean to validate language -VALIDATE_JSON="${VALIDATE_JSON}" # Boolean to validate language -VALIDATE_JSX="${VALIDATE_JSX}" # Boolean to validate language -VALIDATE_KOTLIN="${VALIDATE_KOTLIN}" # Boolean to validate language -VALIDATE_LUA="${VALIDATE_LUA}" # Boolean to validate language -VALIDATE_MARKDOWN="${VALIDATE_MD:-}" # Boolean to validate language -VALIDATE_OPENAPI="${VALIDATE_OPENAPI}" # Boolean to validate language -VALIDATE_PERL="${VALIDATE_PERL}" # Boolean to validate language -VALIDATE_PHP="${VALIDATE_PHP}" # Boolean to validate language -VALIDATE_POWERSHELL="${VALIDATE_POWERSHELL}" # Boolean to validate language -VALIDATE_PYTHON_PYLINT="${VALIDATE_PYTHON:-}" # Boolean to validate language -VALIDATE_PYTHON_FLAKE8="${VALIDATE_PYTHON_FLAKE8}" # Boolean to validate language -VALIDATE_RAKU="${VALIDATE_RAKU}" # Boolean to validate language -VALIDATE_RUBY="${VALIDATE_RUBY}" # Boolean to validate language -VALIDATE_STATES="${VALIDATE_STATES}" # Boolean to validate language -VALIDATE_TERRAFORM="${VALIDATE_TERRAFORM}" # Boolean to validate language -VALIDATE_TERRAFORM_TERRASCAN="${VALIDATE_TERRAFORM_TERRASCAN}" # Boolean to validate language -VALIDATE_TSX="${VALIDATE_TSX}" # Boolean to validate language -VALIDATE_TYPESCRIPT_ES="${VALIDATE_TYPESCRIPT_ES}" # Boolean to validate language -VALIDATE_TYPESCRIPT_STANDARD="${VALIDATE_TYPESCRIPT_STANDARD}" # Boolean to validate language -VALIDATE_XML="${VALIDATE_XML}" # Boolean to validate language -VALIDATE_YAML="${VALIDATE_YAML}" # Boolean to validate language +ANSIBLE_DIRECTORY="${ANSIBLE_DIRECTORY}" # Ansible Directory +DEFAULT_BRANCH="${DEFAULT_BRANCH:-master}" # Default Git Branch to use (master by default) +DISABLE_ERRORS="${DISABLE_ERRORS}" # Boolean to enable warning-only output without throwing errors +GITHUB_EVENT_PATH="${GITHUB_EVENT_PATH}" # Github Event Path +GITHUB_REPOSITORY="${GITHUB_REPOSITORY}" # GitHub Org/Repo passed from system +GITHUB_RUN_ID="${GITHUB_RUN_ID}" # GitHub RUn ID to point to logs +GITHUB_SHA="${GITHUB_SHA}" # GitHub sha from the commit +GITHUB_TOKEN="${GITHUB_TOKEN}" # GitHub Token passed from environment +GITHUB_WORKSPACE="${GITHUB_WORKSPACE}" # Github Workspace +MULTI_STATUS="${MULTI_STATUS:-true}" # Multiple status are created for each check ran +TEST_CASE_RUN="${TEST_CASE_RUN}" # Boolean to validate only test cases +VALIDATE_ALL_CODEBASE="${VALIDATE_ALL_CODEBASE}" # Boolean to validate all files +VALIDATE_ANSIBLE="${VALIDATE_ANSIBLE}" # Boolean to validate language +VALIDATE_ARM="${VALIDATE_ARM}" # Boolean to validate language +VALIDATE_BASH="${VALIDATE_BASH}" # Boolean to validate language +VALIDATE_CLOUDFORMATION="${VALIDATE_CLOUDFORMATION}" # Boolean to validate language +VALIDATE_CLOJURE="${VALIDATE_CLOJURE}" # Boolean to validate language +VALIDATE_COFFEE="${VALIDATE_COFFEE}" # Boolean to validate language +VALIDATE_CSS="${VALIDATE_CSS}" # Boolean to validate language +VALIDATE_DART="${VALIDATE_DART}" # Boolean to validate language +VALIDATE_DOCKER="${VALIDATE_DOCKER}" # Boolean to validate language +VALIDATE_EDITORCONFIG="${VALIDATE_EDITORCONFIG}" # Boolean to validate files with editorconfig +VALIDATE_ENV="${VALIDATE_ENV}" # 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_JAVASCRIPT_ES="${VALIDATE_JAVASCRIPT_ES}" # Boolean to validate language +VALIDATE_JAVASCRIPT_STANDARD="${VALIDATE_JAVASCRIPT_STANDARD}" # Boolean to validate language +VALIDATE_JSON="${VALIDATE_JSON}" # Boolean to validate language +VALIDATE_JSX="${VALIDATE_JSX}" # Boolean to validate language +VALIDATE_KOTLIN="${VALIDATE_KOTLIN}" # Boolean to validate language +VALIDATE_LUA="${VALIDATE_LUA}" # Boolean to validate language +VALIDATE_MARKDOWN="${VALIDATE_MD:-}" # Boolean to validate language +VALIDATE_OPENAPI="${VALIDATE_OPENAPI}" # Boolean to validate language +VALIDATE_PERL="${VALIDATE_PERL}" # Boolean to validate language +VALIDATE_PHP="${VALIDATE_PHP}" # Boolean to validate language +VALIDATE_POWERSHELL="${VALIDATE_POWERSHELL}" # Boolean to validate language +VALIDATE_PYTHON_PYLINT="${VALIDATE_PYTHON:-$VALIDATE_PYTHON_PYLINT}" # Boolean to validate language +VALIDATE_PYTHON_FLAKE8="${VALIDATE_PYTHON_FLAKE8}" # Boolean to validate language +VALIDATE_RAKU="${VALIDATE_RAKU}" # Boolean to validate language +VALIDATE_RUBY="${VALIDATE_RUBY}" # Boolean to validate language +VALIDATE_STATES="${VALIDATE_STATES}" # Boolean to validate language +VALIDATE_TERRAFORM="${VALIDATE_TERRAFORM}" # Boolean to validate language +VALIDATE_TERRAFORM_TERRASCAN="${VALIDATE_TERRAFORM_TERRASCAN}" # Boolean to validate language +VALIDATE_TSX="${VALIDATE_TSX}" # Boolean to validate language +VALIDATE_TYPESCRIPT_ES="${VALIDATE_TYPESCRIPT_ES}" # Boolean to validate language +VALIDATE_TYPESCRIPT_STANDARD="${VALIDATE_TYPESCRIPT_STANDARD}" # Boolean to validate language +VALIDATE_XML="${VALIDATE_XML}" # Boolean to validate language +VALIDATE_YAML="${VALIDATE_YAML}" # Boolean to validate language ############## # Debug Vars # @@ -1097,8 +1097,10 @@ GetLinterRules "LUA" GetLinterRules "MARKDOWN" # Get PowerShell rules GetLinterRules "POWERSHELL" -# Get Python rules -GetLinterRules "PYTHON" +# Get Python pylint rules +GetLinterRules "PYTHON_PYLINT" +# Get Python flake8 rules +GetLinterRules "PYTHON_FLAKE8" # Get Ruby rules GetLinterRules "RUBY" # Get Terraform rules From 8fd0bd3eb5d6174dd63b7db6689e3ca264856a6d Mon Sep 17 00:00:00 2001 From: Gabo Date: Thu, 23 Jul 2020 10:55:15 -0500 Subject: [PATCH 087/135] Fix python file type --- lib/linter.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/linter.sh b/lib/linter.sh index b8eb086c..464b8a53 100755 --- a/lib/linter.sh +++ b/lib/linter.sh @@ -1522,7 +1522,7 @@ if [ "${VALIDATE_PYTHON_PYLINT}" == "true" ]; then # Lint the python files # ######################### # LintCodebase "FILE_TYPE" "LINTER_NAME" "LINTER_CMD" "FILE_TYPES_REGEX" "FILE_ARRAY" - LintCodebase "PYTHON" "pylint" "pylint --rcfile ${PYTHON_PYLINT_LINTER_RULES}" ".*\.\(py\)\$" "${FILE_ARRAY_PYTHON_PYLINT[@]}" + LintCodebase "PYTHON_PYLINT" "pylint" "pylint --rcfile ${PYTHON_PYLINT_LINTER_RULES}" ".*\.\(py\)\$" "${FILE_ARRAY_PYTHON_PYLINT[@]}" fi ################## @@ -1533,7 +1533,7 @@ if [ "${VALIDATE_PYTHON_FLAKE8}" == "true" ]; then # Lint the python files # ######################### # LintCodebase "FILE_TYPE" "LINTER_NAME" "LINTER_CMD" "FILE_TYPES_REGEX" "FILE_ARRAY" - LintCodebase "PYTHON" "flake8" "flake8 --config=${PYTHON_FLAKE8_LINTER_RULES}" ".*\.\(py\)\$" "${FILE_ARRAY_PYTHON_FLAKE8[@]}" + LintCodebase "PYTHON_FLAKE8" "flake8" "flake8 --config=${PYTHON_FLAKE8_LINTER_RULES}" ".*\.\(py\)\$" "${FILE_ARRAY_PYTHON_FLAKE8[@]}" fi ################ From 5f3ae40c9b7ef87813985a75d21fb1eff9b260ac Mon Sep 17 00:00:00 2001 From: Gabo Date: Thu, 23 Jul 2020 13:18:23 -0500 Subject: [PATCH 088/135] Add VALIDATE_PYTHON back to the readme --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 98d2c186..a453dc1e 100644 --- a/README.md +++ b/README.md @@ -210,6 +210,7 @@ and won't run anything unexpected. | **VALIDATE_PERL** | `true` | Flag to enable or disable the linting process of the Perl language. | | **VALIDATE_PHP** | `true` | Flag to enable or disable the linting process of the PHP language. | | **VALIDATE_PROTOBUF** | `true` | Flag to enable or disable the linting process of the Protobuf language. | +| **VALIDATE_PYTHON** | `true` | Flag to enable or disable the linting process of the Python language. (Utilizing: pylint) (keep for backward compatibility) | | **VALIDATE_PYTHON_PYLINT** | `true` | Flag to enable or disable the linting process of the Python language. (Utilizing: pylint) | | **VALIDATE_PYTHON_FLAKE8** | `true` | Flag to enable or disable the linting process of the Python language. (Utilizing: flake8) | | **VALIDATE_POWERSHELL** | `true` | Flag to enable or disable the linting process of the Powershell language. | From 87b825e2a9bb20c04d4d1ac970d764d778c558b0 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 28 Jul 2020 05:24:15 +0000 Subject: [PATCH 089/135] Bump eslint-plugin-jest from 23.18.2 to 23.19.0 in /dependencies Bumps [eslint-plugin-jest](https://github.com/jest-community/eslint-plugin-jest) from 23.18.2 to 23.19.0. - [Release notes](https://github.com/jest-community/eslint-plugin-jest/releases) - [Changelog](https://github.com/jest-community/eslint-plugin-jest/blob/master/CHANGELOG.md) - [Commits](https://github.com/jest-community/eslint-plugin-jest/compare/v23.18.2...v23.19.0) Signed-off-by: dependabot[bot] --- dependencies/package-lock.json | 6 +++--- dependencies/package.json | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/dependencies/package-lock.json b/dependencies/package-lock.json index 31315d49..0d3fe13e 100644 --- a/dependencies/package-lock.json +++ b/dependencies/package-lock.json @@ -1883,9 +1883,9 @@ } }, "eslint-plugin-jest": { - "version": "23.18.2", - "resolved": "https://registry.npmjs.org/eslint-plugin-jest/-/eslint-plugin-jest-23.18.2.tgz", - "integrity": "sha512-afVOE47F0PENnRlnePUHgrDbv1tsDlTAVrjL051oUETB2ImzBwa5GfmUAUhDjAEuxH+xkE6DsmEpZ8obXzUMqQ==", + "version": "23.19.0", + "resolved": "https://registry.npmjs.org/eslint-plugin-jest/-/eslint-plugin-jest-23.19.0.tgz", + "integrity": "sha512-l5PLflALqnODl8Yy0H5hDs18aKJS1KTf66VZGXRpIhmbLbPLaTuMB2P+65fBpkdseSpnTVcIlBYvTvJSBi/itg==", "requires": { "@typescript-eslint/experimental-utils": "^2.5.0" }, diff --git a/dependencies/package.json b/dependencies/package.json index b493cb56..288e37e5 100644 --- a/dependencies/package.json +++ b/dependencies/package.json @@ -9,7 +9,7 @@ "dockerfilelint": "^1.5.0", "eslint": "^7.5.0", "eslint-config-prettier": "^6.11.0", - "eslint-plugin-jest": "^23.18.2", + "eslint-plugin-jest": "^23.19.0", "htmlhint": "^0.14.1", "jsonlint": "^1.6.3", "markdownlint-cli": "^0.23.2", From 3c50eee482a48d3b5d84beff12eff23ed9bdd5e8 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 28 Jul 2020 05:25:24 +0000 Subject: [PATCH 090/135] Bump @typescript-eslint/parser from 3.7.0 to 3.7.1 in /dependencies Bumps [@typescript-eslint/parser](https://github.com/typescript-eslint/typescript-eslint/tree/HEAD/packages/parser) from 3.7.0 to 3.7.1. - [Release notes](https://github.com/typescript-eslint/typescript-eslint/releases) - [Changelog](https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/parser/CHANGELOG.md) - [Commits](https://github.com/typescript-eslint/typescript-eslint/commits/v3.7.1/packages/parser) Signed-off-by: dependabot[bot] --- dependencies/package-lock.json | 54 ++++++++++++++++++++++++++++++---- dependencies/package.json | 2 +- 2 files changed, 49 insertions(+), 7 deletions(-) diff --git a/dependencies/package-lock.json b/dependencies/package-lock.json index 31315d49..f079920d 100644 --- a/dependencies/package-lock.json +++ b/dependencies/package-lock.json @@ -538,15 +538,57 @@ } }, "@typescript-eslint/parser": { - "version": "3.7.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-3.7.0.tgz", - "integrity": "sha512-2LZauVUt7jAWkcIW7djUc3kyW+fSarNEuM3RF2JdLHR9BfX/nDEnyA4/uWz0wseoWVZbDXDF7iF9Jc342flNqQ==", + "version": "3.7.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-3.7.1.tgz", + "integrity": "sha512-W4QV/gXvfIsccN8225784LNOorcm7ch68Fi3V4Wg7gmkWSQRKevO4RrRqWo6N/Z/myK1QAiGgeaXN57m+R/8iQ==", "requires": { "@types/eslint-visitor-keys": "^1.0.0", - "@typescript-eslint/experimental-utils": "3.7.0", - "@typescript-eslint/types": "3.7.0", - "@typescript-eslint/typescript-estree": "3.7.0", + "@typescript-eslint/experimental-utils": "3.7.1", + "@typescript-eslint/types": "3.7.1", + "@typescript-eslint/typescript-estree": "3.7.1", "eslint-visitor-keys": "^1.1.0" + }, + "dependencies": { + "@typescript-eslint/experimental-utils": { + "version": "3.7.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/experimental-utils/-/experimental-utils-3.7.1.tgz", + "integrity": "sha512-TqE97pv7HrqWcGJbLbZt1v59tcqsSVpWTOf1AqrWK7n8nok2sGgVtYRuGXeNeLw3wXlLEbY1MKP3saB2HsO/Ng==", + "requires": { + "@types/json-schema": "^7.0.3", + "@typescript-eslint/types": "3.7.1", + "@typescript-eslint/typescript-estree": "3.7.1", + "eslint-scope": "^5.0.0", + "eslint-utils": "^2.0.0" + } + }, + "@typescript-eslint/types": { + "version": "3.7.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-3.7.1.tgz", + "integrity": "sha512-PZe8twm5Z4b61jt7GAQDor6KiMhgPgf4XmUb9zdrwTbgtC/Sj29gXP1dws9yEn4+aJeyXrjsD9XN7AWFhmnUfg==" + }, + "@typescript-eslint/typescript-estree": { + "version": "3.7.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-3.7.1.tgz", + "integrity": "sha512-m97vNZkI08dunYOr2lVZOHoyfpqRs0KDpd6qkGaIcLGhQ2WPtgHOd/eVbsJZ0VYCQvupKrObAGTOvk3tfpybYA==", + "requires": { + "@typescript-eslint/types": "3.7.1", + "@typescript-eslint/visitor-keys": "3.7.1", + "debug": "^4.1.1", + "glob": "^7.1.6", + "is-glob": "^4.0.1", + "lodash": "^4.17.15", + "semver": "^7.3.2", + "tsutils": "^3.17.1" + } + }, + "@typescript-eslint/visitor-keys": { + "version": "3.7.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-3.7.1.tgz", + "integrity": "sha512-xn22sQbEya+Utj2IqJHGLA3i1jDzR43RzWupxojbSWnj3nnPLavaQmWe5utw03CwYao3r00qzXfgJMGNkrzrAA==", + "requires": { + "eslint-visitor-keys": "^1.1.0" + } + } } }, "@typescript-eslint/types": { diff --git a/dependencies/package.json b/dependencies/package.json index b493cb56..86736d45 100644 --- a/dependencies/package.json +++ b/dependencies/package.json @@ -4,7 +4,7 @@ "@coffeelint/cli": "^3.2.10", "@stoplight/spectral": "^5.4.0", "@typescript-eslint/eslint-plugin": "^3.7.0", - "@typescript-eslint/parser": "^3.7.0", + "@typescript-eslint/parser": "^3.7.1", "babel-eslint": "^10.1.0", "dockerfilelint": "^1.5.0", "eslint": "^7.5.0", From 1619d58331e688a0e356d8b345cdf490c1b463d2 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 28 Jul 2020 12:54:31 +0000 Subject: [PATCH 091/135] Bump @typescript-eslint/eslint-plugin in /dependencies Bumps [@typescript-eslint/eslint-plugin](https://github.com/typescript-eslint/typescript-eslint/tree/HEAD/packages/eslint-plugin) from 3.7.0 to 3.7.1. - [Release notes](https://github.com/typescript-eslint/typescript-eslint/releases) - [Changelog](https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/CHANGELOG.md) - [Commits](https://github.com/typescript-eslint/typescript-eslint/commits/v3.7.1/packages/eslint-plugin) Signed-off-by: dependabot[bot] --- dependencies/package-lock.json | 40 +++++++++++++++++----------------- dependencies/package.json | 2 +- 2 files changed, 21 insertions(+), 21 deletions(-) diff --git a/dependencies/package-lock.json b/dependencies/package-lock.json index a740d54e..8bf1fc2f 100644 --- a/dependencies/package-lock.json +++ b/dependencies/package-lock.json @@ -513,11 +513,11 @@ "integrity": "sha512-/tiJyrc0GPcsReHzgC0SXwOmoPjLqYe01W7dLYB0yasQXMbcRee+ZIk+g8MIQhoBS8fPoBQO3Y93+aeBrI93Ug==" }, "@typescript-eslint/eslint-plugin": { - "version": "3.7.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-3.7.0.tgz", - "integrity": "sha512-4OEcPON3QIx0ntsuiuFP/TkldmBGXf0uKxPQlGtS/W2F3ndYm8Vgdpj/woPJkzUc65gd3iR+qi3K8SDQP/obFg==", + "version": "3.7.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-3.7.1.tgz", + "integrity": "sha512-3DB9JDYkMrc8Au00rGFiJLK2Ja9CoMP6Ut0sHsXp3ZtSugjNxvSSHTnKLfo4o+QmjYBJqEznDqsG1zj4F2xnsg==", "requires": { - "@typescript-eslint/experimental-utils": "3.7.0", + "@typescript-eslint/experimental-utils": "3.7.1", "debug": "^4.1.1", "functional-red-black-tree": "^1.0.1", "regexpp": "^3.0.0", @@ -526,13 +526,13 @@ } }, "@typescript-eslint/experimental-utils": { - "version": "3.7.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/experimental-utils/-/experimental-utils-3.7.0.tgz", - "integrity": "sha512-xpfXXAfZqhhqs5RPQBfAFrWDHoNxD5+sVB5A46TF58Bq1hRfVROrWHcQHHUM9aCBdy9+cwATcvCbRg8aIRbaHQ==", + "version": "3.7.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/experimental-utils/-/experimental-utils-3.7.1.tgz", + "integrity": "sha512-TqE97pv7HrqWcGJbLbZt1v59tcqsSVpWTOf1AqrWK7n8nok2sGgVtYRuGXeNeLw3wXlLEbY1MKP3saB2HsO/Ng==", "requires": { "@types/json-schema": "^7.0.3", - "@typescript-eslint/types": "3.7.0", - "@typescript-eslint/typescript-estree": "3.7.0", + "@typescript-eslint/types": "3.7.1", + "@typescript-eslint/typescript-estree": "3.7.1", "eslint-scope": "^5.0.0", "eslint-utils": "^2.0.0" } @@ -592,17 +592,17 @@ } }, "@typescript-eslint/types": { - "version": "3.7.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-3.7.0.tgz", - "integrity": "sha512-reCaK+hyKkKF+itoylAnLzFeNYAEktB0XVfSQvf0gcVgpz1l49Lt6Vo9x4MVCCxiDydA0iLAjTF/ODH0pbfnpg==" + "version": "3.7.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-3.7.1.tgz", + "integrity": "sha512-PZe8twm5Z4b61jt7GAQDor6KiMhgPgf4XmUb9zdrwTbgtC/Sj29gXP1dws9yEn4+aJeyXrjsD9XN7AWFhmnUfg==" }, "@typescript-eslint/typescript-estree": { - "version": "3.7.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-3.7.0.tgz", - "integrity": "sha512-xr5oobkYRebejlACGr1TJ0Z/r0a2/HUf0SXqPvlgUMwiMqOCu/J+/Dr9U3T0IxpE5oLFSkqMx1FE/dKaZ8KsOQ==", + "version": "3.7.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-3.7.1.tgz", + "integrity": "sha512-m97vNZkI08dunYOr2lVZOHoyfpqRs0KDpd6qkGaIcLGhQ2WPtgHOd/eVbsJZ0VYCQvupKrObAGTOvk3tfpybYA==", "requires": { - "@typescript-eslint/types": "3.7.0", - "@typescript-eslint/visitor-keys": "3.7.0", + "@typescript-eslint/types": "3.7.1", + "@typescript-eslint/visitor-keys": "3.7.1", "debug": "^4.1.1", "glob": "^7.1.6", "is-glob": "^4.0.1", @@ -612,9 +612,9 @@ } }, "@typescript-eslint/visitor-keys": { - "version": "3.7.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-3.7.0.tgz", - "integrity": "sha512-k5PiZdB4vklUpUX4NBncn5RBKty8G3ihTY+hqJsCdMuD0v4jofI5xuqwnVcWxfv6iTm2P/dfEa2wMUnsUY8ODw==", + "version": "3.7.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-3.7.1.tgz", + "integrity": "sha512-xn22sQbEya+Utj2IqJHGLA3i1jDzR43RzWupxojbSWnj3nnPLavaQmWe5utw03CwYao3r00qzXfgJMGNkrzrAA==", "requires": { "eslint-visitor-keys": "^1.1.0" } diff --git a/dependencies/package.json b/dependencies/package.json index 6b7e9c46..3cec01fc 100644 --- a/dependencies/package.json +++ b/dependencies/package.json @@ -3,7 +3,7 @@ "dependencies": { "@coffeelint/cli": "^3.2.10", "@stoplight/spectral": "^5.4.0", - "@typescript-eslint/eslint-plugin": "^3.7.0", + "@typescript-eslint/eslint-plugin": "^3.7.1", "@typescript-eslint/parser": "^3.7.1", "babel-eslint": "^10.1.0", "dockerfilelint": "^1.5.0", From 76775d29b3851482ada4ef34955c2aaaa54f4afc Mon Sep 17 00:00:00 2001 From: Cees-Jan Kiewiet Date: Fri, 24 Jul 2020 20:54:11 +0200 Subject: [PATCH 092/135] Add basic PHPStan support --- .automation/test/php/php_bad_2.php | 4 ++++ .automation/test/php/reports/expected-PHP.tap | 8 +++++-- .../test/php/reports/expected-PHP_PHPSTAN.tap | 11 +++++++++ Dockerfile | 22 +++++++++++++++++- README.md | 1 + TEMPLATES/phpstan.neon | 2 ++ lib/buildFileList.sh | 1 + lib/linter.sh | 23 ++++++++++++++++++- lib/worker.sh | 1 + 9 files changed, 69 insertions(+), 4 deletions(-) create mode 100644 .automation/test/php/php_bad_2.php create mode 100644 .automation/test/php/reports/expected-PHP_PHPSTAN.tap create mode 100644 TEMPLATES/phpstan.neon diff --git a/.automation/test/php/php_bad_2.php b/.automation/test/php/php_bad_2.php new file mode 100644 index 00000000..71559d02 --- /dev/null +++ b/.automation/test/php/php_bad_2.php @@ -0,0 +1,4 @@ + Date: Wed, 29 Jul 2020 08:24:47 -0500 Subject: [PATCH 093/135] Fixed logic --- Dockerfile | 13 +++---------- lib/linter.sh | 9 ++++----- 2 files changed, 7 insertions(+), 15 deletions(-) diff --git a/Dockerfile b/Dockerfile index 34084333..944e5924 100644 --- a/Dockerfile +++ b/Dockerfile @@ -59,21 +59,14 @@ RUN apk add --update --no-cache \ go \ icu-libs \ jq \ - libc-dev \ - libxml2-utils \ + libc-dev libxml2-utils \ make \ musl-dev \ npm nodejs-current \ openjdk8-jre \ perl \ - php7 \ - php7-phar \ - php7-json \ - php7-mbstring \ - php7-tokenizer \ - php7-ctype \ - php7-curl \ - php7-dom \ + php7 php7-phar php7-json php7-mbstring \ + php7-tokenizer php7-ctype php7-curl php7-dom \ py3-setuptools \ readline-dev \ ruby ruby-dev ruby-bundler ruby-rdoc \ diff --git a/lib/linter.sh b/lib/linter.sh index 183b5c8b..09647ad9 100755 --- a/lib/linter.sh +++ b/lib/linter.sh @@ -75,7 +75,7 @@ OPENAPI_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${OPENAPI_FILE_NAME}" PHPSTAN_FILE_NAME='phpstan.neon' # Name of the file PHPSTAN_LINTER_RULES="${GITHUB_WORKSPACE}/${PHPSTAN_FILE_NAME}" # Path to the PHPStan lint rules in the repository if [ ! -f "$PHPSTAN_LINTER_RULES" ]; then - PHPSTAN_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${PHPSTAN_FILE_NAME}" # Path to the PHPStan lint rules + PHPSTAN_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${PHPSTAN_FILE_NAME}" # Path to the PHPStan lint rules fi # Powershell Vars POWERSHELL_FILE_NAME='.powershell-psscriptanalyzer.psd1' # Name of the file @@ -125,7 +125,6 @@ LANGUAGE_ARRAY=('ANSIBLE' 'ARM' 'BASH' 'CLOUDFORMATION' 'CLOJURE' 'COFFEESCRIPT' ############################################ LINTED_LANGUAGES_ARRAY=() # Will be filled at run time with all languages that were linted - ################### # GitHub ENV Vars # ################### @@ -990,7 +989,7 @@ Footer() { ################## # Print if not 0 # ################## - if [ "${!ERROR_COUNTER}" -ne 0 ]; then + if [[ "${!ERROR_COUNTER}" -ne 0 ]]; then # We found errors in the language ################### # Print the goods # @@ -1004,7 +1003,7 @@ Footer() { ###################################### # Check if we validated the langauge # ###################################### - elif [ "${!ERROR_COUNTER}" -eq 0 ] && [[ "${UNIQUE_LINTED_ARRAY[*]}" =~ ${LANGUAGE} ]]; then + elif [[ "${!ERROR_COUNTER}" -eq 0 ]] && [[ "${UNIQUE_LINTED_ARRAY[*]}" =~ ${LANGUAGE} ]]; then # No errors found when linting the language CallStatusAPI "${LANGUAGE}" "success" fi @@ -1026,7 +1025,7 @@ Footer() { # build the variable ERRORS_FOUND_LANGUAGE="ERRORS_FOUND_${LANGUAGE}" # Check if error was found - if [ "${!ERRORS_FOUND_LANGUAGE}" -ne 0 ]; then + if [[ "${!ERRORS_FOUND_LANGUAGE}" -ne 0 ]]; then # Failed exit echo -e "${NC}${F[R]}Exiting with errors found!${NC}" exit 1 From c9de3b17834693f9b239dfca89d497b1a185e1d6 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 30 Jul 2020 05:32:52 +0000 Subject: [PATCH 094/135] Bump borkdude/clj-kondo from 2020.07.26 to 2020.07.29 Bumps borkdude/clj-kondo from 2020.07.26 to 2020.07.29. Signed-off-by: dependabot[bot] --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 944e5924..e50a42bf 100644 --- a/Dockerfile +++ b/Dockerfile @@ -7,7 +7,7 @@ ######################################### # Get dependency images as build stages # ######################################### -FROM borkdude/clj-kondo:2020.07.26 as clj-kondo +FROM borkdude/clj-kondo:2020.07.29 as clj-kondo FROM dotenvlinter/dotenv-linter:2.1.0 as dotenv-linter FROM mstruebing/editorconfig-checker:2.1.0 as editorconfig-checker FROM golangci/golangci-lint:v1.29.0 as golangci-lint From 8161414bef3d774d2081bd66922710b892a5dede Mon Sep 17 00:00:00 2001 From: Eric Nemchik Date: Thu, 30 Jul 2020 14:15:42 -0500 Subject: [PATCH 095/135] Use log functions for all output --- .automation/cleanup-docker.sh | 68 ++++---- .../templates/ghe-config-apply.sh | 20 +-- .automation/upload-docker.sh | 112 ++++++------- Dockerfile | 2 + lib/buildFileList.sh | 42 +++-- lib/linter.sh | 147 +++++++++--------- lib/log.sh | 6 +- lib/validation.sh | 42 +++-- lib/worker.sh | 94 +++++------ 9 files changed, 258 insertions(+), 275 deletions(-) diff --git a/.automation/cleanup-docker.sh b/.automation/cleanup-docker.sh index 028a8aa6..12d29c4b 100755 --- a/.automation/cleanup-docker.sh +++ b/.automation/cleanup-docker.sh @@ -29,11 +29,11 @@ DOCKERFILE_PATH="${DOCKERFILE_PATH}" # Path to the Dockerfile to be uploaded ################################################################################ #### Function Header ########################################################### Header() { - echo "" - echo "-------------------------------------------------------" - echo "----- GitHub Actions remove image from DockerHub ------" - echo "-------------------------------------------------------" - echo "" + echo + info "-------------------------------------------------------" + info "----- GitHub Actions remove image from DockerHub ------" + info "-------------------------------------------------------" + echo } ################################################################################ #### Function ValidateInput #################################################### @@ -42,11 +42,11 @@ ValidateInput() { ################ # Print header # ################ - echo "" - echo "----------------------------------------------" - echo "Gathering variables..." - echo "----------------------------------------------" - echo "" + echo + info "----------------------------------------------" + info "Gathering variables..." + info "----------------------------------------------" + echo ############################ # Validate GITHUB_WORKSPACE # @@ -55,7 +55,7 @@ ValidateInput() { error "Failed to get [GITHUB_WORKSPACE]!" fatal "[${GITHUB_WORKSPACE}]" else - echo "Successfully found:[GITHUB_WORKSPACE], value:[${GITHUB_WORKSPACE}]" + info "Successfully found:[GITHUB_WORKSPACE], value:[${GITHUB_WORKSPACE}]" fi ####################### @@ -67,10 +67,10 @@ ValidateInput() { fatal "[${IMAGE_REPO}]" elif [[ ${IMAGE_REPO} == "github/super-linter" ]]; then # Found our main repo - echo "Successfully found:[IMAGE_REPO], value:[${IMAGE_REPO}]" + info "Successfully found:[IMAGE_REPO], value:[${IMAGE_REPO}]" else # This is a fork and we cant pull vars or any info - warn "No image to cleanup as this is a forked branch, and not being built with current automation!${NC}" + warn "No image to cleanup as this is a forked branch, and not being built with current automation!" exit 0 fi @@ -81,7 +81,7 @@ ValidateInput() { error "Failed to get [IMAGE_VERSION]!" fatal "[${IMAGE_VERSION}]" else - echo "Successfully found:[IMAGE_VERSION], value:[${IMAGE_VERSION}]" + info "Successfully found:[IMAGE_VERSION], value:[${IMAGE_VERSION}]" fi ############################ @@ -91,7 +91,7 @@ ValidateInput() { error "Failed to get [DOCKER_USERNAME]!" fatal "[${DOCKER_USERNAME}]" else - echo "Successfully found:[DOCKER_USERNAME], value:[${DOCKER_USERNAME}]" + info "Successfully found:[DOCKER_USERNAME], value:[${DOCKER_USERNAME}]" fi ############################ @@ -101,7 +101,7 @@ ValidateInput() { error "Failed to get [DOCKER_PASSWORD]!" fatal "[${DOCKER_PASSWORD}]" else - echo "Successfully found:[DOCKER_PASSWORD], value:[********]" + info "Successfully found:[DOCKER_PASSWORD], value:[********]" fi ################################################## @@ -127,11 +127,11 @@ LoginToDocker() { ################ # Print header # ################ - echo "" - echo "----------------------------------------------" - echo "Login to DockerHub..." - echo "----------------------------------------------" - echo "" + echo + info "----------------------------------------------" + info "Login to DockerHub..." + info "----------------------------------------------" + echo ###################### # Login to DockerHub # @@ -152,7 +152,7 @@ LoginToDocker() { fatal "[${LOGIN_CMD}]" else # SUCCESS - echo "Successfully authenticated to DockerHub!" + info "Successfully authenticated to DockerHub!" fi } ################################################################################ @@ -161,11 +161,11 @@ RemoveImage() { ################ # Print header # ################ - echo "" - echo "----------------------------------------------" - echo "Removing the DockerFile image:[${IMAGE_REPO}:${IMAGE_VERSION}]" - echo "----------------------------------------------" - echo "" + echo + info "----------------------------------------------" + info "Removing the DockerFile image:[${IMAGE_REPO}:${IMAGE_VERSION}]" + info "----------------------------------------------" + echo ##################################### # Create Token to auth to DockerHub # @@ -190,7 +190,7 @@ RemoveImage() { fatal "[${TOKEN}]" else # SUCCESS - echo "Successfully gained auth token from DockerHub!" + info "Successfully gained auth token from DockerHub!" fi ################################# @@ -214,17 +214,17 @@ RemoveImage() { fatal "[${REMOVE_CMD}]" else # SUCCESS - echo "Successfully [removed] Docker image tag:[${IMAGE_VERSION}] from DockerHub!" + info "Successfully [removed] Docker image tag:[${IMAGE_VERSION}] from DockerHub!" fi } ################################################################################ #### Function Footer ########################################################### Footer() { - echo "" - echo "-------------------------------------------------------" - echo "The step has completed" - echo "-------------------------------------------------------" - echo "" + echo + info "-------------------------------------------------------" + info "The step has completed" + info "-------------------------------------------------------" + echo } ################################################################################ ################################## MAIN ######################################## diff --git a/.automation/test/ansible/ghe-initialize/templates/ghe-config-apply.sh b/.automation/test/ansible/ghe-initialize/templates/ghe-config-apply.sh index 9258978b..c7370032 100644 --- a/.automation/test/ansible/ghe-initialize/templates/ghe-config-apply.sh +++ b/.automation/test/ansible/ghe-initialize/templates/ghe-config-apply.sh @@ -28,17 +28,17 @@ CheckGHEPid() ################################## if [ ${PID_CHECK} -gt ${PID_CHECK_LIMIT} ]; then # Over the limit, move on - echo "We have checked the pid ${PID_CHECK} times, moving on..." + info "We have checked the pid ${PID_CHECK} times, moving on..." else ################################################ # Check to see if the PID is alive and running # ################################################ if [ ! -f "${GHE_CONFIG_PID}" ]; then # File not found - echo "We're good to move forward, no .pid file found at:[${GHE_CONFIG_PID}]" + info "We're good to move forward, no .pid file found at:[${GHE_CONFIG_PID}]" else # Found the pid running, need to sleep - echo "Current PID found, sleeping ${SLEEP_SECONDS} seconds before next check..." + info "Current PID found, sleeping ${SLEEP_SECONDS} seconds before next check..." ################ # Sleep it off # ################ @@ -55,7 +55,7 @@ CheckGHEPid() if [ ${ERROR_CODE} -ne 0 ]; then error "Failed to sleep!" error "[${SLEEP_CMD}]" - echo "Will try to call apply as last effort..." + info "Will try to call apply as last effort..." #################################### # Call config apply as last effort # #################################### @@ -82,7 +82,7 @@ CheckGHEProcess() ################################## if [ ${PROCESS_CHECK} -gt ${PROCESS_CHECK_LIMIT} ]; then # Over the limit, move on - echo "We have checked the process ${PROCESS_CHECK} times, moving on..." + info "We have checked the process ${PROCESS_CHECK} times, moving on..." else #################################################### # Check to see if the process is alive and running # @@ -99,10 +99,10 @@ CheckGHEProcess() ############################## if [ ${ERROR_CODE} -ne 0 ]; then # No process running on the system - echo "Were good to move forward, no process like:[${GHE_APPLY_COMMAND}] running currently on the system" + info "Were good to move forward, no process like:[${GHE_APPLY_COMMAND}] running currently on the system" else # Found the process running, need to sleep - echo "Current process alive:[${CHECK_PROCESS_CMD}], sleeping ${SLEEP_SECONDS} seconds before next check..." + info "Current process alive:[${CHECK_PROCESS_CMD}], sleeping ${SLEEP_SECONDS} seconds before next check..." ################ # Sleep it off # ################ @@ -119,7 +119,7 @@ CheckGHEProcess() if [ ${ERROR_CODE} -ne 0 ]; then error "Failed to sleep!" error "[${SLEEP_CMD}]" - echo "Will try to call apply as last effort..." + info "Will try to call apply as last effort..." #################################### # Call config apply as last effort # #################################### @@ -144,7 +144,7 @@ RunConfigApply() ########## # Header # ########## - echo "Running ${GHE_APPLY_COMMAND} to the server..." + info "Running ${GHE_APPLY_COMMAND} to the server..." ############################################## # Run the command to apply changes to server # @@ -165,7 +165,7 @@ RunConfigApply() fatal "[${APPLY_CMD}]" else # Success - notice "Successfully ran ${F[C]}${GHE_APPLY_COMMAND}${NC}" + info "Successfully ran ${F[C]}${GHE_APPLY_COMMAND}" fi } ################################################################################ diff --git a/.automation/upload-docker.sh b/.automation/upload-docker.sh index bbb1bae7..bac7f3e8 100755 --- a/.automation/upload-docker.sh +++ b/.automation/upload-docker.sh @@ -35,11 +35,11 @@ UPDATE_MAJOR_TAG=0 # Flag to deploy the major tag version as ################################################################################ #### Function Header ########################################################### Header() { - echo "" - echo "-------------------------------------------------------" - echo "---- GitHub Actions Upload image to [${REGISTRY}] ----" - echo "-------------------------------------------------------" - echo "" + echo + info "-------------------------------------------------------" + info "---- GitHub Actions Upload image to [${REGISTRY}] ----" + info "-------------------------------------------------------" + echo } ################################################################################ #### Function ValidateInput #################################################### @@ -48,11 +48,11 @@ ValidateInput() { ################ # Print header # ################ - echo "" - echo "----------------------------------------------" - echo "Gathering variables..." - echo "----------------------------------------------" - echo "" + echo + info "----------------------------------------------" + info "Gathering variables..." + info "----------------------------------------------" + echo ############################# # Validate GITHUB_WORKSPACE # @@ -61,7 +61,7 @@ ValidateInput() { error "Failed to get [GITHUB_WORKSPACE]!" fatal "[${GITHUB_WORKSPACE}]" else - notice "Successfully found:${F[W]}[GITHUB_WORKSPACE]${F[B]}, value:${F[W]}[${GITHUB_WORKSPACE}]${NC}" + info "Successfully found:${F[W]}[GITHUB_WORKSPACE]${F[B]}, value:${F[W]}[${GITHUB_WORKSPACE}]" fi ##################### @@ -71,7 +71,7 @@ ValidateInput() { error "Failed to get [REGISTRY]!" fatal "[${REGISTRY}]" else - notice "Successfully found:${F[W]}[REGISTRY]${F[B]}, value:${F[W]}[${REGISTRY}]${NC}" + info "Successfully found:${F[W]}[REGISTRY]${F[B]}, value:${F[W]}[${REGISTRY}]" fi ##################################################### @@ -85,7 +85,7 @@ ValidateInput() { error "Failed to get [GPR_USERNAME]!" fatal "[${GPR_USERNAME}]" else - notice "Successfully found:${F[W]}[GPR_USERNAME]${F[B]}, value:${F[W]}[${GPR_USERNAME}]${NC}" + info "Successfully found:${F[W]}[GPR_USERNAME]${F[B]}, value:${F[W]}[${GPR_USERNAME}]" fi ###################### @@ -95,7 +95,7 @@ ValidateInput() { error "Failed to get [GPR_TOKEN]!" fatal "[${GPR_TOKEN}]" else - notice "Successfully found:${F[W]}[GPR_TOKEN]${F[B]}, value:${F[W]}[********]${NC}" + info "Successfully found:${F[W]}[GPR_TOKEN]${F[B]}, value:${F[W]}[********]" fi ######################################## # See if we need values for Ducker hub # @@ -108,7 +108,7 @@ ValidateInput() { error "Failed to get [DOCKER_USERNAME]!" fatal "[${DOCKER_USERNAME}]" else - notice "Successfully found:${F[W]}[DOCKER_USERNAME]${F[B]}, value:${F[W]}[${DOCKER_USERNAME}]${NC}" + info "Successfully found:${F[W]}[DOCKER_USERNAME]${F[B]}, value:${F[W]}[${DOCKER_USERNAME}]" fi ############################ @@ -118,7 +118,7 @@ ValidateInput() { error "Failed to get [DOCKER_PASSWORD]!" fatal "[${DOCKER_PASSWORD}]" else - notice "Successfully found:${F[W]}[DOCKER_PASSWORD]${F[B]}, value:${F[B]}[********]${NC}" + info "Successfully found:${F[W]}[DOCKER_PASSWORD]${F[B]}, value:${F[B]}[********]" fi ########################################### # We were not passed a registry to update # @@ -135,14 +135,14 @@ ValidateInput() { error "Failed to get [IMAGE_REPO]!" fatal "[${IMAGE_REPO}]" else - notice "Successfully found:${F[W]}[IMAGE_REPO]${F[B]}, value:${F[W]}[${IMAGE_REPO}]${NC}" + info "Successfully found:${F[W]}[IMAGE_REPO]${F[B]}, value:${F[W]}[${IMAGE_REPO}]" ############################################### # Need to see if GPR registry and update name # ############################################### if [[ ${REGISTRY} == "GPR" ]]; then NAME="docker.pkg.github.com/${IMAGE_REPO}/super-linter" IMAGE_REPO="${NAME}" - echo "Updated [IMAGE_REPO] to:[${IMAGE_REPO}] for GPR" + info "Updated [IMAGE_REPO] to:[${IMAGE_REPO}] for GPR" fi fi @@ -150,8 +150,8 @@ ValidateInput() { # Validate IMAGE_VERSION # ########################## if [ -z "${IMAGE_VERSION}" ]; then - warn "Failed to get [IMAGE_VERSION]!${NC}" - echo "Pulling from Branch Name..." + warn "Failed to get [IMAGE_VERSION]!" + info "Pulling from Branch Name..." ############################## # Get the name of the branch # ############################## @@ -179,9 +179,9 @@ ValidateInput() { # Set the IMAGE_VERSION to the BRANCH_NAME # ############################################ IMAGE_VERSION="${BRANCH_NAME}" - echo "Tag:[${IMAGE_VERSION}]" + info "Tag:[${IMAGE_VERSION}]" else - notice "Successfully found:${F[W]}[IMAGE_VERSION]${F[B]}, value:${F[W]}[${IMAGE_VERSION}]${NC}" + info "Successfully found:${F[W]}[IMAGE_VERSION]${F[B]}, value:${F[W]}[${IMAGE_VERSION}]" fi ################################## @@ -205,7 +205,7 @@ ValidateInput() { ################################### UPDATE_MAJOR_TAG=1 - echo "- Also deploying a major tag of:[${MAJOR_TAG}]" + info "- Also deploying a major tag of:[${MAJOR_TAG}]" fi ############################ @@ -215,7 +215,7 @@ ValidateInput() { error "Failed to get [DOCKERFILE_PATH]!" fatal "[${DOCKERFILE_PATH}]" else - notice "Successfully found:${F[W]}[DOCKERFILE_PATH]${F[B]}, value:${F[W]}[${DOCKERFILE_PATH}]${NC}" + info "Successfully found:${F[W]}[DOCKERFILE_PATH]${F[B]}, value:${F[W]}[${DOCKERFILE_PATH}]" fi } ################################################################################ @@ -232,11 +232,11 @@ Authenticate() { ################ # Print header # ################ - echo "" - echo "----------------------------------------------" - echo "Login to ${NAME}..." - echo "----------------------------------------------" - echo "" + echo + info "----------------------------------------------" + info "Login to ${NAME}..." + info "----------------------------------------------" + echo ################### # Auth to service # @@ -257,7 +257,7 @@ Authenticate() { fatal "[${LOGIN_CMD}]" fatal else # SUCCESS - notice "Successfully authenticated to ${F[C]}${NAME}${F[B]}!${NC}" + info "Successfully authenticated to ${F[C]}${NAME}${F[B]}!" fi } ################################################################################ @@ -266,11 +266,11 @@ BuildImage() { ################ # Print header # ################ - echo "" - echo "----------------------------------------------" - echo "Building the DockerFile image..." - echo "----------------------------------------------" - echo "" + echo + info "----------------------------------------------" + info "Building the DockerFile image..." + info "----------------------------------------------" + echo ################################ # Validate the DOCKERFILE_PATH # @@ -300,7 +300,7 @@ BuildImage() { fatal "failed to [build] Dockerfile!" else # SUCCESS - notice "Successfully Built image!${NC}" + info "Successfully Built image!" fi ######################################################## @@ -323,7 +323,7 @@ BuildImage() { fatal "failed to [tag] Dockerfile!" else # SUCCESS - notice "Successfully tagged image!${NC}" + info "Successfully tagged image!" fi fi } @@ -333,11 +333,11 @@ UploadImage() { ################ # Print header # ################ - echo "" - echo "----------------------------------------------" - echo "Uploading the DockerFile image to ${REGISTRY}..." - echo "----------------------------------------------" - echo "" + echo + info "----------------------------------------------" + info "Uploading the DockerFile image to ${REGISTRY}..." + info "----------------------------------------------" + echo ############################################ # Upload the docker image that was created # @@ -357,7 +357,7 @@ UploadImage() { fatal "failed to [upload] Dockerfile!" else # SUCCESS - notice "Successfully Uploaded Docker image:${F[W]}[${IMAGE_VERSION}]${F[B]} to ${F[C]}${REGISTRY}${F[B]}!${NC}" + info "Successfully Uploaded Docker image:${F[W]}[${IMAGE_VERSION}]${F[B]} to ${F[C]}${REGISTRY}${F[B]}!" fi ######################### @@ -390,13 +390,13 @@ UploadImage() { ################### # Print the goods # ################### - echo "----------------------------------------------" - echo "Docker Image Details:" - echo "Repository:[${REPO}]" - echo "Tag:[${TAG}]" - echo "Image_ID:[${IMAGE_ID}]" - echo "Size:[${SIZE}]" - echo "----------------------------------------------" + info "----------------------------------------------" + info "Docker Image Details:" + info "Repository:[${REPO}]" + info "Tag:[${TAG}]" + info "Image_ID:[${IMAGE_ID}]" + info "Size:[${SIZE}]" + info "----------------------------------------------" fi ############################################################### @@ -421,18 +421,18 @@ UploadImage() { fatal "failed to [upload] MAJOR_TAG:[${MAJOR_TAG}] Dockerfile!" else # SUCCESS - notice "Successfully Uploaded TAG:${F[W]}[${MAJOR_TAG}]${F[B]} of Docker image to ${F[C]}${REGISTRY}${F[B]}!${NC}" + info "Successfully Uploaded TAG:${F[W]}[${MAJOR_TAG}]${F[B]} of Docker image to ${F[C]}${REGISTRY}${F[B]}!" fi fi } ################################################################################ #### Function Footer ########################################################### Footer() { - echo "" - echo "-------------------------------------------------------" - echo "The step has completed" - echo "-------------------------------------------------------" - echo "" + echo + info "-------------------------------------------------------" + info "The step has completed" + info "-------------------------------------------------------" + echo } ################################################################################ ################################## MAIN ######################################## diff --git a/Dockerfile b/Dockerfile index e50a42bf..3533b1d8 100644 --- a/Dockerfile +++ b/Dockerfile @@ -228,6 +228,8 @@ ENV ACTIONS_RUNNER_DEBUG=${ACTIONS_RUNNER_DEBUG} \ GITHUB_TOKEN=${GITHUB_TOKEN} \ GITHUB_WORKSPACE=${GITHUB_WORKSPACE} \ LINTER_RULES_PATH=${LINTER_RULES_PATH} \ + LOG_FILE=${LOG_FILE} \ + LOG_LEVEL=${LOG_LEVEL} \ OUTPUT_DETAILS=${OUTPUT_DETAILS} \ OUTPUT_FOLDER=${OUTPUT_FOLDER} \ OUTPUT_FORMAT=${OUTPUT_FORMAT} \ diff --git a/lib/buildFileList.sh b/lib/buildFileList.sh index 4a64eea3..ccd47747 100755 --- a/lib/buildFileList.sh +++ b/lib/buildFileList.sh @@ -16,11 +16,8 @@ function BuildFileList() { ################ # print header # ################ - if [[ ${ACTIONS_RUNNER_DEBUG} == "true" ]]; then - echo "" - echo "----------------------------------------------" - echo "Pulling in code history and branches..." - fi + debug "----------------------------------------------" + debug "Pulling in code history and branches..." ################################################################################# # Switch codebase back to the default branch to get a list of all files changed # @@ -40,18 +37,15 @@ function BuildFileList() { ############################## if [ ${ERROR_CODE} -ne 0 ]; then # Error - echo "Failed to switch to ${DEFAULT_BRANCH} branch to get files changed!" + info "Failed to switch to ${DEFAULT_BRANCH} branch to get files changed!" fatal "[${SWITCH_CMD}]" fi ################ # print header # ################ - if [[ ${ACTIONS_RUNNER_DEBUG} == "true" ]]; then - echo "" - echo "----------------------------------------------" - echo "Generating Diff with:[git diff --name-only '${DEFAULT_BRANCH}..${GITHUB_SHA}' --diff-filter=d]" - fi + debug "----------------------------------------------" + debug "Generating Diff with:[git diff --name-only '${DEFAULT_BRANCH}..${GITHUB_SHA}' --diff-filter=d]" ################################################# # Get the Array of files changed in the commits # @@ -75,9 +69,9 @@ function BuildFileList() { ################################################ # Iterate through the array of all files found # ################################################ - echo "" - echo "----------------------------------------------" - echo "Files that have been modified in the commit(s):" + echo + info "----------------------------------------------" + info "Files that have been modified in the commit(s):" for FILE in "${RAW_FILE_ARRAY[@]}"; do ########################### # Get the files extension # @@ -90,12 +84,12 @@ function BuildFileList() { ############## # Print file # ############## - echo "File:[${FILE}], File_type:[${FILE_TYPE}]" + info "File:[${FILE}], File_type:[${FILE_TYPE}]" ######### # DEBUG # ######### - #echo "FILE_TYPE:[${FILE_TYPE}]" + debug "FILE_TYPE:[${FILE_TYPE}]" ################################ # Get the CLOUDFORMATION files # @@ -472,8 +466,8 @@ function BuildFileList() { ####################### # It is a bash script # ####################### - warn "Found bash script without extension:[.sh]${NC}" - echo "Please update file with proper extensions." + warn "Found bash script without extension:[.sh]" + info "Please update file with proper extensions." ################################ # Append the file to the array # ################################ @@ -486,8 +480,8 @@ function BuildFileList() { ####################### # It is a Ruby script # ####################### - warn "Found ruby script without extension:[.rb]${NC}" - echo "Please update file with proper extensions." + warn "Found ruby script without extension:[.rb]" + info "Please update file with proper extensions." ################################ # Append the file to the array # ################################ @@ -500,7 +494,7 @@ function BuildFileList() { ############################ # Extension was not found! # ############################ - warn "Failed to get filetype for:[${FILE}]!${NC}" + warn "Failed to get filetype for:[${FILE}]!" ########################################################## # Set the READ_ONLY_CHANGE_FLAG since this could be exec # ########################################################## @@ -533,7 +527,7 @@ function BuildFileList() { ################ # Footer print # ################ - echo "" - echo "----------------------------------------------" - notice "Successfully gathered list of files...${NC}" + echo + info "----------------------------------------------" + info "Successfully gathered list of files..." } diff --git a/lib/linter.sh b/lib/linter.sh index bb9928cc..f94dd7bc 100755 --- a/lib/linter.sh +++ b/lib/linter.sh @@ -137,6 +137,8 @@ GITHUB_RUN_ID="${GITHUB_RUN_ID}" # GitHub GITHUB_SHA="${GITHUB_SHA}" # GitHub sha from the commit GITHUB_TOKEN="${GITHUB_TOKEN}" # GitHub Token passed from environment GITHUB_WORKSPACE="${GITHUB_WORKSPACE}" # Github Workspace +LOG_FILE="${LOG_FILE:-super-linter.log}" # Default log file name (located in GITHUB_WORKSPACE folder) +LOG_LEVEL="${LOG_LEVEL:-VERBOSE}" # Default log level (VERBOSE, DEBUG, TRACE) MULTI_STATUS="${MULTI_STATUS:-true}" # Multiple status are created for each check ran TEST_CASE_RUN="${TEST_CASE_RUN}" # Boolean to validate only test cases VALIDATE_ALL_CODEBASE="${VALIDATE_ALL_CODEBASE}" # Boolean to validate all files @@ -185,6 +187,16 @@ VALIDATE_YAML="${VALIDATE_YAML}" # Boolean RUN_LOCAL="${RUN_LOCAL}" # Boolean to see if we are running locally ACTIONS_RUNNER_DEBUG="${ACTIONS_RUNNER_DEBUG:-false}" # Boolean to see even more info (debug) +############ +# Log Vars # +############ +LOG_TRACE=$(if [[ ${LOG_LEVEL} == "TRACE" ]]; then echo "true";fi) # Boolean to see trace logs +export LOG_TRACE +LOG_DEBUG=$(if [[ ${LOG_LEVEL} == "DEBUG" || ${ACTIONS_RUNNER_DEBUG} == true ]]; then echo "true";fi) # Boolean to see debug logs +export LOG_DEBUG +LOG_VERBOSE=$(if [[ ${LOG_LEVEL} == "VERBOSE" ]]; then echo "true";fi) # Boolean to see verbose logs (info function) +export LOG_VERBOSE + ################ # Default Vars # ################ @@ -352,15 +364,15 @@ Header() { ########## # Prints # ########## - echo "" - echo "---------------------------------------------" - echo "--- GitHub Actions Multi Language Linter ----" - echo "---------------------------------------------" - echo "" - echo "---------------------------------------------" - echo "The Super-Linter source code can be found at:" - echo " - https://github.com/github/super-linter" - echo "---------------------------------------------" + echo + info "---------------------------------------------" + info "--- GitHub Actions Multi Language Linter ----" + info "---------------------------------------------" + echo + info "---------------------------------------------" + info "The Super-Linter source code can be found at:" + info " - https://github.com/github/super-linter" + info "---------------------------------------------" } ################################################################################ #### Function GetLinterVersions ################################################ @@ -368,9 +380,8 @@ GetLinterVersions() { ######################### # Print version headers # ######################### - echo "" - echo "---------------------------------------------" - echo "Linter Version Info:" + debug "---------------------------------------------" + debug "Linter Version Info:" ########################################################## # Go through the array of linters and print version info # @@ -399,20 +410,19 @@ GetLinterVersions() { # Check the shell for errors # ############################## if [ ${ERROR_CODE} -ne 0 ] || [ -z "${GET_VERSION_CMD[*]}" ]; then - warn "[${LINTER}]: Failed to get version info for:${NC}" + warn "[${LINTER}]: Failed to get version info for:" else ########################## # Print the version info # ########################## - notice "Successfully found version for ${F[W]}[${LINTER}]${F[B]}: ${F[W]}${GET_VERSION_CMD[*]}${NC}" + debug "Successfully found version for ${F[W]}[${LINTER}]${F[B]}: ${F[W]}${GET_VERSION_CMD[*]}" fi done ######################### # Print version footers # ######################### - echo "---------------------------------------------" - echo "" + debug "---------------------------------------------" } ################################################################################ #### Function GetLinterRules ################################################### @@ -434,8 +444,8 @@ GetLinterRules() { # Validate we have the linter rules # ##################################### if [ -f "${GITHUB_WORKSPACE}/${LINTER_RULES_PATH}/${!LANGUAGE_FILE_NAME}" ]; then - echo "----------------------------------------------" - echo "User provided file:[${!LANGUAGE_FILE_NAME}], setting rules file..." + info "----------------------------------------------" + info "User provided file:[${!LANGUAGE_FILE_NAME}], setting rules file..." ######################################## # Update the path to the file location # @@ -445,9 +455,7 @@ GetLinterRules() { ######################################################## # No user default provided, using the template default # ######################################################## - if [[ ${ACTIONS_RUNNER_DEBUG} == "true" ]]; then - echo " -> Codebase does NOT have file:[${LINTER_RULES_PATH}/${!LANGUAGE_FILE_NAME}], using Default rules at:[${!LANGUAGE_LINTER_RULES}]" - fi + debug " -> Codebase does NOT have file:[${LINTER_RULES_PATH}/${!LANGUAGE_FILE_NAME}], using Default rules at:[${!LANGUAGE_LINTER_RULES}]" fi } ################################################################################ @@ -514,7 +522,7 @@ GetStandardRules() { # Get the env to add to string # ################################ ENV="$(echo "${ENV}" | cut -d'"' -f2)" - # echo "ENV:[${ENV}]" + debug "ENV:[${ENV}]" ENV_STRING+="--env ${ENV} " done @@ -652,8 +660,8 @@ GetGitHubVars() { ########## # Prints # ########## - echo "--------------------------------------------" - echo "Gathering GitHub information..." + info "--------------------------------------------" + info "Gathering GitHub information..." ############################### # Get the Run test cases flag # @@ -692,8 +700,8 @@ GetGitHubVars() { ########################################## # We are running locally for a debug run # ########################################## - echo "NOTE: ENV VAR [RUN_LOCAL] has been set to:[true]" - echo "bypassing GitHub Actions variables..." + info "NOTE: ENV VAR [RUN_LOCAL] has been set to:[true]" + info "bypassing GitHub Actions variables..." ############################ # Set the GITHUB_WORKSPACE # @@ -706,7 +714,7 @@ GetGitHubVars() { fatal "Provided volume is not a directory!" fi - echo "Linting all files in mapped directory:[${DEFAULT_WORKSPACE}]" + info "Linting all files in mapped directory:[${DEFAULT_WORKSPACE}]" # No need to touch or set the GITHUB_SHA # No need to touch or set the GITHUB_EVENT_PATH @@ -725,7 +733,7 @@ GetGitHubVars() { error "Failed to get [GITHUB_SHA]!" fatal "[${GITHUB_SHA}]" else - notice "Successfully found:${F[W]}[GITHUB_SHA]${F[B]}, value:${F[W]}[${GITHUB_SHA}]${NC}" + info "Successfully found:${F[W]}[GITHUB_SHA]${F[B]}, value:${F[W]}[${GITHUB_SHA}]" fi ############################ @@ -735,7 +743,7 @@ GetGitHubVars() { error "Failed to get [GITHUB_WORKSPACE]!" fatal "[${GITHUB_WORKSPACE}]" else - notice "Successfully found:${F[W]}[GITHUB_WORKSPACE]${F[B]}, value:${F[W]}[${GITHUB_WORKSPACE}]${NC}" + info "Successfully found:${F[W]}[GITHUB_WORKSPACE]${F[B]}, value:${F[W]}[${GITHUB_WORKSPACE}]" fi ############################ @@ -745,7 +753,7 @@ GetGitHubVars() { error "Failed to get [GITHUB_EVENT_PATH]!" fatal "[${GITHUB_EVENT_PATH}]" else - notice "Successfully found:${F[W]}[GITHUB_EVENT_PATH]${F[B]}, value:${F[W]}[${GITHUB_EVENT_PATH}]${F[B]}${NC}" + info "Successfully found:${F[W]}[GITHUB_EVENT_PATH]${F[B]}, value:${F[W]}[${GITHUB_EVENT_PATH}]${F[B]}" fi ################################################## @@ -764,7 +772,7 @@ GetGitHubVars() { error "Failed to get [GITHUB_ORG]!" fatal "[${GITHUB_ORG}]" else - notice "Successfully found:${F[W]}[GITHUB_ORG]${F[B]}, value:${F[W]}[${GITHUB_ORG}]${NC}" + info "Successfully found:${F[W]}[GITHUB_ORG]${F[B]}, value:${F[W]}[${GITHUB_ORG}]" fi ####################### @@ -779,7 +787,7 @@ GetGitHubVars() { error "Failed to get [GITHUB_REPO]!" fatal "[${GITHUB_REPO}]" else - notice "Successfully found:${F[W]}[GITHUB_REPO]${F[B]}, value:${F[W]}[${GITHUB_REPO}]${NC}" + info "Successfully found:${F[W]}[GITHUB_REPO]${F[B]}, value:${F[W]}[${GITHUB_REPO}]" fi fi @@ -796,7 +804,7 @@ GetGitHubVars() { ################################################################################ MULTI_STATUS='false' else - notice "Successfully found:${F[W]}[GITHUB_TOKEN]${NC}" + info "Successfully found:${F[W]}[GITHUB_TOKEN]" fi ############################### @@ -815,7 +823,7 @@ GetGitHubVars() { error "Failed to get [GITHUB_REPOSITORY]!" fatal "[${GITHUB_REPOSITORY}]" else - notice "Successfully found:${F[W]}[GITHUB_REPOSITORY]${F[B]}, value:${F[W]}[${GITHUB_REPOSITORY}]${NC}" + info "Successfully found:${F[W]}[GITHUB_REPOSITORY]${F[B]}, value:${F[W]}[${GITHUB_REPOSITORY}]" fi ############################ @@ -825,7 +833,7 @@ GetGitHubVars() { error "Failed to get [GITHUB_RUN_ID]!" fatal "[${GITHUB_RUN_ID}]" else - notice "Successfully found:${F[W]}[GITHUB_RUN_ID]${F[B]}, value:${F[W]}[${GITHUB_RUN_ID}]${NC}" + info "Successfully found:${F[W]}[GITHUB_RUN_ID]${F[B]}, value:${F[W]}[${GITHUB_RUN_ID}]" fi fi } @@ -861,10 +869,8 @@ function ValidatePowershellModules() { fatal "[PSSA_MODULE ${VALIDATE_PSSA_MODULE}] [PSSA_CMD ${VALIDATE_PSSA_CMD}]" else # Success - if [[ ${ACTIONS_RUNNER_DEBUG} == "true" ]]; then - notice "Successfully found module ${F[W]}[${VALIDATE_PSSA_MODULE}]${F[B]} in system${NC}" - notice "Successfully found command ${F[W]}[${VALIDATE_PSSA_CMD}]${F[B]} in system${NC}" - fi + debug "Successfully found module ${F[W]}[${VALIDATE_PSSA_MODULE}]${F[B]} in system" + debug "Successfully found command ${F[W]}[${VALIDATE_PSSA_CMD}]${F[B]} in system" fi } ################################################################################ @@ -917,8 +923,8 @@ CallStatusAPI() { ############################## if [ "${ERROR_CODE}" -ne 0 ]; then # ERROR - echo "ERROR! Failed to call GitHub Status API!" - echo "ERROR:[${SEND_STATUS_CMD}]" + info "ERROR! Failed to call GitHub Status API!" + info "ERROR:[${SEND_STATUS_CMD}]" # Not going to fail the script on this yet... fi fi @@ -926,39 +932,39 @@ CallStatusAPI() { ################################################################################ #### Function Reports ########################################################## Reports() { - echo "" - echo "----------------------------------------------" - echo "----------------------------------------------" - echo "Generated reports:" - echo "----------------------------------------------" - echo "----------------------------------------------" - echo "" + echo + info "----------------------------------------------" + info "----------------------------------------------" + info "Generated reports:" + info "----------------------------------------------" + info "----------------------------------------------" + echo ################################### # Prints output report if enabled # ################################### if [ -z "${FORMAT_REPORT}" ] ; then - echo "Reports generated in folder ${REPORT_OUTPUT_FOLDER}" + info "Reports generated in folder ${REPORT_OUTPUT_FOLDER}" fi ################################ # Prints for warnings if found # ################################ for TEST in "${WARNING_ARRAY_TEST[@]}"; do - warn "Expected file to compare with was not found for ${TEST}${NC}" + warn "Expected file to compare with was not found for ${TEST}" done } ################################################################################ #### Function Footer ########################################################### Footer() { - echo "" - echo "----------------------------------------------" - echo "----------------------------------------------" - echo "The script has completed" - echo "----------------------------------------------" - echo "----------------------------------------------" - echo "" + echo + info "----------------------------------------------" + info "----------------------------------------------" + info "The script has completed" + info "----------------------------------------------" + info "----------------------------------------------" + echo #################################################### # Need to clean up the lanuage array of duplicates # @@ -1001,7 +1007,7 @@ Footer() { # Exit with 0 if errors disabled # ################################## if [ "${DISABLE_ERRORS}" == "true" ]; then - warn "Exiting with exit code:[0] as:[DISABLE_ERRORS] was set to:[${DISABLE_ERRORS}]${NC}" + warn "Exiting with exit code:[0] as:[DISABLE_ERRORS] was set to:[${DISABLE_ERRORS}]" exit 0 fi @@ -1022,10 +1028,10 @@ Footer() { ######################## # Footer prints Exit 0 # ######################## - echo "" - notice "All file(s) linted successfully with no errors detected${NC}" - echo "----------------------------------------------" - echo "" + echo + notice "All file(s) linted successfully with no errors detected" + info "----------------------------------------------" + echo # Successful exit exit 0 } @@ -1036,7 +1042,7 @@ Footer() { cleanup() { local -ri EXIT_CODE=$? - sudo sh -c "cat ${LOG_TEMP} >> ${GITHUB_WORKSPACE}/super-linter.log" || true + sudo sh -c "cat ${LOG_TEMP} >> ${GITHUB_WORKSPACE}/${LOG_FILE}" || true exit ${EXIT_CODE} trap - 0 1 2 3 6 14 15 @@ -1118,15 +1124,10 @@ GetLinterRules "TYPESCRIPT" # Get YAML rules GetLinterRules "YAML" -################################# -# Check if were in verbose mode # -################################# -if [[ ${ACTIONS_RUNNER_DEBUG} == "true" ]]; then - ################################## - # Get and print all version info # - ################################## - GetLinterVersions -fi +################################## +# Get and print all version info # +################################## +GetLinterVersions ########################################### # Check to see if this is a test case run # @@ -1562,7 +1563,7 @@ if [ "${VALIDATE_RAKU}" == "true" ]; then ####################### # Lint the raku files # ####################### - echo "${GITHUB_WORKSPACE}/META6.json" + info "${GITHUB_WORKSPACE}/META6.json" if [ -e "${GITHUB_WORKSPACE}/META6.json" ]; then cd "${GITHUB_WORKSPACE}" && zef install --deps-only --/test . fi diff --git a/lib/log.sh b/lib/log.sh index 532a60a5..fce6b072 100644 --- a/lib/log.sh +++ b/lib/log.sh @@ -41,9 +41,9 @@ log() { fi ) } -trace() { log "${TRACE:-}" "${NC}$(date +"%F %T") ${F[B]}[TRACE ]${NC} $*${NC}"; } -debug() { log "${DEBUG:-}" "${NC}$(date +"%F %T") ${F[B]}[DEBUG ]${NC} $*${NC}"; } -info() { log "${VERBOSE:-}" "${NC}$(date +"%F %T") ${F[B]}[INFO ]${NC} $*${NC}"; } +trace() { log "${LOG_TRACE:-}" "${NC}$(date +"%F %T") ${F[B]}[TRACE ]${NC} $*${NC}"; } +debug() { log "${LOG_DEBUG:-}" "${NC}$(date +"%F %T") ${F[B]}[DEBUG ]${NC} $*${NC}"; } +info() { log "${LOG_VERBOSE:-}" "${NC}$(date +"%F %T") ${F[B]}[INFO ]${NC} $*${NC}"; } notice() { log "true" "${NC}$(date +"%F %T") ${F[G]}[NOTICE]${NC} $*${NC}"; } warn() { log "true" "${NC}$(date +"%F %T") ${F[Y]}[WARN ]${NC} $*${NC}"; } error() { log "true" "${NC}$(date +"%F %T") ${F[R]}[ERROR ]${NC} $*${NC}"; } diff --git a/lib/validation.sh b/lib/validation.sh index 178ffbae..1cc7517d 100755 --- a/lib/validation.sh +++ b/lib/validation.sh @@ -13,9 +13,9 @@ function GetValidationInfo() { ############################################ # Print headers for user provided env vars # ############################################ - echo "" - echo "--------------------------------------------" - echo "Gathering user validation information..." + echo + info "--------------------------------------------" + info "Gathering user validation information..." ########################################### # Skip validation if were running locally # @@ -31,10 +31,10 @@ function GetValidationInfo() { if [[ ${VALIDATE_ALL_CODEBASE} != "false" ]]; then # Set to true VALIDATE_ALL_CODEBASE="${DEFAULT_VALIDATE_ALL_CODEBASE}" - echo "- Validating ALL files in code base..." + info "- Validating ALL files in code base..." else # Its false - echo "- Only validating [new], or [edited] files in code base..." + info "- Only validating [new], or [edited] files in code base..." fi fi @@ -167,23 +167,19 @@ function GetValidationInfo() { ACTIONS_RUNNER_DEBUG="true" fi - ################### - # Debug on runner # - ################### - if [[ ${ACTIONS_RUNNER_DEBUG} == "true" ]]; then - ########################### - # Print the validate info # - ########################### - for LINE in "${PRINT_ARRAY[@]}"; do - echo "${LINE}" - done + ########################### + # Print the validate info # + ########################### + for LINE in "${PRINT_ARRAY[@]}"; do + debug "${LINE}" + done - echo "--- DEBUG INFO ---" - echo "---------------------------------------------" - RUNNER=$(whoami) - echo "Runner:[${RUNNER}]" - echo "ENV:" - printenv - echo "---------------------------------------------" - fi + debug "--- DEBUG INFO ---" + debug "---------------------------------------------" + RUNNER=$(whoami) + debug "Runner:[${RUNNER}]" + PRINTENV=$(printenv) + debug "ENV:" + debug "${PRINTENV}" + debug "---------------------------------------------" } diff --git a/lib/worker.sh b/lib/worker.sh index 39312b35..a2d1c1eb 100755 --- a/lib/worker.sh +++ b/lib/worker.sh @@ -53,9 +53,7 @@ function LintCodebase() { fatal "[${VALIDATE_INSTALL_CMD}]" else # Success - if [[ ${ACTIONS_RUNNER_DEBUG} == "true" ]]; then - notice "Successfully found binary for ${F[W]}[${LINTER_NAME}]${F[B]} in system location: ${F[W]}[${VALIDATE_INSTALL_CMD}]${NC}" - fi + debug "Successfully found binary for ${F[W]}[${LINTER_NAME}]${F[B]} in system location: ${F[W]}[${VALIDATE_INSTALL_CMD}]" fi ########################## @@ -74,7 +72,7 @@ function LintCodebase() { if [ ${#FILE_ARRAY[@]} -eq 0 ] && [ "${VALIDATE_ALL_CODEBASE}" == "false" ]; then # No files found in commit and user has asked to not validate code base SKIP_FLAG=1 - # echo " - No files found in changeset to lint for language:[${FILE_TYPE}]" + debug " - No files found in changeset to lint for language:[${FILE_TYPE}]" elif [ ${#FILE_ARRAY[@]} -ne 0 ]; then # We have files added to array of files to check LIST_FILES=("${FILE_ARRAY[@]}") # Copy the array into list @@ -120,7 +118,7 @@ function LintCodebase() { ######################### # Print the header info # ######################### - echo "${LINE}" + info "${LINE}" done ######################################## @@ -165,8 +163,8 @@ function LintCodebase() { ############## # File print # ############## - echo "---------------------------" - echo "File:[${FILE}]" + info "---------------------------" + info "File:[${FILE}]" ################################# # Add the language to the array # @@ -242,7 +240,7 @@ function LintCodebase() { ########### # Success # ########### - notice " - File:${F[W]}[${FILE_NAME}]${F[B]} was linted with ${F[W]}[${LINTER_NAME}]${F[B]} successfully${NC}" + info " - File:${F[W]}[${FILE_NAME}]${F[B]} was linted with ${F[W]}[${LINTER_NAME}]${F[B]} successfully" ####################################################### # Store the linting as a temporary file in TAP format # @@ -278,13 +276,13 @@ function TestCodebase() { ################ # print header # ################ - echo "" - echo "----------------------------------------------" - echo "----------------------------------------------" - echo "Testing Codebase [${FILE_TYPE}] files..." - echo "----------------------------------------------" - echo "----------------------------------------------" - echo "" + echo + info "----------------------------------------------" + info "----------------------------------------------" + info "Testing Codebase [${FILE_TYPE}] files..." + info "----------------------------------------------" + info "----------------------------------------------" + echo ##################################### # Validate we have linter installed # @@ -305,7 +303,7 @@ function TestCodebase() { fatal "[${VALIDATE_INSTALL_CMD}]" else # Success - notice "Successfully found binary for ${F[W]}[${LINTER_NAME}]${F[B]} in system location: ${F[W]}[${VALIDATE_INSTALL_CMD}]${NC}" + info "Successfully found binary for ${F[W]}[${LINTER_NAME}]${F[B]} in system location: ${F[W]}[${VALIDATE_INSTALL_CMD}]" fi ########################## @@ -356,8 +354,8 @@ function TestCodebase() { ############## # File print # ############## - echo "---------------------------" - echo "File:[${FILE}]" + info "---------------------------" + info "File:[${FILE}]" ######################## # Set the lint command # @@ -461,7 +459,7 @@ function TestCodebase() { ########### # Success # ########### - notice " - File:${F[W]}[${FILE_NAME}]${F[B]} was linted with ${F[W]}[${LINTER_NAME}]${F[B]} successfully${NC}" + info " - File:${F[W]}[${FILE_NAME}]${F[B]} was linted with ${F[W]}[${LINTER_NAME}]${F[B]} successfully" fi ####################################################### # Store the linting as a temporary file in TAP format # @@ -491,7 +489,7 @@ function TestCodebase() { ########### # Success # ########### - notice " - File:${F[W]}[${FILE_NAME}]${F[B]} failed test case with ${F[W]}[${LINTER_NAME}]${F[B]} successfully${NC}" + info " - File:${F[W]}[${FILE_NAME}]${F[B]} failed test case with ${F[W]}[${LINTER_NAME}]${F[B]} successfully" fi ####################################################### # Store the linting as a temporary file in TAP format # @@ -521,17 +519,17 @@ function TestCodebase() { ############################################# # We failed to compare the reporting output # ############################################# - error "Failed to assert TAP output:[${LINTER_NAME}]${NC}"! - echo "Please validate the asserts!" + error "Failed to assert TAP output:[${LINTER_NAME}]"! + info "Please validate the asserts!" cat "${TMPFILE}" exit 1 else # Success - notice "Successfully validation in the expected TAP format for ${F[W]}[${LINTER_NAME}]${NC}" + info "Successfully validation in the expected TAP format for ${F[W]}[${LINTER_NAME}]" fi else - warn "No TAP expected file found at:[${EXPECTED_FILE}]${NC}" - echo "skipping report assertions" + warn "No TAP expected file found at:[${EXPECTED_FILE}]" + info "skipping report assertions" ##################################### # Append the file type to the array # ##################################### @@ -546,7 +544,7 @@ function TestCodebase() { ################################################# # We failed to find files and no tests were ran # ################################################# - error "Failed to find any tests ran for the Linter:[${LINTER_NAME}]${NC}"! + error "Failed to find any tests ran for the Linter:[${LINTER_NAME}]"! fatal "Please validate logic or that tests exist!" fi } @@ -564,11 +562,11 @@ function RunTestCases() { ################# # Header prints # ################# - echo "" - echo "----------------------------------------------" - echo "-------------- TEST CASE RUN -----------------" - echo "----------------------------------------------" - echo "" + echo + info "----------------------------------------------" + info "-------------- TEST CASE RUN -----------------" + info "----------------------------------------------" + echo ####################### # Test case languages # @@ -661,11 +659,8 @@ function LintAnsibleFiles() { fatal "[${VALIDATE_INSTALL_CMD}]" else # Success - if [[ ${ACTIONS_RUNNER_DEBUG} == "true" ]]; then - # Success - notice "Successfully found binary in system${NC}" - echo "Location:[${VALIDATE_INSTALL_CMD}]" - fi + debug "Successfully found binary in system" + debug "Location:[${VALIDATE_INSTALL_CMD}]" fi ########################## @@ -700,7 +695,7 @@ function LintAnsibleFiles() { ################################### # Send message that were skipping # ################################### - #echo "- Skipping Ansible lint run as file(s) that were modified were read only..." + debug "- Skipping Ansible lint run as file(s) that were modified were read only..." ############################ # Create flag to skip loop # ############################ @@ -715,7 +710,7 @@ function LintAnsibleFiles() { ######################### # Print the header line # ######################### - echo "${LINE}" + info "${LINE}" done fi @@ -755,8 +750,8 @@ function LintAnsibleFiles() { ############## # File print # ############## - echo "---------------------------" - echo "File:[${FILE}]" + info "---------------------------" + info "File:[${FILE}]" ################################ # Lint the file with the rules # @@ -792,7 +787,7 @@ function LintAnsibleFiles() { ########### # Success # ########### - notice " - File:${F[W]}[${FILE_NAME}]${F[B]} was linted with ${F[W]}[${LINTER_NAME}]${F[B]} successfully${NC}" + info " - File:${F[W]}[${FILE_NAME}]${F[B]} was linted with ${F[W]}[${LINTER_NAME}]${F[B]} successfully" ####################################################### # Store the linting as a temporary file in TAP format # @@ -810,17 +805,12 @@ function LintAnsibleFiles() { HeaderTap "${INDEX}" "${REPORT_OUTPUT_FILE}" cat "${TMPFILE}" >> "${REPORT_OUTPUT_FILE}" fi - else # No ansible directory found in path - ############################### - # Check to see if debug is on # - ############################### - if [[ ${ACTIONS_RUNNER_DEBUG} == "true" ]]; then - ######################## - # No Ansible dir found # - ######################## - warn "No Ansible base directory found at:[${ANSIBLE_DIRECTORY}]${NC}" - echo "skipping ansible lint" - fi + else + ######################## + # No Ansible dir found # + ######################## + warn "No Ansible base directory found at:[${ANSIBLE_DIRECTORY}]" + debug "skipping ansible lint" fi } ################################################################################ From d581a2d43ac0d170a45ee7fa61430b9319e0e971 Mon Sep 17 00:00:00 2001 From: Eric Nemchik Date: Thu, 30 Jul 2020 14:19:07 -0500 Subject: [PATCH 096/135] Fix mistake --- .automation/upload-docker.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.automation/upload-docker.sh b/.automation/upload-docker.sh index bac7f3e8..0510276a 100755 --- a/.automation/upload-docker.sh +++ b/.automation/upload-docker.sh @@ -255,7 +255,7 @@ Authenticate() { # ERROR error "Failed to authenticate to ${NAME}!" fatal "[${LOGIN_CMD}]" -fatal else + else # SUCCESS info "Successfully authenticated to ${F[C]}${NAME}${F[B]}!" fi From adb504d2330c117488286e4b5f28e71a1caa54ac Mon Sep 17 00:00:00 2001 From: Eric Nemchik Date: Thu, 30 Jul 2020 14:26:10 -0500 Subject: [PATCH 097/135] Use export to Workaround SC2034 --- lib/buildFileList.sh | 2 +- lib/linter.sh | 24 ++++++++++++------------ 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/lib/buildFileList.sh b/lib/buildFileList.sh index ccd47747..2f07defd 100755 --- a/lib/buildFileList.sh +++ b/lib/buildFileList.sh @@ -503,7 +503,7 @@ function BuildFileList() { fi done - echo ${READ_ONLY_CHANGE_FLAG} > /dev/null 2>&1 || true # Workaround SC2034 + export READ_ONLY_CHANGE_FLAG # Workaround SC2034 ######################################### # Need to switch back to branch of code # diff --git a/lib/linter.sh b/lib/linter.sh index f94dd7bc..7bfe9592 100755 --- a/lib/linter.sh +++ b/lib/linter.sh @@ -209,18 +209,18 @@ DEFAULT_IFS="${IFS}" # Get the Default IFS for ############################################################### # Default Vars that are called in Subs and need to be ignored # ############################################################### -DEFAULT_DISABLE_ERRORS='false' # Default to enabling errors -echo "${DEFAULT_DISABLE_ERRORS}" > /dev/null 2>&1 || true # Workaround SC2034 -RAW_FILE_ARRAY=() # Array of all files that were changed -echo "${RAW_FILE_ARRAY[*]}" > /dev/null 2>&1 || true # Workaround SC2034 -READ_ONLY_CHANGE_FLAG=0 # Flag set to 1 if files changed are not txt or md -echo "${READ_ONLY_CHANGE_FLAG}" > /dev/null 2>&1 || true # Workaround SC2034 -TEST_CASE_FOLDER='.automation/test' # Folder for test cases we should always ignore -echo "${TEST_CASE_FOLDER}" > /dev/null 2>&1 || true # Workaround SC2034 -DEFAULT_ANSIBLE_DIRECTORY="${GITHUB_WORKSPACE}/ansible" # Default Ansible Directory -echo "${DEFAULT_ANSIBLE_DIRECTORY}" > /dev/null 2>&1 || true # Workaround SC2034 -WARNING_ARRAY_TEST=() # Array of warning linters that did not have an expected test result. -echo "${WARNING_ARRAY_TEST[*]}" > /dev/null 2>&1 || true # Workaround SC2034 +DEFAULT_DISABLE_ERRORS='false' # Default to enabling errors +export DEFAULT_DISABLE_ERRORS # Workaround SC2034 +RAW_FILE_ARRAY=() # Array of all files that were changed +export RAW_FILE_ARRAY # Workaround SC2034 +READ_ONLY_CHANGE_FLAG=0 # Flag set to 1 if files changed are not txt or md +export READ_ONLY_CHANGE_FLAG # Workaround SC2034 +TEST_CASE_FOLDER='.automation/test' # Folder for test cases we should always ignore +export TEST_CASE_FOLDER # Workaround SC2034 +DEFAULT_ANSIBLE_DIRECTORY="${GITHUB_WORKSPACE}/ansible" # Default Ansible Directory +export DEFAULT_ANSIBLE_DIRECTORY # Workaround SC2034 +WARNING_ARRAY_TEST=() # Array of warning linters that did not have an expected test result. +export WARNING_ARRAY_TEST # Workaround SC2034 ############## # Format # From c541a221bb228431fef90cf049c36be3e62a7f1e Mon Sep 17 00:00:00 2001 From: Eric Nemchik Date: Thu, 30 Jul 2020 15:05:16 -0500 Subject: [PATCH 098/135] Ditch empty echos --- .automation/cleanup-docker.sh | 10 ---------- .automation/upload-docker.sh | 12 ------------ lib/buildFileList.sh | 2 -- lib/linter.sh | 8 -------- lib/validation.sh | 1 - lib/worker.sh | 4 ---- 6 files changed, 37 deletions(-) diff --git a/.automation/cleanup-docker.sh b/.automation/cleanup-docker.sh index 12d29c4b..d9eb6312 100755 --- a/.automation/cleanup-docker.sh +++ b/.automation/cleanup-docker.sh @@ -29,11 +29,9 @@ DOCKERFILE_PATH="${DOCKERFILE_PATH}" # Path to the Dockerfile to be uploaded ################################################################################ #### Function Header ########################################################### Header() { - echo info "-------------------------------------------------------" info "----- GitHub Actions remove image from DockerHub ------" info "-------------------------------------------------------" - echo } ################################################################################ #### Function ValidateInput #################################################### @@ -42,11 +40,9 @@ ValidateInput() { ################ # Print header # ################ - echo info "----------------------------------------------" info "Gathering variables..." info "----------------------------------------------" - echo ############################ # Validate GITHUB_WORKSPACE # @@ -127,11 +123,9 @@ LoginToDocker() { ################ # Print header # ################ - echo info "----------------------------------------------" info "Login to DockerHub..." info "----------------------------------------------" - echo ###################### # Login to DockerHub # @@ -161,11 +155,9 @@ RemoveImage() { ################ # Print header # ################ - echo info "----------------------------------------------" info "Removing the DockerFile image:[${IMAGE_REPO}:${IMAGE_VERSION}]" info "----------------------------------------------" - echo ##################################### # Create Token to auth to DockerHub # @@ -220,11 +212,9 @@ RemoveImage() { ################################################################################ #### Function Footer ########################################################### Footer() { - echo info "-------------------------------------------------------" info "The step has completed" info "-------------------------------------------------------" - echo } ################################################################################ ################################## MAIN ######################################## diff --git a/.automation/upload-docker.sh b/.automation/upload-docker.sh index 0510276a..f9557959 100755 --- a/.automation/upload-docker.sh +++ b/.automation/upload-docker.sh @@ -35,11 +35,9 @@ UPDATE_MAJOR_TAG=0 # Flag to deploy the major tag version as ################################################################################ #### Function Header ########################################################### Header() { - echo info "-------------------------------------------------------" info "---- GitHub Actions Upload image to [${REGISTRY}] ----" info "-------------------------------------------------------" - echo } ################################################################################ #### Function ValidateInput #################################################### @@ -48,11 +46,9 @@ ValidateInput() { ################ # Print header # ################ - echo info "----------------------------------------------" info "Gathering variables..." info "----------------------------------------------" - echo ############################# # Validate GITHUB_WORKSPACE # @@ -232,11 +228,9 @@ Authenticate() { ################ # Print header # ################ - echo info "----------------------------------------------" info "Login to ${NAME}..." info "----------------------------------------------" - echo ################### # Auth to service # @@ -266,11 +260,9 @@ BuildImage() { ################ # Print header # ################ - echo info "----------------------------------------------" info "Building the DockerFile image..." info "----------------------------------------------" - echo ################################ # Validate the DOCKERFILE_PATH # @@ -333,11 +325,9 @@ UploadImage() { ################ # Print header # ################ - echo info "----------------------------------------------" info "Uploading the DockerFile image to ${REGISTRY}..." info "----------------------------------------------" - echo ############################################ # Upload the docker image that was created # @@ -428,11 +418,9 @@ UploadImage() { ################################################################################ #### Function Footer ########################################################### Footer() { - echo info "-------------------------------------------------------" info "The step has completed" info "-------------------------------------------------------" - echo } ################################################################################ ################################## MAIN ######################################## diff --git a/lib/buildFileList.sh b/lib/buildFileList.sh index 2f07defd..6c0ba76b 100755 --- a/lib/buildFileList.sh +++ b/lib/buildFileList.sh @@ -69,7 +69,6 @@ function BuildFileList() { ################################################ # Iterate through the array of all files found # ################################################ - echo info "----------------------------------------------" info "Files that have been modified in the commit(s):" for FILE in "${RAW_FILE_ARRAY[@]}"; do @@ -527,7 +526,6 @@ function BuildFileList() { ################ # Footer print # ################ - echo info "----------------------------------------------" info "Successfully gathered list of files..." } diff --git a/lib/linter.sh b/lib/linter.sh index 7bfe9592..062c2df8 100755 --- a/lib/linter.sh +++ b/lib/linter.sh @@ -364,11 +364,9 @@ Header() { ########## # Prints # ########## - echo info "---------------------------------------------" info "--- GitHub Actions Multi Language Linter ----" info "---------------------------------------------" - echo info "---------------------------------------------" info "The Super-Linter source code can be found at:" info " - https://github.com/github/super-linter" @@ -932,13 +930,11 @@ CallStatusAPI() { ################################################################################ #### Function Reports ########################################################## Reports() { - echo info "----------------------------------------------" info "----------------------------------------------" info "Generated reports:" info "----------------------------------------------" info "----------------------------------------------" - echo ################################### # Prints output report if enabled # @@ -958,13 +954,11 @@ Reports() { ################################################################################ #### Function Footer ########################################################### Footer() { - echo info "----------------------------------------------" info "----------------------------------------------" info "The script has completed" info "----------------------------------------------" info "----------------------------------------------" - echo #################################################### # Need to clean up the lanuage array of duplicates # @@ -1028,10 +1022,8 @@ Footer() { ######################## # Footer prints Exit 0 # ######################## - echo notice "All file(s) linted successfully with no errors detected" info "----------------------------------------------" - echo # Successful exit exit 0 } diff --git a/lib/validation.sh b/lib/validation.sh index 1cc7517d..6e4105b0 100755 --- a/lib/validation.sh +++ b/lib/validation.sh @@ -13,7 +13,6 @@ function GetValidationInfo() { ############################################ # Print headers for user provided env vars # ############################################ - echo info "--------------------------------------------" info "Gathering user validation information..." diff --git a/lib/worker.sh b/lib/worker.sh index a2d1c1eb..b5d5988c 100755 --- a/lib/worker.sh +++ b/lib/worker.sh @@ -276,13 +276,11 @@ function TestCodebase() { ################ # print header # ################ - echo info "----------------------------------------------" info "----------------------------------------------" info "Testing Codebase [${FILE_TYPE}] files..." info "----------------------------------------------" info "----------------------------------------------" - echo ##################################### # Validate we have linter installed # @@ -562,11 +560,9 @@ function RunTestCases() { ################# # Header prints # ################# - echo info "----------------------------------------------" info "-------------- TEST CASE RUN -----------------" info "----------------------------------------------" - echo ####################### # Test case languages # From 2d2fafef1b931da8ee2e8145f98d6ed81ebb1d04 Mon Sep 17 00:00:00 2001 From: Eric Nemchik Date: Thu, 30 Jul 2020 15:18:24 -0500 Subject: [PATCH 099/135] Format code --- lib/buildFileList.sh | 1016 ++++++++++---------- lib/linter.sh | 2109 +++++++++++++++++++++--------------------- lib/log.sh | 32 +- lib/termColors.sh | 32 +- lib/validation.sh | 320 +++---- lib/worker.sh | 1612 ++++++++++++++++---------------- 6 files changed, 2562 insertions(+), 2559 deletions(-) diff --git a/lib/buildFileList.sh b/lib/buildFileList.sh index 6c0ba76b..a98e885f 100755 --- a/lib/buildFileList.sh +++ b/lib/buildFileList.sh @@ -10,522 +10,522 @@ ################################################################################ #### Function BuildFileList #################################################### function BuildFileList() { - # Need to build a list of all files changed - # This can be pulled from the GITHUB_EVENT_PATH payload + # Need to build a list of all files changed + # This can be pulled from the GITHUB_EVENT_PATH payload - ################ - # print header # - ################ - debug "----------------------------------------------" - debug "Pulling in code history and branches..." + ################ + # print header # + ################ + debug "----------------------------------------------" + debug "Pulling in code history and branches..." - ################################################################################# - # Switch codebase back to the default branch to get a list of all files changed # - ################################################################################# - SWITCH_CMD=$( - git -C "${GITHUB_WORKSPACE}" pull --quiet - git -C "${GITHUB_WORKSPACE}" checkout "${DEFAULT_BRANCH}" 2>&1 - ) + ################################################################################# + # Switch codebase back to the default branch to get a list of all files changed # + ################################################################################# + SWITCH_CMD=$( + git -C "${GITHUB_WORKSPACE}" pull --quiet + git -C "${GITHUB_WORKSPACE}" checkout "${DEFAULT_BRANCH}" 2>&1 + ) - ####################### - # Load the error code # - ####################### - ERROR_CODE=$? + ####################### + # Load the error code # + ####################### + ERROR_CODE=$? - ############################## - # Check the shell for errors # - ############################## - if [ ${ERROR_CODE} -ne 0 ]; then - # Error - info "Failed to switch to ${DEFAULT_BRANCH} branch to get files changed!" - fatal "[${SWITCH_CMD}]" - fi - - ################ - # print header # - ################ - debug "----------------------------------------------" - debug "Generating Diff with:[git diff --name-only '${DEFAULT_BRANCH}..${GITHUB_SHA}' --diff-filter=d]" - - ################################################# - # Get the Array of files changed in the commits # - ################################################# - mapfile -t RAW_FILE_ARRAY < <(git -C "${GITHUB_WORKSPACE}" diff --name-only "${DEFAULT_BRANCH}..${GITHUB_SHA}" --diff-filter=d 2>&1) - - ####################### - # Load the error code # - ####################### - ERROR_CODE=$? - - ############################## - # Check the shell for errors # - ############################## - if [ ${ERROR_CODE} -ne 0 ]; then - # Error - error "Failed to gain a list of all files changed!" - fatal "[${RAW_FILE_ARRAY[*]}]" - fi - - ################################################ - # Iterate through the array of all files found # - ################################################ - info "----------------------------------------------" - info "Files that have been modified in the commit(s):" - for FILE in "${RAW_FILE_ARRAY[@]}"; do - ########################### - # Get the files extension # - ########################### - # Extract just the file extension - FILE_TYPE=${FILE##*.} - # To lowercase - FILE_TYPE=${FILE_TYPE,,} - - ############## - # Print file # - ############## - info "File:[${FILE}], File_type:[${FILE_TYPE}]" - - ######### - # DEBUG # - ######### - debug "FILE_TYPE:[${FILE_TYPE}]" - - ################################ - # Get the CLOUDFORMATION files # - ################################ - if [ "${FILE_TYPE}" == "yml" ] || [ "${FILE_TYPE}" == "yaml" ]; then - ################################ - # Append the file to the array # - ################################ - FILE_ARRAY_YAML+=("${FILE}") - ########################################################## - # Set the READ_ONLY_CHANGE_FLAG since this could be exec # - ########################################################## - READ_ONLY_CHANGE_FLAG=1 - - ##################################### - # Check if the file is CFN template # - ##################################### - if DetectCloudFormationFile "${FILE}"; then - ################################ - # Append the file to the array # - ################################ - FILE_ARRAY_CLOUDFORMATION+=("${FILE}") - - ########################################################## - # Set the READ_ONLY_CHANGE_FLAG since this could be exec # - ########################################################## - READ_ONLY_CHANGE_FLAG=1 - fi - ###################### - # Get the JSON files # - ###################### - elif [ "${FILE_TYPE}" == "json" ]; then - ################################ - # Append the file to the array # - ################################ - FILE_ARRAY_JSON+=("${FILE}") - ############################ - # Check if file is OpenAPI # - ############################ - if DetectOpenAPIFile "${FILE}"; then - ################################ - # Append the file to the array # - ################################ - FILE_ARRAY_OPENAPI+=("${FILE}") - fi - ############################ - # Check if file is ARM # - ############################ - if DetectARMFile "${FILE}"; then - ################################ - # Append the file to the array # - ################################ - FILE_ARRAY_ARM+=("${FILE}") - fi - ##################################### - # Check if the file is CFN template # - ##################################### - if DetectCloudFormationFile "${FILE}"; then - ################################ - # Append the file to the array # - ################################ - FILE_ARRAY_CLOUDFORMATION+=("${FILE}") - fi - ############################################ - # Check if the file is AWS States Language # - ############################################ - if DetectAWSStatesFIle "${FILE}"; then - ################################ - # Append the file to the array # - ################################ - FILE_ARRAY_STATES+=("${FILE}") - fi - ########################################################## - # Set the READ_ONLY_CHANGE_FLAG since this could be exec # - ########################################################## - READ_ONLY_CHANGE_FLAG=1 - ##################### - # Get the XML files # - ##################### - elif [ "${FILE_TYPE}" == "xml" ]; then - ################################ - # Append the file to the array # - ################################ - FILE_ARRAY_XML+=("${FILE}") - ########################################################## - # Set the READ_ONLY_CHANGE_FLAG since this could be exec # - ########################################################## - READ_ONLY_CHANGE_FLAG=1 - ########################## - # Get the MARKDOWN files # - ########################## - elif [ "${FILE_TYPE}" == "md" ]; then - ################################ - # Append the file to the array # - ################################ - FILE_ARRAY_MARKDOWN+=("${FILE}") - ###################### - # Get the BASH files # - ###################### - elif [ "${FILE_TYPE}" == "sh" ]; then - ################################ - # Append the file to the array # - ################################ - FILE_ARRAY_BASH+=("${FILE}") - ########################################################## - # Set the READ_ONLY_CHANGE_FLAG since this could be exec # - ########################################################## - READ_ONLY_CHANGE_FLAG=1 - ###################### - # Get the PERL files # - ###################### - elif [ "${FILE_TYPE}" == "pl" ]; then - ################################ - # Append the file to the array # - ################################ - FILE_ARRAY_PERL+=("${FILE}") - ########################################################## - # Set the READ_ONLY_CHANGE_FLAG since this could be exec # - ########################################################## - READ_ONLY_CHANGE_FLAG=1 - ###################### - # Get the RAKU files # - ###################### - elif [ "${FILE_TYPE}" == "raku" ] || [ "${FILE_TYPE}" == "rakumod" ] \ - || [ "${FILE_TYPE}" == "rakutest" ] || [ "${FILE_TYPE}" == "pm6" ] \ - || [ "${FILE_TYPE}" == "pl6" ] || [ "${FILE_TYPE}" == "p6" ] ; then - ################################ - # Append the file to the array # - ################################ - FILE_ARRAY_RAKU+=("${FILE}") - ########################################################## - # Set the READ_ONLY_CHANGE_FLAG since this could be exec # - ########################################################## - READ_ONLY_CHANGE_FLAG=1 - ###################### - # Get the PHP files # - ###################### - elif [ "${FILE_TYPE}" == "php" ]; then - ################################ - # Append the file to the array # - ################################ - FILE_ARRAY_PHP+=("${FILE}") - FILE_ARRAY_PHP_PHPSTAN+=("${FILE}") - ########################################################## - # Set the READ_ONLY_CHANGE_FLAG since this could be exec # - ########################################################## - READ_ONLY_CHANGE_FLAG=1 - ###################### - # Get the RUBY files # - ###################### - elif [ "${FILE_TYPE}" == "rb" ]; then - ################################ - # Append the file to the array # - ################################ - FILE_ARRAY_RUBY+=("${FILE}") - ########################################################## - # Set the READ_ONLY_CHANGE_FLAG since this could be exec # - ########################################################## - READ_ONLY_CHANGE_FLAG=1 - ######################## - # Get the PYTHON files # - ######################## - elif [ "${FILE_TYPE}" == "py" ]; then - ################################ - # Append the file to the array # - ################################ - FILE_ARRAY_PYTHON_PYLINT+=("${FILE}") - FILE_ARRAY_PYTHON_FLAKE8+=("${FILE}") - ########################################################## - # Set the READ_ONLY_CHANGE_FLAG since this could be exec # - ########################################################## - READ_ONLY_CHANGE_FLAG=1 - ######################## - # Get the COFFEE files # - ######################## - elif [ "${FILE_TYPE}" == "coffee" ]; then - ################################ - # Append the file to the array # - ################################ - FILE_ARRAY_COFFEESCRIPT+=("${FILE}") - ########################################################## - # Set the READ_ONLY_CHANGE_FLAG since this could be exec # - ########################################################## - READ_ONLY_CHANGE_FLAG=1 - ############################ - # Get the JavaScript files # - ############################ - elif [ "${FILE_TYPE}" == "js" ]; then - ################################ - # Append the file to the array # - ################################ - FILE_ARRAY_JAVASCRIPT_ES+=("${FILE}") - FILE_ARRAY_JAVASCRIPT_STANDARD+=("${FILE}") - ########################################################## - # Set the READ_ONLY_CHANGE_FLAG since this could be exec # - ########################################################## - READ_ONLY_CHANGE_FLAG=1 - ############################ - # Get the JSX files # - ############################ - elif [ "${FILE_TYPE}" == "jsx" ]; then - ################################ - # Append the file to the array # - ################################ - FILE_ARRAY_JSX+=("${FILE}") - ########################################################## - # Set the READ_ONLY_CHANGE_FLAG since this could be exec # - ########################################################## - READ_ONLY_CHANGE_FLAG=1 - ############################ - # Get the TSX files # - ############################ - elif [ "${FILE_TYPE}" == "tsx" ]; then - ################################ - # Append the file to the array # - ################################ - FILE_ARRAY_TSX+=("${FILE}") - ########################################################## - # Set the READ_ONLY_CHANGE_FLAG since this could be exec # - ########################################################## - READ_ONLY_CHANGE_FLAG=1 - ######################## - # Get the Golang files # - ######################## - ############################ - # Get the TypeScript files # - ############################ - elif [ "${FILE_TYPE}" == "ts" ]; then - ################################ - # Append the file to the array # - ################################ - FILE_ARRAY_TYPESCRIPT_ES+=("${FILE}") - FILE_ARRAY_TYPESCRIPT_STANDARD+=("${FILE}") - ########################################################## - # Set the READ_ONLY_CHANGE_FLAG since this could be exec # - ########################################################## - READ_ONLY_CHANGE_FLAG=1 - ######################## - # Get the Golang files # - ######################## - elif [ "${FILE_TYPE}" == "go" ]; then - ################################ - # Append the file to the array # - ################################ - FILE_ARRAY_GO+=("${FILE}") - ########################################################## - # Set the READ_ONLY_CHANGE_FLAG since this could be exec # - ########################################################## - READ_ONLY_CHANGE_FLAG=1 - ########################### - # Get the Terraform files # - ########################### - elif [ "${FILE_TYPE}" == "tf" ]; then - ################################ - # Append the file to the array # - ################################ - FILE_ARRAY_TERRAFORM+=("${FILE}") - FILE_ARRAY_TERRAFORM_TERRASCAN+=("${FILE}") - ########################################################## - # Set the READ_ONLY_CHANGE_FLAG since this could be exec # - ########################################################## - READ_ONLY_CHANGE_FLAG=1 - ########################### - # Get the Powershell files # - ########################### - elif [ "${FILE_TYPE}" == "ps1" ]; then - ################################ - # Append the file to the array # - ################################ - FILE_ARRAY_POWERSHELL+=("${FILE}") - elif [ "${FILE_TYPE}" == "css" ]; then - ################################ - # Append the file to the array # - ################################ - FILE_ARRAY_CSS+=("${FILE}") - ########################################################## - # Set the READ_ONLY_CHANGE_FLAG since this could be exec # - ########################################################## - READ_ONLY_CHANGE_FLAG=1 - elif [ "${FILE_TYPE}" == "env" ]; then - ################################ - # Append the file to the array # - ################################ - FILE_ARRAY_ENV+=("${FILE}") - ########################################################## - # Set the READ_ONLY_CHANGE_FLAG since this could be exec # - ########################################################## - READ_ONLY_CHANGE_FLAG=1 - elif [ "${FILE_TYPE}" == "kt" ] || [ "${FILE_TYPE}" == "kts" ]; then - ################################ - # Append the file to the array # - ################################ - FILE_ARRAY_KOTLIN+=("${FILE}") - ########################################################## - # Set the READ_ONLY_CHANGE_FLAG since this could be exec # - ########################################################## - READ_ONLY_CHANGE_FLAG=1 - elif [ "$FILE_TYPE" == "lua" ]; then - ################################ - # Append the file to the array # - ################################ - FILE_ARRAY_LUA+=("$FILE") - ########################################################## - # Set the READ_ONLY_CHANGE_FLAG since this could be exec # - ########################################################## - READ_ONLY_CHANGE_FLAG=1 - ############################ - # Get the Protocol Buffers files # - ############################ - elif [ "${FILE_TYPE}" == "dart" ]; then - ################################ - # Append the file to the array # - ################################ - FILE_ARRAY_DART+=("${FILE}") - ########################################################## - # Set the READ_ONLY_CHANGE_FLAG since this could be exec # - ########################################################## - READ_ONLY_CHANGE_FLAG=1 - elif [ "${FILE_TYPE}" == "proto" ]; then - ################################ - # Append the file to the array # - ################################ - FILE_ARRAY_PROTOBUF+=("${FILE}") - ########################################################## - # Set the READ_ONLY_CHANGE_FLAG since this could be exec # - ########################################################## - READ_ONLY_CHANGE_FLAG=1 - elif [ "${FILE}" == "dockerfile" ] || [ "${FILE_TYPE}" == "dockerfile" ]; then - ################################ - # Append the file to the array # - ################################ - FILE_ARRAY_DOCKER+=("${FILE}") - ########################################################## - # Set the READ_ONLY_CHANGE_FLAG since this could be exec # - ########################################################## - READ_ONLY_CHANGE_FLAG=1 - elif [ "${FILE_TYPE}" == "clj" ] || [ "${FILE_TYPE}" == "cljs" ] || [ "${FILE_TYPE}" == "cljc" ] || [ "${FILE_TYPE}" == "edn" ]; then - ################################ - # Append the file to the array # - ################################ - FILE_ARRAY_CLOJURE+=("${FILE}") - ########################################################## - # Set the READ_ONLY_CHANGE_FLAG since this could be exec # - ########################################################## - READ_ONLY_CHANGE_FLAG=1 - elif [ "${FILE_TYPE}" == "html" ]; then - ################################ - # Append the file to the array # - ##############################p## - FILE_ARRAY_HTML+=("${FILE}") - ########################################################## - # Set the READ_ONLY_CHANGE_FLAG since this could be exec # - ########################################################## - 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 - ############################################## - # Use file to see if we can parse what it is # - ############################################## - GET_FILE_TYPE_CMD=$(file "${FILE}" 2>&1) - - ################# - # Check if bash # - ################# - if [[ ${GET_FILE_TYPE_CMD} == *"Bourne-Again shell script"* ]]; then - ####################### - # It is a bash script # - ####################### - warn "Found bash script without extension:[.sh]" - info "Please update file with proper extensions." - ################################ - # Append the file to the array # - ################################ - FILE_ARRAY_BASH+=("${FILE}") - ########################################################## - # Set the READ_ONLY_CHANGE_FLAG since this could be exec # - ########################################################## - READ_ONLY_CHANGE_FLAG=1 - elif [[ ${GET_FILE_TYPE_CMD} == *"Ruby script"* ]]; then - ####################### - # It is a Ruby script # - ####################### - warn "Found ruby script without extension:[.rb]" - info "Please update file with proper extensions." - ################################ - # Append the file to the array # - ################################ - FILE_ARRAY_RUBY+=("${FILE}") - ########################################################## - # Set the READ_ONLY_CHANGE_FLAG since this could be exec # - ########################################################## - READ_ONLY_CHANGE_FLAG=1 - else - ############################ - # Extension was not found! # - ############################ - warn "Failed to get filetype for:[${FILE}]!" - ########################################################## - # Set the READ_ONLY_CHANGE_FLAG since this could be exec # - ########################################################## - READ_ONLY_CHANGE_FLAG=1 - fi + ############################## + # Check the shell for errors # + ############################## + if [ ${ERROR_CODE} -ne 0 ]; then + # Error + info "Failed to switch to ${DEFAULT_BRANCH} branch to get files changed!" + fatal "[${SWITCH_CMD}]" fi - done - export READ_ONLY_CHANGE_FLAG # Workaround SC2034 + ################ + # print header # + ################ + debug "----------------------------------------------" + debug "Generating Diff with:[git diff --name-only '${DEFAULT_BRANCH}..${GITHUB_SHA}' --diff-filter=d]" - ######################################### - # Need to switch back to branch of code # - ######################################### - SWITCH2_CMD=$(git -C "${GITHUB_WORKSPACE}" checkout --progress --force "${GITHUB_SHA}" 2>&1) + ################################################# + # Get the Array of files changed in the commits # + ################################################# + mapfile -t RAW_FILE_ARRAY < <(git -C "${GITHUB_WORKSPACE}" diff --name-only "${DEFAULT_BRANCH}..${GITHUB_SHA}" --diff-filter=d 2>&1) - ####################### - # Load the error code # - ####################### - ERROR_CODE=$? + ####################### + # Load the error code # + ####################### + ERROR_CODE=$? - ############################## - # Check the shell for errors # - ############################## - if [ ${ERROR_CODE} -ne 0 ]; then - # Error - error "Failed to switch back to branch!" - fatal "[${SWITCH2_CMD}]" - fi + ############################## + # Check the shell for errors # + ############################## + if [ ${ERROR_CODE} -ne 0 ]; then + # Error + error "Failed to gain a list of all files changed!" + fatal "[${RAW_FILE_ARRAY[*]}]" + fi - ################ - # Footer print # - ################ - info "----------------------------------------------" - info "Successfully gathered list of files..." + ################################################ + # Iterate through the array of all files found # + ################################################ + info "----------------------------------------------" + info "Files that have been modified in the commit(s):" + for FILE in "${RAW_FILE_ARRAY[@]}"; do + ########################### + # Get the files extension # + ########################### + # Extract just the file extension + FILE_TYPE=${FILE##*.} + # To lowercase + FILE_TYPE=${FILE_TYPE,,} + + ############## + # Print file # + ############## + info "File:[${FILE}], File_type:[${FILE_TYPE}]" + + ######### + # DEBUG # + ######### + debug "FILE_TYPE:[${FILE_TYPE}]" + + ################################ + # Get the CLOUDFORMATION files # + ################################ + if [ "${FILE_TYPE}" == "yml" ] || [ "${FILE_TYPE}" == "yaml" ]; then + ################################ + # Append the file to the array # + ################################ + FILE_ARRAY_YAML+=("${FILE}") + ########################################################## + # Set the READ_ONLY_CHANGE_FLAG since this could be exec # + ########################################################## + READ_ONLY_CHANGE_FLAG=1 + + ##################################### + # Check if the file is CFN template # + ##################################### + if DetectCloudFormationFile "${FILE}"; then + ################################ + # Append the file to the array # + ################################ + FILE_ARRAY_CLOUDFORMATION+=("${FILE}") + + ########################################################## + # Set the READ_ONLY_CHANGE_FLAG since this could be exec # + ########################################################## + READ_ONLY_CHANGE_FLAG=1 + fi + ###################### + # Get the JSON files # + ###################### + elif [ "${FILE_TYPE}" == "json" ]; then + ################################ + # Append the file to the array # + ################################ + FILE_ARRAY_JSON+=("${FILE}") + ############################ + # Check if file is OpenAPI # + ############################ + if DetectOpenAPIFile "${FILE}"; then + ################################ + # Append the file to the array # + ################################ + FILE_ARRAY_OPENAPI+=("${FILE}") + fi + ############################ + # Check if file is ARM # + ############################ + if DetectARMFile "${FILE}"; then + ################################ + # Append the file to the array # + ################################ + FILE_ARRAY_ARM+=("${FILE}") + fi + ##################################### + # Check if the file is CFN template # + ##################################### + if DetectCloudFormationFile "${FILE}"; then + ################################ + # Append the file to the array # + ################################ + FILE_ARRAY_CLOUDFORMATION+=("${FILE}") + fi + ############################################ + # Check if the file is AWS States Language # + ############################################ + if DetectAWSStatesFIle "${FILE}"; then + ################################ + # Append the file to the array # + ################################ + FILE_ARRAY_STATES+=("${FILE}") + fi + ########################################################## + # Set the READ_ONLY_CHANGE_FLAG since this could be exec # + ########################################################## + READ_ONLY_CHANGE_FLAG=1 + ##################### + # Get the XML files # + ##################### + elif [ "${FILE_TYPE}" == "xml" ]; then + ################################ + # Append the file to the array # + ################################ + FILE_ARRAY_XML+=("${FILE}") + ########################################################## + # Set the READ_ONLY_CHANGE_FLAG since this could be exec # + ########################################################## + READ_ONLY_CHANGE_FLAG=1 + ########################## + # Get the MARKDOWN files # + ########################## + elif [ "${FILE_TYPE}" == "md" ]; then + ################################ + # Append the file to the array # + ################################ + FILE_ARRAY_MARKDOWN+=("${FILE}") + ###################### + # Get the BASH files # + ###################### + elif [ "${FILE_TYPE}" == "sh" ]; then + ################################ + # Append the file to the array # + ################################ + FILE_ARRAY_BASH+=("${FILE}") + ########################################################## + # Set the READ_ONLY_CHANGE_FLAG since this could be exec # + ########################################################## + READ_ONLY_CHANGE_FLAG=1 + ###################### + # Get the PERL files # + ###################### + elif [ "${FILE_TYPE}" == "pl" ]; then + ################################ + # Append the file to the array # + ################################ + FILE_ARRAY_PERL+=("${FILE}") + ########################################################## + # Set the READ_ONLY_CHANGE_FLAG since this could be exec # + ########################################################## + READ_ONLY_CHANGE_FLAG=1 + ###################### + # Get the RAKU files # + ###################### + elif [ "${FILE_TYPE}" == "raku" ] || [ "${FILE_TYPE}" == "rakumod" ] || + [ "${FILE_TYPE}" == "rakutest" ] || [ "${FILE_TYPE}" == "pm6" ] || + [ "${FILE_TYPE}" == "pl6" ] || [ "${FILE_TYPE}" == "p6" ]; then + ################################ + # Append the file to the array # + ################################ + FILE_ARRAY_RAKU+=("${FILE}") + ########################################################## + # Set the READ_ONLY_CHANGE_FLAG since this could be exec # + ########################################################## + READ_ONLY_CHANGE_FLAG=1 + ###################### + # Get the PHP files # + ###################### + elif [ "${FILE_TYPE}" == "php" ]; then + ################################ + # Append the file to the array # + ################################ + FILE_ARRAY_PHP+=("${FILE}") + FILE_ARRAY_PHP_PHPSTAN+=("${FILE}") + ########################################################## + # Set the READ_ONLY_CHANGE_FLAG since this could be exec # + ########################################################## + READ_ONLY_CHANGE_FLAG=1 + ###################### + # Get the RUBY files # + ###################### + elif [ "${FILE_TYPE}" == "rb" ]; then + ################################ + # Append the file to the array # + ################################ + FILE_ARRAY_RUBY+=("${FILE}") + ########################################################## + # Set the READ_ONLY_CHANGE_FLAG since this could be exec # + ########################################################## + READ_ONLY_CHANGE_FLAG=1 + ######################## + # Get the PYTHON files # + ######################## + elif [ "${FILE_TYPE}" == "py" ]; then + ################################ + # Append the file to the array # + ################################ + FILE_ARRAY_PYTHON_PYLINT+=("${FILE}") + FILE_ARRAY_PYTHON_FLAKE8+=("${FILE}") + ########################################################## + # Set the READ_ONLY_CHANGE_FLAG since this could be exec # + ########################################################## + READ_ONLY_CHANGE_FLAG=1 + ######################## + # Get the COFFEE files # + ######################## + elif [ "${FILE_TYPE}" == "coffee" ]; then + ################################ + # Append the file to the array # + ################################ + FILE_ARRAY_COFFEESCRIPT+=("${FILE}") + ########################################################## + # Set the READ_ONLY_CHANGE_FLAG since this could be exec # + ########################################################## + READ_ONLY_CHANGE_FLAG=1 + ############################ + # Get the JavaScript files # + ############################ + elif [ "${FILE_TYPE}" == "js" ]; then + ################################ + # Append the file to the array # + ################################ + FILE_ARRAY_JAVASCRIPT_ES+=("${FILE}") + FILE_ARRAY_JAVASCRIPT_STANDARD+=("${FILE}") + ########################################################## + # Set the READ_ONLY_CHANGE_FLAG since this could be exec # + ########################################################## + READ_ONLY_CHANGE_FLAG=1 + ############################ + # Get the JSX files # + ############################ + elif [ "${FILE_TYPE}" == "jsx" ]; then + ################################ + # Append the file to the array # + ################################ + FILE_ARRAY_JSX+=("${FILE}") + ########################################################## + # Set the READ_ONLY_CHANGE_FLAG since this could be exec # + ########################################################## + READ_ONLY_CHANGE_FLAG=1 + ############################ + # Get the TSX files # + ############################ + elif [ "${FILE_TYPE}" == "tsx" ]; then + ################################ + # Append the file to the array # + ################################ + FILE_ARRAY_TSX+=("${FILE}") + ########################################################## + # Set the READ_ONLY_CHANGE_FLAG since this could be exec # + ########################################################## + READ_ONLY_CHANGE_FLAG=1 + ######################## + # Get the Golang files # + ######################## + ############################ + # Get the TypeScript files # + ############################ + elif [ "${FILE_TYPE}" == "ts" ]; then + ################################ + # Append the file to the array # + ################################ + FILE_ARRAY_TYPESCRIPT_ES+=("${FILE}") + FILE_ARRAY_TYPESCRIPT_STANDARD+=("${FILE}") + ########################################################## + # Set the READ_ONLY_CHANGE_FLAG since this could be exec # + ########################################################## + READ_ONLY_CHANGE_FLAG=1 + ######################## + # Get the Golang files # + ######################## + elif [ "${FILE_TYPE}" == "go" ]; then + ################################ + # Append the file to the array # + ################################ + FILE_ARRAY_GO+=("${FILE}") + ########################################################## + # Set the READ_ONLY_CHANGE_FLAG since this could be exec # + ########################################################## + READ_ONLY_CHANGE_FLAG=1 + ########################### + # Get the Terraform files # + ########################### + elif [ "${FILE_TYPE}" == "tf" ]; then + ################################ + # Append the file to the array # + ################################ + FILE_ARRAY_TERRAFORM+=("${FILE}") + FILE_ARRAY_TERRAFORM_TERRASCAN+=("${FILE}") + ########################################################## + # Set the READ_ONLY_CHANGE_FLAG since this could be exec # + ########################################################## + READ_ONLY_CHANGE_FLAG=1 + ########################### + # Get the Powershell files # + ########################### + elif [ "${FILE_TYPE}" == "ps1" ]; then + ################################ + # Append the file to the array # + ################################ + FILE_ARRAY_POWERSHELL+=("${FILE}") + elif [ "${FILE_TYPE}" == "css" ]; then + ################################ + # Append the file to the array # + ################################ + FILE_ARRAY_CSS+=("${FILE}") + ########################################################## + # Set the READ_ONLY_CHANGE_FLAG since this could be exec # + ########################################################## + READ_ONLY_CHANGE_FLAG=1 + elif [ "${FILE_TYPE}" == "env" ]; then + ################################ + # Append the file to the array # + ################################ + FILE_ARRAY_ENV+=("${FILE}") + ########################################################## + # Set the READ_ONLY_CHANGE_FLAG since this could be exec # + ########################################################## + READ_ONLY_CHANGE_FLAG=1 + elif [ "${FILE_TYPE}" == "kt" ] || [ "${FILE_TYPE}" == "kts" ]; then + ################################ + # Append the file to the array # + ################################ + FILE_ARRAY_KOTLIN+=("${FILE}") + ########################################################## + # Set the READ_ONLY_CHANGE_FLAG since this could be exec # + ########################################################## + READ_ONLY_CHANGE_FLAG=1 + elif [ "$FILE_TYPE" == "lua" ]; then + ################################ + # Append the file to the array # + ################################ + FILE_ARRAY_LUA+=("$FILE") + ########################################################## + # Set the READ_ONLY_CHANGE_FLAG since this could be exec # + ########################################################## + READ_ONLY_CHANGE_FLAG=1 + ############################ + # Get the Protocol Buffers files # + ############################ + elif [ "${FILE_TYPE}" == "dart" ]; then + ################################ + # Append the file to the array # + ################################ + FILE_ARRAY_DART+=("${FILE}") + ########################################################## + # Set the READ_ONLY_CHANGE_FLAG since this could be exec # + ########################################################## + READ_ONLY_CHANGE_FLAG=1 + elif [ "${FILE_TYPE}" == "proto" ]; then + ################################ + # Append the file to the array # + ################################ + FILE_ARRAY_PROTOBUF+=("${FILE}") + ########################################################## + # Set the READ_ONLY_CHANGE_FLAG since this could be exec # + ########################################################## + READ_ONLY_CHANGE_FLAG=1 + elif [ "${FILE}" == "dockerfile" ] || [ "${FILE_TYPE}" == "dockerfile" ]; then + ################################ + # Append the file to the array # + ################################ + FILE_ARRAY_DOCKER+=("${FILE}") + ########################################################## + # Set the READ_ONLY_CHANGE_FLAG since this could be exec # + ########################################################## + READ_ONLY_CHANGE_FLAG=1 + elif [ "${FILE_TYPE}" == "clj" ] || [ "${FILE_TYPE}" == "cljs" ] || [ "${FILE_TYPE}" == "cljc" ] || [ "${FILE_TYPE}" == "edn" ]; then + ################################ + # Append the file to the array # + ################################ + FILE_ARRAY_CLOJURE+=("${FILE}") + ########################################################## + # Set the READ_ONLY_CHANGE_FLAG since this could be exec # + ########################################################## + READ_ONLY_CHANGE_FLAG=1 + elif [ "${FILE_TYPE}" == "html" ]; then + ################################ + # Append the file to the array # + ##############################p## + FILE_ARRAY_HTML+=("${FILE}") + ########################################################## + # Set the READ_ONLY_CHANGE_FLAG since this could be exec # + ########################################################## + 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 + ############################################## + # Use file to see if we can parse what it is # + ############################################## + GET_FILE_TYPE_CMD=$(file "${FILE}" 2>&1) + + ################# + # Check if bash # + ################# + if [[ ${GET_FILE_TYPE_CMD} == *"Bourne-Again shell script"* ]]; then + ####################### + # It is a bash script # + ####################### + warn "Found bash script without extension:[.sh]" + info "Please update file with proper extensions." + ################################ + # Append the file to the array # + ################################ + FILE_ARRAY_BASH+=("${FILE}") + ########################################################## + # Set the READ_ONLY_CHANGE_FLAG since this could be exec # + ########################################################## + READ_ONLY_CHANGE_FLAG=1 + elif [[ ${GET_FILE_TYPE_CMD} == *"Ruby script"* ]]; then + ####################### + # It is a Ruby script # + ####################### + warn "Found ruby script without extension:[.rb]" + info "Please update file with proper extensions." + ################################ + # Append the file to the array # + ################################ + FILE_ARRAY_RUBY+=("${FILE}") + ########################################################## + # Set the READ_ONLY_CHANGE_FLAG since this could be exec # + ########################################################## + READ_ONLY_CHANGE_FLAG=1 + else + ############################ + # Extension was not found! # + ############################ + warn "Failed to get filetype for:[${FILE}]!" + ########################################################## + # Set the READ_ONLY_CHANGE_FLAG since this could be exec # + ########################################################## + READ_ONLY_CHANGE_FLAG=1 + fi + fi + done + + export READ_ONLY_CHANGE_FLAG # Workaround SC2034 + + ######################################### + # Need to switch back to branch of code # + ######################################### + SWITCH2_CMD=$(git -C "${GITHUB_WORKSPACE}" checkout --progress --force "${GITHUB_SHA}" 2>&1) + + ####################### + # Load the error code # + ####################### + ERROR_CODE=$? + + ############################## + # Check the shell for errors # + ############################## + if [ ${ERROR_CODE} -ne 0 ]; then + # Error + error "Failed to switch back to branch!" + fatal "[${SWITCH2_CMD}]" + fi + + ################ + # Footer print # + ################ + info "----------------------------------------------" + info "Successfully gathered list of files..." } diff --git a/lib/linter.sh b/lib/linter.sh index 062c2df8..e106dd0e 100755 --- a/lib/linter.sh +++ b/lib/linter.sh @@ -22,103 +22,103 @@ source /action/lib/worker.sh # Source the function script(s) # GLOBALS # ########### # Default Vars -DEFAULT_RULES_LOCATION='/action/lib/.automation' # Default rules files location +DEFAULT_RULES_LOCATION='/action/lib/.automation' # Default rules files location # Ansible Vars -ANSIBLE_FILE_NAME='.ansible-lint.yml' # Name of the file -ANSIBLE_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${ANSIBLE_FILE_NAME}" # Path to the Ansible lint rules +ANSIBLE_FILE_NAME='.ansible-lint.yml' # Name of the file +ANSIBLE_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${ANSIBLE_FILE_NAME}" # Path to the Ansible lint rules # Azure Resource Manager Vars -ARM_FILE_NAME='.arm-ttk.psd1' # Name of the file -ARM_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${ARM_FILE_NAME}" # Path to the ARM lint rules +ARM_FILE_NAME='.arm-ttk.psd1' # Name of the file +ARM_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${ARM_FILE_NAME}" # Path to the ARM lint rules # Cloudformation Vars -CLOUDFORMATION_FILE_NAME='.cfnlintrc.yml' # Name of the file -CLOUDFORMATION_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${CLOUDFORMATION_FILE_NAME}" # Path to the cloudformation lint rules +CLOUDFORMATION_FILE_NAME='.cfnlintrc.yml' # Name of the file +CLOUDFORMATION_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${CLOUDFORMATION_FILE_NAME}" # Path to the cloudformation lint rules # Clojure Vars -CLOJURE_FILE_NAME='.clj-kondo/config.edn' # Name of the file -CLOJURE_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${CLOJURE_FILE_NAME}" # Path to the Clojure lint rules +CLOJURE_FILE_NAME='.clj-kondo/config.edn' # Name of the file +CLOJURE_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${CLOJURE_FILE_NAME}" # Path to the Clojure lint rules # Coffee Vars -COFFEE_FILE_NAME='.coffee-lint.json' # Name of the file -COFFEESCRIPT_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${COFFEE_FILE_NAME}" # Path to the coffeescript lint rules +COFFEE_FILE_NAME='.coffee-lint.json' # Name of the file +COFFEESCRIPT_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${COFFEE_FILE_NAME}" # Path to the coffeescript lint rules # CSS Vars -CSS_FILE_NAME='.stylelintrc.json' # Name of the file -CSS_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${CSS_FILE_NAME}" # Path to the CSS lint rules +CSS_FILE_NAME='.stylelintrc.json' # Name of the file +CSS_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${CSS_FILE_NAME}" # Path to the CSS lint rules # Dart Vars -DART_FILE_NAME='analysis_options.yaml' # Name of the file -DART_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${DART_FILE_NAME}" # Path to the DART lint rules +DART_FILE_NAME='analysis_options.yaml' # Name of the file +DART_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${DART_FILE_NAME}" # Path to the DART lint rules # Docker Vars -DOCKER_FILE_NAME='.dockerfilelintrc' # Name of the file -DOCKER_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${DOCKER_FILE_NAME}" # Path to the Docker lint rules +DOCKER_FILE_NAME='.dockerfilelintrc' # Name of the file +DOCKER_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${DOCKER_FILE_NAME}" # Path to the Docker lint rules # Golang Vars -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_FILE_NAME='.golangci.yml' # Name of the file +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 +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_FILE_NAME='.htmlhintrc' # Name of the file -HTML_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${HTML_FILE_NAME}" # Path to the CSS lint rules +HTML_FILE_NAME='.htmlhintrc' # Name of the file +HTML_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${HTML_FILE_NAME}" # Path to the CSS lint rules # Javascript Vars -JAVASCRIPT_FILE_NAME="${JAVASCRIPT_ES_CONFIG_FILE:-.eslintrc.yml}" # Name of the file -JAVASCRIPT_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${JAVASCRIPT_FILE_NAME}" # Path to the Javascript lint rules -JAVASCRIPT_STANDARD_LINTER_RULES='' # ENV string to pass when running js standard +JAVASCRIPT_FILE_NAME="${JAVASCRIPT_ES_CONFIG_FILE:-.eslintrc.yml}" # Name of the file +JAVASCRIPT_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${JAVASCRIPT_FILE_NAME}" # Path to the Javascript lint rules +JAVASCRIPT_STANDARD_LINTER_RULES='' # ENV string to pass when running js standard # Default linter path -LINTER_RULES_PATH="${LINTER_RULES_PATH:-.github/linters}" # Linter Path Directory +LINTER_RULES_PATH="${LINTER_RULES_PATH:-.github/linters}" # Linter Path Directory # Lua Vars -LUA_FILE_NAME='.luacheckrc' # Name of the file -LUA_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${LUA_FILE_NAME}" # Path to the Lua lint rules +LUA_FILE_NAME='.luacheckrc' # Name of the file +LUA_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${LUA_FILE_NAME}" # Path to the Lua lint rules # MD Vars -MARKDOWN_FILE_NAME='.markdown-lint.yml' # Name of the file -MARKDOWN_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${MARKDOWN_FILE_NAME}" # Path to the markdown lint rules +MARKDOWN_FILE_NAME='.markdown-lint.yml' # Name of the file +MARKDOWN_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${MARKDOWN_FILE_NAME}" # Path to the markdown lint rules # OpenAPI Vars -OPENAPI_FILE_NAME='.openapirc.yml' # Name of the file -OPENAPI_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${OPENAPI_FILE_NAME}" # Path to the OpenAPI lint rules +OPENAPI_FILE_NAME='.openapirc.yml' # Name of the file +OPENAPI_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${OPENAPI_FILE_NAME}" # Path to the OpenAPI lint rules # PHP Vars -PHPSTAN_FILE_NAME='phpstan.neon' # Name of the file -PHPSTAN_LINTER_RULES="${GITHUB_WORKSPACE}/${PHPSTAN_FILE_NAME}" # Path to the PHPStan lint rules in the repository +PHPSTAN_FILE_NAME='phpstan.neon' # Name of the file +PHPSTAN_LINTER_RULES="${GITHUB_WORKSPACE}/${PHPSTAN_FILE_NAME}" # Path to the PHPStan lint rules in the repository if [ ! -f "$PHPSTAN_LINTER_RULES" ]; then - PHPSTAN_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${PHPSTAN_FILE_NAME}" # Path to the PHPStan lint rules + PHPSTAN_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${PHPSTAN_FILE_NAME}" # Path to the PHPStan lint rules fi # Powershell Vars -POWERSHELL_FILE_NAME='.powershell-psscriptanalyzer.psd1' # Name of the file -POWERSHELL_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${POWERSHELL_FILE_NAME}" # Path to the Powershell lint rules +POWERSHELL_FILE_NAME='.powershell-psscriptanalyzer.psd1' # Name of the file +POWERSHELL_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${POWERSHELL_FILE_NAME}" # Path to the Powershell lint rules # Protocol Buffers Vars -PROTOBUF_FILE_NAME='.protolintrc.yml' # Name of the file -PROTOBUF_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${PROTOBUF_FILE_NAME}" # Path to the Protocol Buffers lint rules +PROTOBUF_FILE_NAME='.protolintrc.yml' # Name of the file +PROTOBUF_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${PROTOBUF_FILE_NAME}" # Path to the Protocol Buffers lint rules # Python Vars -PYTHON_PYLINT_FILE_NAME="${PYTHON_PYLINT_CONFIG_FILE:-.python-lint}" # Name of the file -PYTHON_PYLINT_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${PYTHON_PYLINT_FILE_NAME}" # Path to the python lint rules -PYTHON_FLAKE8_FILE_NAME="${PYTHON_FLAKE8_CONFIG_FILE:-.flake8}" # Name of the file -PYTHON_FLAKE8_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${PYTHON_FLAKE8_FILE_NAME}" # Path to the python lint rules +PYTHON_PYLINT_FILE_NAME="${PYTHON_PYLINT_CONFIG_FILE:-.python-lint}" # Name of the file +PYTHON_PYLINT_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${PYTHON_PYLINT_FILE_NAME}" # Path to the python lint rules +PYTHON_FLAKE8_FILE_NAME="${PYTHON_FLAKE8_CONFIG_FILE:-.flake8}" # Name of the file +PYTHON_FLAKE8_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${PYTHON_FLAKE8_FILE_NAME}" # Path to the python lint rules # Ruby Vars -RUBY_FILE_NAME="${RUBY_CONFIG_FILE:-.ruby-lint.yml}" # Name of the file -RUBY_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${RUBY_FILE_NAME}" # Path to the ruby lint rules +RUBY_FILE_NAME="${RUBY_CONFIG_FILE:-.ruby-lint.yml}" # Name of the file +RUBY_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${RUBY_FILE_NAME}" # Path to the ruby lint rules # Terraform Vars -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_FILE_NAME='.tflint.hcl' # Name of the file +TERRAFORM_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${TERRAFORM_FILE_NAME}" # Path to the Terraform lint rules # Typescript Vars -TYPESCRIPT_FILE_NAME="${TYPESCRIPT_ES_CONFIG_FILE:-.eslintrc.yml}" # Name of the file -TYPESCRIPT_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${TYPESCRIPT_FILE_NAME}" # Path to the Typescript lint rules -TYPESCRIPT_STANDARD_LINTER_RULES='' # ENV string to pass when running js standard +TYPESCRIPT_FILE_NAME="${TYPESCRIPT_ES_CONFIG_FILE:-.eslintrc.yml}" # Name of the file +TYPESCRIPT_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${TYPESCRIPT_FILE_NAME}" # Path to the Typescript lint rules +TYPESCRIPT_STANDARD_LINTER_RULES='' # ENV string to pass when running js standard # YAML Vars -YAML_FILE_NAME="${YAML_CONFIG_FILE:-.yaml-lint.yml}" # Name of the file -YAML_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${YAML_FILE_NAME}" # Path to the yaml lint rules +YAML_FILE_NAME="${YAML_CONFIG_FILE:-.yaml-lint.yml}" # Name of the file +YAML_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${YAML_FILE_NAME}" # Path to the yaml lint rules ####################################### # Linter array for information prints # ####################################### LINTER_ARRAY=('ansible-lint' 'arm-ttk' 'asl-validator' 'cfn-lint' 'clj-kondo' 'coffeelint' - 'dart' 'dockerfilelint' 'dotenv-linter' 'eslint' 'flake8' 'golangci-lint' 'htmlhint' - 'jsonlint' 'ktlint' 'lua' 'markdownlint' 'npm-groovy-lint' 'perl' 'protolint' 'pwsh' - 'pylint' 'raku' 'rubocop' 'shellcheck' 'spectral' 'standard' 'stylelint' 'terrascan' - 'tflint' 'xmllint' 'yamllint') + 'dart' 'dockerfilelint' 'dotenv-linter' 'eslint' 'flake8' 'golangci-lint' 'htmlhint' + 'jsonlint' 'ktlint' 'lua' 'markdownlint' 'npm-groovy-lint' 'perl' 'protolint' 'pwsh' + 'pylint' 'raku' 'rubocop' 'shellcheck' 'spectral' 'standard' 'stylelint' 'terrascan' + 'tflint' 'xmllint' 'yamllint') ############################# # Language array for prints # ############################# LANGUAGE_ARRAY=('ANSIBLE' 'ARM' 'BASH' 'CLOUDFORMATION' 'CLOJURE' 'COFFEESCRIPT' 'CSS' - 'DART' 'DOCKER' 'ENV' 'GO' 'GROOVY' 'HTML' 'JAVASCRIPT_ES' 'JAVASCRIPT_STANDARD' - 'JSON' 'JSX' 'KOTLIN' 'LUA' 'MARKDOWN' 'OPENAPI' 'PERL' 'PHP' 'PHP_PHPSTAN' 'POWERSHELL' - 'PROTOBUF' 'PYTHON_PYLINT' 'PYTHON_FLAKE8' 'RAKU' 'RUBY' 'STATES' 'TERRAFORM' - 'TERRAFORM_TERRASCAN' 'TSX' 'TYPESCRIPT_ES' 'TYPESCRIPT_STANDARD' 'XML' 'YML') + 'DART' 'DOCKER' 'ENV' 'GO' 'GROOVY' 'HTML' 'JAVASCRIPT_ES' 'JAVASCRIPT_STANDARD' + 'JSON' 'JSX' 'KOTLIN' 'LUA' 'MARKDOWN' 'OPENAPI' 'PERL' 'PHP' 'PHP_PHPSTAN' 'POWERSHELL' + 'PROTOBUF' 'PYTHON_PYLINT' 'PYTHON_FLAKE8' 'RAKU' 'RUBY' 'STATES' 'TERRAFORM' + 'TERRAFORM_TERRASCAN' 'TSX' 'TYPESCRIPT_ES' 'TYPESCRIPT_STANDARD' 'XML' 'YML') ############################################ # Array for all languages that were linted # @@ -128,58 +128,58 @@ LINTED_LANGUAGES_ARRAY=() # Will be filled at run time with all languages that w ################### # GitHub ENV Vars # ################### -ANSIBLE_DIRECTORY="${ANSIBLE_DIRECTORY}" # Ansible Directory -DEFAULT_BRANCH="${DEFAULT_BRANCH:-master}" # Default Git Branch to use (master by default) -DISABLE_ERRORS="${DISABLE_ERRORS}" # Boolean to enable warning-only output without throwing errors -GITHUB_EVENT_PATH="${GITHUB_EVENT_PATH}" # Github Event Path -GITHUB_REPOSITORY="${GITHUB_REPOSITORY}" # GitHub Org/Repo passed from system -GITHUB_RUN_ID="${GITHUB_RUN_ID}" # GitHub RUn ID to point to logs -GITHUB_SHA="${GITHUB_SHA}" # GitHub sha from the commit -GITHUB_TOKEN="${GITHUB_TOKEN}" # GitHub Token passed from environment -GITHUB_WORKSPACE="${GITHUB_WORKSPACE}" # Github Workspace -LOG_FILE="${LOG_FILE:-super-linter.log}" # Default log file name (located in GITHUB_WORKSPACE folder) -LOG_LEVEL="${LOG_LEVEL:-VERBOSE}" # Default log level (VERBOSE, DEBUG, TRACE) -MULTI_STATUS="${MULTI_STATUS:-true}" # Multiple status are created for each check ran -TEST_CASE_RUN="${TEST_CASE_RUN}" # Boolean to validate only test cases -VALIDATE_ALL_CODEBASE="${VALIDATE_ALL_CODEBASE}" # Boolean to validate all files -VALIDATE_ANSIBLE="${VALIDATE_ANSIBLE}" # Boolean to validate language -VALIDATE_ARM="${VALIDATE_ARM}" # Boolean to validate language -VALIDATE_BASH="${VALIDATE_BASH}" # Boolean to validate language -VALIDATE_CLOUDFORMATION="${VALIDATE_CLOUDFORMATION}" # Boolean to validate language -VALIDATE_CLOJURE="${VALIDATE_CLOJURE}" # Boolean to validate language -VALIDATE_COFFEE="${VALIDATE_COFFEE}" # Boolean to validate language -VALIDATE_CSS="${VALIDATE_CSS}" # Boolean to validate language -VALIDATE_DART="${VALIDATE_DART}" # Boolean to validate language -VALIDATE_DOCKER="${VALIDATE_DOCKER}" # Boolean to validate language -VALIDATE_EDITORCONFIG="${VALIDATE_EDITORCONFIG}" # Boolean to validate files with editorconfig -VALIDATE_ENV="${VALIDATE_ENV}" # 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_JAVASCRIPT_ES="${VALIDATE_JAVASCRIPT_ES}" # Boolean to validate language -VALIDATE_JAVASCRIPT_STANDARD="${VALIDATE_JAVASCRIPT_STANDARD}" # Boolean to validate language -VALIDATE_JSON="${VALIDATE_JSON}" # Boolean to validate language -VALIDATE_JSX="${VALIDATE_JSX}" # Boolean to validate language -VALIDATE_KOTLIN="${VALIDATE_KOTLIN}" # Boolean to validate language -VALIDATE_LUA="${VALIDATE_LUA}" # Boolean to validate language -VALIDATE_MARKDOWN="${VALIDATE_MD:-}" # Boolean to validate language -VALIDATE_OPENAPI="${VALIDATE_OPENAPI}" # Boolean to validate language -VALIDATE_PERL="${VALIDATE_PERL}" # Boolean to validate language -VALIDATE_PHP="${VALIDATE_PHP}" # Boolean to validate language -VALIDATE_PHP_PHPSTAN="${VALIDATE_PHP_PHPSTAN}" # Boolean to validate language -VALIDATE_POWERSHELL="${VALIDATE_POWERSHELL}" # Boolean to validate language -VALIDATE_PYTHON_PYLINT="${VALIDATE_PYTHON:-$VALIDATE_PYTHON_PYLINT}" # Boolean to validate language -VALIDATE_PYTHON_FLAKE8="${VALIDATE_PYTHON_FLAKE8}" # Boolean to validate language -VALIDATE_RAKU="${VALIDATE_RAKU}" # Boolean to validate language -VALIDATE_RUBY="${VALIDATE_RUBY}" # Boolean to validate language -VALIDATE_STATES="${VALIDATE_STATES}" # Boolean to validate language -VALIDATE_TERRAFORM="${VALIDATE_TERRAFORM}" # Boolean to validate language -VALIDATE_TERRAFORM_TERRASCAN="${VALIDATE_TERRAFORM_TERRASCAN}" # Boolean to validate language -VALIDATE_TSX="${VALIDATE_TSX}" # Boolean to validate language -VALIDATE_TYPESCRIPT_ES="${VALIDATE_TYPESCRIPT_ES}" # Boolean to validate language -VALIDATE_TYPESCRIPT_STANDARD="${VALIDATE_TYPESCRIPT_STANDARD}" # Boolean to validate language -VALIDATE_XML="${VALIDATE_XML}" # Boolean to validate language -VALIDATE_YAML="${VALIDATE_YAML}" # Boolean to validate language +ANSIBLE_DIRECTORY="${ANSIBLE_DIRECTORY}" # Ansible Directory +DEFAULT_BRANCH="${DEFAULT_BRANCH:-master}" # Default Git Branch to use (master by default) +DISABLE_ERRORS="${DISABLE_ERRORS}" # Boolean to enable warning-only output without throwing errors +GITHUB_EVENT_PATH="${GITHUB_EVENT_PATH}" # Github Event Path +GITHUB_REPOSITORY="${GITHUB_REPOSITORY}" # GitHub Org/Repo passed from system +GITHUB_RUN_ID="${GITHUB_RUN_ID}" # GitHub RUn ID to point to logs +GITHUB_SHA="${GITHUB_SHA}" # GitHub sha from the commit +GITHUB_TOKEN="${GITHUB_TOKEN}" # GitHub Token passed from environment +GITHUB_WORKSPACE="${GITHUB_WORKSPACE}" # Github Workspace +LOG_FILE="${LOG_FILE:-super-linter.log}" # Default log file name (located in GITHUB_WORKSPACE folder) +LOG_LEVEL="${LOG_LEVEL:-VERBOSE}" # Default log level (VERBOSE, DEBUG, TRACE) +MULTI_STATUS="${MULTI_STATUS:-true}" # Multiple status are created for each check ran +TEST_CASE_RUN="${TEST_CASE_RUN}" # Boolean to validate only test cases +VALIDATE_ALL_CODEBASE="${VALIDATE_ALL_CODEBASE}" # Boolean to validate all files +VALIDATE_ANSIBLE="${VALIDATE_ANSIBLE}" # Boolean to validate language +VALIDATE_ARM="${VALIDATE_ARM}" # Boolean to validate language +VALIDATE_BASH="${VALIDATE_BASH}" # Boolean to validate language +VALIDATE_CLOUDFORMATION="${VALIDATE_CLOUDFORMATION}" # Boolean to validate language +VALIDATE_CLOJURE="${VALIDATE_CLOJURE}" # Boolean to validate language +VALIDATE_COFFEE="${VALIDATE_COFFEE}" # Boolean to validate language +VALIDATE_CSS="${VALIDATE_CSS}" # Boolean to validate language +VALIDATE_DART="${VALIDATE_DART}" # Boolean to validate language +VALIDATE_DOCKER="${VALIDATE_DOCKER}" # Boolean to validate language +VALIDATE_EDITORCONFIG="${VALIDATE_EDITORCONFIG}" # Boolean to validate files with editorconfig +VALIDATE_ENV="${VALIDATE_ENV}" # 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_JAVASCRIPT_ES="${VALIDATE_JAVASCRIPT_ES}" # Boolean to validate language +VALIDATE_JAVASCRIPT_STANDARD="${VALIDATE_JAVASCRIPT_STANDARD}" # Boolean to validate language +VALIDATE_JSON="${VALIDATE_JSON}" # Boolean to validate language +VALIDATE_JSX="${VALIDATE_JSX}" # Boolean to validate language +VALIDATE_KOTLIN="${VALIDATE_KOTLIN}" # Boolean to validate language +VALIDATE_LUA="${VALIDATE_LUA}" # Boolean to validate language +VALIDATE_MARKDOWN="${VALIDATE_MD:-}" # Boolean to validate language +VALIDATE_OPENAPI="${VALIDATE_OPENAPI}" # Boolean to validate language +VALIDATE_PERL="${VALIDATE_PERL}" # Boolean to validate language +VALIDATE_PHP="${VALIDATE_PHP}" # Boolean to validate language +VALIDATE_PHP_PHPSTAN="${VALIDATE_PHP_PHPSTAN}" # Boolean to validate language +VALIDATE_POWERSHELL="${VALIDATE_POWERSHELL}" # Boolean to validate language +VALIDATE_PYTHON_PYLINT="${VALIDATE_PYTHON:-$VALIDATE_PYTHON_PYLINT}" # Boolean to validate language +VALIDATE_PYTHON_FLAKE8="${VALIDATE_PYTHON_FLAKE8}" # Boolean to validate language +VALIDATE_RAKU="${VALIDATE_RAKU}" # Boolean to validate language +VALIDATE_RUBY="${VALIDATE_RUBY}" # Boolean to validate language +VALIDATE_STATES="${VALIDATE_STATES}" # Boolean to validate language +VALIDATE_TERRAFORM="${VALIDATE_TERRAFORM}" # Boolean to validate language +VALIDATE_TERRAFORM_TERRASCAN="${VALIDATE_TERRAFORM_TERRASCAN}" # Boolean to validate language +VALIDATE_TSX="${VALIDATE_TSX}" # Boolean to validate language +VALIDATE_TYPESCRIPT_ES="${VALIDATE_TYPESCRIPT_ES}" # Boolean to validate language +VALIDATE_TYPESCRIPT_STANDARD="${VALIDATE_TYPESCRIPT_STANDARD}" # Boolean to validate language +VALIDATE_XML="${VALIDATE_XML}" # Boolean to validate language +VALIDATE_YAML="${VALIDATE_YAML}" # Boolean to validate language ############## # Debug Vars # @@ -190,37 +190,41 @@ ACTIONS_RUNNER_DEBUG="${ACTIONS_RUNNER_DEBUG:-false}" # Boolean to see even more ############ # Log Vars # ############ -LOG_TRACE=$(if [[ ${LOG_LEVEL} == "TRACE" ]]; then echo "true";fi) # Boolean to see trace logs +if [[ ${ACTIONS_RUNNER_DEBUG} == true ]]; then LOG_LEVEL="DEBUG"; fi +# Boolean to see trace logs +LOG_TRACE=$(if [[ ${LOG_LEVEL} == "TRACE" ]]; then echo "true"; fi) export LOG_TRACE -LOG_DEBUG=$(if [[ ${LOG_LEVEL} == "DEBUG" || ${ACTIONS_RUNNER_DEBUG} == true ]]; then echo "true";fi) # Boolean to see debug logs +# Boolean to see debug logs +LOG_DEBUG=$(if [[ ${LOG_LEVEL} == "DEBUG" || ${LOG_LEVEL} == "TRACE" ]]; then echo "true"; fi) export LOG_DEBUG -LOG_VERBOSE=$(if [[ ${LOG_LEVEL} == "VERBOSE" ]]; then echo "true";fi) # Boolean to see verbose logs (info function) +# Boolean to see verbose logs (info function) +LOG_VERBOSE=$(if [[ ${LOG_LEVEL} == "VERBOSE" || ${LOG_LEVEL} == "DEBUG" || ${LOG_LEVEL} == "TRACE" ]]; then echo "true"; fi) export LOG_VERBOSE ################ # Default Vars # ################ -DEFAULT_VALIDATE_ALL_CODEBASE='true' # Default value for validate all files -DEFAULT_WORKSPACE="${DEFAULT_WORKSPACE:-/tmp/lint}" # Default workspace if running locally -DEFAULT_RUN_LOCAL='false' # Default value for debugging locally -DEFAULT_TEST_CASE_RUN='false' # Flag to tell code to run only test cases -DEFAULT_IFS="${IFS}" # Get the Default IFS for updating +DEFAULT_VALIDATE_ALL_CODEBASE='true' # Default value for validate all files +DEFAULT_WORKSPACE="${DEFAULT_WORKSPACE:-/tmp/lint}" # Default workspace if running locally +DEFAULT_RUN_LOCAL='false' # Default value for debugging locally +DEFAULT_TEST_CASE_RUN='false' # Flag to tell code to run only test cases +DEFAULT_IFS="${IFS}" # Get the Default IFS for updating ############################################################### # Default Vars that are called in Subs and need to be ignored # ############################################################### -DEFAULT_DISABLE_ERRORS='false' # Default to enabling errors -export DEFAULT_DISABLE_ERRORS # Workaround SC2034 -RAW_FILE_ARRAY=() # Array of all files that were changed -export RAW_FILE_ARRAY # Workaround SC2034 -READ_ONLY_CHANGE_FLAG=0 # Flag set to 1 if files changed are not txt or md -export READ_ONLY_CHANGE_FLAG # Workaround SC2034 -TEST_CASE_FOLDER='.automation/test' # Folder for test cases we should always ignore -export TEST_CASE_FOLDER # Workaround SC2034 -DEFAULT_ANSIBLE_DIRECTORY="${GITHUB_WORKSPACE}/ansible" # Default Ansible Directory -export DEFAULT_ANSIBLE_DIRECTORY # Workaround SC2034 -WARNING_ARRAY_TEST=() # Array of warning linters that did not have an expected test result. -export WARNING_ARRAY_TEST # Workaround SC2034 +DEFAULT_DISABLE_ERRORS='false' # Default to enabling errors +export DEFAULT_DISABLE_ERRORS # Workaround SC2034 +RAW_FILE_ARRAY=() # Array of all files that were changed +export RAW_FILE_ARRAY # Workaround SC2034 +READ_ONLY_CHANGE_FLAG=0 # Flag set to 1 if files changed are not txt or md +export READ_ONLY_CHANGE_FLAG # Workaround SC2034 +TEST_CASE_FOLDER='.automation/test' # Folder for test cases we should always ignore +export TEST_CASE_FOLDER # Workaround SC2034 +DEFAULT_ANSIBLE_DIRECTORY="${GITHUB_WORKSPACE}/ansible" # Default Ansible Directory +export DEFAULT_ANSIBLE_DIRECTORY # Workaround SC2034 +WARNING_ARRAY_TEST=() # Array of warning linters that did not have an expected test result. +export WARNING_ARRAY_TEST # Workaround SC2034 ############## # Format # @@ -356,561 +360,133 @@ export ERRORS_FOUND_YAML # Workaround SC2034 ################################################################################ #### Function Header ########################################################### Header() { - ############################### - # Give them the possum action # - ############################### - /bin/bash /action/lib/possum.sh + ############################### + # Give them the possum action # + ############################### + /bin/bash /action/lib/possum.sh - ########## - # Prints # - ########## - info "---------------------------------------------" - info "--- GitHub Actions Multi Language Linter ----" - info "---------------------------------------------" - info "---------------------------------------------" - info "The Super-Linter source code can be found at:" - info " - https://github.com/github/super-linter" - info "---------------------------------------------" + ########## + # Prints # + ########## + info "---------------------------------------------" + info "--- GitHub Actions Multi Language Linter ----" + info "---------------------------------------------" + info "---------------------------------------------" + info "The Super-Linter source code can be found at:" + info " - https://github.com/github/super-linter" + info "---------------------------------------------" } ################################################################################ #### Function GetLinterVersions ################################################ GetLinterVersions() { - ######################### - # Print version headers # - ######################### - debug "---------------------------------------------" - debug "Linter Version Info:" + ######################### + # Print version headers # + ######################### + debug "---------------------------------------------" + debug "Linter Version Info:" - ########################################################## - # Go through the array of linters and print version info # - ########################################################## - for LINTER in "${LINTER_ARRAY[@]}"; do - #################### - # Get the versions # - #################### - if [[ "${LINTER}" == "arm-ttk" ]]; then - # Need specific command for ARM - mapfile -t GET_VERSION_CMD < <(grep -iE 'version' "${ARM_TTK_PSD1}" | xargs 2>&1) - elif [[ "${LINTER}" == "protolint" ]]; then - # Need specific command for Protolint - mapfile -t GET_VERSION_CMD < <(echo "--version not supported") - else - # Standard version command - mapfile -t GET_VERSION_CMD < <("${LINTER}" --version 2>&1) - fi + ########################################################## + # Go through the array of linters and print version info # + ########################################################## + for LINTER in "${LINTER_ARRAY[@]}"; do + #################### + # Get the versions # + #################### + if [[ ${LINTER} == "arm-ttk" ]]; then + # Need specific command for ARM + mapfile -t GET_VERSION_CMD < <(grep -iE 'version' "${ARM_TTK_PSD1}" | xargs 2>&1) + elif [[ ${LINTER} == "protolint" ]]; then + # Need specific command for Protolint + mapfile -t GET_VERSION_CMD < <(echo "--version not supported") + else + # Standard version command + mapfile -t GET_VERSION_CMD < <("${LINTER}" --version 2>&1) + fi - ####################### - # Load the error code # - ####################### - ERROR_CODE=$? + ####################### + # Load the error code # + ####################### + ERROR_CODE=$? - ############################## - # Check the shell for errors # - ############################## - if [ ${ERROR_CODE} -ne 0 ] || [ -z "${GET_VERSION_CMD[*]}" ]; then - warn "[${LINTER}]: Failed to get version info for:" - else - ########################## - # Print the version info # - ########################## - debug "Successfully found version for ${F[W]}[${LINTER}]${F[B]}: ${F[W]}${GET_VERSION_CMD[*]}" - fi - done + ############################## + # Check the shell for errors # + ############################## + if [ ${ERROR_CODE} -ne 0 ] || [ -z "${GET_VERSION_CMD[*]}" ]; then + warn "[${LINTER}]: Failed to get version info for:" + else + ########################## + # Print the version info # + ########################## + debug "Successfully found version for ${F[W]}[${LINTER}]${F[B]}: ${F[W]}${GET_VERSION_CMD[*]}" + fi + done - ######################### - # Print version footers # - ######################### - debug "---------------------------------------------" + ######################### + # Print version footers # + ######################### + debug "---------------------------------------------" } ################################################################################ #### Function GetLinterRules ################################################### GetLinterRules() { - # Need to validate the rules files exist + # Need to validate the rules files exist - ################ - # Pull in vars # - ################ - LANGUAGE_NAME="${1}" # Name of the language were looking for + ################ + # Pull in vars # + ################ + LANGUAGE_NAME="${1}" # Name of the language were looking for - ####################################################### - # Need to create the variables for the real variables # - ####################################################### - LANGUAGE_FILE_NAME="${LANGUAGE_NAME}_FILE_NAME" - LANGUAGE_LINTER_RULES="${LANGUAGE_NAME}_LINTER_RULES" + ####################################################### + # Need to create the variables for the real variables # + ####################################################### + LANGUAGE_FILE_NAME="${LANGUAGE_NAME}_FILE_NAME" + LANGUAGE_LINTER_RULES="${LANGUAGE_NAME}_LINTER_RULES" - ##################################### - # Validate we have the linter rules # - ##################################### - if [ -f "${GITHUB_WORKSPACE}/${LINTER_RULES_PATH}/${!LANGUAGE_FILE_NAME}" ]; then - info "----------------------------------------------" - info "User provided file:[${!LANGUAGE_FILE_NAME}], setting rules file..." + ##################################### + # Validate we have the linter rules # + ##################################### + if [ -f "${GITHUB_WORKSPACE}/${LINTER_RULES_PATH}/${!LANGUAGE_FILE_NAME}" ]; then + info "----------------------------------------------" + info "User provided file:[${!LANGUAGE_FILE_NAME}], setting rules file..." - ######################################## - # Update the path to the file location # - ######################################## - eval "${LANGUAGE_LINTER_RULES}=${GITHUB_WORKSPACE}/${LINTER_RULES_PATH}/${!LANGUAGE_FILE_NAME}" - else - ######################################################## - # No user default provided, using the template default # - ######################################################## - debug " -> Codebase does NOT have file:[${LINTER_RULES_PATH}/${!LANGUAGE_FILE_NAME}], using Default rules at:[${!LANGUAGE_LINTER_RULES}]" - fi + ######################################## + # Update the path to the file location # + ######################################## + eval "${LANGUAGE_LINTER_RULES}=${GITHUB_WORKSPACE}/${LINTER_RULES_PATH}/${!LANGUAGE_FILE_NAME}" + else + ######################################################## + # No user default provided, using the template default # + ######################################################## + debug " -> Codebase does NOT have file:[${LINTER_RULES_PATH}/${!LANGUAGE_FILE_NAME}], using Default rules at:[${!LANGUAGE_LINTER_RULES}]" + fi } ################################################################################ #### Function GetStandardRules ################################################# GetStandardRules() { - ################ - # Pull In Vars # - ################ - LINTER="${1}" # Type: javascript | typescript + ################ + # Pull In Vars # + ################ + LINTER="${1}" # Type: javascript | typescript - ######################################################################### - # Need to get the ENV vars from the linter rules to run in command line # - ######################################################################### - # Copy orig IFS to var - ORIG_IFS="${IFS}" - # Set the IFS to newline - IFS=$'\n' + ######################################################################### + # Need to get the ENV vars from the linter rules to run in command line # + ######################################################################### + # Copy orig IFS to var + ORIG_IFS="${IFS}" + # Set the IFS to newline + IFS=$'\n' - ######################################### - # Get list of all environment variables # - ######################################### - # Only env vars that are marked as true - GET_ENV_ARRAY=() - if [[ ${LINTER} == "javascript" ]]; then - mapfile -t GET_ENV_ARRAY < <(yq .env "${JAVASCRIPT_LINTER_RULES}" | grep true) - elif [[ ${LINTER} == "typescript" ]]; then - mapfile -t GET_ENV_ARRAY < <(yq .env "${TYPESCRIPT_LINTER_RULES}" | grep true) - fi - - ####################### - # Load the error code # - ####################### - ERROR_CODE=$? - - ############################## - # Check the shell for errors # - ############################## - if [ ${ERROR_CODE} -ne 0 ]; then - # ERROR - error "Failed to gain list of ENV vars to load!" - fatal "[${GET_ENV_ARRAY[*]}]" - fi - - ########################## - # Set IFS back to normal # - ########################## - # Set IFS back to Orig - IFS="${ORIG_IFS}" - - ###################### - # Set the env string # - ###################### - ENV_STRING='' - - ############################# - # Pull out the envs to load # - ############################# - for ENV in "${GET_ENV_ARRAY[@]}"; do - ############################# - # remove spaces from return # - ############################# - ENV="$(echo -e "${ENV}" | tr -d '[:space:]')" - ################################ - # Get the env to add to string # - ################################ - ENV="$(echo "${ENV}" | cut -d'"' -f2)" - debug "ENV:[${ENV}]" - ENV_STRING+="--env ${ENV} " - done - - ######################################### - # Remove trailing and ending whitespace # - ######################################### - if [[ ${LINTER} == "javascript" ]]; then - JAVASCRIPT_STANDARD_LINTER_RULES="$(echo -e "${ENV_STRING}" | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//')" - elif [[ ${LINTER} == "typescript" ]]; then - TYPESCRIPT_STANDARD_LINTER_RULES="$(echo -e "${ENV_STRING}" | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//')" - fi -} -################################################################################ -#### Function DetectOpenAPIFile ################################################ -DetectOpenAPIFile() { - ################ - # Pull in vars # - ################ - FILE="${1}" - - ############################### - # Check the file for keywords # - ############################### - grep -E '"openapi":|"swagger":|^openapi:|^swagger:' "${FILE}" > /dev/null - - ####################### - # Load the error code # - ####################### - ERROR_CODE=$? - - ############################## - # Check the shell for errors # - ############################## - if [ ${ERROR_CODE} -eq 0 ]; then - ######################## - # Found string in file # - ######################## - return 0 - else - ################### - # No string match # - ################### - return 1 - fi -} -################################################################################ -#### Function DetectARMFile #################################################### -DetectARMFile() { - ################ - # Pull in vars # - ################ - FILE="${1}" # Name of the file/path we are validating - - ############################### - # Check the file for keywords # - ############################### - grep -E 'schema.management.azure.com' "${FILE}" > /dev/null - - ####################### - # Load the error code # - ####################### - ERROR_CODE=$? - - ############################## - # Check the shell for errors # - ############################## - if [ ${ERROR_CODE} -eq 0 ]; then - ######################## - # Found string in file # - ######################## - return 0 - else - ################### - # No string match # - ################### - return 1 - fi -} -################################################################################ -#### Function DetectCloudFormationFile ######################################### -DetectCloudFormationFile() { - ################ - # Pull in Vars # - ################ - FILE="${1}" # File that we need to validate - - # https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/template-formats.html - # AWSTemplateFormatVersion is optional - ####################################### - # Check if file has AWS Template info # - ####################################### - if grep -q 'AWSTemplateFormatVersion' "${FILE}" > /dev/null; then - # Found it - return 0 - fi - - ##################################### - # See if it contains AWS References # - ##################################### - if grep -q -E '(AWS|Alexa|Custom)::' "${FILE}" > /dev/null; then - # Found it - return 0 - fi - - ##################################################### - # No identifiers of a CLOUDFORMATION template found # - ##################################################### - return 1 -} -################################################################################ -#### Function DetectAWSStatesFIle ############################################## -DetectAWSStatesFIle() { - ################ - # Pull in Vars # - ################ - FILE="${1}" # File that we need to validate - - # https://states-language.net/spec.html#example - ############################### - # check if file has resources # - ############################### - if grep '"Resource": *"arn"*' "${FILE}"; then - # Found it - return 0 - fi - - ################################################# - # No identifiers of a AWS States Language found # - ################################################# - return 1 -} -################################################################################ -#### Function GetGitHubVars #################################################### -GetGitHubVars() { - ########## - # Prints # - ########## - info "--------------------------------------------" - info "Gathering GitHub information..." - - ############################### - # Get the Run test cases flag # - ############################### - if [ -z "${TEST_CASE_RUN}" ]; then - ################################## - # No flag passed, set to default # - ################################## - TEST_CASE_RUN="${DEFAULT_TEST_CASE_RUN}" - fi - - ############################### - # Convert string to lowercase # - ############################### - TEST_CASE_RUN="${TEST_CASE_RUN,,}" - - ########################## - # Get the run local flag # - ########################## - if [ -z "${RUN_LOCAL}" ]; then - ################################## - # No flag passed, set to default # - ################################## - RUN_LOCAL="${DEFAULT_RUN_LOCAL}" - fi - - ############################### - # Convert string to lowercase # - ############################### - RUN_LOCAL="${RUN_LOCAL,,}" - - ################################# - # Check if were running locally # - ################################# - if [[ ${RUN_LOCAL} != "false" ]]; then - ########################################## - # We are running locally for a debug run # - ########################################## - info "NOTE: ENV VAR [RUN_LOCAL] has been set to:[true]" - info "bypassing GitHub Actions variables..." - - ############################ - # Set the GITHUB_WORKSPACE # - ############################ - if [ -z "${GITHUB_WORKSPACE}" ]; then - GITHUB_WORKSPACE="${DEFAULT_WORKSPACE}" + ######################################### + # Get list of all environment variables # + ######################################### + # Only env vars that are marked as true + GET_ENV_ARRAY=() + if [[ ${LINTER} == "javascript" ]]; then + mapfile -t GET_ENV_ARRAY < <(yq .env "${JAVASCRIPT_LINTER_RULES}" | grep true) + elif [[ ${LINTER} == "typescript" ]]; then + mapfile -t GET_ENV_ARRAY < <(yq .env "${TYPESCRIPT_LINTER_RULES}" | grep true) fi - if [ ! -d "${GITHUB_WORKSPACE}" ]; then - fatal "Provided volume is not a directory!" - fi - - info "Linting all files in mapped directory:[${DEFAULT_WORKSPACE}]" - - # No need to touch or set the GITHUB_SHA - # No need to touch or set the GITHUB_EVENT_PATH - # No need to touch or set the GITHUB_ORG - # No need to touch or set the GITHUB_REPO - - ################################# - # Set the VALIDATE_ALL_CODEBASE # - ################################# - VALIDATE_ALL_CODEBASE="${DEFAULT_VALIDATE_ALL_CODEBASE}" - else - ############################ - # Validate we have a value # - ############################ - if [ -z "${GITHUB_SHA}" ]; then - error "Failed to get [GITHUB_SHA]!" - fatal "[${GITHUB_SHA}]" - else - info "Successfully found:${F[W]}[GITHUB_SHA]${F[B]}, value:${F[W]}[${GITHUB_SHA}]" - fi - - ############################ - # Validate we have a value # - ############################ - if [ -z "${GITHUB_WORKSPACE}" ]; then - error "Failed to get [GITHUB_WORKSPACE]!" - fatal "[${GITHUB_WORKSPACE}]" - else - info "Successfully found:${F[W]}[GITHUB_WORKSPACE]${F[B]}, value:${F[W]}[${GITHUB_WORKSPACE}]" - fi - - ############################ - # Validate we have a value # - ############################ - if [ -z "${GITHUB_EVENT_PATH}" ]; then - error "Failed to get [GITHUB_EVENT_PATH]!" - fatal "[${GITHUB_EVENT_PATH}]" - else - info "Successfully found:${F[W]}[GITHUB_EVENT_PATH]${F[B]}, value:${F[W]}[${GITHUB_EVENT_PATH}]${F[B]}" - fi - - ################################################## - # Need to pull the GitHub Vars from the env file # - ################################################## - - ###################### - # Get the GitHub Org # - ###################### - GITHUB_ORG=$(jq -r '.repository.owner.login' < "${GITHUB_EVENT_PATH}") - - ############################ - # Validate we have a value # - ############################ - if [ -z "${GITHUB_ORG}" ]; then - error "Failed to get [GITHUB_ORG]!" - fatal "[${GITHUB_ORG}]" - else - info "Successfully found:${F[W]}[GITHUB_ORG]${F[B]}, value:${F[W]}[${GITHUB_ORG}]" - fi - - ####################### - # Get the GitHub Repo # - ####################### - GITHUB_REPO=$(jq -r '.repository.name' < "${GITHUB_EVENT_PATH}") - - ############################ - # Validate we have a value # - ############################ - if [ -z "${GITHUB_REPO}" ]; then - error "Failed to get [GITHUB_REPO]!" - fatal "[${GITHUB_REPO}]" - else - info "Successfully found:${F[W]}[GITHUB_REPO]${F[B]}, value:${F[W]}[${GITHUB_REPO}]" - fi - fi - - ############################ - # Validate we have a value # - ############################ - if [ -z "${GITHUB_TOKEN}" ] && [[ ${RUN_LOCAL} == "false" ]]; then - error "Failed to get [GITHUB_TOKEN]!" - error "[${GITHUB_TOKEN}]" - error "Please set a [GITHUB_TOKEN] from the main workflow environment to take advantage of multiple status reports!" - - ################################################################################ - # Need to set MULTI_STATUS to false as we cant hit API endpoints without token # - ################################################################################ - MULTI_STATUS='false' - else - info "Successfully found:${F[W]}[GITHUB_TOKEN]" - fi - - ############################### - # Convert string to lowercase # - ############################### - MULTI_STATUS="${MULTI_STATUS,,}" - - ####################################################################### - # Check to see if the multi status is set, and we have a token to use # - ####################################################################### - if [ "${MULTI_STATUS}" == "true" ] && [ -n "${GITHUB_TOKEN}" ]; then - ############################ - # Validate we have a value # - ############################ - if [ -z "${GITHUB_REPOSITORY}" ]; then - error "Failed to get [GITHUB_REPOSITORY]!" - fatal "[${GITHUB_REPOSITORY}]" - else - info "Successfully found:${F[W]}[GITHUB_REPOSITORY]${F[B]}, value:${F[W]}[${GITHUB_REPOSITORY}]" - fi - - ############################ - # Validate we have a value # - ############################ - if [ -z "${GITHUB_RUN_ID}" ]; then - error "Failed to get [GITHUB_RUN_ID]!" - fatal "[${GITHUB_RUN_ID}]" - else - info "Successfully found:${F[W]}[GITHUB_RUN_ID]${F[B]}, value:${F[W]}[${GITHUB_RUN_ID}]" - fi - fi -} -################################################################################ -#### Function ValidatePowershellModules ######################################## -function ValidatePowershellModules() { - VALIDATE_PSSA_MODULE=$(pwsh -c "(Get-Module -Name PSScriptAnalyzer -ListAvailable | Select-Object -First 1).Name" 2>&1) - # If module found, ensure Invoke-ScriptAnalyzer command is available - if [[ ${VALIDATE_PSSA_MODULE} == "PSScriptAnalyzer" ]]; then - VALIDATE_PSSA_CMD=$(pwsh -c "(Get-Command Invoke-ScriptAnalyzer | Select-Object -First 1).Name" 2>&1) - else - fatal "Failed to find module." - fi - - ######################################### - # validate we found the script analyzer # - ######################################### - if [[ ${VALIDATE_PSSA_CMD} != "Invoke-ScriptAnalyzer" ]]; then - fatal "Failed to find module." - fi - - ####################### - # Load the error code # - ####################### - ERROR_CODE=$? - - ############################## - # Check the shell for errors # - ############################## - if [ ${ERROR_CODE} -ne 0 ]; then - # Failed - error "Failed find module [PSScriptAnalyzer] for [${LINTER_NAME}] in system!" - fatal "[PSSA_MODULE ${VALIDATE_PSSA_MODULE}] [PSSA_CMD ${VALIDATE_PSSA_CMD}]" - else - # Success - debug "Successfully found module ${F[W]}[${VALIDATE_PSSA_MODULE}]${F[B]} in system" - debug "Successfully found command ${F[W]}[${VALIDATE_PSSA_CMD}]${F[B]} in system" - fi -} -################################################################################ -#### Function CallStatusAPI #################################################### -CallStatusAPI() { - #################### - # Pull in the vars # - #################### - LANGUAGE="${1}" # langauge that was validated - STATUS="${2}" # success | error - SUCCESS_MSG='No errors were found in the linting process' - FAIL_MSG='Errors were detected, please view logs' - MESSAGE='' # Message to send to status API - - ###################################### - # Check the status to create message # - ###################################### - if [ "${STATUS}" == "success" ]; then - # Success - MESSAGE="${SUCCESS_MSG}" - else - # Failure - MESSAGE="${FAIL_MSG}" - fi - - ########################################################## - # Check to see if were enabled for multi Status mesaages # - ########################################################## - if [ "${MULTI_STATUS}" == "true" ]; then - ############################################## - # Call the status API to create status check # - ############################################## - SEND_STATUS_CMD=$(curl -f -s -X POST \ - --url "${GITHUB_API_URL}/repos/${GITHUB_REPOSITORY}/statuses/${GITHUB_SHA}" \ - -H 'accept: application/vnd.github.v3+json' \ - -H "authorization: Bearer ${GITHUB_TOKEN}" \ - -H 'content-type: application/json' \ - -d "{ \"state\": \"${STATUS}\", - \"target_url\": \"https://github.com/${GITHUB_REPOSITORY}/actions/runs/${GITHUB_RUN_ID}\", - \"description\": \"${MESSAGE}\", \"context\": \"--> Linted: ${LANGUAGE}\" - }" 2>&1) - ####################### # Load the error code # ####################### @@ -919,116 +495,543 @@ CallStatusAPI() { ############################## # Check the shell for errors # ############################## - if [ "${ERROR_CODE}" -ne 0 ]; then - # ERROR - info "ERROR! Failed to call GitHub Status API!" - info "ERROR:[${SEND_STATUS_CMD}]" - # Not going to fail the script on this yet... + if [ ${ERROR_CODE} -ne 0 ]; then + # ERROR + error "Failed to gain list of ENV vars to load!" + fatal "[${GET_ENV_ARRAY[*]}]" + fi + + ########################## + # Set IFS back to normal # + ########################## + # Set IFS back to Orig + IFS="${ORIG_IFS}" + + ###################### + # Set the env string # + ###################### + ENV_STRING='' + + ############################# + # Pull out the envs to load # + ############################# + for ENV in "${GET_ENV_ARRAY[@]}"; do + ############################# + # remove spaces from return # + ############################# + ENV="$(echo -e "${ENV}" | tr -d '[:space:]')" + ################################ + # Get the env to add to string # + ################################ + ENV="$(echo "${ENV}" | cut -d'"' -f2)" + debug "ENV:[${ENV}]" + ENV_STRING+="--env ${ENV} " + done + + ######################################### + # Remove trailing and ending whitespace # + ######################################### + if [[ ${LINTER} == "javascript" ]]; then + JAVASCRIPT_STANDARD_LINTER_RULES="$(echo -e "${ENV_STRING}" | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//')" + elif [[ ${LINTER} == "typescript" ]]; then + TYPESCRIPT_STANDARD_LINTER_RULES="$(echo -e "${ENV_STRING}" | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//')" + fi +} +################################################################################ +#### Function DetectOpenAPIFile ################################################ +DetectOpenAPIFile() { + ################ + # Pull in vars # + ################ + FILE="${1}" + + ############################### + # Check the file for keywords # + ############################### + grep -E '"openapi":|"swagger":|^openapi:|^swagger:' "${FILE}" > /dev/null + + ####################### + # Load the error code # + ####################### + ERROR_CODE=$? + + ############################## + # Check the shell for errors # + ############################## + if [ ${ERROR_CODE} -eq 0 ]; then + ######################## + # Found string in file # + ######################## + return 0 + else + ################### + # No string match # + ################### + return 1 + fi +} +################################################################################ +#### Function DetectARMFile #################################################### +DetectARMFile() { + ################ + # Pull in vars # + ################ + FILE="${1}" # Name of the file/path we are validating + + ############################### + # Check the file for keywords # + ############################### + grep -E 'schema.management.azure.com' "${FILE}" > /dev/null + + ####################### + # Load the error code # + ####################### + ERROR_CODE=$? + + ############################## + # Check the shell for errors # + ############################## + if [ ${ERROR_CODE} -eq 0 ]; then + ######################## + # Found string in file # + ######################## + return 0 + else + ################### + # No string match # + ################### + return 1 + fi +} +################################################################################ +#### Function DetectCloudFormationFile ######################################### +DetectCloudFormationFile() { + ################ + # Pull in Vars # + ################ + FILE="${1}" # File that we need to validate + + # https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/template-formats.html + # AWSTemplateFormatVersion is optional + ####################################### + # Check if file has AWS Template info # + ####################################### + if grep -q 'AWSTemplateFormatVersion' "${FILE}" > /dev/null; then + # Found it + return 0 + fi + + ##################################### + # See if it contains AWS References # + ##################################### + if grep -q -E '(AWS|Alexa|Custom)::' "${FILE}" > /dev/null; then + # Found it + return 0 + fi + + ##################################################### + # No identifiers of a CLOUDFORMATION template found # + ##################################################### + return 1 +} +################################################################################ +#### Function DetectAWSStatesFIle ############################################## +DetectAWSStatesFIle() { + ################ + # Pull in Vars # + ################ + FILE="${1}" # File that we need to validate + + # https://states-language.net/spec.html#example + ############################### + # check if file has resources # + ############################### + if grep '"Resource": *"arn"*' "${FILE}"; then + # Found it + return 0 + fi + + ################################################# + # No identifiers of a AWS States Language found # + ################################################# + return 1 +} +################################################################################ +#### Function GetGitHubVars #################################################### +GetGitHubVars() { + ########## + # Prints # + ########## + info "--------------------------------------------" + info "Gathering GitHub information..." + + ############################### + # Get the Run test cases flag # + ############################### + if [ -z "${TEST_CASE_RUN}" ]; then + ################################## + # No flag passed, set to default # + ################################## + TEST_CASE_RUN="${DEFAULT_TEST_CASE_RUN}" + fi + + ############################### + # Convert string to lowercase # + ############################### + TEST_CASE_RUN="${TEST_CASE_RUN,,}" + + ########################## + # Get the run local flag # + ########################## + if [ -z "${RUN_LOCAL}" ]; then + ################################## + # No flag passed, set to default # + ################################## + RUN_LOCAL="${DEFAULT_RUN_LOCAL}" + fi + + ############################### + # Convert string to lowercase # + ############################### + RUN_LOCAL="${RUN_LOCAL,,}" + + ################################# + # Check if were running locally # + ################################# + if [[ ${RUN_LOCAL} != "false" ]]; then + ########################################## + # We are running locally for a debug run # + ########################################## + info "NOTE: ENV VAR [RUN_LOCAL] has been set to:[true]" + info "bypassing GitHub Actions variables..." + + ############################ + # Set the GITHUB_WORKSPACE # + ############################ + if [ -z "${GITHUB_WORKSPACE}" ]; then + GITHUB_WORKSPACE="${DEFAULT_WORKSPACE}" + fi + + if [ ! -d "${GITHUB_WORKSPACE}" ]; then + fatal "Provided volume is not a directory!" + fi + + info "Linting all files in mapped directory:[${DEFAULT_WORKSPACE}]" + + # No need to touch or set the GITHUB_SHA + # No need to touch or set the GITHUB_EVENT_PATH + # No need to touch or set the GITHUB_ORG + # No need to touch or set the GITHUB_REPO + + ################################# + # Set the VALIDATE_ALL_CODEBASE # + ################################# + VALIDATE_ALL_CODEBASE="${DEFAULT_VALIDATE_ALL_CODEBASE}" + else + ############################ + # Validate we have a value # + ############################ + if [ -z "${GITHUB_SHA}" ]; then + error "Failed to get [GITHUB_SHA]!" + fatal "[${GITHUB_SHA}]" + else + info "Successfully found:${F[W]}[GITHUB_SHA]${F[B]}, value:${F[W]}[${GITHUB_SHA}]" + fi + + ############################ + # Validate we have a value # + ############################ + if [ -z "${GITHUB_WORKSPACE}" ]; then + error "Failed to get [GITHUB_WORKSPACE]!" + fatal "[${GITHUB_WORKSPACE}]" + else + info "Successfully found:${F[W]}[GITHUB_WORKSPACE]${F[B]}, value:${F[W]}[${GITHUB_WORKSPACE}]" + fi + + ############################ + # Validate we have a value # + ############################ + if [ -z "${GITHUB_EVENT_PATH}" ]; then + error "Failed to get [GITHUB_EVENT_PATH]!" + fatal "[${GITHUB_EVENT_PATH}]" + else + info "Successfully found:${F[W]}[GITHUB_EVENT_PATH]${F[B]}, value:${F[W]}[${GITHUB_EVENT_PATH}]${F[B]}" + fi + + ################################################## + # Need to pull the GitHub Vars from the env file # + ################################################## + + ###################### + # Get the GitHub Org # + ###################### + GITHUB_ORG=$(jq -r '.repository.owner.login' < "${GITHUB_EVENT_PATH}") + + ############################ + # Validate we have a value # + ############################ + if [ -z "${GITHUB_ORG}" ]; then + error "Failed to get [GITHUB_ORG]!" + fatal "[${GITHUB_ORG}]" + else + info "Successfully found:${F[W]}[GITHUB_ORG]${F[B]}, value:${F[W]}[${GITHUB_ORG}]" + fi + + ####################### + # Get the GitHub Repo # + ####################### + GITHUB_REPO=$(jq -r '.repository.name' < "${GITHUB_EVENT_PATH}") + + ############################ + # Validate we have a value # + ############################ + if [ -z "${GITHUB_REPO}" ]; then + error "Failed to get [GITHUB_REPO]!" + fatal "[${GITHUB_REPO}]" + else + info "Successfully found:${F[W]}[GITHUB_REPO]${F[B]}, value:${F[W]}[${GITHUB_REPO}]" + fi + fi + + ############################ + # Validate we have a value # + ############################ + if [ -z "${GITHUB_TOKEN}" ] && [[ ${RUN_LOCAL} == "false" ]]; then + error "Failed to get [GITHUB_TOKEN]!" + error "[${GITHUB_TOKEN}]" + error "Please set a [GITHUB_TOKEN] from the main workflow environment to take advantage of multiple status reports!" + + ################################################################################ + # Need to set MULTI_STATUS to false as we cant hit API endpoints without token # + ################################################################################ + MULTI_STATUS='false' + else + info "Successfully found:${F[W]}[GITHUB_TOKEN]" + fi + + ############################### + # Convert string to lowercase # + ############################### + MULTI_STATUS="${MULTI_STATUS,,}" + + ####################################################################### + # Check to see if the multi status is set, and we have a token to use # + ####################################################################### + if [ "${MULTI_STATUS}" == "true" ] && [ -n "${GITHUB_TOKEN}" ]; then + ############################ + # Validate we have a value # + ############################ + if [ -z "${GITHUB_REPOSITORY}" ]; then + error "Failed to get [GITHUB_REPOSITORY]!" + fatal "[${GITHUB_REPOSITORY}]" + else + info "Successfully found:${F[W]}[GITHUB_REPOSITORY]${F[B]}, value:${F[W]}[${GITHUB_REPOSITORY}]" + fi + + ############################ + # Validate we have a value # + ############################ + if [ -z "${GITHUB_RUN_ID}" ]; then + error "Failed to get [GITHUB_RUN_ID]!" + fatal "[${GITHUB_RUN_ID}]" + else + info "Successfully found:${F[W]}[GITHUB_RUN_ID]${F[B]}, value:${F[W]}[${GITHUB_RUN_ID}]" + fi + fi +} +################################################################################ +#### Function ValidatePowershellModules ######################################## +function ValidatePowershellModules() { + VALIDATE_PSSA_MODULE=$(pwsh -c "(Get-Module -Name PSScriptAnalyzer -ListAvailable | Select-Object -First 1).Name" 2>&1) + # If module found, ensure Invoke-ScriptAnalyzer command is available + if [[ ${VALIDATE_PSSA_MODULE} == "PSScriptAnalyzer" ]]; then + VALIDATE_PSSA_CMD=$(pwsh -c "(Get-Command Invoke-ScriptAnalyzer | Select-Object -First 1).Name" 2>&1) + else + fatal "Failed to find module." + fi + + ######################################### + # validate we found the script analyzer # + ######################################### + if [[ ${VALIDATE_PSSA_CMD} != "Invoke-ScriptAnalyzer" ]]; then + fatal "Failed to find module." + fi + + ####################### + # Load the error code # + ####################### + ERROR_CODE=$? + + ############################## + # Check the shell for errors # + ############################## + if [ ${ERROR_CODE} -ne 0 ]; then + # Failed + error "Failed find module [PSScriptAnalyzer] for [${LINTER_NAME}] in system!" + fatal "[PSSA_MODULE ${VALIDATE_PSSA_MODULE}] [PSSA_CMD ${VALIDATE_PSSA_CMD}]" + else + # Success + debug "Successfully found module ${F[W]}[${VALIDATE_PSSA_MODULE}]${F[B]} in system" + debug "Successfully found command ${F[W]}[${VALIDATE_PSSA_CMD}]${F[B]} in system" + fi +} +################################################################################ +#### Function CallStatusAPI #################################################### +CallStatusAPI() { + #################### + # Pull in the vars # + #################### + LANGUAGE="${1}" # langauge that was validated + STATUS="${2}" # success | error + SUCCESS_MSG='No errors were found in the linting process' + FAIL_MSG='Errors were detected, please view logs' + MESSAGE='' # Message to send to status API + + ###################################### + # Check the status to create message # + ###################################### + if [ "${STATUS}" == "success" ]; then + # Success + MESSAGE="${SUCCESS_MSG}" + else + # Failure + MESSAGE="${FAIL_MSG}" + fi + + ########################################################## + # Check to see if were enabled for multi Status mesaages # + ########################################################## + if [ "${MULTI_STATUS}" == "true" ]; then + ############################################## + # Call the status API to create status check # + ############################################## + SEND_STATUS_CMD=$(curl -f -s -X POST \ + --url "${GITHUB_API_URL}/repos/${GITHUB_REPOSITORY}/statuses/${GITHUB_SHA}" \ + -H 'accept: application/vnd.github.v3+json' \ + -H "authorization: Bearer ${GITHUB_TOKEN}" \ + -H 'content-type: application/json' \ + -d "{ \"state\": \"${STATUS}\", + \"target_url\": \"https://github.com/${GITHUB_REPOSITORY}/actions/runs/${GITHUB_RUN_ID}\", + \"description\": \"${MESSAGE}\", \"context\": \"--> Linted: ${LANGUAGE}\" + }" 2>&1) + + ####################### + # Load the error code # + ####################### + ERROR_CODE=$? + + ############################## + # Check the shell for errors # + ############################## + if [ "${ERROR_CODE}" -ne 0 ]; then + # ERROR + info "ERROR! Failed to call GitHub Status API!" + info "ERROR:[${SEND_STATUS_CMD}]" + # Not going to fail the script on this yet... + fi fi - fi } ################################################################################ #### Function Reports ########################################################## Reports() { - info "----------------------------------------------" - info "----------------------------------------------" - info "Generated reports:" - info "----------------------------------------------" - info "----------------------------------------------" + info "----------------------------------------------" + info "----------------------------------------------" + info "Generated reports:" + info "----------------------------------------------" + info "----------------------------------------------" - ################################### - # Prints output report if enabled # - ################################### - if [ -z "${FORMAT_REPORT}" ] ; then - info "Reports generated in folder ${REPORT_OUTPUT_FOLDER}" - fi + ################################### + # Prints output report if enabled # + ################################### + if [ -z "${FORMAT_REPORT}" ]; then + info "Reports generated in folder ${REPORT_OUTPUT_FOLDER}" + fi - ################################ - # Prints for warnings if found # - ################################ - for TEST in "${WARNING_ARRAY_TEST[@]}"; do - warn "Expected file to compare with was not found for ${TEST}" - done + ################################ + # Prints for warnings if found # + ################################ + for TEST in "${WARNING_ARRAY_TEST[@]}"; do + warn "Expected file to compare with was not found for ${TEST}" + done } ################################################################################ #### Function Footer ########################################################### Footer() { - info "----------------------------------------------" - info "----------------------------------------------" - info "The script has completed" - info "----------------------------------------------" - info "----------------------------------------------" + info "----------------------------------------------" + info "----------------------------------------------" + info "The script has completed" + info "----------------------------------------------" + info "----------------------------------------------" - #################################################### - # Need to clean up the lanuage array of duplicates # - #################################################### - mapfile -t UNIQUE_LINTED_ARRAY < <(echo "${LINTED_LANGUAGES_ARRAY[@]}" | tr ' ' '\n' | sort -u | tr '\n' ' ') + #################################################### + # Need to clean up the lanuage array of duplicates # + #################################################### + mapfile -t UNIQUE_LINTED_ARRAY < <(echo "${LINTED_LANGUAGES_ARRAY[@]}" | tr ' ' '\n' | sort -u | tr '\n' ' ') - ############################## - # Prints for errors if found # - ############################## - for LANGUAGE in "${LANGUAGE_ARRAY[@]}"; do - ########################### - # Build the error counter # - ########################### - ERROR_COUNTER="ERRORS_FOUND_${LANGUAGE}" + ############################## + # Prints for errors if found # + ############################## + for LANGUAGE in "${LANGUAGE_ARRAY[@]}"; do + ########################### + # Build the error counter # + ########################### + ERROR_COUNTER="ERRORS_FOUND_${LANGUAGE}" - ################## - # Print if not 0 # - ################## - if [[ "${!ERROR_COUNTER}" -ne 0 ]]; then - # We found errors in the language - ################### - # Print the goods # - ################### - error "ERRORS FOUND${NC} in ${LANGUAGE}:[${!ERROR_COUNTER}]" + ################## + # Print if not 0 # + ################## + if [[ ${!ERROR_COUNTER} -ne 0 ]]; then + # We found errors in the language + ################### + # Print the goods # + ################### + error "ERRORS FOUND${NC} in ${LANGUAGE}:[${!ERROR_COUNTER}]" - ######################################### - # Create status API for Failed language # - ######################################### - CallStatusAPI "${LANGUAGE}" "error" - ###################################### - # Check if we validated the langauge # - ###################################### - elif [[ "${!ERROR_COUNTER}" -eq 0 ]] && [[ "${UNIQUE_LINTED_ARRAY[*]}" =~ ${LANGUAGE} ]]; then - # No errors found when linting the language - CallStatusAPI "${LANGUAGE}" "success" + ######################################### + # Create status API for Failed language # + ######################################### + CallStatusAPI "${LANGUAGE}" "error" + ###################################### + # Check if we validated the langauge # + ###################################### + elif [[ ${!ERROR_COUNTER} -eq 0 ]] && [[ ${UNIQUE_LINTED_ARRAY[*]} =~ ${LANGUAGE} ]]; then + # No errors found when linting the language + CallStatusAPI "${LANGUAGE}" "success" + fi + done + + ################################## + # Exit with 0 if errors disabled # + ################################## + if [ "${DISABLE_ERRORS}" == "true" ]; then + warn "Exiting with exit code:[0] as:[DISABLE_ERRORS] was set to:[${DISABLE_ERRORS}]" + exit 0 fi - done - ################################## - # Exit with 0 if errors disabled # - ################################## - if [ "${DISABLE_ERRORS}" == "true" ]; then - warn "Exiting with exit code:[0] as:[DISABLE_ERRORS] was set to:[${DISABLE_ERRORS}]" + ############################### + # Exit with 1 if errors found # + ############################### + # Loop through all languages + for LANGUAGE in "${LANGUAGE_ARRAY[@]}"; do + # build the variable + ERRORS_FOUND_LANGUAGE="ERRORS_FOUND_${LANGUAGE}" + # Check if error was found + if [[ ${!ERRORS_FOUND_LANGUAGE} -ne 0 ]]; then + # Failed exit + fatal "Exiting with errors found!" + fi + done + + ######################## + # Footer prints Exit 0 # + ######################## + notice "All file(s) linted successfully with no errors detected" + info "----------------------------------------------" + # Successful exit exit 0 - fi - - ############################### - # Exit with 1 if errors found # - ############################### - # Loop through all languages - for LANGUAGE in "${LANGUAGE_ARRAY[@]}"; do - # build the variable - ERRORS_FOUND_LANGUAGE="ERRORS_FOUND_${LANGUAGE}" - # Check if error was found - if [[ "${!ERRORS_FOUND_LANGUAGE}" -ne 0 ]]; then - # Failed exit - fatal "Exiting with errors found!" - fi - done - - ######################## - # Footer prints Exit 0 # - ######################## - notice "All file(s) linted successfully with no errors detected" - info "----------------------------------------------" - # Successful exit - exit 0 } - ################################################################################ #### Function Cleanup ########################################################## cleanup() { @@ -1054,10 +1057,10 @@ Header # check flag for validating the report folder does not exist # ############################################################## if [ -n "${OUTPUT_FORMAT}" ]; then - if [ -d "${REPORT_OUTPUT_FOLDER}" ] ; then - error "ERROR! Found ${REPORT_OUTPUT_FOLDER}" - fatal "Please remove the folder and try again." - fi + if [ -d "${REPORT_OUTPUT_FOLDER}" ]; then + error "ERROR! Found ${REPORT_OUTPUT_FOLDER}" + fatal "Please remove the folder and try again." + fi fi ####################### @@ -1126,560 +1129,560 @@ GetLinterVersions ########################################### if [[ ${TEST_CASE_RUN} != "false" ]]; then - ############################################# - # Set the multi status to off for test runs # - ############################################# - MULTI_STATUS='false' + ############################################# + # Set the multi status to off for test runs # + ############################################# + MULTI_STATUS='false' - ########################### - # Run only the test cases # - ########################### - # Code will exit from inside this loop - RunTestCases + ########################### + # Run only the test cases # + ########################### + # Code will exit from inside this loop + RunTestCases fi ############################################# # check flag for validation of all codebase # ############################################# if [ "${VALIDATE_ALL_CODEBASE}" == "false" ]; then - ######################################## - # Get list of files changed if env set # - ######################################## - BuildFileList + ######################################## + # Get list of files changed if env set # + ######################################## + BuildFileList fi ################### # ANSIBLE LINTING # ################### if [ "${VALIDATE_ANSIBLE}" == "true" ]; then - ########################## - # Lint the Ansible files # - ########################## - # Due to the nature of how we want to validate Ansible, we cannot use the - # 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 + ########################## + # Lint the Ansible files # + ########################## + # Due to the nature of how we want to validate Ansible, we cannot use the + # 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 ######################## # 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' + # 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 + 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 + ########################### + # 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[@]}" + ############################### + # 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 ################ # BASH LINTING # ################ if [ "${VALIDATE_BASH}" == "true" ]; then - ####################### - # Lint the bash files # - ####################### - # LintCodebase "FILE_TYPE" "LINTER_NAME" "LINTER_CMD" "FILE_TYPES_REGEX" "FILE_ARRAY" - LintCodebase "BASH" "shellcheck" "shellcheck --color" ".*\.\(sh\|bash\|dash\|ksh\)\$" "${FILE_ARRAY_BASH[@]}" + ####################### + # Lint the bash files # + ####################### + # LintCodebase "FILE_TYPE" "LINTER_NAME" "LINTER_CMD" "FILE_TYPES_REGEX" "FILE_ARRAY" + LintCodebase "BASH" "shellcheck" "shellcheck --color" ".*\.\(sh\|bash\|dash\|ksh\)\$" "${FILE_ARRAY_BASH[@]}" fi ########################## # CLOUDFORMATION LINTING # ########################## if [ "${VALIDATE_CLOUDFORMATION}" == "true" ]; then - # If we are validating all codebase we need to build file list because not every yml/json file is an CLOUDFORMATION file - if [ "${VALIDATE_ALL_CODEBASE}" == "true" ]; then - ############################################################################### - # Set the file seperator to newline to allow for grabbing objects with spaces # - ############################################################################### - IFS=$'\n' + # If we are validating all codebase we need to build file list because not every yml/json file is an CLOUDFORMATION 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 DetectCloudFormationFile "${FILE}"; then - FILE_ARRAY_CLOUDFORMATION+=("${FILE}") - fi - done + mapfile -t LIST_FILES < <(find "${GITHUB_WORKSPACE}" -type f -regex ".*\.\(yml\|yaml\|json\)\$" 2>&1) + for FILE in "${LIST_FILES[@]}"; do + if DetectCloudFormationFile "${FILE}"; then + FILE_ARRAY_CLOUDFORMATION+=("${FILE}") + fi + done - ########################### - # Set IFS back to default # - ########################### - IFS="${DEFAULT_IFS}" - fi + ########################### + # Set IFS back to default # + ########################### + IFS="${DEFAULT_IFS}" + fi - ################################# - # Lint the CloudFormation files # - ################################# - # LintCodebase "FILE_TYPE" "LINTER_NAME" "LINTER_CMD" "FILE_TYPES_REGEX" "FILE_ARRAY" - LintCodebase "CLOUDFORMATION" "cfn-lint" "cfn-lint --config-file ${CLOUDFORMATION_LINTER_RULES}" "disabledfileext" "${FILE_ARRAY_CLOUDFORMATION[@]}" + ################################# + # Lint the CloudFormation files # + ################################# + # LintCodebase "FILE_TYPE" "LINTER_NAME" "LINTER_CMD" "FILE_TYPES_REGEX" "FILE_ARRAY" + LintCodebase "CLOUDFORMATION" "cfn-lint" "cfn-lint --config-file ${CLOUDFORMATION_LINTER_RULES}" "disabledfileext" "${FILE_ARRAY_CLOUDFORMATION[@]}" 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[@]}" + ################################# + # 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 ######################## # COFFEESCRIPT LINTING # ######################## if [ "${VALIDATE_COFFEE}" == "true" ]; then - ######################### - # Lint the coffee files # - ######################### - # LintCodebase "FILE_TYPE" "LINTER_NAME" "LINTER_CMD" "FILE_TYPES_REGEX" "FILE_ARRAY" - LintCodebase "COFFEESCRIPT" "coffeelint" "coffeelint -f ${COFFEESCRIPT_LINTER_RULES}" ".*\.\(coffee\)\$" "${FILE_ARRAY_COFFEESCRIPT[@]}" + ######################### + # Lint the coffee files # + ######################### + # LintCodebase "FILE_TYPE" "LINTER_NAME" "LINTER_CMD" "FILE_TYPES_REGEX" "FILE_ARRAY" + LintCodebase "COFFEESCRIPT" "coffeelint" "coffeelint -f ${COFFEESCRIPT_LINTER_RULES}" ".*\.\(coffee\)\$" "${FILE_ARRAY_COFFEESCRIPT[@]}" 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[@]}" + ################################# + # 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[@]}" + ####################### + # 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[@]}" + ######################### + # 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[@]}" + #################################### + # 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[@]}" + ####################### + # 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 # ################## if [ "${VALIDATE_GO}" == "true" ]; then - ######################### - # Lint the golang files # - ######################### - # LintCodebase "FILE_TYPE" "LINTER_NAME" "LINTER_CMD" "FILE_TYPES_REGEX" "FILE_ARRAY" - LintCodebase "GO" "golangci-lint" "golangci-lint run -c ${GO_LINTER_RULES}" ".*\.\(go\)\$" "${FILE_ARRAY_GO[@]}" + ######################### + # Lint the golang files # + ######################### + # LintCodebase "FILE_TYPE" "LINTER_NAME" "LINTER_CMD" "FILE_TYPES_REGEX" "FILE_ARRAY" + LintCodebase "GO" "golangci-lint" "golangci-lint run -c ${GO_LINTER_RULES}" ".*\.\(go\)\$" "${FILE_ARRAY_GO[@]}" fi ################## # GROOVY LINTING # ################## if [ "$VALIDATE_GROOVY" == "true" ]; then - ######################### - # Lint the groovy files # - ######################### - # LintCodebase "FILE_TYPE" "LINTER_NAME" "LINTER_CMD" "FILE_TYPES_REGEX" "FILE_ARRAY" - LintCodebase "GROOVY" "npm-groovy-lint" "npm-groovy-lint -c $GROOVY_LINTER_RULES --failon error" ".*\.\(groovy\|jenkinsfile\|gradle\)\$" "${FILE_ARRAY_GROOVY[@]}" + ######################### + # Lint the groovy files # + ######################### + # LintCodebase "FILE_TYPE" "LINTER_NAME" "LINTER_CMD" "FILE_TYPES_REGEX" "FILE_ARRAY" + LintCodebase "GROOVY" "npm-groovy-lint" "npm-groovy-lint -c $GROOVY_LINTER_RULES --failon error" ".*\.\(groovy\|jenkinsfile\|gradle\)\$" "${FILE_ARRAY_GROOVY[@]}" 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[@]}" + ########################### + # Get HTML standard rules # + ########################### + GetStandardRules "htmlhint" + ####################### + # Lint the HTML files # + ####################### + LintCodebase "HTML" "htmlhint" "htmlhint --config ${HTML_LINTER_RULES}" ".*\.\(html\)\$" "${FILE_ARRAY_HTML[@]}" fi ###################### # JAVASCRIPT LINTING # ###################### if [ "${VALIDATE_JAVASCRIPT_ES}" == "true" ]; then - ############################# - # Lint the Javascript files # - ############################# - # LintCodebase "FILE_TYPE" "LINTER_NAME" "LINTER_CMD" "FILE_TYPES_REGEX" "FILE_ARRAY" - LintCodebase "JAVASCRIPT_ES" "eslint" "eslint --no-eslintrc -c ${JAVASCRIPT_LINTER_RULES}" ".*\.\(js\)\$" "${FILE_ARRAY_JAVASCRIPT_ES[@]}" + ############################# + # Lint the Javascript files # + ############################# + # LintCodebase "FILE_TYPE" "LINTER_NAME" "LINTER_CMD" "FILE_TYPES_REGEX" "FILE_ARRAY" + LintCodebase "JAVASCRIPT_ES" "eslint" "eslint --no-eslintrc -c ${JAVASCRIPT_LINTER_RULES}" ".*\.\(js\)\$" "${FILE_ARRAY_JAVASCRIPT_ES[@]}" fi ###################### # JAVASCRIPT LINTING # ###################### if [ "${VALIDATE_JAVASCRIPT_STANDARD}" == "true" ]; then - ################################# - # Get Javascript standard rules # - ################################# - GetStandardRules "javascript" - ############################# - # Lint the Javascript files # - ############################# - # LintCodebase "FILE_TYPE" "LINTER_NAME" "LINTER_CMD" "FILE_TYPES_REGEX" "FILE_ARRAY" - LintCodebase "JAVASCRIPT_STANDARD" "standard" "standard ${JAVASCRIPT_STANDARD_LINTER_RULES}" ".*\.\(js\)\$" "${FILE_ARRAY_JAVASCRIPT_STANDARD[@]}" + ################################# + # Get Javascript standard rules # + ################################# + GetStandardRules "javascript" + ############################# + # Lint the Javascript files # + ############################# + # LintCodebase "FILE_TYPE" "LINTER_NAME" "LINTER_CMD" "FILE_TYPES_REGEX" "FILE_ARRAY" + LintCodebase "JAVASCRIPT_STANDARD" "standard" "standard ${JAVASCRIPT_STANDARD_LINTER_RULES}" ".*\.\(js\)\$" "${FILE_ARRAY_JAVASCRIPT_STANDARD[@]}" 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[@]}" + ####################### + # 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 # ############### if [ "${VALIDATE_JSX}" == "true" ]; then - ###################### - # Lint the JSX files # - ###################### - # LintCodebase "FILE_TYPE" "LINTER_NAME" "LINTER_CMD" "FILE_TYPES_REGEX" "FILE_ARRAY" - LintCodebase "JSX" "eslint" "eslint --no-eslintrc -c ${JAVASCRIPT_LINTER_RULES}" ".*\.\(jsx\)\$" "${FILE_ARRAY_JSX[@]}" + ###################### + # Lint the JSX files # + ###################### + # LintCodebase "FILE_TYPE" "LINTER_NAME" "LINTER_CMD" "FILE_TYPES_REGEX" "FILE_ARRAY" + LintCodebase "JSX" "eslint" "eslint --no-eslintrc -c ${JAVASCRIPT_LINTER_RULES}" ".*\.\(jsx\)\$" "${FILE_ARRAY_JSX[@]}" 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[@]}" + ####################### + # 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 ############### # LUA LINTING # ############### if [ "${VALIDATE_LUA}" == "true" ]; then - ###################### - # Lint the Lua files # - ###################### - # LintCodebase "FILE_TYPE" "LINTER_NAME" "LINTER_CMD" "FILE_TYPES_REGEX" "FILE_ARRAY" - LintCodebase "LUA" "lua" "luacheck --config ${LUA_LINTER_RULES}" ".*\.\(lua\)\$" "${FILE_ARRAY_LUA[@]}" + ###################### + # Lint the Lua files # + ###################### + # LintCodebase "FILE_TYPE" "LINTER_NAME" "LINTER_CMD" "FILE_TYPES_REGEX" "FILE_ARRAY" + LintCodebase "LUA" "lua" "luacheck --config ${LUA_LINTER_RULES}" ".*\.\(lua\)\$" "${FILE_ARRAY_LUA[@]}" 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[@]}" + ########################### + # 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' + # 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 + 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 + ########################### + # 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[@]}" + ########################## + # 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[@]}" + ####################### + # 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[@]}" + ####################### + # 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 ################### # PHPStan LINTING # ################### if [ "${VALIDATE_PHP_PHPSTAN}" == "true" ]; then - ####################### - # Lint the PHP files # - ####################### - # LintCodebase "FILE_TYPE" "LINTER_NAME" "LINTER_CMD" "FILE_TYPES_REGEX" "FILE_ARRAY" - LintCodebase "PHP_PHPSTAN" "phpstan" "phpstan analyse --no-progress --no-ansi -c ${PHPSTAN_LINTER_RULES}" ".*\.\(php\)\$" "${FILE_ARRAY_PHP_PHPSTAN[@]}" + ####################### + # Lint the PHP files # + ####################### + # LintCodebase "FILE_TYPE" "LINTER_NAME" "LINTER_CMD" "FILE_TYPES_REGEX" "FILE_ARRAY" + LintCodebase "PHP_PHPSTAN" "phpstan" "phpstan analyse --no-progress --no-ansi -c ${PHPSTAN_LINTER_RULES}" ".*\.\(php\)\$" "${FILE_ARRAY_PHP_PHPSTAN[@]}" fi ###################### # POWERSHELL LINTING # ###################### if [ "${VALIDATE_POWERSHELL}" == "true" ]; then - ############################################################### - # For POWERSHELL, ensure PSScriptAnalyzer module is available # - ############################################################### - ValidatePowershellModules + ############################################################### + # 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[@]}" + ############################# + # 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[@]}" + ####################### + # 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_PYLINT}" == "true" ]; then - ######################### - # Lint the python files # - ######################### - # LintCodebase "FILE_TYPE" "LINTER_NAME" "LINTER_CMD" "FILE_TYPES_REGEX" "FILE_ARRAY" - LintCodebase "PYTHON_PYLINT" "pylint" "pylint --rcfile ${PYTHON_PYLINT_LINTER_RULES}" ".*\.\(py\)\$" "${FILE_ARRAY_PYTHON_PYLINT[@]}" + ######################### + # Lint the python files # + ######################### + # LintCodebase "FILE_TYPE" "LINTER_NAME" "LINTER_CMD" "FILE_TYPES_REGEX" "FILE_ARRAY" + LintCodebase "PYTHON_PYLINT" "pylint" "pylint --rcfile ${PYTHON_PYLINT_LINTER_RULES}" ".*\.\(py\)\$" "${FILE_ARRAY_PYTHON_PYLINT[@]}" fi ################## # PYTHON LINTING # ################## if [ "${VALIDATE_PYTHON_FLAKE8}" == "true" ]; then - ######################### - # Lint the python files # - ######################### - # LintCodebase "FILE_TYPE" "LINTER_NAME" "LINTER_CMD" "FILE_TYPES_REGEX" "FILE_ARRAY" - LintCodebase "PYTHON_FLAKE8" "flake8" "flake8 --config=${PYTHON_FLAKE8_LINTER_RULES}" ".*\.\(py\)\$" "${FILE_ARRAY_PYTHON_FLAKE8[@]}" + ######################### + # Lint the python files # + ######################### + # LintCodebase "FILE_TYPE" "LINTER_NAME" "LINTER_CMD" "FILE_TYPES_REGEX" "FILE_ARRAY" + LintCodebase "PYTHON_FLAKE8" "flake8" "flake8 --config=${PYTHON_FLAKE8_LINTER_RULES}" ".*\.\(py\)\$" "${FILE_ARRAY_PYTHON_FLAKE8[@]}" fi ################ # RAKU LINTING # ################ if [ "${VALIDATE_RAKU}" == "true" ]; then - ####################### - # Lint the raku files # - ####################### + ####################### + # Lint the raku files # + ####################### info "${GITHUB_WORKSPACE}/META6.json" if [ -e "${GITHUB_WORKSPACE}/META6.json" ]; then - cd "${GITHUB_WORKSPACE}" && zef install --deps-only --/test . + 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[@]}" + # 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[@]}" + ####################### + # 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' + # 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 + 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 + ########################### + # 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[@]}" + ######################### + # 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[@]}" + ############################ + # 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 ############################### # TERRAFORM TERRASCAN LINTING # ############################### if [ "${VALIDATE_TERRAFORM_TERRASCAN}" == "true" ]; then - ############################ - # Lint the Terraform files # - ############################ - # LintCodebase "FILE_TYPE" "LINTER_NAME" "LINTER_CMD" "FILE_TYPES_REGEX" "FILE_ARRAY" - LintCodebase "TERRAFORM_TERRASCAN" "terrascan" "terrascan -f " ".*\.\(tf\)\$" "${FILE_ARRAY_TERRAFORM_TERRASCAN[@]}" + ############################ + # Lint the Terraform files # + ############################ + # LintCodebase "FILE_TYPE" "LINTER_NAME" "LINTER_CMD" "FILE_TYPES_REGEX" "FILE_ARRAY" + LintCodebase "TERRAFORM_TERRASCAN" "terrascan" "terrascan -f " ".*\.\(tf\)\$" "${FILE_ARRAY_TERRAFORM_TERRASCAN[@]}" fi ############### # TSX LINTING # ############### if [ "${VALIDATE_TSX}" == "true" ]; then - ###################### - # Lint the TSX files # - ###################### - LintCodebase "TSX" "eslint" "eslint --no-eslintrc -c ${TYPESCRIPT_LINTER_RULES}" ".*\.\(tsx\)\$" "${FILE_ARRAY_TSX[@]}" + ###################### + # Lint the TSX files # + ###################### + LintCodebase "TSX" "eslint" "eslint --no-eslintrc -c ${TYPESCRIPT_LINTER_RULES}" ".*\.\(tsx\)\$" "${FILE_ARRAY_TSX[@]}" fi ###################### # TYPESCRIPT LINTING # ###################### if [ "${VALIDATE_TYPESCRIPT_ES}" == "true" ]; then - ############################# - # Lint the Typescript files # - ############################# - LintCodebase "TYPESCRIPT_ES" "eslint" "eslint --no-eslintrc -c ${TYPESCRIPT_LINTER_RULES}" ".*\.\(ts\)\$" "${FILE_ARRAY_TYPESCRIPT_ES[@]}" + ############################# + # Lint the Typescript files # + ############################# + LintCodebase "TYPESCRIPT_ES" "eslint" "eslint --no-eslintrc -c ${TYPESCRIPT_LINTER_RULES}" ".*\.\(ts\)\$" "${FILE_ARRAY_TYPESCRIPT_ES[@]}" fi ###################### # TYPESCRIPT LINTING # ###################### if [ "${VALIDATE_TYPESCRIPT_STANDARD}" == "true" ]; then - ################################# - # Get Typescript standard rules # - ################################# - GetStandardRules "typescript" - ############################# - # Lint the Typescript files # - ############################# - LintCodebase "TYPESCRIPT_STANDARD" "standard" "standard --parser @typescript-eslint/parser --plugin @typescript-eslint/eslint-plugin ${TYPESCRIPT_STANDARD_LINTER_RULES}" ".*\.\(ts\)\$" "${FILE_ARRAY_TYPESCRIPT_STANDARD[@]}" + ################################# + # Get Typescript standard rules # + ################################# + GetStandardRules "typescript" + ############################# + # Lint the Typescript files # + ############################# + LintCodebase "TYPESCRIPT_STANDARD" "standard" "standard --parser @typescript-eslint/parser --plugin @typescript-eslint/eslint-plugin ${TYPESCRIPT_STANDARD_LINTER_RULES}" ".*\.\(ts\)\$" "${FILE_ARRAY_TYPESCRIPT_STANDARD[@]}" fi ############### # XML LINTING # ############### if [ "${VALIDATE_XML}" == "true" ]; then - ###################### - # Lint the XML Files # - ###################### - # LintCodebase "FILE_TYPE" "LINTER_NAME" "LINTER_CMD" "FILE_TYPES_REGEX" "FILE_ARRAY" - LintCodebase "XML" "xmllint" "xmllint" ".*\.\(xml\)\$" "${FILE_ARRAY_XML[@]}" + ###################### + # Lint the XML Files # + ###################### + # LintCodebase "FILE_TYPE" "LINTER_NAME" "LINTER_CMD" "FILE_TYPES_REGEX" "FILE_ARRAY" + LintCodebase "XML" "xmllint" "xmllint" ".*\.\(xml\)\$" "${FILE_ARRAY_XML[@]}" fi ############### # YAML LINTING # ############### if [ "${VALIDATE_YAML}" == "true" ]; then - ###################### - # Lint the Yml Files # - ###################### - # LintCodebase "FILE_TYPE" "LINTER_NAME" "LINTER_CMD" "FILE_TYPES_REGEX" "FILE_ARRAY" - LintCodebase "YAML" "yamllint" "yamllint -c ${YAML_LINTER_RULES}" ".*\.\(yml\|yaml\)\$" "${FILE_ARRAY_YAML[@]}" + ###################### + # Lint the Yml Files # + ###################### + # LintCodebase "FILE_TYPE" "LINTER_NAME" "LINTER_CMD" "FILE_TYPES_REGEX" "FILE_ARRAY" + LintCodebase "YAML" "yamllint" "yamllint -c ${YAML_LINTER_RULES}" ".*\.\(yml\|yaml\)\$" "${FILE_ARRAY_YAML[@]}" fi ########### diff --git a/lib/log.sh b/lib/log.sh index fce6b072..f6bd73a2 100644 --- a/lib/log.sh +++ b/lib/log.sh @@ -1,24 +1,24 @@ #!/usr/bin/env bash declare -Agr B=( - [B]=$(echo -e "\e[44m") - [C]=$(echo -e "\e[46m") - [G]=$(echo -e "\e[42m") - [K]=$(echo -e "\e[40m") - [M]=$(echo -e "\e[45m") - [R]=$(echo -e "\e[41m") - [W]=$(echo -e "\e[47m") - [Y]=$(echo -e "\e[43m") + [B]=$(echo -e "\e[44m") + [C]=$(echo -e "\e[46m") + [G]=$(echo -e "\e[42m") + [K]=$(echo -e "\e[40m") + [M]=$(echo -e "\e[45m") + [R]=$(echo -e "\e[41m") + [W]=$(echo -e "\e[47m") + [Y]=$(echo -e "\e[43m") ) declare -Agr F=( - [B]=$(echo -e "\e[0;34m") - [C]=$(echo -e "\e[0;36m") - [G]=$(echo -e "\e[0;32m") - [K]=$(echo -e "\e[0;30m") - [M]=$(echo -e "\e[0;35m") - [R]=$(echo -e "\e[0;31m") - [W]=$(echo -e "\e[0;37m") - [Y]=$(echo -e "\e[0;33m") + [B]=$(echo -e "\e[0;34m") + [C]=$(echo -e "\e[0;36m") + [G]=$(echo -e "\e[0;32m") + [K]=$(echo -e "\e[0;30m") + [M]=$(echo -e "\e[0;35m") + [R]=$(echo -e "\e[0;31m") + [W]=$(echo -e "\e[0;37m") + [Y]=$(echo -e "\e[0;33m") ) readonly NC=$(echo -e "\e[0m") diff --git a/lib/termColors.sh b/lib/termColors.sh index 8f22a26c..ce3e0e66 100755 --- a/lib/termColors.sh +++ b/lib/termColors.sh @@ -1,24 +1,24 @@ #!/usr/bin/env bash declare -Agr B=( - [B]=$(echo -e "\e[44m") - [C]=$(echo -e "\e[46m") - [G]=$(echo -e "\e[42m") - [K]=$(echo -e "\e[40m") - [M]=$(echo -e "\e[45m") - [R]=$(echo -e "\e[41m") - [W]=$(echo -e "\e[47m") - [Y]=$(echo -e "\e[43m") + [B]=$(echo -e "\e[44m") + [C]=$(echo -e "\e[46m") + [G]=$(echo -e "\e[42m") + [K]=$(echo -e "\e[40m") + [M]=$(echo -e "\e[45m") + [R]=$(echo -e "\e[41m") + [W]=$(echo -e "\e[47m") + [Y]=$(echo -e "\e[43m") ) declare -Agr F=( - [B]=$(echo -e "\e[0;34m") - [C]=$(echo -e "\e[0;36m") - [G]=$(echo -e "\e[0;32m") - [K]=$(echo -e "\e[0;30m") - [M]=$(echo -e "\e[0;35m") - [R]=$(echo -e "\e[0;31m") - [W]=$(echo -e "\e[0;37m") - [Y]=$(echo -e "\e[0;33m") + [B]=$(echo -e "\e[0;34m") + [C]=$(echo -e "\e[0;36m") + [G]=$(echo -e "\e[0;32m") + [K]=$(echo -e "\e[0;30m") + [M]=$(echo -e "\e[0;35m") + [R]=$(echo -e "\e[0;31m") + [W]=$(echo -e "\e[0;37m") + [Y]=$(echo -e "\e[0;33m") ) readonly NC=$(echo -e "\e[0m") diff --git a/lib/validation.sh b/lib/validation.sh index 6e4105b0..fcbcd4ac 100755 --- a/lib/validation.sh +++ b/lib/validation.sh @@ -10,175 +10,175 @@ ################################################################################ #### Function GetValidationInfo ################################################ function GetValidationInfo() { - ############################################ - # Print headers for user provided env vars # - ############################################ - info "--------------------------------------------" - info "Gathering user validation information..." + ############################################ + # Print headers for user provided env vars # + ############################################ + info "--------------------------------------------" + info "Gathering user validation information..." + + ########################################### + # Skip validation if were running locally # + ########################################### + if [[ ${RUN_LOCAL} != "true" ]]; then + ############################### + # Convert string to lowercase # + ############################### + VALIDATE_ALL_CODEBASE="${VALIDATE_ALL_CODEBASE,,}" + ###################################### + # Validate we should check all files # + ###################################### + if [[ ${VALIDATE_ALL_CODEBASE} != "false" ]]; then + # Set to true + VALIDATE_ALL_CODEBASE="${DEFAULT_VALIDATE_ALL_CODEBASE}" + info "- Validating ALL files in code base..." + else + # Its false + info "- Only validating [new], or [edited] files in code base..." + fi + fi + + ###################### + # Create Print Array # + ###################### + PRINT_ARRAY=() + + ################################ + # Convert strings to lowercase # + ################################ + # Loop through all languages + for LANGUAGE in "${LANGUAGE_ARRAY[@]}"; do + # build the variable + VALIDATE_LANGUAGE="VALIDATE_${LANGUAGE}" + # Set the value of the var to lowercase + eval "${VALIDATE_LANGUAGE}=${!VALIDATE_LANGUAGE,,}" + done + + ################################################ + # Determine if any linters were explicitly set # + ################################################ + ANY_SET="false" + # Loop through all languages + for LANGUAGE in "${LANGUAGE_ARRAY[@]}"; do + # build the variable + VALIDATE_LANGUAGE="VALIDATE_${LANGUAGE}" + # Check to see if the variable was set + if [ -n "${!VALIDATE_LANGUAGE}" ]; then + # It was set, need to set flag + ANY_SET="true" + fi + done + + ################################################### + # Validate if we should check individual lanuages # + ################################################### + # Loop through all languages + for LANGUAGE in "${LANGUAGE_ARRAY[@]}"; do + # build the variable + VALIDATE_LANGUAGE="VALIDATE_${LANGUAGE}" + # Check if ANY_SET was set + if [[ ${ANY_SET} == "true" ]]; then + # Check to see if the variable was set + if [ -z "${!VALIDATE_LANGUAGE}" ]; then + # Flag was not set, default to false + eval "${VALIDATE_LANGUAGE}='false'" + fi + else + # No linter flags were set - default all to true + eval "${VALIDATE_LANGUAGE}='true'" + fi + done + + ####################################### + # Print which linters we are enabling # + ####################################### + # Loop through all languages + for LANGUAGE in "${LANGUAGE_ARRAY[@]}"; do + # build the variable + VALIDATE_LANGUAGE="VALIDATE_${LANGUAGE}" + if [[ ${!VALIDATE_LANGUAGE} == "true" ]]; then + # We need to validate + PRINT_ARRAY+=("- Validating [$LANGUAGE] files in code base...") + else + # We are skipping the language + PRINT_ARRAY+=("- Excluding [$LANGUAGE] files in code base...") + fi + done + + ############################## + # Validate Ansible Directory # + ############################## + if [ -z "${ANSIBLE_DIRECTORY}" ]; then + # No Value, need to default + ANSIBLE_DIRECTORY="${DEFAULT_ANSIBLE_DIRECTORY}" + else + # Check if first char is '/' + if [[ ${ANSIBLE_DIRECTORY:0:1} == "/" ]]; then + # Remove first char + ANSIBLE_DIRECTORY="${ANSIBLE_DIRECTORY:1}" + fi + # Need to give it full path + TEMP_ANSIBLE_DIRECTORY="${GITHUB_WORKSPACE}/${ANSIBLE_DIRECTORY}" + # Set the value + ANSIBLE_DIRECTORY="${TEMP_ANSIBLE_DIRECTORY}" + fi + + ############################### + # Get the disable errors flag # + ############################### + if [ -z "${DISABLE_ERRORS}" ]; then + ################################## + # No flag passed, set to default # + ################################## + DISABLE_ERRORS="${DEFAULT_DISABLE_ERRORS}" + fi - ########################################### - # Skip validation if were running locally # - ########################################### - if [[ ${RUN_LOCAL} != "true" ]]; then ############################### # Convert string to lowercase # ############################### - VALIDATE_ALL_CODEBASE="${VALIDATE_ALL_CODEBASE,,}" - ###################################### - # Validate we should check all files # - ###################################### - if [[ ${VALIDATE_ALL_CODEBASE} != "false" ]]; then - # Set to true - VALIDATE_ALL_CODEBASE="${DEFAULT_VALIDATE_ALL_CODEBASE}" - info "- Validating ALL files in code base..." - else - # Its false - info "- Only validating [new], or [edited] files in code base..." + DISABLE_ERRORS="${DISABLE_ERRORS,,}" + + ############################ + # Set to false if not true # + ############################ + if [ "${DISABLE_ERRORS}" != "true" ]; then + DISABLE_ERRORS="false" fi - fi - ###################### - # Create Print Array # - ###################### - PRINT_ARRAY=() - - ################################ - # Convert strings to lowercase # - ################################ - # Loop through all languages - for LANGUAGE in "${LANGUAGE_ARRAY[@]}"; do - # build the variable - VALIDATE_LANGUAGE="VALIDATE_${LANGUAGE}" - # Set the value of the var to lowercase - eval "${VALIDATE_LANGUAGE}=${!VALIDATE_LANGUAGE,,}" - done - - ################################################ - # Determine if any linters were explicitly set # - ################################################ - ANY_SET="false" - # Loop through all languages - for LANGUAGE in "${LANGUAGE_ARRAY[@]}"; do - # build the variable - VALIDATE_LANGUAGE="VALIDATE_${LANGUAGE}" - # Check to see if the variable was set - if [ -n "${!VALIDATE_LANGUAGE}" ]; then - # It was set, need to set flag - ANY_SET="true" + ############################ + # Get the run verbose flag # + ############################ + if [ -z "${ACTIONS_RUNNER_DEBUG}" ]; then + ################################## + # No flag passed, set to default # + ################################## + ACTIONS_RUNNER_DEBUG="${DEFAULT_ACTIONS_RUNNER_DEBUG}" fi - done - ################################################### - # Validate if we should check individual lanuages # - ################################################### - # Loop through all languages - for LANGUAGE in "${LANGUAGE_ARRAY[@]}"; do - # build the variable - VALIDATE_LANGUAGE="VALIDATE_${LANGUAGE}" - # Check if ANY_SET was set - if [[ ${ANY_SET} == "true" ]]; then - # Check to see if the variable was set - if [ -z "${!VALIDATE_LANGUAGE}" ]; then - # Flag was not set, default to false - eval "${VALIDATE_LANGUAGE}='false'" - fi - else - # No linter flags were set - default all to true - eval "${VALIDATE_LANGUAGE}='true'" + ############################### + # Convert string to lowercase # + ############################### + ACTIONS_RUNNER_DEBUG="${ACTIONS_RUNNER_DEBUG,,}" + + ############################ + # Set to true if not false # + ############################ + if [ "${ACTIONS_RUNNER_DEBUG}" != "false" ]; then + ACTIONS_RUNNER_DEBUG="true" fi - done - ####################################### - # Print which linters we are enabling # - ####################################### - # Loop through all languages - for LANGUAGE in "${LANGUAGE_ARRAY[@]}"; do - # build the variable - VALIDATE_LANGUAGE="VALIDATE_${LANGUAGE}" - if [[ ${!VALIDATE_LANGUAGE} == "true" ]]; then - # We need to validate - PRINT_ARRAY+=("- Validating [$LANGUAGE] files in code base...") - else - # We are skipping the language - PRINT_ARRAY+=("- Excluding [$LANGUAGE] files in code base...") - fi - done + ########################### + # Print the validate info # + ########################### + for LINE in "${PRINT_ARRAY[@]}"; do + debug "${LINE}" + done - ############################## - # Validate Ansible Directory # - ############################## - if [ -z "${ANSIBLE_DIRECTORY}" ]; then - # No Value, need to default - ANSIBLE_DIRECTORY="${DEFAULT_ANSIBLE_DIRECTORY}" - else - # Check if first char is '/' - if [[ ${ANSIBLE_DIRECTORY:0:1} == "/" ]]; then - # Remove first char - ANSIBLE_DIRECTORY="${ANSIBLE_DIRECTORY:1}" - fi - # Need to give it full path - TEMP_ANSIBLE_DIRECTORY="${GITHUB_WORKSPACE}/${ANSIBLE_DIRECTORY}" - # Set the value - ANSIBLE_DIRECTORY="${TEMP_ANSIBLE_DIRECTORY}" - fi - - ############################### - # Get the disable errors flag # - ############################### - if [ -z "${DISABLE_ERRORS}" ]; then - ################################## - # No flag passed, set to default # - ################################## - DISABLE_ERRORS="${DEFAULT_DISABLE_ERRORS}" - fi - - ############################### - # Convert string to lowercase # - ############################### - DISABLE_ERRORS="${DISABLE_ERRORS,,}" - - ############################ - # Set to false if not true # - ############################ - if [ "${DISABLE_ERRORS}" != "true" ]; then - DISABLE_ERRORS="false" - fi - - ############################ - # Get the run verbose flag # - ############################ - if [ -z "${ACTIONS_RUNNER_DEBUG}" ]; then - ################################## - # No flag passed, set to default # - ################################## - ACTIONS_RUNNER_DEBUG="${DEFAULT_ACTIONS_RUNNER_DEBUG}" - fi - - ############################### - # Convert string to lowercase # - ############################### - ACTIONS_RUNNER_DEBUG="${ACTIONS_RUNNER_DEBUG,,}" - - ############################ - # Set to true if not false # - ############################ - if [ "${ACTIONS_RUNNER_DEBUG}" != "false" ]; then - ACTIONS_RUNNER_DEBUG="true" - fi - - ########################### - # Print the validate info # - ########################### - for LINE in "${PRINT_ARRAY[@]}"; do - debug "${LINE}" - done - - debug "--- DEBUG INFO ---" - debug "---------------------------------------------" - RUNNER=$(whoami) - debug "Runner:[${RUNNER}]" - PRINTENV=$(printenv) - debug "ENV:" - debug "${PRINTENV}" - debug "---------------------------------------------" + debug "--- DEBUG INFO ---" + debug "---------------------------------------------" + RUNNER=$(whoami) + debug "Runner:[${RUNNER}]" + PRINTENV=$(printenv) + debug "ENV:" + debug "${PRINTENV}" + debug "---------------------------------------------" } diff --git a/lib/worker.sh b/lib/worker.sh index b5d5988c..929b3ff9 100755 --- a/lib/worker.sh +++ b/lib/worker.sh @@ -10,883 +10,883 @@ ################################################################################ #### Function LintCodebase ##################################################### function LintCodebase() { - #################### - # Pull in the vars # - #################### - FILE_TYPE="${1}" && shift # Pull the variable and remove from array path (Example: JSON) - LINTER_NAME="${1}" && shift # Pull the variable and remove from array path (Example: jsonlint) - LINTER_COMMAND="${1}" && shift # Pull the variable and remove from array path (Example: jsonlint -c ConfigFile /path/to/file) - FILE_EXTENSIONS="${1}" && shift # Pull the variable and remove from array path (Example: *.json) - FILE_ARRAY=("$@") # Array of files to validate (Example: ${FILE_ARRAY_JSON}) + #################### + # Pull in the vars # + #################### + FILE_TYPE="${1}" && shift # Pull the variable and remove from array path (Example: JSON) + LINTER_NAME="${1}" && shift # Pull the variable and remove from array path (Example: jsonlint) + LINTER_COMMAND="${1}" && shift # Pull the variable and remove from array path (Example: jsonlint -c ConfigFile /path/to/file) + FILE_EXTENSIONS="${1}" && shift # Pull the variable and remove from array path (Example: *.json) + FILE_ARRAY=("$@") # Array of files to validate (Example: ${FILE_ARRAY_JSON}) - ###################### - # Create Print Array # - ###################### - PRINT_ARRAY=() - - ################ - # print header # - ################ - PRINT_ARRAY+=("") - PRINT_ARRAY+=("----------------------------------------------") - PRINT_ARRAY+=("----------------------------------------------") - PRINT_ARRAY+=("Linting [${FILE_TYPE}] files...") - PRINT_ARRAY+=("----------------------------------------------") - PRINT_ARRAY+=("----------------------------------------------") - - ##################################### - # Validate we have linter installed # - ##################################### - VALIDATE_INSTALL_CMD=$(command -v "${LINTER_NAME}" 2>&1) - - ####################### - # Load the error code # - ####################### - ERROR_CODE=$? - - ############################## - # Check the shell for errors # - ############################## - if [ ${ERROR_CODE} -ne 0 ]; then - # Failed - error "Failed to find [${LINTER_NAME}] in system!" - fatal "[${VALIDATE_INSTALL_CMD}]" - else - # Success - debug "Successfully found binary for ${F[W]}[${LINTER_NAME}]${F[B]} in system location: ${F[W]}[${VALIDATE_INSTALL_CMD}]" - fi - - ########################## - # Initialize empty Array # - ########################## - LIST_FILES=() - - ################ - # Set the flag # - ################ - SKIP_FLAG=0 - - ############################################################ - # Check to see if we need to go through array or all files # - ############################################################ - if [ ${#FILE_ARRAY[@]} -eq 0 ] && [ "${VALIDATE_ALL_CODEBASE}" == "false" ]; then - # No files found in commit and user has asked to not validate code base - SKIP_FLAG=1 - debug " - No files found in changeset to lint for language:[${FILE_TYPE}]" - elif [ ${#FILE_ARRAY[@]} -ne 0 ]; then - # We have files added to array of files to check - LIST_FILES=("${FILE_ARRAY[@]}") # Copy the array into list - else - ############################################################################### - # Set the file seperator to newline to allow for grabbing objects with spaces # - ############################################################################### - IFS=$'\n' - - ################################# - # Get list of all files to lint # - ################################# - mapfile -t LIST_FILES < <(find "${GITHUB_WORKSPACE}" -type f -regex "${FILE_EXTENSIONS}" 2>&1) - - ########################### - # Set IFS back to default # - ########################### - IFS="${DEFAULT_IFS}" - - ############################################################ - # Set it back to empty if loaded with blanks from scanning # - ############################################################ - if [ ${#LIST_FILES[@]} -lt 1 ]; then - ###################### - # Set to empty array # - ###################### - LIST_FILES=() - ############################# - # Skip as we found no files # - ############################# - SKIP_FLAG=1 - fi - fi - - ############################### - # Check if any data was found # - ############################### - if [ ${SKIP_FLAG} -eq 0 ]; then ###################### - # Print Header array # + # Create Print Array # ###################### - for LINE in "${PRINT_ARRAY[@]}"; do - ######################### - # Print the header info # - ######################### - info "${LINE}" - done + PRINT_ARRAY=() - ######################################## - # Prepare context if TAP format output # - ######################################## - if IsTAP ; then - TMPFILE=$(mktemp -q "/tmp/super-linter-${FILE_TYPE}.XXXXXX") - INDEX=0 - mkdir -p "${REPORT_OUTPUT_FOLDER}" - REPORT_OUTPUT_FILE="${REPORT_OUTPUT_FOLDER}/super-linter-${FILE_TYPE}.${OUTPUT_FORMAT}" - fi + ################ + # print header # + ################ + PRINT_ARRAY+=("") + PRINT_ARRAY+=("----------------------------------------------") + PRINT_ARRAY+=("----------------------------------------------") + PRINT_ARRAY+=("Linting [${FILE_TYPE}] files...") + PRINT_ARRAY+=("----------------------------------------------") + PRINT_ARRAY+=("----------------------------------------------") - ################## - # Lint the files # - ################## - for FILE in "${LIST_FILES[@]}"; do - ################################### - # Get the file name and directory # - ################################### - FILE_NAME=$(basename "${FILE}" 2>&1) - DIR_NAME=$(dirname "${FILE}" 2>&1) - - ##################################################### - # Make sure we dont lint node modules or test cases # - ##################################################### - if [[ ${FILE} == *"node_modules"* ]]; then - # This is a node modules file - continue - elif [[ ${FILE} == *"${TEST_CASE_FOLDER}"* ]]; then - # This is the test cases, we should always skip - continue - elif [[ ${FILE} == *".git"* ]]; then - # This is likely the .git folder and shouldnt be parsed - continue - fi - - ################################## - # Increase the linted file index # - ################################## - (("INDEX++")) - - ############## - # File print # - ############## - info "---------------------------" - info "File:[${FILE}]" - - ################################# - # Add the language to the array # - ################################# - LINTED_LANGUAGES_ARRAY+=("${FILE_TYPE}") - - #################### - # Set the base Var # - #################### - LINT_CMD='' - - #################################### - # Corner case for pwsh subshell # - # - PowerShell (PSScriptAnalyzer) # - # - ARM (arm-ttk) # - #################################### - if [[ ${FILE_TYPE} == "POWERSHELL" ]] || [[ ${FILE_TYPE} == "ARM" ]]; then - ################################ - # Lint the file with the rules # - ################################ - # Need to run PowerShell commands using pwsh -c, also exit with exit code from inner subshell - LINT_CMD=$( - cd "${GITHUB_WORKSPACE}" || exit - pwsh -NoProfile -NoLogo -Command "${LINTER_COMMAND} ${FILE}; if (\${Error}.Count) { exit 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 - ################################ - # Lint the file with the rules # - ################################ - LINT_CMD=$( - cd "${GITHUB_WORKSPACE}" || exit - ${LINTER_COMMAND} "${FILE}" 2>&1 - ) - fi - ####################### - # Load the error code # - ####################### - ERROR_CODE=$? - - ############################## - # Check the shell for errors # - ############################## - if [ ${ERROR_CODE} -ne 0 ]; then - ######### - # Error # - ######### - error "Found errors in [${LINTER_NAME}] linter!" - error "[${LINT_CMD}]" - error "Linter CMD:[${LINTER_COMMAND} ${FILE}]" - # Increment the error count - (("ERRORS_FOUND_${FILE_TYPE}++")) - - ####################################################### - # Store the linting as a temporary file in TAP format # - ####################################################### - if IsTAP ; then - NotOkTap "${INDEX}" "${FILE}" "${TMPFILE}" - AddDetailedMessageIfEnabled "${LINT_CMD}" "${TMPFILE}" - fi - else - ########### - # Success # - ########### - info " - File:${F[W]}[${FILE_NAME}]${F[B]} was linted with ${F[W]}[${LINTER_NAME}]${F[B]} successfully" - - ####################################################### - # Store the linting as a temporary file in TAP format # - ####################################################### - if IsTAP ; then - OkTap "${INDEX}" "${FILE}" "${TMPFILE}" - fi - fi - done - - ################################# - # Generate report in TAP format # - ################################# - if IsTAP && [ ${INDEX} -gt 0 ] ; then - HeaderTap "${INDEX}" "${REPORT_OUTPUT_FILE}" - cat "${TMPFILE}" >> "${REPORT_OUTPUT_FILE}" - fi - fi -} -################################################################################ -#### Function TestCodebase ##################################################### -function TestCodebase() { - #################### - # Pull in the vars # - #################### - FILE_TYPE="${1}" # Pull the variable and remove from array path (Example: JSON) - LINTER_NAME="${2}" # Pull the variable and remove from array path (Example: jsonlint) - LINTER_COMMAND="${3}" # Pull the variable and remove from array path (Example: jsonlint -c ConfigFile /path/to/file) - FILE_EXTENSIONS="${4}" # Pull the variable and remove from array path (Example: *.json) - INDVIDUAL_TEST_FOLDER="${5}" # Folder for specific tests - TESTS_RAN=0 # Incremented when tests are ran, this will help find failed finds - - ################ - # print header # - ################ - info "----------------------------------------------" - info "----------------------------------------------" - info "Testing Codebase [${FILE_TYPE}] files..." - info "----------------------------------------------" - info "----------------------------------------------" - - ##################################### - # Validate we have linter installed # - ##################################### - VALIDATE_INSTALL_CMD=$(command -v "${LINTER_NAME}" 2>&1) - - ####################### - # Load the error code # - ####################### - ERROR_CODE=$? - - ############################## - # Check the shell for errors # - ############################## - if [ ${ERROR_CODE} -ne 0 ]; then - # Failed - error "Failed to find [${LINTER_NAME}] in system!" - fatal "[${VALIDATE_INSTALL_CMD}]" - else - # Success - info "Successfully found binary for ${F[W]}[${LINTER_NAME}]${F[B]} in system location: ${F[W]}[${VALIDATE_INSTALL_CMD}]" - fi - - ########################## - # Initialize empty Array # - ########################## - LIST_FILES=() - - ################################# - # Get list of all files to lint # - ################################# - mapfile -t LIST_FILES < <(find "${GITHUB_WORKSPACE}/${TEST_CASE_FOLDER}/${INDVIDUAL_TEST_FOLDER}" -type f -regex "${FILE_EXTENSIONS}" ! -path "${GITHUB_WORKSPACE}/${TEST_CASE_FOLDER}/ansible/ghe-initialize/*" | sort 2>&1) - - ######################################## - # Prepare context if TAP output format # - ######################################## - if IsTAP ; then - TMPFILE=$(mktemp -q "/tmp/super-linter-${FILE_TYPE}.XXXXXX") - mkdir -p "${REPORT_OUTPUT_FOLDER}" - REPORT_OUTPUT_FILE="${REPORT_OUTPUT_FOLDER}/super-linter-${FILE_TYPE}.${OUTPUT_FORMAT}" - fi - - ################## - # Lint the files # - ################## - for FILE in "${LIST_FILES[@]}"; do - ##################### - # Get the file name # - ##################### - FILE_NAME=$(basename "${FILE}" 2>&1) - DIR_NAME=$(dirname "${FILE}" 2>&1) - - ############################ - # Get the file pass status # - ############################ - # Example: markdown_good_1.md -> good - FILE_STATUS=$(echo "${FILE_NAME}" | cut -f2 -d'_') - - ######################################################### - # If not found, assume it should be linted successfully # - ######################################################### - if [ -z "${FILE_STATUS}" ] || [[ ${FILE} == *"README"* ]]; then - ################################## - # Set to good for proper linting # - ################################## - FILE_STATUS="good" - fi - - ############## - # File print # - ############## - info "---------------------------" - info "File:[${FILE}]" - - ######################## - # Set the lint command # - ######################## - LINT_CMD='' - - ####################################### - # Check if docker and get folder name # - ####################################### - if [[ ${FILE_TYPE} == "DOCKER" ]]; then - if [[ ${FILE} == *"good"* ]]; then - ############# - # Good file # - ############# - FILE_STATUS='good' - else - ############ - # Bad file # - ############ - FILE_STATUS='bad' - fi - fi - - ##################### - # Check for ansible # - ##################### - if [[ ${FILE_TYPE} == "ANSIBLE" ]]; then - ######################################## - # Make sure we dont lint certain files # - ######################################## - if [[ ${FILE} == *"vault.yml"* ]] || [[ ${FILE} == *"galaxy.yml"* ]]; then - # This is a file we dont look at - continue - fi - - ################################ - # Lint the file with the rules # - ################################ - LINT_CMD=$( - cd "${GITHUB_WORKSPACE}/${TEST_CASE_FOLDER}/${INDVIDUAL_TEST_FOLDER}" || exit - ${LINTER_COMMAND} "${FILE}" 2>&1 - ) - elif [[ ${FILE_TYPE} == "POWERSHELL" ]] || [[ ${FILE_TYPE} == "ARM" ]]; then - ################################ - # Lint the file with the rules # - ################################ - # Need to run PowerShell commands using pwsh -c, also exit with exit code from inner subshell - LINT_CMD=$( - cd "${GITHUB_WORKSPACE}/${TEST_CASE_FOLDER}" || exit - pwsh -NoProfile -NoLogo -Command "${LINTER_COMMAND} ${FILE}; if (\${Error}.Count) { exit 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 - ################################ - # Lint the file with the rules # - ################################ - LINT_CMD=$( - cd "${GITHUB_WORKSPACE}/${TEST_CASE_FOLDER}" || exit - ${LINTER_COMMAND} "${FILE}" 2>&1 - ) - fi + ##################################### + # Validate we have linter installed # + ##################################### + VALIDATE_INSTALL_CMD=$(command -v "${LINTER_NAME}" 2>&1) ####################### # Load the error code # ####################### ERROR_CODE=$? - ######################################## - # Increment counter that check was ran # - ######################################## - (("TESTS_RAN++")) - - ######################################## - # Check for if it was supposed to pass # - ######################################## - if [[ ${FILE_STATUS} == "good" ]]; then - ############################## - # Check the shell for errors # - ############################## - if [ ${ERROR_CODE} -ne 0 ]; then - ######### - # Error # - ######### - error "Found errors in [${LINTER_NAME}] linter!" - error "[${LINT_CMD}]" - error "Linter CMD:[${LINTER_COMMAND} ${FILE}]" - # Increment the error count - (("ERRORS_FOUND_${FILE_TYPE}++")) - else - ########### - # Success # - ########### - info " - File:${F[W]}[${FILE_NAME}]${F[B]} was linted with ${F[W]}[${LINTER_NAME}]${F[B]} successfully" - fi - ####################################################### - # Store the linting as a temporary file in TAP format # - ####################################################### - if IsTAP ; then - OkTap "${TESTS_RAN}" "${FILE_NAME}" "${TMPFILE}" - fi + ############################## + # Check the shell for errors # + ############################## + if [ ${ERROR_CODE} -ne 0 ]; then + # Failed + error "Failed to find [${LINTER_NAME}] in system!" + fatal "[${VALIDATE_INSTALL_CMD}]" else - ####################################### - # File status = bad, this should fail # - ####################################### - ############################## - # Check the shell for errors # - ############################## - if [ ${ERROR_CODE} -eq 0 ]; then - ######### - # Error # - ######### - error "Found errors in [${LINTER_NAME}] linter!" - error "This file should have failed test case!" - error "Command run:${NC}[\$${LINT_CMD}]" - error "[${LINT_CMD}]" - error "Linter CMD:[${LINTER_COMMAND} ${FILE}]" - # Increment the error count - (("ERRORS_FOUND_${FILE_TYPE}++")) - else - ########### - # Success # - ########### - info " - File:${F[W]}[${FILE_NAME}]${F[B]} failed test case with ${F[W]}[${LINTER_NAME}]${F[B]} successfully" - fi - ####################################################### - # Store the linting as a temporary file in TAP format # - ####################################################### - if IsTAP ; then - NotOkTap "${TESTS_RAN}" "${FILE_NAME}" "${TMPFILE}" - AddDetailedMessageIfEnabled "${LINT_CMD}" "${TMPFILE}" - fi - fi - done - - ########################################################################### - # Generate report in TAP format and validate with the expected TAP output # - ########################################################################### - if IsTAP && [ ${TESTS_RAN} -gt 0 ] ; then - HeaderTap "${TESTS_RAN}" "${REPORT_OUTPUT_FILE}" - cat "${TMPFILE}" >> "${REPORT_OUTPUT_FILE}" - - ######################################################################## - # If expected TAP report exists then compare with the generated report # - ######################################################################## - EXPECTED_FILE="${GITHUB_WORKSPACE}/${TEST_CASE_FOLDER}/${INDVIDUAL_TEST_FOLDER}/reports/expected-${FILE_TYPE}.tap" - if [ -e "${EXPECTED_FILE}" ] ; then - TMPFILE=$(mktemp -q "/tmp/diff-${FILE_TYPE}.XXXXXX") - ## Ignore white spaces, case sensitive - if ! diff -a -w -i "${EXPECTED_FILE}" "${REPORT_OUTPUT_FILE}" > "${TMPFILE}" 2>&1; then - ############################################# - # We failed to compare the reporting output # - ############################################# - error "Failed to assert TAP output:[${LINTER_NAME}]"! - info "Please validate the asserts!" - cat "${TMPFILE}" - exit 1 - else # Success - info "Successfully validation in the expected TAP format for ${F[W]}[${LINTER_NAME}]" - fi - else - warn "No TAP expected file found at:[${EXPECTED_FILE}]" - info "skipping report assertions" - ##################################### - # Append the file type to the array # - ##################################### - WARNING_ARRAY_TEST+=("${FILE_TYPE}") + debug "Successfully found binary for ${F[W]}[${LINTER_NAME}]${F[B]} in system location: ${F[W]}[${VALIDATE_INSTALL_CMD}]" fi - fi - ############################## - # Validate we ran some tests # - ############################## - if [ "${TESTS_RAN}" -eq 0 ]; then - ################################################# - # We failed to find files and no tests were ran # - ################################################# - error "Failed to find any tests ran for the Linter:[${LINTER_NAME}]"! - fatal "Please validate logic or that tests exist!" - fi + ########################## + # Initialize empty Array # + ########################## + LIST_FILES=() + + ################ + # Set the flag # + ################ + SKIP_FLAG=0 + + ############################################################ + # Check to see if we need to go through array or all files # + ############################################################ + if [ ${#FILE_ARRAY[@]} -eq 0 ] && [ "${VALIDATE_ALL_CODEBASE}" == "false" ]; then + # No files found in commit and user has asked to not validate code base + SKIP_FLAG=1 + debug " - No files found in changeset to lint for language:[${FILE_TYPE}]" + elif [ ${#FILE_ARRAY[@]} -ne 0 ]; then + # We have files added to array of files to check + LIST_FILES=("${FILE_ARRAY[@]}") # Copy the array into list + else + ############################################################################### + # Set the file seperator to newline to allow for grabbing objects with spaces # + ############################################################################### + IFS=$'\n' + + ################################# + # Get list of all files to lint # + ################################# + mapfile -t LIST_FILES < <(find "${GITHUB_WORKSPACE}" -type f -regex "${FILE_EXTENSIONS}" 2>&1) + + ########################### + # Set IFS back to default # + ########################### + IFS="${DEFAULT_IFS}" + + ############################################################ + # Set it back to empty if loaded with blanks from scanning # + ############################################################ + if [ ${#LIST_FILES[@]} -lt 1 ]; then + ###################### + # Set to empty array # + ###################### + LIST_FILES=() + ############################# + # Skip as we found no files # + ############################# + SKIP_FLAG=1 + fi + fi + + ############################### + # Check if any data was found # + ############################### + if [ ${SKIP_FLAG} -eq 0 ]; then + ###################### + # Print Header array # + ###################### + for LINE in "${PRINT_ARRAY[@]}"; do + ######################### + # Print the header info # + ######################### + info "${LINE}" + done + + ######################################## + # Prepare context if TAP format output # + ######################################## + if IsTAP; then + TMPFILE=$(mktemp -q "/tmp/super-linter-${FILE_TYPE}.XXXXXX") + INDEX=0 + mkdir -p "${REPORT_OUTPUT_FOLDER}" + REPORT_OUTPUT_FILE="${REPORT_OUTPUT_FOLDER}/super-linter-${FILE_TYPE}.${OUTPUT_FORMAT}" + fi + + ################## + # Lint the files # + ################## + for FILE in "${LIST_FILES[@]}"; do + ################################### + # Get the file name and directory # + ################################### + FILE_NAME=$(basename "${FILE}" 2>&1) + DIR_NAME=$(dirname "${FILE}" 2>&1) + + ##################################################### + # Make sure we dont lint node modules or test cases # + ##################################################### + if [[ ${FILE} == *"node_modules"* ]]; then + # This is a node modules file + continue + elif [[ ${FILE} == *"${TEST_CASE_FOLDER}"* ]]; then + # This is the test cases, we should always skip + continue + elif [[ ${FILE} == *".git"* ]]; then + # This is likely the .git folder and shouldnt be parsed + continue + fi + + ################################## + # Increase the linted file index # + ################################## + (("INDEX++")) + + ############## + # File print # + ############## + info "---------------------------" + info "File:[${FILE}]" + + ################################# + # Add the language to the array # + ################################# + LINTED_LANGUAGES_ARRAY+=("${FILE_TYPE}") + + #################### + # Set the base Var # + #################### + LINT_CMD='' + + #################################### + # Corner case for pwsh subshell # + # - PowerShell (PSScriptAnalyzer) # + # - ARM (arm-ttk) # + #################################### + if [[ ${FILE_TYPE} == "POWERSHELL" ]] || [[ ${FILE_TYPE} == "ARM" ]]; then + ################################ + # Lint the file with the rules # + ################################ + # Need to run PowerShell commands using pwsh -c, also exit with exit code from inner subshell + LINT_CMD=$( + cd "${GITHUB_WORKSPACE}" || exit + pwsh -NoProfile -NoLogo -Command "${LINTER_COMMAND} ${FILE}; if (\${Error}.Count) { exit 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 + ################################ + # Lint the file with the rules # + ################################ + LINT_CMD=$( + cd "${GITHUB_WORKSPACE}" || exit + ${LINTER_COMMAND} "${FILE}" 2>&1 + ) + fi + ####################### + # Load the error code # + ####################### + ERROR_CODE=$? + + ############################## + # Check the shell for errors # + ############################## + if [ ${ERROR_CODE} -ne 0 ]; then + ######### + # Error # + ######### + error "Found errors in [${LINTER_NAME}] linter!" + error "[${LINT_CMD}]" + error "Linter CMD:[${LINTER_COMMAND} ${FILE}]" + # Increment the error count + (("ERRORS_FOUND_${FILE_TYPE}++")) + + ####################################################### + # Store the linting as a temporary file in TAP format # + ####################################################### + if IsTAP; then + NotOkTap "${INDEX}" "${FILE}" "${TMPFILE}" + AddDetailedMessageIfEnabled "${LINT_CMD}" "${TMPFILE}" + fi + else + ########### + # Success # + ########### + info " - File:${F[W]}[${FILE_NAME}]${F[B]} was linted with ${F[W]}[${LINTER_NAME}]${F[B]} successfully" + + ####################################################### + # Store the linting as a temporary file in TAP format # + ####################################################### + if IsTAP; then + OkTap "${INDEX}" "${FILE}" "${TMPFILE}" + fi + fi + done + + ################################# + # Generate report in TAP format # + ################################# + if IsTAP && [ ${INDEX} -gt 0 ]; then + HeaderTap "${INDEX}" "${REPORT_OUTPUT_FILE}" + cat "${TMPFILE}" >> "${REPORT_OUTPUT_FILE}" + fi + fi } ################################################################################ -#### Function RunTestCases ##################################################### -function RunTestCases() { - # This loop will run the test cases and exclude user code - # This is called from the automation process to validate new code - # When a PR is opened, the new code is validated with the default branch - # version of linter.sh, and a new container is built with the latest codebase - # for testing. That container is spun up, and ran, - # with the flag: TEST_CASE_RUN=true - # So that the new code can be validated against the test cases +#### Function TestCodebase ##################################################### +function TestCodebase() { + #################### + # Pull in the vars # + #################### + FILE_TYPE="${1}" # Pull the variable and remove from array path (Example: JSON) + LINTER_NAME="${2}" # Pull the variable and remove from array path (Example: jsonlint) + LINTER_COMMAND="${3}" # Pull the variable and remove from array path (Example: jsonlint -c ConfigFile /path/to/file) + FILE_EXTENSIONS="${4}" # Pull the variable and remove from array path (Example: *.json) + INDVIDUAL_TEST_FOLDER="${5}" # Folder for specific tests + TESTS_RAN=0 # Incremented when tests are ran, this will help find failed finds - ################# - # Header prints # - ################# - info "----------------------------------------------" - info "-------------- TEST CASE RUN -----------------" - info "----------------------------------------------" + ################ + # print header # + ################ + info "----------------------------------------------" + info "----------------------------------------------" + info "Testing Codebase [${FILE_TYPE}] files..." + info "----------------------------------------------" + info "----------------------------------------------" - ####################### - # Test case languages # - ####################### - # TestCodebase "Language" "Linter" "Linter-command" "Regex to find files" "Test Folder" - TestCodebase "ANSIBLE" "ansible-lint" "ansible-lint -v -c ${ANSIBLE_LINTER_RULES}" ".*\.\(yml\|yaml\)\$" "ansible" - TestCodebase "ARM" "arm-ttk" "Import-Module ${ARM_TTK_PSD1} ; \${config} = \$(Import-PowerShellDataFile -Path ${ARM_LINTER_RULES}) ; Test-AzTemplate @config -TemplatePath" ".*\.\(json\)\$" "arm" - TestCodebase "BASH" "shellcheck" "shellcheck --color" ".*\.\(sh\|bash\|dash\|ksh\)\$" "shell" - TestCodebase "CLOUDFORMATION" "cfn-lint" "cfn-lint --config-file ${CLOUDFORMATION_LINTER_RULES}" ".*\.\(json\|yml\|yaml\)\$" "cloudformation" - TestCodebase "CLOJURE" "clj-kondo" "clj-kondo --config ${CLOJURE_LINTER_RULES} --lint" ".*\.\(clj\|cljs\|cljc\|edn\)\$" "clojure" - TestCodebase "COFFEESCRIPT" "coffeelint" "coffeelint -f ${COFFEESCRIPT_LINTER_RULES}" ".*\.\(coffee\)\$" "coffeescript" - TestCodebase "CSS" "stylelint" "stylelint --config ${CSS_LINTER_RULES}" ".*\.\(css\)\$" "css" - TestCodebase "DART" "dart" "dartanalyzer --fatal-infos --fatal-warnings --options ${DART_LINTER_RULES}" ".*\.\(dart\)\$" "dart" - TestCodebase "DOCKER" "dockerfilelint" "dockerfilelint -c ${DOCKER_LINTER_RULES}" ".*\(Dockerfile\)\$" "docker" - TestCodebase "EDITORCONFIG" "editorconfig-checker" "editorconfig-checker" ".*\.ext$" "editorconfig-checker" - TestCodebase "ENV" "dotenv-linter" "dotenv-linter" ".*\.\(env\)\$" "env" - 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 "JAVASCRIPT_ES" "eslint" "eslint --no-eslintrc -c ${JAVASCRIPT_LINTER_RULES}" ".*\.\(js\)\$" "javascript" - TestCodebase "JAVASCRIPT_STANDARD" "standard" "standard ${JAVASCRIPT_STANDARD_LINTER_RULES}" ".*\.\(js\)\$" "javascript" - TestCodebase "JSON" "jsonlint" "jsonlint" ".*\.\(json\)\$" "json" - TestCodebase "KOTLIN" "ktlint" "ktlint" ".*\.\(kt\|kts\)\$" "kotlin" - TestCodebase "LUA" "lua" "luacheck" ".*\.\(lua\)\$" "lua" - TestCodebase "MARKDOWN" "markdownlint" "markdownlint -c ${MARKDOWN_LINTER_RULES}" ".*\.\(md\)\$" "markdown" - TestCodebase "PERL" "perl" "perl -Mstrict -cw" ".*\.\(pl\)\$" "perl" - TestCodebase "PHP" "php" "php -l" ".*\.\(php\)\$" "php" - TestCodebase "PHP_PHPSTAN" "phpstan" "phpstan analyse --no-progress --no-ansi -c ${PHPSTAN_LINTER_RULES}" ".*\.\(php\)\$" "php" - TestCodebase "OPENAPI" "spectral" "spectral lint -r ${OPENAPI_LINTER_RULES}" ".*\.\(ymlopenapi\|jsonopenapi\)\$" "openapi" - TestCodebase "POWERSHELL" "pwsh" "Invoke-ScriptAnalyzer -EnableExit -Settings ${POWERSHELL_LINTER_RULES} -Path" ".*\.\(ps1\|psm1\|psd1\|ps1xml\|pssc\|psrc\|cdxml\)\$" "powershell" - TestCodebase "PROTOBUF" "protolint" "protolint lint --config_path ${PROTOBUF_LINTER_RULES}" ".*\.\(proto\)\$" "protobuf" - TestCodebase "PYTHON_PYLINT" "pylint" "pylint --rcfile ${PYTHON_PYLINT_LINTER_RULES}" ".*\.\(py\)\$" "python" - TestCodebase "PYTHON_FLAKE8" "flake8" "flake8 --config ${PYTHON_FLAKE8_LINTER_RULES}" ".*\.\(py\)\$" "python" - TestCodebase "RAKU" "raku" "raku -c" ".*\.\(raku\|rakumod\|rakutest\|pm6\|pl6\|p6\)\$" "raku" - TestCodebase "RUBY" "rubocop" "rubocop -c ${RUBY_LINTER_RULES}" ".*\.\(rb\)\$" "ruby" - TestCodebase "STATES" "asl-validator" "asl-validator --json-path" ".*\.\(json\)\$" "states" - TestCodebase "TERRAFORM" "tflint" "tflint -c ${TERRAFORM_LINTER_RULES}" ".*\.\(tf\)\$" "terraform" - TestCodebase "TERRAFORM_TERRASCAN" "terrascan" "terrascan -f " ".*\.\(tf\)\$" "terraform_terrascan" - TestCodebase "TYPESCRIPT_ES" "eslint" "eslint --no-eslintrc -c ${TYPESCRIPT_LINTER_RULES}" ".*\.\(ts\)\$" "typescript" - TestCodebase "TYPESCRIPT_STANDARD" "standard" "standard --parser @typescript-eslint/parser --plugin @typescript-eslint/eslint-plugin ${TYPESCRIPT_STANDARD_LINTER_RULES}" ".*\.\(ts\)\$" "typescript" - TestCodebase "XML" "xmllint" "xmllint" ".*\.\(xml\)\$" "xml" - TestCodebase "YAML" "yamllint" "yamllint -c ${YAML_LINTER_RULES}" ".*\.\(yml\|yaml\)\$" "yml" + ##################################### + # Validate we have linter installed # + ##################################### + VALIDATE_INSTALL_CMD=$(command -v "${LINTER_NAME}" 2>&1) - ################# - # Footer prints # - ################# - # Call the footer to display run information - # and exit with error code - Footer -} -################################################################################ -#### Function LintAnsibleFiles ################################################# -function LintAnsibleFiles() { - ###################### - # Create Print Array # - ###################### - PRINT_ARRAY=() + ####################### + # Load the error code # + ####################### + ERROR_CODE=$? - ################ - # print header # - ################ - PRINT_ARRAY+=("") - PRINT_ARRAY+=("----------------------------------------------") - PRINT_ARRAY+=("----------------------------------------------") - PRINT_ARRAY+=("Linting [Ansible] files...") - PRINT_ARRAY+=("----------------------------------------------") - PRINT_ARRAY+=("----------------------------------------------") + ############################## + # Check the shell for errors # + ############################## + if [ ${ERROR_CODE} -ne 0 ]; then + # Failed + error "Failed to find [${LINTER_NAME}] in system!" + fatal "[${VALIDATE_INSTALL_CMD}]" + else + # Success + info "Successfully found binary for ${F[W]}[${LINTER_NAME}]${F[B]} in system location: ${F[W]}[${VALIDATE_INSTALL_CMD}]" + fi - ###################### - # Name of the linter # - ###################### - LINTER_NAME="ansible-lint" - - ########################################### - # Validate we have ansible-lint installed # - ########################################### - VALIDATE_INSTALL_CMD=$(command -v "${LINTER_NAME}" 2>&1) - - ####################### - # Load the error code # - ####################### - ERROR_CODE=$? - - ############################## - # Check the shell for errors # - ############################## - if [ ${ERROR_CODE} -ne 0 ]; then - # Failed - error "Failed to find ${LINTER_NAME} in system!" - fatal "[${VALIDATE_INSTALL_CMD}]" - else - # Success - debug "Successfully found binary in system" - debug "Location:[${VALIDATE_INSTALL_CMD}]" - fi - - ########################## - # Initialize empty Array # - ########################## - LIST_FILES=() - - ####################### - # Create flag to skip # - ####################### - SKIP_FLAG=0 - - ###################################################### - # Only go into ansible linter if we have base folder # - ###################################################### - if [ -d "${ANSIBLE_DIRECTORY}" ]; then + ########################## + # Initialize empty Array # + ########################## + LIST_FILES=() ################################# # Get list of all files to lint # ################################# - mapfile -t LIST_FILES < <(ls "${ANSIBLE_DIRECTORY}"/*.{yaml,yml} 2>&1) - - ############################################################### - # Set the list to empty if only MD and TXT files were changed # - ############################################################### - # No need to run the full ansible checks on read only file changes - if [ "${READ_ONLY_CHANGE_FLAG}" -eq 0 ]; then - ########################## - # Set the array to empty # - ########################## - LIST_FILES=() - ################################### - # Send message that were skipping # - ################################### - debug "- Skipping Ansible lint run as file(s) that were modified were read only..." - ############################ - # Create flag to skip loop # - ############################ - SKIP_FLAG=1 - fi - - #################################### - # Check if we have data to look at # - #################################### - if [ ${SKIP_FLAG} -eq 0 ]; then - for LINE in "${PRINT_ARRAY[@]}"; do - ######################### - # Print the header line # - ######################### - info "${LINE}" - done - fi + mapfile -t LIST_FILES < <(find "${GITHUB_WORKSPACE}/${TEST_CASE_FOLDER}/${INDVIDUAL_TEST_FOLDER}" -type f -regex "${FILE_EXTENSIONS}" ! -path "${GITHUB_WORKSPACE}/${TEST_CASE_FOLDER}/ansible/ghe-initialize/*" | sort 2>&1) ######################################## # Prepare context if TAP output format # ######################################## - if IsTAP ; then - TMPFILE=$(mktemp -q "/tmp/super-linter-${FILE_TYPE}.XXXXXX") - INDEX=0 - mkdir -p "${REPORT_OUTPUT_FOLDER}" - REPORT_OUTPUT_FILE="${REPORT_OUTPUT_FOLDER}/super-linter-${FILE_TYPE}.${OUTPUT_FORMAT}" + if IsTAP; then + TMPFILE=$(mktemp -q "/tmp/super-linter-${FILE_TYPE}.XXXXXX") + mkdir -p "${REPORT_OUTPUT_FOLDER}" + REPORT_OUTPUT_FILE="${REPORT_OUTPUT_FOLDER}/super-linter-${FILE_TYPE}.${OUTPUT_FORMAT}" fi ################## # Lint the files # ################## for FILE in "${LIST_FILES[@]}"; do + ##################### + # Get the file name # + ##################### + FILE_NAME=$(basename "${FILE}" 2>&1) + DIR_NAME=$(dirname "${FILE}" 2>&1) - ######################################## - # Make sure we dont lint certain files # - ######################################## - if [[ ${FILE} == *"vault.yml"* ]] || [[ ${FILE} == *"galaxy.yml"* ]]; then - # This is a file we dont look at - continue - fi + ############################ + # Get the file pass status # + ############################ + # Example: markdown_good_1.md -> good + FILE_STATUS=$(echo "${FILE_NAME}" | cut -f2 -d'_') - ################################## - # Increase the linted file index # - ################################## - (("INDEX++")) - - #################### - # Get the filename # - #################### - FILE_NAME=$(basename "${ANSIBLE_DIRECTORY}/${FILE}" 2>&1) - - ############## - # File print # - ############## - info "---------------------------" - info "File:[${FILE}]" - - ################################ - # Lint the file with the rules # - ################################ - LINT_CMD=$("${LINTER_NAME}" -v -c "${ANSIBLE_LINTER_RULES}" "${ANSIBLE_DIRECTORY}/${FILE}" 2>&1) - - ####################### - # Load the error code # - ####################### - ERROR_CODE=$? - - ############################## - # Check the shell for errors # - ############################## - if [ ${ERROR_CODE} -ne 0 ]; then - ######### - # Error # - ######### - error "Found errors in [${LINTER_NAME}] linter!" - error "[${LINT_CMD}]" - # Increment error count - ((ERRORS_FOUND_ANSIBLE++)) - - ####################################################### - # Store the linting as a temporary file in TAP format # - ####################################################### - if IsTAP ; then - NotOkTap "${INDEX}" "${FILE}" "${TMPFILE}" - AddDetailedMessageIfEnabled "${LINT_CMD}" "${TMPFILE}" + ######################################################### + # If not found, assume it should be linted successfully # + ######################################################### + if [ -z "${FILE_STATUS}" ] || [[ ${FILE} == *"README"* ]]; then + ################################## + # Set to good for proper linting # + ################################## + FILE_STATUS="good" fi - else - ########### - # Success # - ########### - info " - File:${F[W]}[${FILE_NAME}]${F[B]} was linted with ${F[W]}[${LINTER_NAME}]${F[B]} successfully" + ############## + # File print # + ############## + info "---------------------------" + info "File:[${FILE}]" - ####################################################### - # Store the linting as a temporary file in TAP format # - ####################################################### - if IsTAP ; then - OkTap "${INDEX}" "${FILE}" "${TMPFILE}" + ######################## + # Set the lint command # + ######################## + LINT_CMD='' + + ####################################### + # Check if docker and get folder name # + ####################################### + if [[ ${FILE_TYPE} == "DOCKER" ]]; then + if [[ ${FILE} == *"good"* ]]; then + ############# + # Good file # + ############# + FILE_STATUS='good' + else + ############ + # Bad file # + ############ + FILE_STATUS='bad' + fi + fi + + ##################### + # Check for ansible # + ##################### + if [[ ${FILE_TYPE} == "ANSIBLE" ]]; then + ######################################## + # Make sure we dont lint certain files # + ######################################## + if [[ ${FILE} == *"vault.yml"* ]] || [[ ${FILE} == *"galaxy.yml"* ]]; then + # This is a file we dont look at + continue + fi + + ################################ + # Lint the file with the rules # + ################################ + LINT_CMD=$( + cd "${GITHUB_WORKSPACE}/${TEST_CASE_FOLDER}/${INDVIDUAL_TEST_FOLDER}" || exit + ${LINTER_COMMAND} "${FILE}" 2>&1 + ) + elif [[ ${FILE_TYPE} == "POWERSHELL" ]] || [[ ${FILE_TYPE} == "ARM" ]]; then + ################################ + # Lint the file with the rules # + ################################ + # Need to run PowerShell commands using pwsh -c, also exit with exit code from inner subshell + LINT_CMD=$( + cd "${GITHUB_WORKSPACE}/${TEST_CASE_FOLDER}" || exit + pwsh -NoProfile -NoLogo -Command "${LINTER_COMMAND} ${FILE}; if (\${Error}.Count) { exit 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 + ################################ + # Lint the file with the rules # + ################################ + LINT_CMD=$( + cd "${GITHUB_WORKSPACE}/${TEST_CASE_FOLDER}" || exit + ${LINTER_COMMAND} "${FILE}" 2>&1 + ) + fi + + ####################### + # Load the error code # + ####################### + ERROR_CODE=$? + + ######################################## + # Increment counter that check was ran # + ######################################## + (("TESTS_RAN++")) + + ######################################## + # Check for if it was supposed to pass # + ######################################## + if [[ ${FILE_STATUS} == "good" ]]; then + ############################## + # Check the shell for errors # + ############################## + if [ ${ERROR_CODE} -ne 0 ]; then + ######### + # Error # + ######### + error "Found errors in [${LINTER_NAME}] linter!" + error "[${LINT_CMD}]" + error "Linter CMD:[${LINTER_COMMAND} ${FILE}]" + # Increment the error count + (("ERRORS_FOUND_${FILE_TYPE}++")) + else + ########### + # Success # + ########### + info " - File:${F[W]}[${FILE_NAME}]${F[B]} was linted with ${F[W]}[${LINTER_NAME}]${F[B]} successfully" + fi + ####################################################### + # Store the linting as a temporary file in TAP format # + ####################################################### + if IsTAP; then + OkTap "${TESTS_RAN}" "${FILE_NAME}" "${TMPFILE}" + fi + else + ####################################### + # File status = bad, this should fail # + ####################################### + ############################## + # Check the shell for errors # + ############################## + if [ ${ERROR_CODE} -eq 0 ]; then + ######### + # Error # + ######### + error "Found errors in [${LINTER_NAME}] linter!" + error "This file should have failed test case!" + error "Command run:${NC}[\$${LINT_CMD}]" + error "[${LINT_CMD}]" + error "Linter CMD:[${LINTER_COMMAND} ${FILE}]" + # Increment the error count + (("ERRORS_FOUND_${FILE_TYPE}++")) + else + ########### + # Success # + ########### + info " - File:${F[W]}[${FILE_NAME}]${F[B]} failed test case with ${F[W]}[${LINTER_NAME}]${F[B]} successfully" + fi + ####################################################### + # Store the linting as a temporary file in TAP format # + ####################################################### + if IsTAP; then + NotOkTap "${TESTS_RAN}" "${FILE_NAME}" "${TMPFILE}" + AddDetailedMessageIfEnabled "${LINT_CMD}" "${TMPFILE}" + fi fi - fi done - ################################# - # Generate report in TAP format # - ################################# - if IsTAP && [ ${INDEX} -gt 0 ] ; then - HeaderTap "${INDEX}" "${REPORT_OUTPUT_FILE}" - cat "${TMPFILE}" >> "${REPORT_OUTPUT_FILE}" + ########################################################################### + # Generate report in TAP format and validate with the expected TAP output # + ########################################################################### + if IsTAP && [ ${TESTS_RAN} -gt 0 ]; then + HeaderTap "${TESTS_RAN}" "${REPORT_OUTPUT_FILE}" + cat "${TMPFILE}" >> "${REPORT_OUTPUT_FILE}" + + ######################################################################## + # If expected TAP report exists then compare with the generated report # + ######################################################################## + EXPECTED_FILE="${GITHUB_WORKSPACE}/${TEST_CASE_FOLDER}/${INDVIDUAL_TEST_FOLDER}/reports/expected-${FILE_TYPE}.tap" + if [ -e "${EXPECTED_FILE}" ]; then + TMPFILE=$(mktemp -q "/tmp/diff-${FILE_TYPE}.XXXXXX") + ## Ignore white spaces, case sensitive + if ! diff -a -w -i "${EXPECTED_FILE}" "${REPORT_OUTPUT_FILE}" > "${TMPFILE}" 2>&1; then + ############################################# + # We failed to compare the reporting output # + ############################################# + error "Failed to assert TAP output:[${LINTER_NAME}]"! + info "Please validate the asserts!" + cat "${TMPFILE}" + exit 1 + else + # Success + info "Successfully validation in the expected TAP format for ${F[W]}[${LINTER_NAME}]" + fi + else + warn "No TAP expected file found at:[${EXPECTED_FILE}]" + info "skipping report assertions" + ##################################### + # Append the file type to the array # + ##################################### + WARNING_ARRAY_TEST+=("${FILE_TYPE}") + fi + fi + + ############################## + # Validate we ran some tests # + ############################## + if [ "${TESTS_RAN}" -eq 0 ]; then + ################################################# + # We failed to find files and no tests were ran # + ################################################# + error "Failed to find any tests ran for the Linter:[${LINTER_NAME}]"! + fatal "Please validate logic or that tests exist!" + fi +} +################################################################################ +#### Function RunTestCases ##################################################### +function RunTestCases() { + # This loop will run the test cases and exclude user code + # This is called from the automation process to validate new code + # When a PR is opened, the new code is validated with the default branch + # version of linter.sh, and a new container is built with the latest codebase + # for testing. That container is spun up, and ran, + # with the flag: TEST_CASE_RUN=true + # So that the new code can be validated against the test cases + + ################# + # Header prints # + ################# + info "----------------------------------------------" + info "-------------- TEST CASE RUN -----------------" + info "----------------------------------------------" + + ####################### + # Test case languages # + ####################### + # TestCodebase "Language" "Linter" "Linter-command" "Regex to find files" "Test Folder" + TestCodebase "ANSIBLE" "ansible-lint" "ansible-lint -v -c ${ANSIBLE_LINTER_RULES}" ".*\.\(yml\|yaml\)\$" "ansible" + TestCodebase "ARM" "arm-ttk" "Import-Module ${ARM_TTK_PSD1} ; \${config} = \$(Import-PowerShellDataFile -Path ${ARM_LINTER_RULES}) ; Test-AzTemplate @config -TemplatePath" ".*\.\(json\)\$" "arm" + TestCodebase "BASH" "shellcheck" "shellcheck --color" ".*\.\(sh\|bash\|dash\|ksh\)\$" "shell" + TestCodebase "CLOUDFORMATION" "cfn-lint" "cfn-lint --config-file ${CLOUDFORMATION_LINTER_RULES}" ".*\.\(json\|yml\|yaml\)\$" "cloudformation" + TestCodebase "CLOJURE" "clj-kondo" "clj-kondo --config ${CLOJURE_LINTER_RULES} --lint" ".*\.\(clj\|cljs\|cljc\|edn\)\$" "clojure" + TestCodebase "COFFEESCRIPT" "coffeelint" "coffeelint -f ${COFFEESCRIPT_LINTER_RULES}" ".*\.\(coffee\)\$" "coffeescript" + TestCodebase "CSS" "stylelint" "stylelint --config ${CSS_LINTER_RULES}" ".*\.\(css\)\$" "css" + TestCodebase "DART" "dart" "dartanalyzer --fatal-infos --fatal-warnings --options ${DART_LINTER_RULES}" ".*\.\(dart\)\$" "dart" + TestCodebase "DOCKER" "dockerfilelint" "dockerfilelint -c ${DOCKER_LINTER_RULES}" ".*\(Dockerfile\)\$" "docker" + TestCodebase "EDITORCONFIG" "editorconfig-checker" "editorconfig-checker" ".*\.ext$" "editorconfig-checker" + TestCodebase "ENV" "dotenv-linter" "dotenv-linter" ".*\.\(env\)\$" "env" + 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 "JAVASCRIPT_ES" "eslint" "eslint --no-eslintrc -c ${JAVASCRIPT_LINTER_RULES}" ".*\.\(js\)\$" "javascript" + TestCodebase "JAVASCRIPT_STANDARD" "standard" "standard ${JAVASCRIPT_STANDARD_LINTER_RULES}" ".*\.\(js\)\$" "javascript" + TestCodebase "JSON" "jsonlint" "jsonlint" ".*\.\(json\)\$" "json" + TestCodebase "KOTLIN" "ktlint" "ktlint" ".*\.\(kt\|kts\)\$" "kotlin" + TestCodebase "LUA" "lua" "luacheck" ".*\.\(lua\)\$" "lua" + TestCodebase "MARKDOWN" "markdownlint" "markdownlint -c ${MARKDOWN_LINTER_RULES}" ".*\.\(md\)\$" "markdown" + TestCodebase "PERL" "perl" "perl -Mstrict -cw" ".*\.\(pl\)\$" "perl" + TestCodebase "PHP" "php" "php -l" ".*\.\(php\)\$" "php" + TestCodebase "PHP_PHPSTAN" "phpstan" "phpstan analyse --no-progress --no-ansi -c ${PHPSTAN_LINTER_RULES}" ".*\.\(php\)\$" "php" + TestCodebase "OPENAPI" "spectral" "spectral lint -r ${OPENAPI_LINTER_RULES}" ".*\.\(ymlopenapi\|jsonopenapi\)\$" "openapi" + TestCodebase "POWERSHELL" "pwsh" "Invoke-ScriptAnalyzer -EnableExit -Settings ${POWERSHELL_LINTER_RULES} -Path" ".*\.\(ps1\|psm1\|psd1\|ps1xml\|pssc\|psrc\|cdxml\)\$" "powershell" + TestCodebase "PROTOBUF" "protolint" "protolint lint --config_path ${PROTOBUF_LINTER_RULES}" ".*\.\(proto\)\$" "protobuf" + TestCodebase "PYTHON_PYLINT" "pylint" "pylint --rcfile ${PYTHON_PYLINT_LINTER_RULES}" ".*\.\(py\)\$" "python" + TestCodebase "PYTHON_FLAKE8" "flake8" "flake8 --config ${PYTHON_FLAKE8_LINTER_RULES}" ".*\.\(py\)\$" "python" + TestCodebase "RAKU" "raku" "raku -c" ".*\.\(raku\|rakumod\|rakutest\|pm6\|pl6\|p6\)\$" "raku" + TestCodebase "RUBY" "rubocop" "rubocop -c ${RUBY_LINTER_RULES}" ".*\.\(rb\)\$" "ruby" + TestCodebase "STATES" "asl-validator" "asl-validator --json-path" ".*\.\(json\)\$" "states" + TestCodebase "TERRAFORM" "tflint" "tflint -c ${TERRAFORM_LINTER_RULES}" ".*\.\(tf\)\$" "terraform" + TestCodebase "TERRAFORM_TERRASCAN" "terrascan" "terrascan -f " ".*\.\(tf\)\$" "terraform_terrascan" + TestCodebase "TYPESCRIPT_ES" "eslint" "eslint --no-eslintrc -c ${TYPESCRIPT_LINTER_RULES}" ".*\.\(ts\)\$" "typescript" + TestCodebase "TYPESCRIPT_STANDARD" "standard" "standard --parser @typescript-eslint/parser --plugin @typescript-eslint/eslint-plugin ${TYPESCRIPT_STANDARD_LINTER_RULES}" ".*\.\(ts\)\$" "typescript" + TestCodebase "XML" "xmllint" "xmllint" ".*\.\(xml\)\$" "xml" + TestCodebase "YAML" "yamllint" "yamllint -c ${YAML_LINTER_RULES}" ".*\.\(yml\|yaml\)\$" "yml" + + ################# + # Footer prints # + ################# + # Call the footer to display run information + # and exit with error code + Footer +} +################################################################################ +#### Function LintAnsibleFiles ################################################# +function LintAnsibleFiles() { + ###################### + # Create Print Array # + ###################### + PRINT_ARRAY=() + + ################ + # print header # + ################ + PRINT_ARRAY+=("") + PRINT_ARRAY+=("----------------------------------------------") + PRINT_ARRAY+=("----------------------------------------------") + PRINT_ARRAY+=("Linting [Ansible] files...") + PRINT_ARRAY+=("----------------------------------------------") + PRINT_ARRAY+=("----------------------------------------------") + + ###################### + # Name of the linter # + ###################### + LINTER_NAME="ansible-lint" + + ########################################### + # Validate we have ansible-lint installed # + ########################################### + VALIDATE_INSTALL_CMD=$(command -v "${LINTER_NAME}" 2>&1) + + ####################### + # Load the error code # + ####################### + ERROR_CODE=$? + + ############################## + # Check the shell for errors # + ############################## + if [ ${ERROR_CODE} -ne 0 ]; then + # Failed + error "Failed to find ${LINTER_NAME} in system!" + fatal "[${VALIDATE_INSTALL_CMD}]" + else + # Success + debug "Successfully found binary in system" + debug "Location:[${VALIDATE_INSTALL_CMD}]" + fi + + ########################## + # Initialize empty Array # + ########################## + LIST_FILES=() + + ####################### + # Create flag to skip # + ####################### + SKIP_FLAG=0 + + ###################################################### + # Only go into ansible linter if we have base folder # + ###################################################### + if [ -d "${ANSIBLE_DIRECTORY}" ]; then + + ################################# + # Get list of all files to lint # + ################################# + mapfile -t LIST_FILES < <(ls "${ANSIBLE_DIRECTORY}"/*.{yaml,yml} 2>&1) + + ############################################################### + # Set the list to empty if only MD and TXT files were changed # + ############################################################### + # No need to run the full ansible checks on read only file changes + if [ "${READ_ONLY_CHANGE_FLAG}" -eq 0 ]; then + ########################## + # Set the array to empty # + ########################## + LIST_FILES=() + ################################### + # Send message that were skipping # + ################################### + debug "- Skipping Ansible lint run as file(s) that were modified were read only..." + ############################ + # Create flag to skip loop # + ############################ + SKIP_FLAG=1 + fi + + #################################### + # Check if we have data to look at # + #################################### + if [ ${SKIP_FLAG} -eq 0 ]; then + for LINE in "${PRINT_ARRAY[@]}"; do + ######################### + # Print the header line # + ######################### + info "${LINE}" + done + fi + + ######################################## + # Prepare context if TAP output format # + ######################################## + if IsTAP; then + TMPFILE=$(mktemp -q "/tmp/super-linter-${FILE_TYPE}.XXXXXX") + INDEX=0 + mkdir -p "${REPORT_OUTPUT_FOLDER}" + REPORT_OUTPUT_FILE="${REPORT_OUTPUT_FOLDER}/super-linter-${FILE_TYPE}.${OUTPUT_FORMAT}" + fi + + ################## + # Lint the files # + ################## + for FILE in "${LIST_FILES[@]}"; do + + ######################################## + # Make sure we dont lint certain files # + ######################################## + if [[ ${FILE} == *"vault.yml"* ]] || [[ ${FILE} == *"galaxy.yml"* ]]; then + # This is a file we dont look at + continue + fi + + ################################## + # Increase the linted file index # + ################################## + (("INDEX++")) + + #################### + # Get the filename # + #################### + FILE_NAME=$(basename "${ANSIBLE_DIRECTORY}/${FILE}" 2>&1) + + ############## + # File print # + ############## + info "---------------------------" + info "File:[${FILE}]" + + ################################ + # Lint the file with the rules # + ################################ + LINT_CMD=$("${LINTER_NAME}" -v -c "${ANSIBLE_LINTER_RULES}" "${ANSIBLE_DIRECTORY}/${FILE}" 2>&1) + + ####################### + # Load the error code # + ####################### + ERROR_CODE=$? + + ############################## + # Check the shell for errors # + ############################## + if [ ${ERROR_CODE} -ne 0 ]; then + ######### + # Error # + ######### + error "Found errors in [${LINTER_NAME}] linter!" + error "[${LINT_CMD}]" + # Increment error count + ((ERRORS_FOUND_ANSIBLE++)) + + ####################################################### + # Store the linting as a temporary file in TAP format # + ####################################################### + if IsTAP; then + NotOkTap "${INDEX}" "${FILE}" "${TMPFILE}" + AddDetailedMessageIfEnabled "${LINT_CMD}" "${TMPFILE}" + fi + + else + ########### + # Success # + ########### + info " - File:${F[W]}[${FILE_NAME}]${F[B]} was linted with ${F[W]}[${LINTER_NAME}]${F[B]} successfully" + + ####################################################### + # Store the linting as a temporary file in TAP format # + ####################################################### + if IsTAP; then + OkTap "${INDEX}" "${FILE}" "${TMPFILE}" + fi + fi + done + + ################################# + # Generate report in TAP format # + ################################# + if IsTAP && [ ${INDEX} -gt 0 ]; then + HeaderTap "${INDEX}" "${REPORT_OUTPUT_FILE}" + cat "${TMPFILE}" >> "${REPORT_OUTPUT_FILE}" + fi + else + ######################## + # No Ansible dir found # + ######################## + warn "No Ansible base directory found at:[${ANSIBLE_DIRECTORY}]" + debug "skipping ansible lint" fi - else - ######################## - # No Ansible dir found # - ######################## - warn "No Ansible base directory found at:[${ANSIBLE_DIRECTORY}]" - debug "skipping ansible lint" - fi } ################################################################################ #### Function IsTap ############################################################ function IsTAP() { - if [ "${OUTPUT_FORMAT}" == "tap" ] ; then - return 0 - else - return 1 - fi + if [ "${OUTPUT_FORMAT}" == "tap" ]; then + return 0 + else + return 1 + fi } ################################################################################ #### Function TransformTAPDetails ############################################## function TransformTAPDetails() { - DATA=${1} - if [ -n "${DATA}" ] && [ "${OUTPUT_DETAILS}" == "detailed" ] ; then - ######################################################### - # Transform new lines to \\n, remove colours and colons # - ######################################################### - echo "${DATA}" | awk 'BEGIN{RS="\n";ORS="\\n"}1' | sed -r "s/\x1B\[([0-9]{1,3}(;[0-9]{1,2})?)?[mGK]//g" | tr ':' ' ' - fi + DATA=${1} + if [ -n "${DATA}" ] && [ "${OUTPUT_DETAILS}" == "detailed" ]; then + ######################################################### + # Transform new lines to \\n, remove colours and colons # + ######################################################### + echo "${DATA}" | awk 'BEGIN{RS="\n";ORS="\\n"}1' | sed -r "s/\x1B\[([0-9]{1,3}(;[0-9]{1,2})?)?[mGK]//g" | tr ':' ' ' + fi } ################################################################################ #### Function HeaderTap ######################################################## function HeaderTap() { - ################ - # Pull in Vars # - ################ - INDEX="${1}" # File being validated - OUTPUT_FILE="${2}" # Output location + ################ + # Pull in Vars # + ################ + INDEX="${1}" # File being validated + OUTPUT_FILE="${2}" # Output location - ################### - # Print the goods # - ################### - printf "TAP version 13\n1..%s\n" "${INDEX}" > "${OUTPUT_FILE}" + ################### + # Print the goods # + ################### + printf "TAP version 13\n1..%s\n" "${INDEX}" > "${OUTPUT_FILE}" } ################################################################################ #### Function OkTap ############################################################ function OkTap() { - ################ - # Pull in Vars # - ################ - INDEX="${1}" # Location - FILE="${2}" # File being validated - TEMP_FILE="${3}" # Temp file location + ################ + # Pull in Vars # + ################ + INDEX="${1}" # Location + FILE="${2}" # File being validated + TEMP_FILE="${3}" # Temp file location - ################### - # Print the goods # - ################### - echo "ok ${INDEX} - ${FILE}" >> "${TEMP_FILE}" + ################### + # Print the goods # + ################### + echo "ok ${INDEX} - ${FILE}" >> "${TEMP_FILE}" } ################################################################################ #### Function NotOkTap ######################################################### function NotOkTap() { - ################ - # Pull in Vars # - ################ - INDEX="${1}" # Location - FILE="${2}" # File being validated - TEMP_FILE="${3}" # Temp file location + ################ + # Pull in Vars # + ################ + INDEX="${1}" # Location + FILE="${2}" # File being validated + TEMP_FILE="${3}" # Temp file location - ################### - # Print the goods # - ################### - echo "not ok ${INDEX} - ${FILE}" >> "${TEMP_FILE}" + ################### + # Print the goods # + ################### + echo "not ok ${INDEX} - ${FILE}" >> "${TEMP_FILE}" } ################################################################################ #### Function AddDetailedMessageIfEnabled ###################################### function AddDetailedMessageIfEnabled() { - ################ - # Pull in Vars # - ################ - LINT_CMD="${1}" # Linter command - TEMP_FILE="${2}" # Temp file + ################ + # Pull in Vars # + ################ + LINT_CMD="${1}" # Linter command + TEMP_FILE="${2}" # Temp file - #################### - # Check the return # - #################### - DETAILED_MSG=$(TransformTAPDetails "${LINT_CMD}") - if [ -n "${DETAILED_MSG}" ] ; then - printf " ---\n message: %s\n ...\n" "${DETAILED_MSG}" >> "${TEMP_FILE}" - fi + #################### + # Check the return # + #################### + DETAILED_MSG=$(TransformTAPDetails "${LINT_CMD}") + if [ -n "${DETAILED_MSG}" ]; then + printf " ---\n message: %s\n ...\n" "${DETAILED_MSG}" >> "${TEMP_FILE}" + fi } From d49f6ce71f880141bcef618a63a1e930b8ab3b00 Mon Sep 17 00:00:00 2001 From: Eric Nemchik Date: Thu, 30 Jul 2020 15:19:21 -0500 Subject: [PATCH 100/135] Remove sudo --- lib/linter.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/linter.sh b/lib/linter.sh index e106dd0e..231fa185 100755 --- a/lib/linter.sh +++ b/lib/linter.sh @@ -1037,7 +1037,7 @@ Footer() { cleanup() { local -ri EXIT_CODE=$? - sudo sh -c "cat ${LOG_TEMP} >> ${GITHUB_WORKSPACE}/${LOG_FILE}" || true + sh -c "cat ${LOG_TEMP} >> ${GITHUB_WORKSPACE}/${LOG_FILE}" || true exit ${EXIT_CODE} trap - 0 1 2 3 6 14 15 From a03fd743f1f00c8f9edc50d57193f21c81267446 Mon Sep 17 00:00:00 2001 From: Eric Nemchik Date: Thu, 30 Jul 2020 15:26:01 -0500 Subject: [PATCH 101/135] Document new variables --- README.md | 71 ++++++++++++++++++++++++++++--------------------------- 1 file changed, 36 insertions(+), 35 deletions(-) diff --git a/README.md b/README.md index 7cc6f0ac..68c4c1ed 100644 --- a/README.md +++ b/README.md @@ -41,39 +41,39 @@ The design of the **Super-Linter** is currently to allow linting to occur in **G Developers on **GitHub** can call the **GitHub Action** to lint their code base with the following list of linters: -| _Language_ | _Linter_ | -| -------------------------------- | ------------------------------------------------------------------------------------ | -| **Ansible** | [ansible-lint](https://github.com/ansible/ansible-lint) | -| **Azure Resource Manager (ARM)** | [arm-ttk](https://github.com/azure/arm-ttk) | -| **AWS CloudFormation templates** | [cfn-lint](https://github.com/aws-cloudformation/cfn-python-lint/) | -| **CSS** | [stylelint](https://stylelint.io/) | -| **Clojure** | [clj-kondo](https://github.com/borkdude/clj-kondo) | -| **CoffeeScript** | [coffeelint](https://coffeelint.github.io/) | -| **Dart** | [dartanalyzer](https://dart.dev/guides/language/analysis-options) | -| **Dockerfile** | [dockerfilelint](https://github.com/replicatedhq/dockerfilelint.git) | -| **EDITORCONFIG** | [editorconfig-checker](https://github.com/editorconfig-checker/editorconfig-checker) | -| **ENV** | [dotenv-linter](https://github.com/dotenv-linter/dotenv-linter) | -| **Golang** | [golangci-lint](https://github.com/golangci/golangci-lint) | -| **Groovy** | [npm-groovy-lint](https://github.com/nvuillam/npm-groovy-lint) | -| **HTMLHint** | [HTMLHint](https://github.com/htmlhint/HTMLHint) | -| **JavaScript** | [eslint](https://eslint.org/) [standard js](https://standardjs.com/) | -| **JSON** | [jsonlint](https://github.com/zaach/jsonlint) | -| **Kotlin** | [ktlint](https://github.com/pinterest/ktlint) | -| **Lua** | [luacheck](https://github.com/luarocks/luacheck) | -| **Markdown** | [markdownlint](https://github.com/igorshubovych/markdownlint-cli#readme) | -| **OpenAPI** | [spectral](https://github.com/stoplightio/spectral) | -| **Perl** | [perl](https://pkgs.alpinelinux.org/package/edge/main/x86/perl) | -| **PHP** | [PHP](https://www.php.net/) | -| **PowerShell** | [PSScriptAnalyzer](https://github.com/PowerShell/Psscriptanalyzer) | -| **Protocol Buffers** | [protolint](https://github.com/yoheimuta/protolint) | -| **Python3** | [pylint](https://www.pylint.org/) [flake8](https://flake8.pycqa.org/en/latest/) | -| **Raku** | [raku](https://raku.org) | -| **Ruby** | [RuboCop](https://github.com/rubocop-hq/rubocop) | -| **Shell** | [Shellcheck](https://github.com/koalaman/shellcheck) | -| **Terraform** | [tflint](https://github.com/terraform-linters/tflint) [terrascan](https://github.com/accurics/terrascan) | -| **TypeScript** | [eslint](https://eslint.org/) [standard js](https://standardjs.com/) | -| **XML** | [LibXML](http://xmlsoft.org/) | -| **YAML** | [YamlLint](https://github.com/adrienverge/yamllint) | +| _Language_ | _Linter_ | +| -------------------------------- | -------------------------------------------------------------------------------------------------------- | +| **Ansible** | [ansible-lint](https://github.com/ansible/ansible-lint) | +| **Azure Resource Manager (ARM)** | [arm-ttk](https://github.com/azure/arm-ttk) | +| **AWS CloudFormation templates** | [cfn-lint](https://github.com/aws-cloudformation/cfn-python-lint/) | +| **CSS** | [stylelint](https://stylelint.io/) | +| **Clojure** | [clj-kondo](https://github.com/borkdude/clj-kondo) | +| **CoffeeScript** | [coffeelint](https://coffeelint.github.io/) | +| **Dart** | [dartanalyzer](https://dart.dev/guides/language/analysis-options) | +| **Dockerfile** | [dockerfilelint](https://github.com/replicatedhq/dockerfilelint.git) | +| **EDITORCONFIG** | [editorconfig-checker](https://github.com/editorconfig-checker/editorconfig-checker) | +| **ENV** | [dotenv-linter](https://github.com/dotenv-linter/dotenv-linter) | +| **Golang** | [golangci-lint](https://github.com/golangci/golangci-lint) | +| **Groovy** | [npm-groovy-lint](https://github.com/nvuillam/npm-groovy-lint) | +| **HTMLHint** | [HTMLHint](https://github.com/htmlhint/HTMLHint) | +| **JavaScript** | [eslint](https://eslint.org/) [standard js](https://standardjs.com/) | +| **JSON** | [jsonlint](https://github.com/zaach/jsonlint) | +| **Kotlin** | [ktlint](https://github.com/pinterest/ktlint) | +| **Lua** | [luacheck](https://github.com/luarocks/luacheck) | +| **Markdown** | [markdownlint](https://github.com/igorshubovych/markdownlint-cli#readme) | +| **OpenAPI** | [spectral](https://github.com/stoplightio/spectral) | +| **Perl** | [perl](https://pkgs.alpinelinux.org/package/edge/main/x86/perl) | +| **PHP** | [PHP](https://www.php.net/) | +| **PowerShell** | [PSScriptAnalyzer](https://github.com/PowerShell/Psscriptanalyzer) | +| **Protocol Buffers** | [protolint](https://github.com/yoheimuta/protolint) | +| **Python3** | [pylint](https://www.pylint.org/) [flake8](https://flake8.pycqa.org/en/latest/) | +| **Raku** | [raku](https://raku.org) | +| **Ruby** | [RuboCop](https://github.com/rubocop-hq/rubocop) | +| **Shell** | [Shellcheck](https://github.com/koalaman/shellcheck) | +| **Terraform** | [tflint](https://github.com/terraform-linters/tflint) [terrascan](https://github.com/accurics/terrascan) | +| **TypeScript** | [eslint](https://eslint.org/) [standard js](https://standardjs.com/) | +| **XML** | [LibXML](http://xmlsoft.org/) | +| **YAML** | [YamlLint](https://github.com/adrienverge/yamllint) | ## How to use @@ -176,6 +176,8 @@ and won't run anything unexpected. | **DISABLE_ERRORS** | `false` | Flag to have the linter complete with exit code 0 even if errors were detected. | | **JAVASCRIPT_ES_CONFIG_FILE** | `.eslintrc.yml` | Filename for [eslint configuration](https://eslint.org/docs/user-guide/configuring#configuration-file-formats) (ex: `.eslintrc.yml`, `.eslintrc.json`) | | **LINTER_RULES_PATH** | `.github/linters` | Directory for all linter configuration rules. | +| **LOG_FILE** | `super-linter.log` | The file name for outputting logs. All output is sent to the log file regardless of `LOG_LEVEL`. | +| **LOG_LEVEL** | `VERBOSE` | How much output the script will generate to the console. One of `VERBOSE`, `DEBUG` or `TRACE`. | | **MULTI_STATUS** | `true` | A status API is made for each language that is linted to make visual parsing easier. | | **OUTPUT_FORMAT** | `none` | The report format to be generated, besides the stdout one. Output format of tap is currently using v13 of the specification. Supported formats: tap | | **OUTPUT_FOLDER** | `super-linter.report` | The location where the output reporting will be generated to. Output folder must not previously exist. | @@ -219,7 +221,7 @@ and won't run anything unexpected. | **VALIDATE_RUBY** | `true` | Flag to enable or disable the linting process of the Ruby language. | | **VALIDATE_STATES** | `true` | Flag to enable or disable the linting process for AWS States Language. | | **VALIDATE_TERRAFORM** | `true` | Flag to enable or disable the linting process of the Terraform language. | -| **VALIDATE_TERRAFORM_TERRASCAN** | `false` | Flag to enable or disable the linting process of the Terraform language for security related issues. | +| **VALIDATE_TERRAFORM_TERRASCAN** | `false` | Flag to enable or disable the linting process of the Terraform language for security related issues. | | **VALIDATE_TSX** | `true` | Flag to enable or disable the linting process for tsx files (Utilizing: eslint) | | **VALIDATE_TYPESCRIPT_ES** | `true` | Flag to enable or disable the linting process of the Typescript language. (Utilizing: eslint) | | **VALIDATE_TYPESCRIPT_STANDARD** | `true` | Flag to enable or disable the linting process of the Typescript language. (Utilizing: standard) | @@ -227,7 +229,6 @@ and won't run anything unexpected. | **VALIDATE_YAML** | `true` | Flag to enable or disable the linting process of the YAML language. | | **YAML_CONFIG_FILE** | `.yaml-lint.yml` | Filename for [Yamllint configuration](https://yamllint.readthedocs.io/en/stable/configuration.html) (ex: `.yaml-lint.yml`, `.yamllint.yml`) | - ### Template rules files You can use the **GitHub** **Super-Linter** _with_ or _without_ your own personal rules sets. This allows for greater flexibility for each individual code base. The Template rules all try to follow the standards we believe should be enabled at the basic level. From 0e547aa871176a6916f44b80a175a2c457185a4a Mon Sep 17 00:00:00 2001 From: Eric Nemchik Date: Thu, 30 Jul 2020 15:39:05 -0500 Subject: [PATCH 102/135] Format (fix indentation) --- lib/buildFileList.sh | 996 ++++++++++++------------ lib/linter.sh | 1748 +++++++++++++++++++++--------------------- lib/log.sh | 54 +- lib/termColors.sh | 32 +- lib/validation.sh | 316 ++++---- lib/worker.sh | 1596 +++++++++++++++++++------------------- 6 files changed, 2371 insertions(+), 2371 deletions(-) diff --git a/lib/buildFileList.sh b/lib/buildFileList.sh index a98e885f..3e52de0f 100755 --- a/lib/buildFileList.sh +++ b/lib/buildFileList.sh @@ -10,522 +10,522 @@ ################################################################################ #### Function BuildFileList #################################################### function BuildFileList() { - # Need to build a list of all files changed - # This can be pulled from the GITHUB_EVENT_PATH payload + # Need to build a list of all files changed + # This can be pulled from the GITHUB_EVENT_PATH payload - ################ - # print header # - ################ - debug "----------------------------------------------" - debug "Pulling in code history and branches..." + ################ + # print header # + ################ + debug "----------------------------------------------" + debug "Pulling in code history and branches..." - ################################################################################# - # Switch codebase back to the default branch to get a list of all files changed # - ################################################################################# - SWITCH_CMD=$( - git -C "${GITHUB_WORKSPACE}" pull --quiet - git -C "${GITHUB_WORKSPACE}" checkout "${DEFAULT_BRANCH}" 2>&1 - ) + ################################################################################# + # Switch codebase back to the default branch to get a list of all files changed # + ################################################################################# + SWITCH_CMD=$( + git -C "${GITHUB_WORKSPACE}" pull --quiet + git -C "${GITHUB_WORKSPACE}" checkout "${DEFAULT_BRANCH}" 2>&1 + ) - ####################### - # Load the error code # - ####################### - ERROR_CODE=$? + ####################### + # Load the error code # + ####################### + ERROR_CODE=$? - ############################## - # Check the shell for errors # - ############################## - if [ ${ERROR_CODE} -ne 0 ]; then - # Error - info "Failed to switch to ${DEFAULT_BRANCH} branch to get files changed!" - fatal "[${SWITCH_CMD}]" - fi + ############################## + # Check the shell for errors # + ############################## + if [ ${ERROR_CODE} -ne 0 ]; then + # Error + info "Failed to switch to ${DEFAULT_BRANCH} branch to get files changed!" + fatal "[${SWITCH_CMD}]" + fi - ################ - # print header # - ################ - debug "----------------------------------------------" - debug "Generating Diff with:[git diff --name-only '${DEFAULT_BRANCH}..${GITHUB_SHA}' --diff-filter=d]" + ################ + # print header # + ################ + debug "----------------------------------------------" + debug "Generating Diff with:[git diff --name-only '${DEFAULT_BRANCH}..${GITHUB_SHA}' --diff-filter=d]" - ################################################# - # Get the Array of files changed in the commits # - ################################################# - mapfile -t RAW_FILE_ARRAY < <(git -C "${GITHUB_WORKSPACE}" diff --name-only "${DEFAULT_BRANCH}..${GITHUB_SHA}" --diff-filter=d 2>&1) + ################################################# + # Get the Array of files changed in the commits # + ################################################# + mapfile -t RAW_FILE_ARRAY < <(git -C "${GITHUB_WORKSPACE}" diff --name-only "${DEFAULT_BRANCH}..${GITHUB_SHA}" --diff-filter=d 2>&1) - ####################### - # Load the error code # - ####################### - ERROR_CODE=$? + ####################### + # Load the error code # + ####################### + ERROR_CODE=$? - ############################## - # Check the shell for errors # - ############################## - if [ ${ERROR_CODE} -ne 0 ]; then - # Error - error "Failed to gain a list of all files changed!" - fatal "[${RAW_FILE_ARRAY[*]}]" - fi + ############################## + # Check the shell for errors # + ############################## + if [ ${ERROR_CODE} -ne 0 ]; then + # Error + error "Failed to gain a list of all files changed!" + fatal "[${RAW_FILE_ARRAY[*]}]" + fi - ################################################ - # Iterate through the array of all files found # - ################################################ - info "----------------------------------------------" - info "Files that have been modified in the commit(s):" - for FILE in "${RAW_FILE_ARRAY[@]}"; do - ########################### - # Get the files extension # - ########################### - # Extract just the file extension - FILE_TYPE=${FILE##*.} - # To lowercase - FILE_TYPE=${FILE_TYPE,,} + ################################################ + # Iterate through the array of all files found # + ################################################ + info "----------------------------------------------" + info "Files that have been modified in the commit(s):" + for FILE in "${RAW_FILE_ARRAY[@]}"; do + ########################### + # Get the files extension # + ########################### + # Extract just the file extension + FILE_TYPE=${FILE##*.} + # To lowercase + FILE_TYPE=${FILE_TYPE,,} - ############## - # Print file # - ############## - info "File:[${FILE}], File_type:[${FILE_TYPE}]" + ############## + # Print file # + ############## + info "File:[${FILE}], File_type:[${FILE_TYPE}]" - ######### - # DEBUG # - ######### - debug "FILE_TYPE:[${FILE_TYPE}]" + ######### + # DEBUG # + ######### + debug "FILE_TYPE:[${FILE_TYPE}]" + ################################ + # Get the CLOUDFORMATION files # + ################################ + if [ "${FILE_TYPE}" == "yml" ] || [ "${FILE_TYPE}" == "yaml" ]; then + ################################ + # Append the file to the array # + ################################ + FILE_ARRAY_YAML+=("${FILE}") + ########################################################## + # Set the READ_ONLY_CHANGE_FLAG since this could be exec # + ########################################################## + READ_ONLY_CHANGE_FLAG=1 + + ##################################### + # Check if the file is CFN template # + ##################################### + if DetectCloudFormationFile "${FILE}"; then ################################ - # Get the CLOUDFORMATION files # + # Append the file to the array # ################################ - if [ "${FILE_TYPE}" == "yml" ] || [ "${FILE_TYPE}" == "yaml" ]; then - ################################ - # Append the file to the array # - ################################ - FILE_ARRAY_YAML+=("${FILE}") - ########################################################## - # Set the READ_ONLY_CHANGE_FLAG since this could be exec # - ########################################################## - READ_ONLY_CHANGE_FLAG=1 + FILE_ARRAY_CLOUDFORMATION+=("${FILE}") - ##################################### - # Check if the file is CFN template # - ##################################### - if DetectCloudFormationFile "${FILE}"; then - ################################ - # Append the file to the array # - ################################ - FILE_ARRAY_CLOUDFORMATION+=("${FILE}") + ########################################################## + # Set the READ_ONLY_CHANGE_FLAG since this could be exec # + ########################################################## + READ_ONLY_CHANGE_FLAG=1 + fi + ###################### + # Get the JSON files # + ###################### + elif [ "${FILE_TYPE}" == "json" ]; then + ################################ + # Append the file to the array # + ################################ + FILE_ARRAY_JSON+=("${FILE}") + ############################ + # Check if file is OpenAPI # + ############################ + if DetectOpenAPIFile "${FILE}"; then + ################################ + # Append the file to the array # + ################################ + FILE_ARRAY_OPENAPI+=("${FILE}") + fi + ############################ + # Check if file is ARM # + ############################ + if DetectARMFile "${FILE}"; then + ################################ + # Append the file to the array # + ################################ + FILE_ARRAY_ARM+=("${FILE}") + fi + ##################################### + # Check if the file is CFN template # + ##################################### + if DetectCloudFormationFile "${FILE}"; then + ################################ + # Append the file to the array # + ################################ + FILE_ARRAY_CLOUDFORMATION+=("${FILE}") + fi + ############################################ + # Check if the file is AWS States Language # + ############################################ + if DetectAWSStatesFIle "${FILE}"; then + ################################ + # Append the file to the array # + ################################ + FILE_ARRAY_STATES+=("${FILE}") + fi + ########################################################## + # Set the READ_ONLY_CHANGE_FLAG since this could be exec # + ########################################################## + READ_ONLY_CHANGE_FLAG=1 + ##################### + # Get the XML files # + ##################### + elif [ "${FILE_TYPE}" == "xml" ]; then + ################################ + # Append the file to the array # + ################################ + FILE_ARRAY_XML+=("${FILE}") + ########################################################## + # Set the READ_ONLY_CHANGE_FLAG since this could be exec # + ########################################################## + READ_ONLY_CHANGE_FLAG=1 + ########################## + # Get the MARKDOWN files # + ########################## + elif [ "${FILE_TYPE}" == "md" ]; then + ################################ + # Append the file to the array # + ################################ + FILE_ARRAY_MARKDOWN+=("${FILE}") + ###################### + # Get the BASH files # + ###################### + elif [ "${FILE_TYPE}" == "sh" ]; then + ################################ + # Append the file to the array # + ################################ + FILE_ARRAY_BASH+=("${FILE}") + ########################################################## + # Set the READ_ONLY_CHANGE_FLAG since this could be exec # + ########################################################## + READ_ONLY_CHANGE_FLAG=1 + ###################### + # Get the PERL files # + ###################### + elif [ "${FILE_TYPE}" == "pl" ]; then + ################################ + # Append the file to the array # + ################################ + FILE_ARRAY_PERL+=("${FILE}") + ########################################################## + # Set the READ_ONLY_CHANGE_FLAG since this could be exec # + ########################################################## + READ_ONLY_CHANGE_FLAG=1 + ###################### + # Get the RAKU files # + ###################### + elif [ "${FILE_TYPE}" == "raku" ] || [ "${FILE_TYPE}" == "rakumod" ] || + [ "${FILE_TYPE}" == "rakutest" ] || [ "${FILE_TYPE}" == "pm6" ] || + [ "${FILE_TYPE}" == "pl6" ] || [ "${FILE_TYPE}" == "p6" ]; then + ################################ + # Append the file to the array # + ################################ + FILE_ARRAY_RAKU+=("${FILE}") + ########################################################## + # Set the READ_ONLY_CHANGE_FLAG since this could be exec # + ########################################################## + READ_ONLY_CHANGE_FLAG=1 + ###################### + # Get the PHP files # + ###################### + elif [ "${FILE_TYPE}" == "php" ]; then + ################################ + # Append the file to the array # + ################################ + FILE_ARRAY_PHP+=("${FILE}") + FILE_ARRAY_PHP_PHPSTAN+=("${FILE}") + ########################################################## + # Set the READ_ONLY_CHANGE_FLAG since this could be exec # + ########################################################## + READ_ONLY_CHANGE_FLAG=1 + ###################### + # Get the RUBY files # + ###################### + elif [ "${FILE_TYPE}" == "rb" ]; then + ################################ + # Append the file to the array # + ################################ + FILE_ARRAY_RUBY+=("${FILE}") + ########################################################## + # Set the READ_ONLY_CHANGE_FLAG since this could be exec # + ########################################################## + READ_ONLY_CHANGE_FLAG=1 + ######################## + # Get the PYTHON files # + ######################## + elif [ "${FILE_TYPE}" == "py" ]; then + ################################ + # Append the file to the array # + ################################ + FILE_ARRAY_PYTHON_PYLINT+=("${FILE}") + FILE_ARRAY_PYTHON_FLAKE8+=("${FILE}") + ########################################################## + # Set the READ_ONLY_CHANGE_FLAG since this could be exec # + ########################################################## + READ_ONLY_CHANGE_FLAG=1 + ######################## + # Get the COFFEE files # + ######################## + elif [ "${FILE_TYPE}" == "coffee" ]; then + ################################ + # Append the file to the array # + ################################ + FILE_ARRAY_COFFEESCRIPT+=("${FILE}") + ########################################################## + # Set the READ_ONLY_CHANGE_FLAG since this could be exec # + ########################################################## + READ_ONLY_CHANGE_FLAG=1 + ############################ + # Get the JavaScript files # + ############################ + elif [ "${FILE_TYPE}" == "js" ]; then + ################################ + # Append the file to the array # + ################################ + FILE_ARRAY_JAVASCRIPT_ES+=("${FILE}") + FILE_ARRAY_JAVASCRIPT_STANDARD+=("${FILE}") + ########################################################## + # Set the READ_ONLY_CHANGE_FLAG since this could be exec # + ########################################################## + READ_ONLY_CHANGE_FLAG=1 + ############################ + # Get the JSX files # + ############################ + elif [ "${FILE_TYPE}" == "jsx" ]; then + ################################ + # Append the file to the array # + ################################ + FILE_ARRAY_JSX+=("${FILE}") + ########################################################## + # Set the READ_ONLY_CHANGE_FLAG since this could be exec # + ########################################################## + READ_ONLY_CHANGE_FLAG=1 + ############################ + # Get the TSX files # + ############################ + elif [ "${FILE_TYPE}" == "tsx" ]; then + ################################ + # Append the file to the array # + ################################ + FILE_ARRAY_TSX+=("${FILE}") + ########################################################## + # Set the READ_ONLY_CHANGE_FLAG since this could be exec # + ########################################################## + READ_ONLY_CHANGE_FLAG=1 + ######################## + # Get the Golang files # + ######################## + ############################ + # Get the TypeScript files # + ############################ + elif [ "${FILE_TYPE}" == "ts" ]; then + ################################ + # Append the file to the array # + ################################ + FILE_ARRAY_TYPESCRIPT_ES+=("${FILE}") + FILE_ARRAY_TYPESCRIPT_STANDARD+=("${FILE}") + ########################################################## + # Set the READ_ONLY_CHANGE_FLAG since this could be exec # + ########################################################## + READ_ONLY_CHANGE_FLAG=1 + ######################## + # Get the Golang files # + ######################## + elif [ "${FILE_TYPE}" == "go" ]; then + ################################ + # Append the file to the array # + ################################ + FILE_ARRAY_GO+=("${FILE}") + ########################################################## + # Set the READ_ONLY_CHANGE_FLAG since this could be exec # + ########################################################## + READ_ONLY_CHANGE_FLAG=1 + ########################### + # Get the Terraform files # + ########################### + elif [ "${FILE_TYPE}" == "tf" ]; then + ################################ + # Append the file to the array # + ################################ + FILE_ARRAY_TERRAFORM+=("${FILE}") + FILE_ARRAY_TERRAFORM_TERRASCAN+=("${FILE}") + ########################################################## + # Set the READ_ONLY_CHANGE_FLAG since this could be exec # + ########################################################## + READ_ONLY_CHANGE_FLAG=1 + ########################### + # Get the Powershell files # + ########################### + elif [ "${FILE_TYPE}" == "ps1" ]; then + ################################ + # Append the file to the array # + ################################ + FILE_ARRAY_POWERSHELL+=("${FILE}") + elif [ "${FILE_TYPE}" == "css" ]; then + ################################ + # Append the file to the array # + ################################ + FILE_ARRAY_CSS+=("${FILE}") + ########################################################## + # Set the READ_ONLY_CHANGE_FLAG since this could be exec # + ########################################################## + READ_ONLY_CHANGE_FLAG=1 + elif [ "${FILE_TYPE}" == "env" ]; then + ################################ + # Append the file to the array # + ################################ + FILE_ARRAY_ENV+=("${FILE}") + ########################################################## + # Set the READ_ONLY_CHANGE_FLAG since this could be exec # + ########################################################## + READ_ONLY_CHANGE_FLAG=1 + elif [ "${FILE_TYPE}" == "kt" ] || [ "${FILE_TYPE}" == "kts" ]; then + ################################ + # Append the file to the array # + ################################ + FILE_ARRAY_KOTLIN+=("${FILE}") + ########################################################## + # Set the READ_ONLY_CHANGE_FLAG since this could be exec # + ########################################################## + READ_ONLY_CHANGE_FLAG=1 + elif [ "$FILE_TYPE" == "lua" ]; then + ################################ + # Append the file to the array # + ################################ + FILE_ARRAY_LUA+=("$FILE") + ########################################################## + # Set the READ_ONLY_CHANGE_FLAG since this could be exec # + ########################################################## + READ_ONLY_CHANGE_FLAG=1 + ############################ + # Get the Protocol Buffers files # + ############################ + elif [ "${FILE_TYPE}" == "dart" ]; then + ################################ + # Append the file to the array # + ################################ + FILE_ARRAY_DART+=("${FILE}") + ########################################################## + # Set the READ_ONLY_CHANGE_FLAG since this could be exec # + ########################################################## + READ_ONLY_CHANGE_FLAG=1 + elif [ "${FILE_TYPE}" == "proto" ]; then + ################################ + # Append the file to the array # + ################################ + FILE_ARRAY_PROTOBUF+=("${FILE}") + ########################################################## + # Set the READ_ONLY_CHANGE_FLAG since this could be exec # + ########################################################## + READ_ONLY_CHANGE_FLAG=1 + elif [ "${FILE}" == "dockerfile" ] || [ "${FILE_TYPE}" == "dockerfile" ]; then + ################################ + # Append the file to the array # + ################################ + FILE_ARRAY_DOCKER+=("${FILE}") + ########################################################## + # Set the READ_ONLY_CHANGE_FLAG since this could be exec # + ########################################################## + READ_ONLY_CHANGE_FLAG=1 + elif [ "${FILE_TYPE}" == "clj" ] || [ "${FILE_TYPE}" == "cljs" ] || [ "${FILE_TYPE}" == "cljc" ] || [ "${FILE_TYPE}" == "edn" ]; then + ################################ + # Append the file to the array # + ################################ + FILE_ARRAY_CLOJURE+=("${FILE}") + ########################################################## + # Set the READ_ONLY_CHANGE_FLAG since this could be exec # + ########################################################## + READ_ONLY_CHANGE_FLAG=1 + elif [ "${FILE_TYPE}" == "html" ]; then + ################################ + # Append the file to the array # + ##############################p## + FILE_ARRAY_HTML+=("${FILE}") + ########################################################## + # Set the READ_ONLY_CHANGE_FLAG since this could be exec # + ########################################################## + 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 + ############################################## + # Use file to see if we can parse what it is # + ############################################## + GET_FILE_TYPE_CMD=$(file "${FILE}" 2>&1) - ########################################################## - # Set the READ_ONLY_CHANGE_FLAG since this could be exec # - ########################################################## - READ_ONLY_CHANGE_FLAG=1 - fi - ###################### - # Get the JSON files # - ###################### - elif [ "${FILE_TYPE}" == "json" ]; then - ################################ - # Append the file to the array # - ################################ - FILE_ARRAY_JSON+=("${FILE}") - ############################ - # Check if file is OpenAPI # - ############################ - if DetectOpenAPIFile "${FILE}"; then - ################################ - # Append the file to the array # - ################################ - FILE_ARRAY_OPENAPI+=("${FILE}") - fi - ############################ - # Check if file is ARM # - ############################ - if DetectARMFile "${FILE}"; then - ################################ - # Append the file to the array # - ################################ - FILE_ARRAY_ARM+=("${FILE}") - fi - ##################################### - # Check if the file is CFN template # - ##################################### - if DetectCloudFormationFile "${FILE}"; then - ################################ - # Append the file to the array # - ################################ - FILE_ARRAY_CLOUDFORMATION+=("${FILE}") - fi - ############################################ - # Check if the file is AWS States Language # - ############################################ - if DetectAWSStatesFIle "${FILE}"; then - ################################ - # Append the file to the array # - ################################ - FILE_ARRAY_STATES+=("${FILE}") - fi - ########################################################## - # Set the READ_ONLY_CHANGE_FLAG since this could be exec # - ########################################################## - READ_ONLY_CHANGE_FLAG=1 - ##################### - # Get the XML files # - ##################### - elif [ "${FILE_TYPE}" == "xml" ]; then - ################################ - # Append the file to the array # - ################################ - FILE_ARRAY_XML+=("${FILE}") - ########################################################## - # Set the READ_ONLY_CHANGE_FLAG since this could be exec # - ########################################################## - READ_ONLY_CHANGE_FLAG=1 - ########################## - # Get the MARKDOWN files # - ########################## - elif [ "${FILE_TYPE}" == "md" ]; then - ################################ - # Append the file to the array # - ################################ - FILE_ARRAY_MARKDOWN+=("${FILE}") - ###################### - # Get the BASH files # - ###################### - elif [ "${FILE_TYPE}" == "sh" ]; then - ################################ - # Append the file to the array # - ################################ - FILE_ARRAY_BASH+=("${FILE}") - ########################################################## - # Set the READ_ONLY_CHANGE_FLAG since this could be exec # - ########################################################## - READ_ONLY_CHANGE_FLAG=1 - ###################### - # Get the PERL files # - ###################### - elif [ "${FILE_TYPE}" == "pl" ]; then - ################################ - # Append the file to the array # - ################################ - FILE_ARRAY_PERL+=("${FILE}") - ########################################################## - # Set the READ_ONLY_CHANGE_FLAG since this could be exec # - ########################################################## - READ_ONLY_CHANGE_FLAG=1 - ###################### - # Get the RAKU files # - ###################### - elif [ "${FILE_TYPE}" == "raku" ] || [ "${FILE_TYPE}" == "rakumod" ] || - [ "${FILE_TYPE}" == "rakutest" ] || [ "${FILE_TYPE}" == "pm6" ] || - [ "${FILE_TYPE}" == "pl6" ] || [ "${FILE_TYPE}" == "p6" ]; then - ################################ - # Append the file to the array # - ################################ - FILE_ARRAY_RAKU+=("${FILE}") - ########################################################## - # Set the READ_ONLY_CHANGE_FLAG since this could be exec # - ########################################################## - READ_ONLY_CHANGE_FLAG=1 - ###################### - # Get the PHP files # - ###################### - elif [ "${FILE_TYPE}" == "php" ]; then - ################################ - # Append the file to the array # - ################################ - FILE_ARRAY_PHP+=("${FILE}") - FILE_ARRAY_PHP_PHPSTAN+=("${FILE}") - ########################################################## - # Set the READ_ONLY_CHANGE_FLAG since this could be exec # - ########################################################## - READ_ONLY_CHANGE_FLAG=1 - ###################### - # Get the RUBY files # - ###################### - elif [ "${FILE_TYPE}" == "rb" ]; then - ################################ - # Append the file to the array # - ################################ - FILE_ARRAY_RUBY+=("${FILE}") - ########################################################## - # Set the READ_ONLY_CHANGE_FLAG since this could be exec # - ########################################################## - READ_ONLY_CHANGE_FLAG=1 - ######################## - # Get the PYTHON files # - ######################## - elif [ "${FILE_TYPE}" == "py" ]; then - ################################ - # Append the file to the array # - ################################ - FILE_ARRAY_PYTHON_PYLINT+=("${FILE}") - FILE_ARRAY_PYTHON_FLAKE8+=("${FILE}") - ########################################################## - # Set the READ_ONLY_CHANGE_FLAG since this could be exec # - ########################################################## - READ_ONLY_CHANGE_FLAG=1 - ######################## - # Get the COFFEE files # - ######################## - elif [ "${FILE_TYPE}" == "coffee" ]; then - ################################ - # Append the file to the array # - ################################ - FILE_ARRAY_COFFEESCRIPT+=("${FILE}") - ########################################################## - # Set the READ_ONLY_CHANGE_FLAG since this could be exec # - ########################################################## - READ_ONLY_CHANGE_FLAG=1 + ################# + # Check if bash # + ################# + if [[ ${GET_FILE_TYPE_CMD} == *"Bourne-Again shell script"* ]]; then + ####################### + # It is a bash script # + ####################### + warn "Found bash script without extension:[.sh]" + info "Please update file with proper extensions." + ################################ + # Append the file to the array # + ################################ + FILE_ARRAY_BASH+=("${FILE}") + ########################################################## + # Set the READ_ONLY_CHANGE_FLAG since this could be exec # + ########################################################## + READ_ONLY_CHANGE_FLAG=1 + elif [[ ${GET_FILE_TYPE_CMD} == *"Ruby script"* ]]; then + ####################### + # It is a Ruby script # + ####################### + warn "Found ruby script without extension:[.rb]" + info "Please update file with proper extensions." + ################################ + # Append the file to the array # + ################################ + FILE_ARRAY_RUBY+=("${FILE}") + ########################################################## + # Set the READ_ONLY_CHANGE_FLAG since this could be exec # + ########################################################## + READ_ONLY_CHANGE_FLAG=1 + else ############################ - # Get the JavaScript files # + # Extension was not found! # ############################ - elif [ "${FILE_TYPE}" == "js" ]; then - ################################ - # Append the file to the array # - ################################ - FILE_ARRAY_JAVASCRIPT_ES+=("${FILE}") - FILE_ARRAY_JAVASCRIPT_STANDARD+=("${FILE}") - ########################################################## - # Set the READ_ONLY_CHANGE_FLAG since this could be exec # - ########################################################## - READ_ONLY_CHANGE_FLAG=1 - ############################ - # Get the JSX files # - ############################ - elif [ "${FILE_TYPE}" == "jsx" ]; then - ################################ - # Append the file to the array # - ################################ - FILE_ARRAY_JSX+=("${FILE}") - ########################################################## - # Set the READ_ONLY_CHANGE_FLAG since this could be exec # - ########################################################## - READ_ONLY_CHANGE_FLAG=1 - ############################ - # Get the TSX files # - ############################ - elif [ "${FILE_TYPE}" == "tsx" ]; then - ################################ - # Append the file to the array # - ################################ - FILE_ARRAY_TSX+=("${FILE}") - ########################################################## - # Set the READ_ONLY_CHANGE_FLAG since this could be exec # - ########################################################## - READ_ONLY_CHANGE_FLAG=1 - ######################## - # Get the Golang files # - ######################## - ############################ - # Get the TypeScript files # - ############################ - elif [ "${FILE_TYPE}" == "ts" ]; then - ################################ - # Append the file to the array # - ################################ - FILE_ARRAY_TYPESCRIPT_ES+=("${FILE}") - FILE_ARRAY_TYPESCRIPT_STANDARD+=("${FILE}") - ########################################################## - # Set the READ_ONLY_CHANGE_FLAG since this could be exec # - ########################################################## - READ_ONLY_CHANGE_FLAG=1 - ######################## - # Get the Golang files # - ######################## - elif [ "${FILE_TYPE}" == "go" ]; then - ################################ - # Append the file to the array # - ################################ - FILE_ARRAY_GO+=("${FILE}") - ########################################################## - # Set the READ_ONLY_CHANGE_FLAG since this could be exec # - ########################################################## - READ_ONLY_CHANGE_FLAG=1 - ########################### - # Get the Terraform files # - ########################### - elif [ "${FILE_TYPE}" == "tf" ]; then - ################################ - # Append the file to the array # - ################################ - FILE_ARRAY_TERRAFORM+=("${FILE}") - FILE_ARRAY_TERRAFORM_TERRASCAN+=("${FILE}") - ########################################################## - # Set the READ_ONLY_CHANGE_FLAG since this could be exec # - ########################################################## - READ_ONLY_CHANGE_FLAG=1 - ########################### - # Get the Powershell files # - ########################### - elif [ "${FILE_TYPE}" == "ps1" ]; then - ################################ - # Append the file to the array # - ################################ - FILE_ARRAY_POWERSHELL+=("${FILE}") - elif [ "${FILE_TYPE}" == "css" ]; then - ################################ - # Append the file to the array # - ################################ - FILE_ARRAY_CSS+=("${FILE}") - ########################################################## - # Set the READ_ONLY_CHANGE_FLAG since this could be exec # - ########################################################## - READ_ONLY_CHANGE_FLAG=1 - elif [ "${FILE_TYPE}" == "env" ]; then - ################################ - # Append the file to the array # - ################################ - FILE_ARRAY_ENV+=("${FILE}") - ########################################################## - # Set the READ_ONLY_CHANGE_FLAG since this could be exec # - ########################################################## - READ_ONLY_CHANGE_FLAG=1 - elif [ "${FILE_TYPE}" == "kt" ] || [ "${FILE_TYPE}" == "kts" ]; then - ################################ - # Append the file to the array # - ################################ - FILE_ARRAY_KOTLIN+=("${FILE}") - ########################################################## - # Set the READ_ONLY_CHANGE_FLAG since this could be exec # - ########################################################## - READ_ONLY_CHANGE_FLAG=1 - elif [ "$FILE_TYPE" == "lua" ]; then - ################################ - # Append the file to the array # - ################################ - FILE_ARRAY_LUA+=("$FILE") - ########################################################## - # Set the READ_ONLY_CHANGE_FLAG since this could be exec # - ########################################################## - READ_ONLY_CHANGE_FLAG=1 - ############################ - # Get the Protocol Buffers files # - ############################ - elif [ "${FILE_TYPE}" == "dart" ]; then - ################################ - # Append the file to the array # - ################################ - FILE_ARRAY_DART+=("${FILE}") - ########################################################## - # Set the READ_ONLY_CHANGE_FLAG since this could be exec # - ########################################################## - READ_ONLY_CHANGE_FLAG=1 - elif [ "${FILE_TYPE}" == "proto" ]; then - ################################ - # Append the file to the array # - ################################ - FILE_ARRAY_PROTOBUF+=("${FILE}") - ########################################################## - # Set the READ_ONLY_CHANGE_FLAG since this could be exec # - ########################################################## - READ_ONLY_CHANGE_FLAG=1 - elif [ "${FILE}" == "dockerfile" ] || [ "${FILE_TYPE}" == "dockerfile" ]; then - ################################ - # Append the file to the array # - ################################ - FILE_ARRAY_DOCKER+=("${FILE}") - ########################################################## - # Set the READ_ONLY_CHANGE_FLAG since this could be exec # - ########################################################## - READ_ONLY_CHANGE_FLAG=1 - elif [ "${FILE_TYPE}" == "clj" ] || [ "${FILE_TYPE}" == "cljs" ] || [ "${FILE_TYPE}" == "cljc" ] || [ "${FILE_TYPE}" == "edn" ]; then - ################################ - # Append the file to the array # - ################################ - FILE_ARRAY_CLOJURE+=("${FILE}") - ########################################################## - # Set the READ_ONLY_CHANGE_FLAG since this could be exec # - ########################################################## - READ_ONLY_CHANGE_FLAG=1 - elif [ "${FILE_TYPE}" == "html" ]; then - ################################ - # Append the file to the array # - ##############################p## - FILE_ARRAY_HTML+=("${FILE}") - ########################################################## - # Set the READ_ONLY_CHANGE_FLAG since this could be exec # - ########################################################## - 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 - ############################################## - # Use file to see if we can parse what it is # - ############################################## - GET_FILE_TYPE_CMD=$(file "${FILE}" 2>&1) - - ################# - # Check if bash # - ################# - if [[ ${GET_FILE_TYPE_CMD} == *"Bourne-Again shell script"* ]]; then - ####################### - # It is a bash script # - ####################### - warn "Found bash script without extension:[.sh]" - info "Please update file with proper extensions." - ################################ - # Append the file to the array # - ################################ - FILE_ARRAY_BASH+=("${FILE}") - ########################################################## - # Set the READ_ONLY_CHANGE_FLAG since this could be exec # - ########################################################## - READ_ONLY_CHANGE_FLAG=1 - elif [[ ${GET_FILE_TYPE_CMD} == *"Ruby script"* ]]; then - ####################### - # It is a Ruby script # - ####################### - warn "Found ruby script without extension:[.rb]" - info "Please update file with proper extensions." - ################################ - # Append the file to the array # - ################################ - FILE_ARRAY_RUBY+=("${FILE}") - ########################################################## - # Set the READ_ONLY_CHANGE_FLAG since this could be exec # - ########################################################## - READ_ONLY_CHANGE_FLAG=1 - else - ############################ - # Extension was not found! # - ############################ - warn "Failed to get filetype for:[${FILE}]!" - ########################################################## - # Set the READ_ONLY_CHANGE_FLAG since this could be exec # - ########################################################## - READ_ONLY_CHANGE_FLAG=1 - fi - fi - done - - export READ_ONLY_CHANGE_FLAG # Workaround SC2034 - - ######################################### - # Need to switch back to branch of code # - ######################################### - SWITCH2_CMD=$(git -C "${GITHUB_WORKSPACE}" checkout --progress --force "${GITHUB_SHA}" 2>&1) - - ####################### - # Load the error code # - ####################### - ERROR_CODE=$? - - ############################## - # Check the shell for errors # - ############################## - if [ ${ERROR_CODE} -ne 0 ]; then - # Error - error "Failed to switch back to branch!" - fatal "[${SWITCH2_CMD}]" + warn "Failed to get filetype for:[${FILE}]!" + ########################################################## + # Set the READ_ONLY_CHANGE_FLAG since this could be exec # + ########################################################## + READ_ONLY_CHANGE_FLAG=1 + fi fi + done - ################ - # Footer print # - ################ - info "----------------------------------------------" - info "Successfully gathered list of files..." + export READ_ONLY_CHANGE_FLAG # Workaround SC2034 + + ######################################### + # Need to switch back to branch of code # + ######################################### + SWITCH2_CMD=$(git -C "${GITHUB_WORKSPACE}" checkout --progress --force "${GITHUB_SHA}" 2>&1) + + ####################### + # Load the error code # + ####################### + ERROR_CODE=$? + + ############################## + # Check the shell for errors # + ############################## + if [ ${ERROR_CODE} -ne 0 ]; then + # Error + error "Failed to switch back to branch!" + fatal "[${SWITCH2_CMD}]" + fi + + ################ + # Footer print # + ################ + info "----------------------------------------------" + info "Successfully gathered list of files..." } diff --git a/lib/linter.sh b/lib/linter.sh index 231fa185..6327f7cb 100755 --- a/lib/linter.sh +++ b/lib/linter.sh @@ -75,7 +75,7 @@ OPENAPI_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${OPENAPI_FILE_NAME}" # Path to PHPSTAN_FILE_NAME='phpstan.neon' # Name of the file PHPSTAN_LINTER_RULES="${GITHUB_WORKSPACE}/${PHPSTAN_FILE_NAME}" # Path to the PHPStan lint rules in the repository if [ ! -f "$PHPSTAN_LINTER_RULES" ]; then - PHPSTAN_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${PHPSTAN_FILE_NAME}" # Path to the PHPStan lint rules + PHPSTAN_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${PHPSTAN_FILE_NAME}" # Path to the PHPStan lint rules fi # Powershell Vars POWERSHELL_FILE_NAME='.powershell-psscriptanalyzer.psd1' # Name of the file @@ -106,19 +106,19 @@ YAML_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${YAML_FILE_NAME}" # Path to the ya # Linter array for information prints # ####################################### LINTER_ARRAY=('ansible-lint' 'arm-ttk' 'asl-validator' 'cfn-lint' 'clj-kondo' 'coffeelint' - 'dart' 'dockerfilelint' 'dotenv-linter' 'eslint' 'flake8' 'golangci-lint' 'htmlhint' - 'jsonlint' 'ktlint' 'lua' 'markdownlint' 'npm-groovy-lint' 'perl' 'protolint' 'pwsh' - 'pylint' 'raku' 'rubocop' 'shellcheck' 'spectral' 'standard' 'stylelint' 'terrascan' - 'tflint' 'xmllint' 'yamllint') + 'dart' 'dockerfilelint' 'dotenv-linter' 'eslint' 'flake8' 'golangci-lint' 'htmlhint' + 'jsonlint' 'ktlint' 'lua' 'markdownlint' 'npm-groovy-lint' 'perl' 'protolint' 'pwsh' + 'pylint' 'raku' 'rubocop' 'shellcheck' 'spectral' 'standard' 'stylelint' 'terrascan' + 'tflint' 'xmllint' 'yamllint') ############################# # Language array for prints # ############################# LANGUAGE_ARRAY=('ANSIBLE' 'ARM' 'BASH' 'CLOUDFORMATION' 'CLOJURE' 'COFFEESCRIPT' 'CSS' - 'DART' 'DOCKER' 'ENV' 'GO' 'GROOVY' 'HTML' 'JAVASCRIPT_ES' 'JAVASCRIPT_STANDARD' - 'JSON' 'JSX' 'KOTLIN' 'LUA' 'MARKDOWN' 'OPENAPI' 'PERL' 'PHP' 'PHP_PHPSTAN' 'POWERSHELL' - 'PROTOBUF' 'PYTHON_PYLINT' 'PYTHON_FLAKE8' 'RAKU' 'RUBY' 'STATES' 'TERRAFORM' - 'TERRAFORM_TERRASCAN' 'TSX' 'TYPESCRIPT_ES' 'TYPESCRIPT_STANDARD' 'XML' 'YML') + 'DART' 'DOCKER' 'ENV' 'GO' 'GROOVY' 'HTML' 'JAVASCRIPT_ES' 'JAVASCRIPT_STANDARD' + 'JSON' 'JSX' 'KOTLIN' 'LUA' 'MARKDOWN' 'OPENAPI' 'PERL' 'PHP' 'PHP_PHPSTAN' 'POWERSHELL' + 'PROTOBUF' 'PYTHON_PYLINT' 'PYTHON_FLAKE8' 'RAKU' 'RUBY' 'STATES' 'TERRAFORM' + 'TERRAFORM_TERRASCAN' 'TSX' 'TYPESCRIPT_ES' 'TYPESCRIPT_STANDARD' 'XML' 'YML') ############################################ # Array for all languages that were linted # @@ -360,502 +360,560 @@ export ERRORS_FOUND_YAML # Workaround SC2034 ################################################################################ #### Function Header ########################################################### Header() { - ############################### - # Give them the possum action # - ############################### - /bin/bash /action/lib/possum.sh + ############################### + # Give them the possum action # + ############################### + /bin/bash /action/lib/possum.sh - ########## - # Prints # - ########## - info "---------------------------------------------" - info "--- GitHub Actions Multi Language Linter ----" - info "---------------------------------------------" - info "---------------------------------------------" - info "The Super-Linter source code can be found at:" - info " - https://github.com/github/super-linter" - info "---------------------------------------------" + ########## + # Prints # + ########## + info "---------------------------------------------" + info "--- GitHub Actions Multi Language Linter ----" + info "---------------------------------------------" + info "---------------------------------------------" + info "The Super-Linter source code can be found at:" + info " - https://github.com/github/super-linter" + info "---------------------------------------------" } ################################################################################ #### Function GetLinterVersions ################################################ GetLinterVersions() { - ######################### - # Print version headers # - ######################### - debug "---------------------------------------------" - debug "Linter Version Info:" + ######################### + # Print version headers # + ######################### + debug "---------------------------------------------" + debug "Linter Version Info:" - ########################################################## - # Go through the array of linters and print version info # - ########################################################## - for LINTER in "${LINTER_ARRAY[@]}"; do - #################### - # Get the versions # - #################### - if [[ ${LINTER} == "arm-ttk" ]]; then - # Need specific command for ARM - mapfile -t GET_VERSION_CMD < <(grep -iE 'version' "${ARM_TTK_PSD1}" | xargs 2>&1) - elif [[ ${LINTER} == "protolint" ]]; then - # Need specific command for Protolint - mapfile -t GET_VERSION_CMD < <(echo "--version not supported") - else - # Standard version command - mapfile -t GET_VERSION_CMD < <("${LINTER}" --version 2>&1) - fi + ########################################################## + # Go through the array of linters and print version info # + ########################################################## + for LINTER in "${LINTER_ARRAY[@]}"; do + #################### + # Get the versions # + #################### + if [[ ${LINTER} == "arm-ttk" ]]; then + # Need specific command for ARM + mapfile -t GET_VERSION_CMD < <(grep -iE 'version' "${ARM_TTK_PSD1}" | xargs 2>&1) + elif [[ ${LINTER} == "protolint" ]]; then + # Need specific command for Protolint + mapfile -t GET_VERSION_CMD < <(echo "--version not supported") + else + # Standard version command + mapfile -t GET_VERSION_CMD < <("${LINTER}" --version 2>&1) + fi - ####################### - # Load the error code # - ####################### - ERROR_CODE=$? + ####################### + # Load the error code # + ####################### + ERROR_CODE=$? - ############################## - # Check the shell for errors # - ############################## - if [ ${ERROR_CODE} -ne 0 ] || [ -z "${GET_VERSION_CMD[*]}" ]; then - warn "[${LINTER}]: Failed to get version info for:" - else - ########################## - # Print the version info # - ########################## - debug "Successfully found version for ${F[W]}[${LINTER}]${F[B]}: ${F[W]}${GET_VERSION_CMD[*]}" - fi - done + ############################## + # Check the shell for errors # + ############################## + if [ ${ERROR_CODE} -ne 0 ] || [ -z "${GET_VERSION_CMD[*]}" ]; then + warn "[${LINTER}]: Failed to get version info for:" + else + ########################## + # Print the version info # + ########################## + debug "Successfully found version for ${F[W]}[${LINTER}]${F[B]}: ${F[W]}${GET_VERSION_CMD[*]}" + fi + done - ######################### - # Print version footers # - ######################### - debug "---------------------------------------------" + ######################### + # Print version footers # + ######################### + debug "---------------------------------------------" } ################################################################################ #### Function GetLinterRules ################################################### GetLinterRules() { - # Need to validate the rules files exist + # Need to validate the rules files exist - ################ - # Pull in vars # - ################ - LANGUAGE_NAME="${1}" # Name of the language were looking for + ################ + # Pull in vars # + ################ + LANGUAGE_NAME="${1}" # Name of the language were looking for - ####################################################### - # Need to create the variables for the real variables # - ####################################################### - LANGUAGE_FILE_NAME="${LANGUAGE_NAME}_FILE_NAME" - LANGUAGE_LINTER_RULES="${LANGUAGE_NAME}_LINTER_RULES" + ####################################################### + # Need to create the variables for the real variables # + ####################################################### + LANGUAGE_FILE_NAME="${LANGUAGE_NAME}_FILE_NAME" + LANGUAGE_LINTER_RULES="${LANGUAGE_NAME}_LINTER_RULES" - ##################################### - # Validate we have the linter rules # - ##################################### - if [ -f "${GITHUB_WORKSPACE}/${LINTER_RULES_PATH}/${!LANGUAGE_FILE_NAME}" ]; then - info "----------------------------------------------" - info "User provided file:[${!LANGUAGE_FILE_NAME}], setting rules file..." + ##################################### + # Validate we have the linter rules # + ##################################### + if [ -f "${GITHUB_WORKSPACE}/${LINTER_RULES_PATH}/${!LANGUAGE_FILE_NAME}" ]; then + info "----------------------------------------------" + info "User provided file:[${!LANGUAGE_FILE_NAME}], setting rules file..." - ######################################## - # Update the path to the file location # - ######################################## - eval "${LANGUAGE_LINTER_RULES}=${GITHUB_WORKSPACE}/${LINTER_RULES_PATH}/${!LANGUAGE_FILE_NAME}" - else - ######################################################## - # No user default provided, using the template default # - ######################################################## - debug " -> Codebase does NOT have file:[${LINTER_RULES_PATH}/${!LANGUAGE_FILE_NAME}], using Default rules at:[${!LANGUAGE_LINTER_RULES}]" - fi + ######################################## + # Update the path to the file location # + ######################################## + eval "${LANGUAGE_LINTER_RULES}=${GITHUB_WORKSPACE}/${LINTER_RULES_PATH}/${!LANGUAGE_FILE_NAME}" + else + ######################################################## + # No user default provided, using the template default # + ######################################################## + debug " -> Codebase does NOT have file:[${LINTER_RULES_PATH}/${!LANGUAGE_FILE_NAME}], using Default rules at:[${!LANGUAGE_LINTER_RULES}]" + fi } ################################################################################ #### Function GetStandardRules ################################################# GetStandardRules() { - ################ - # Pull In Vars # - ################ - LINTER="${1}" # Type: javascript | typescript + ################ + # Pull In Vars # + ################ + LINTER="${1}" # Type: javascript | typescript - ######################################################################### - # Need to get the ENV vars from the linter rules to run in command line # - ######################################################################### - # Copy orig IFS to var - ORIG_IFS="${IFS}" - # Set the IFS to newline - IFS=$'\n' + ######################################################################### + # Need to get the ENV vars from the linter rules to run in command line # + ######################################################################### + # Copy orig IFS to var + ORIG_IFS="${IFS}" + # Set the IFS to newline + IFS=$'\n' - ######################################### - # Get list of all environment variables # - ######################################### - # Only env vars that are marked as true - GET_ENV_ARRAY=() - if [[ ${LINTER} == "javascript" ]]; then - mapfile -t GET_ENV_ARRAY < <(yq .env "${JAVASCRIPT_LINTER_RULES}" | grep true) - elif [[ ${LINTER} == "typescript" ]]; then - mapfile -t GET_ENV_ARRAY < <(yq .env "${TYPESCRIPT_LINTER_RULES}" | grep true) - fi + ######################################### + # Get list of all environment variables # + ######################################### + # Only env vars that are marked as true + GET_ENV_ARRAY=() + if [[ ${LINTER} == "javascript" ]]; then + mapfile -t GET_ENV_ARRAY < <(yq .env "${JAVASCRIPT_LINTER_RULES}" | grep true) + elif [[ ${LINTER} == "typescript" ]]; then + mapfile -t GET_ENV_ARRAY < <(yq .env "${TYPESCRIPT_LINTER_RULES}" | grep true) + fi - ####################### - # Load the error code # - ####################### - ERROR_CODE=$? + ####################### + # Load the error code # + ####################### + ERROR_CODE=$? - ############################## - # Check the shell for errors # - ############################## - if [ ${ERROR_CODE} -ne 0 ]; then - # ERROR - error "Failed to gain list of ENV vars to load!" - fatal "[${GET_ENV_ARRAY[*]}]" - fi + ############################## + # Check the shell for errors # + ############################## + if [ ${ERROR_CODE} -ne 0 ]; then + # ERROR + error "Failed to gain list of ENV vars to load!" + fatal "[${GET_ENV_ARRAY[*]}]" + fi - ########################## - # Set IFS back to normal # - ########################## - # Set IFS back to Orig - IFS="${ORIG_IFS}" + ########################## + # Set IFS back to normal # + ########################## + # Set IFS back to Orig + IFS="${ORIG_IFS}" - ###################### - # Set the env string # - ###################### - ENV_STRING='' + ###################### + # Set the env string # + ###################### + ENV_STRING='' + ############################# + # Pull out the envs to load # + ############################# + for ENV in "${GET_ENV_ARRAY[@]}"; do ############################# - # Pull out the envs to load # + # remove spaces from return # ############################# - for ENV in "${GET_ENV_ARRAY[@]}"; do - ############################# - # remove spaces from return # - ############################# - ENV="$(echo -e "${ENV}" | tr -d '[:space:]')" - ################################ - # Get the env to add to string # - ################################ - ENV="$(echo "${ENV}" | cut -d'"' -f2)" - debug "ENV:[${ENV}]" - ENV_STRING+="--env ${ENV} " - done + ENV="$(echo -e "${ENV}" | tr -d '[:space:]')" + ################################ + # Get the env to add to string # + ################################ + ENV="$(echo "${ENV}" | cut -d'"' -f2)" + debug "ENV:[${ENV}]" + ENV_STRING+="--env ${ENV} " + done - ######################################### - # Remove trailing and ending whitespace # - ######################################### - if [[ ${LINTER} == "javascript" ]]; then - JAVASCRIPT_STANDARD_LINTER_RULES="$(echo -e "${ENV_STRING}" | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//')" - elif [[ ${LINTER} == "typescript" ]]; then - TYPESCRIPT_STANDARD_LINTER_RULES="$(echo -e "${ENV_STRING}" | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//')" - fi + ######################################### + # Remove trailing and ending whitespace # + ######################################### + if [[ ${LINTER} == "javascript" ]]; then + JAVASCRIPT_STANDARD_LINTER_RULES="$(echo -e "${ENV_STRING}" | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//')" + elif [[ ${LINTER} == "typescript" ]]; then + TYPESCRIPT_STANDARD_LINTER_RULES="$(echo -e "${ENV_STRING}" | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//')" + fi } ################################################################################ #### Function DetectOpenAPIFile ################################################ DetectOpenAPIFile() { - ################ - # Pull in vars # - ################ - FILE="${1}" + ################ + # Pull in vars # + ################ + FILE="${1}" - ############################### - # Check the file for keywords # - ############################### - grep -E '"openapi":|"swagger":|^openapi:|^swagger:' "${FILE}" > /dev/null + ############################### + # Check the file for keywords # + ############################### + grep -E '"openapi":|"swagger":|^openapi:|^swagger:' "${FILE}" > /dev/null - ####################### - # Load the error code # - ####################### - ERROR_CODE=$? + ####################### + # Load the error code # + ####################### + ERROR_CODE=$? - ############################## - # Check the shell for errors # - ############################## - if [ ${ERROR_CODE} -eq 0 ]; then - ######################## - # Found string in file # - ######################## - return 0 - else - ################### - # No string match # - ################### - return 1 - fi + ############################## + # Check the shell for errors # + ############################## + if [ ${ERROR_CODE} -eq 0 ]; then + ######################## + # Found string in file # + ######################## + return 0 + else + ################### + # No string match # + ################### + return 1 + fi } ################################################################################ #### Function DetectARMFile #################################################### DetectARMFile() { - ################ - # Pull in vars # - ################ - FILE="${1}" # Name of the file/path we are validating + ################ + # Pull in vars # + ################ + FILE="${1}" # Name of the file/path we are validating - ############################### - # Check the file for keywords # - ############################### - grep -E 'schema.management.azure.com' "${FILE}" > /dev/null + ############################### + # Check the file for keywords # + ############################### + grep -E 'schema.management.azure.com' "${FILE}" > /dev/null - ####################### - # Load the error code # - ####################### - ERROR_CODE=$? + ####################### + # Load the error code # + ####################### + ERROR_CODE=$? - ############################## - # Check the shell for errors # - ############################## - if [ ${ERROR_CODE} -eq 0 ]; then - ######################## - # Found string in file # - ######################## - return 0 - else - ################### - # No string match # - ################### - return 1 - fi + ############################## + # Check the shell for errors # + ############################## + if [ ${ERROR_CODE} -eq 0 ]; then + ######################## + # Found string in file # + ######################## + return 0 + else + ################### + # No string match # + ################### + return 1 + fi } ################################################################################ #### Function DetectCloudFormationFile ######################################### DetectCloudFormationFile() { - ################ - # Pull in Vars # - ################ - FILE="${1}" # File that we need to validate + ################ + # Pull in Vars # + ################ + FILE="${1}" # File that we need to validate - # https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/template-formats.html - # AWSTemplateFormatVersion is optional - ####################################### - # Check if file has AWS Template info # - ####################################### - if grep -q 'AWSTemplateFormatVersion' "${FILE}" > /dev/null; then - # Found it - return 0 - fi + # https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/template-formats.html + # AWSTemplateFormatVersion is optional + ####################################### + # Check if file has AWS Template info # + ####################################### + if grep -q 'AWSTemplateFormatVersion' "${FILE}" > /dev/null; then + # Found it + return 0 + fi - ##################################### - # See if it contains AWS References # - ##################################### - if grep -q -E '(AWS|Alexa|Custom)::' "${FILE}" > /dev/null; then - # Found it - return 0 - fi + ##################################### + # See if it contains AWS References # + ##################################### + if grep -q -E '(AWS|Alexa|Custom)::' "${FILE}" > /dev/null; then + # Found it + return 0 + fi - ##################################################### - # No identifiers of a CLOUDFORMATION template found # - ##################################################### - return 1 + ##################################################### + # No identifiers of a CLOUDFORMATION template found # + ##################################################### + return 1 } ################################################################################ #### Function DetectAWSStatesFIle ############################################## DetectAWSStatesFIle() { - ################ - # Pull in Vars # - ################ - FILE="${1}" # File that we need to validate + ################ + # Pull in Vars # + ################ + FILE="${1}" # File that we need to validate - # https://states-language.net/spec.html#example - ############################### - # check if file has resources # - ############################### - if grep '"Resource": *"arn"*' "${FILE}"; then - # Found it - return 0 - fi + # https://states-language.net/spec.html#example + ############################### + # check if file has resources # + ############################### + if grep '"Resource": *"arn"*' "${FILE}"; then + # Found it + return 0 + fi - ################################################# - # No identifiers of a AWS States Language found # - ################################################# - return 1 + ################################################# + # No identifiers of a AWS States Language found # + ################################################# + return 1 } ################################################################################ #### Function GetGitHubVars #################################################### GetGitHubVars() { - ########## - # Prints # - ########## - info "--------------------------------------------" - info "Gathering GitHub information..." + ########## + # Prints # + ########## + info "--------------------------------------------" + info "Gathering GitHub information..." - ############################### - # Get the Run test cases flag # - ############################### - if [ -z "${TEST_CASE_RUN}" ]; then - ################################## - # No flag passed, set to default # - ################################## - TEST_CASE_RUN="${DEFAULT_TEST_CASE_RUN}" + ############################### + # Get the Run test cases flag # + ############################### + if [ -z "${TEST_CASE_RUN}" ]; then + ################################## + # No flag passed, set to default # + ################################## + TEST_CASE_RUN="${DEFAULT_TEST_CASE_RUN}" + fi + + ############################### + # Convert string to lowercase # + ############################### + TEST_CASE_RUN="${TEST_CASE_RUN,,}" + + ########################## + # Get the run local flag # + ########################## + if [ -z "${RUN_LOCAL}" ]; then + ################################## + # No flag passed, set to default # + ################################## + RUN_LOCAL="${DEFAULT_RUN_LOCAL}" + fi + + ############################### + # Convert string to lowercase # + ############################### + RUN_LOCAL="${RUN_LOCAL,,}" + + ################################# + # Check if were running locally # + ################################# + if [[ ${RUN_LOCAL} != "false" ]]; then + ########################################## + # We are running locally for a debug run # + ########################################## + info "NOTE: ENV VAR [RUN_LOCAL] has been set to:[true]" + info "bypassing GitHub Actions variables..." + + ############################ + # Set the GITHUB_WORKSPACE # + ############################ + if [ -z "${GITHUB_WORKSPACE}" ]; then + GITHUB_WORKSPACE="${DEFAULT_WORKSPACE}" fi - ############################### - # Convert string to lowercase # - ############################### - TEST_CASE_RUN="${TEST_CASE_RUN,,}" - - ########################## - # Get the run local flag # - ########################## - if [ -z "${RUN_LOCAL}" ]; then - ################################## - # No flag passed, set to default # - ################################## - RUN_LOCAL="${DEFAULT_RUN_LOCAL}" + if [ ! -d "${GITHUB_WORKSPACE}" ]; then + fatal "Provided volume is not a directory!" fi - ############################### - # Convert string to lowercase # - ############################### - RUN_LOCAL="${RUN_LOCAL,,}" + info "Linting all files in mapped directory:[${DEFAULT_WORKSPACE}]" + + # No need to touch or set the GITHUB_SHA + # No need to touch or set the GITHUB_EVENT_PATH + # No need to touch or set the GITHUB_ORG + # No need to touch or set the GITHUB_REPO ################################# - # Check if were running locally # + # Set the VALIDATE_ALL_CODEBASE # ################################# - if [[ ${RUN_LOCAL} != "false" ]]; then - ########################################## - # We are running locally for a debug run # - ########################################## - info "NOTE: ENV VAR [RUN_LOCAL] has been set to:[true]" - info "bypassing GitHub Actions variables..." - - ############################ - # Set the GITHUB_WORKSPACE # - ############################ - if [ -z "${GITHUB_WORKSPACE}" ]; then - GITHUB_WORKSPACE="${DEFAULT_WORKSPACE}" - fi - - if [ ! -d "${GITHUB_WORKSPACE}" ]; then - fatal "Provided volume is not a directory!" - fi - - info "Linting all files in mapped directory:[${DEFAULT_WORKSPACE}]" - - # No need to touch or set the GITHUB_SHA - # No need to touch or set the GITHUB_EVENT_PATH - # No need to touch or set the GITHUB_ORG - # No need to touch or set the GITHUB_REPO - - ################################# - # Set the VALIDATE_ALL_CODEBASE # - ################################# - VALIDATE_ALL_CODEBASE="${DEFAULT_VALIDATE_ALL_CODEBASE}" + VALIDATE_ALL_CODEBASE="${DEFAULT_VALIDATE_ALL_CODEBASE}" + else + ############################ + # Validate we have a value # + ############################ + if [ -z "${GITHUB_SHA}" ]; then + error "Failed to get [GITHUB_SHA]!" + fatal "[${GITHUB_SHA}]" else - ############################ - # Validate we have a value # - ############################ - if [ -z "${GITHUB_SHA}" ]; then - error "Failed to get [GITHUB_SHA]!" - fatal "[${GITHUB_SHA}]" - else - info "Successfully found:${F[W]}[GITHUB_SHA]${F[B]}, value:${F[W]}[${GITHUB_SHA}]" - fi - - ############################ - # Validate we have a value # - ############################ - if [ -z "${GITHUB_WORKSPACE}" ]; then - error "Failed to get [GITHUB_WORKSPACE]!" - fatal "[${GITHUB_WORKSPACE}]" - else - info "Successfully found:${F[W]}[GITHUB_WORKSPACE]${F[B]}, value:${F[W]}[${GITHUB_WORKSPACE}]" - fi - - ############################ - # Validate we have a value # - ############################ - if [ -z "${GITHUB_EVENT_PATH}" ]; then - error "Failed to get [GITHUB_EVENT_PATH]!" - fatal "[${GITHUB_EVENT_PATH}]" - else - info "Successfully found:${F[W]}[GITHUB_EVENT_PATH]${F[B]}, value:${F[W]}[${GITHUB_EVENT_PATH}]${F[B]}" - fi - - ################################################## - # Need to pull the GitHub Vars from the env file # - ################################################## - - ###################### - # Get the GitHub Org # - ###################### - GITHUB_ORG=$(jq -r '.repository.owner.login' < "${GITHUB_EVENT_PATH}") - - ############################ - # Validate we have a value # - ############################ - if [ -z "${GITHUB_ORG}" ]; then - error "Failed to get [GITHUB_ORG]!" - fatal "[${GITHUB_ORG}]" - else - info "Successfully found:${F[W]}[GITHUB_ORG]${F[B]}, value:${F[W]}[${GITHUB_ORG}]" - fi - - ####################### - # Get the GitHub Repo # - ####################### - GITHUB_REPO=$(jq -r '.repository.name' < "${GITHUB_EVENT_PATH}") - - ############################ - # Validate we have a value # - ############################ - if [ -z "${GITHUB_REPO}" ]; then - error "Failed to get [GITHUB_REPO]!" - fatal "[${GITHUB_REPO}]" - else - info "Successfully found:${F[W]}[GITHUB_REPO]${F[B]}, value:${F[W]}[${GITHUB_REPO}]" - fi + info "Successfully found:${F[W]}[GITHUB_SHA]${F[B]}, value:${F[W]}[${GITHUB_SHA}]" fi ############################ # Validate we have a value # ############################ - if [ -z "${GITHUB_TOKEN}" ] && [[ ${RUN_LOCAL} == "false" ]]; then - error "Failed to get [GITHUB_TOKEN]!" - error "[${GITHUB_TOKEN}]" - error "Please set a [GITHUB_TOKEN] from the main workflow environment to take advantage of multiple status reports!" - - ################################################################################ - # Need to set MULTI_STATUS to false as we cant hit API endpoints without token # - ################################################################################ - MULTI_STATUS='false' + if [ -z "${GITHUB_WORKSPACE}" ]; then + error "Failed to get [GITHUB_WORKSPACE]!" + fatal "[${GITHUB_WORKSPACE}]" else - info "Successfully found:${F[W]}[GITHUB_TOKEN]" + info "Successfully found:${F[W]}[GITHUB_WORKSPACE]${F[B]}, value:${F[W]}[${GITHUB_WORKSPACE}]" fi - ############################### - # Convert string to lowercase # - ############################### - MULTI_STATUS="${MULTI_STATUS,,}" - - ####################################################################### - # Check to see if the multi status is set, and we have a token to use # - ####################################################################### - if [ "${MULTI_STATUS}" == "true" ] && [ -n "${GITHUB_TOKEN}" ]; then - ############################ - # Validate we have a value # - ############################ - if [ -z "${GITHUB_REPOSITORY}" ]; then - error "Failed to get [GITHUB_REPOSITORY]!" - fatal "[${GITHUB_REPOSITORY}]" - else - info "Successfully found:${F[W]}[GITHUB_REPOSITORY]${F[B]}, value:${F[W]}[${GITHUB_REPOSITORY}]" - fi - - ############################ - # Validate we have a value # - ############################ - if [ -z "${GITHUB_RUN_ID}" ]; then - error "Failed to get [GITHUB_RUN_ID]!" - fatal "[${GITHUB_RUN_ID}]" - else - info "Successfully found:${F[W]}[GITHUB_RUN_ID]${F[B]}, value:${F[W]}[${GITHUB_RUN_ID}]" - fi + ############################ + # Validate we have a value # + ############################ + if [ -z "${GITHUB_EVENT_PATH}" ]; then + error "Failed to get [GITHUB_EVENT_PATH]!" + fatal "[${GITHUB_EVENT_PATH}]" + else + info "Successfully found:${F[W]}[GITHUB_EVENT_PATH]${F[B]}, value:${F[W]}[${GITHUB_EVENT_PATH}]${F[B]}" fi + + ################################################## + # Need to pull the GitHub Vars from the env file # + ################################################## + + ###################### + # Get the GitHub Org # + ###################### + GITHUB_ORG=$(jq -r '.repository.owner.login' < "${GITHUB_EVENT_PATH}") + + ############################ + # Validate we have a value # + ############################ + if [ -z "${GITHUB_ORG}" ]; then + error "Failed to get [GITHUB_ORG]!" + fatal "[${GITHUB_ORG}]" + else + info "Successfully found:${F[W]}[GITHUB_ORG]${F[B]}, value:${F[W]}[${GITHUB_ORG}]" + fi + + ####################### + # Get the GitHub Repo # + ####################### + GITHUB_REPO=$(jq -r '.repository.name' < "${GITHUB_EVENT_PATH}") + + ############################ + # Validate we have a value # + ############################ + if [ -z "${GITHUB_REPO}" ]; then + error "Failed to get [GITHUB_REPO]!" + fatal "[${GITHUB_REPO}]" + else + info "Successfully found:${F[W]}[GITHUB_REPO]${F[B]}, value:${F[W]}[${GITHUB_REPO}]" + fi + fi + + ############################ + # Validate we have a value # + ############################ + if [ -z "${GITHUB_TOKEN}" ] && [[ ${RUN_LOCAL} == "false" ]]; then + error "Failed to get [GITHUB_TOKEN]!" + error "[${GITHUB_TOKEN}]" + error "Please set a [GITHUB_TOKEN] from the main workflow environment to take advantage of multiple status reports!" + + ################################################################################ + # Need to set MULTI_STATUS to false as we cant hit API endpoints without token # + ################################################################################ + MULTI_STATUS='false' + else + info "Successfully found:${F[W]}[GITHUB_TOKEN]" + fi + + ############################### + # Convert string to lowercase # + ############################### + MULTI_STATUS="${MULTI_STATUS,,}" + + ####################################################################### + # Check to see if the multi status is set, and we have a token to use # + ####################################################################### + if [ "${MULTI_STATUS}" == "true" ] && [ -n "${GITHUB_TOKEN}" ]; then + ############################ + # Validate we have a value # + ############################ + if [ -z "${GITHUB_REPOSITORY}" ]; then + error "Failed to get [GITHUB_REPOSITORY]!" + fatal "[${GITHUB_REPOSITORY}]" + else + info "Successfully found:${F[W]}[GITHUB_REPOSITORY]${F[B]}, value:${F[W]}[${GITHUB_REPOSITORY}]" + fi + + ############################ + # Validate we have a value # + ############################ + if [ -z "${GITHUB_RUN_ID}" ]; then + error "Failed to get [GITHUB_RUN_ID]!" + fatal "[${GITHUB_RUN_ID}]" + else + info "Successfully found:${F[W]}[GITHUB_RUN_ID]${F[B]}, value:${F[W]}[${GITHUB_RUN_ID}]" + fi + fi } ################################################################################ #### Function ValidatePowershellModules ######################################## function ValidatePowershellModules() { - VALIDATE_PSSA_MODULE=$(pwsh -c "(Get-Module -Name PSScriptAnalyzer -ListAvailable | Select-Object -First 1).Name" 2>&1) - # If module found, ensure Invoke-ScriptAnalyzer command is available - if [[ ${VALIDATE_PSSA_MODULE} == "PSScriptAnalyzer" ]]; then - VALIDATE_PSSA_CMD=$(pwsh -c "(Get-Command Invoke-ScriptAnalyzer | Select-Object -First 1).Name" 2>&1) - else - fatal "Failed to find module." - fi + VALIDATE_PSSA_MODULE=$(pwsh -c "(Get-Module -Name PSScriptAnalyzer -ListAvailable | Select-Object -First 1).Name" 2>&1) + # If module found, ensure Invoke-ScriptAnalyzer command is available + if [[ ${VALIDATE_PSSA_MODULE} == "PSScriptAnalyzer" ]]; then + VALIDATE_PSSA_CMD=$(pwsh -c "(Get-Command Invoke-ScriptAnalyzer | Select-Object -First 1).Name" 2>&1) + else + fatal "Failed to find module." + fi - ######################################### - # validate we found the script analyzer # - ######################################### - if [[ ${VALIDATE_PSSA_CMD} != "Invoke-ScriptAnalyzer" ]]; then - fatal "Failed to find module." - fi + ######################################### + # validate we found the script analyzer # + ######################################### + if [[ ${VALIDATE_PSSA_CMD} != "Invoke-ScriptAnalyzer" ]]; then + fatal "Failed to find module." + fi + + ####################### + # Load the error code # + ####################### + ERROR_CODE=$? + + ############################## + # Check the shell for errors # + ############################## + if [ ${ERROR_CODE} -ne 0 ]; then + # Failed + error "Failed find module [PSScriptAnalyzer] for [${LINTER_NAME}] in system!" + fatal "[PSSA_MODULE ${VALIDATE_PSSA_MODULE}] [PSSA_CMD ${VALIDATE_PSSA_CMD}]" + else + # Success + debug "Successfully found module ${F[W]}[${VALIDATE_PSSA_MODULE}]${F[B]} in system" + debug "Successfully found command ${F[W]}[${VALIDATE_PSSA_CMD}]${F[B]} in system" + fi +} +################################################################################ +#### Function CallStatusAPI #################################################### +CallStatusAPI() { + #################### + # Pull in the vars # + #################### + LANGUAGE="${1}" # langauge that was validated + STATUS="${2}" # success | error + SUCCESS_MSG='No errors were found in the linting process' + FAIL_MSG='Errors were detected, please view logs' + MESSAGE='' # Message to send to status API + + ###################################### + # Check the status to create message # + ###################################### + if [ "${STATUS}" == "success" ]; then + # Success + MESSAGE="${SUCCESS_MSG}" + else + # Failure + MESSAGE="${FAIL_MSG}" + fi + + ########################################################## + # Check to see if were enabled for multi Status mesaages # + ########################################################## + if [ "${MULTI_STATUS}" == "true" ]; then + ############################################## + # Call the status API to create status check # + ############################################## + SEND_STATUS_CMD=$(curl -f -s -X POST \ + --url "${GITHUB_API_URL}/repos/${GITHUB_REPOSITORY}/statuses/${GITHUB_SHA}" \ + -H 'accept: application/vnd.github.v3+json' \ + -H "authorization: Bearer ${GITHUB_TOKEN}" \ + -H 'content-type: application/json' \ + -d "{ \"state\": \"${STATUS}\", + \"target_url\": \"https://github.com/${GITHUB_REPOSITORY}/actions/runs/${GITHUB_RUN_ID}\", + \"description\": \"${MESSAGE}\", \"context\": \"--> Linted: ${LANGUAGE}\" + }" 2>&1) ####################### # Load the error code # @@ -865,182 +923,124 @@ function ValidatePowershellModules() { ############################## # Check the shell for errors # ############################## - if [ ${ERROR_CODE} -ne 0 ]; then - # Failed - error "Failed find module [PSScriptAnalyzer] for [${LINTER_NAME}] in system!" - fatal "[PSSA_MODULE ${VALIDATE_PSSA_MODULE}] [PSSA_CMD ${VALIDATE_PSSA_CMD}]" - else - # Success - debug "Successfully found module ${F[W]}[${VALIDATE_PSSA_MODULE}]${F[B]} in system" - debug "Successfully found command ${F[W]}[${VALIDATE_PSSA_CMD}]${F[B]} in system" - fi -} -################################################################################ -#### Function CallStatusAPI #################################################### -CallStatusAPI() { - #################### - # Pull in the vars # - #################### - LANGUAGE="${1}" # langauge that was validated - STATUS="${2}" # success | error - SUCCESS_MSG='No errors were found in the linting process' - FAIL_MSG='Errors were detected, please view logs' - MESSAGE='' # Message to send to status API - - ###################################### - # Check the status to create message # - ###################################### - if [ "${STATUS}" == "success" ]; then - # Success - MESSAGE="${SUCCESS_MSG}" - else - # Failure - MESSAGE="${FAIL_MSG}" - fi - - ########################################################## - # Check to see if were enabled for multi Status mesaages # - ########################################################## - if [ "${MULTI_STATUS}" == "true" ]; then - ############################################## - # Call the status API to create status check # - ############################################## - SEND_STATUS_CMD=$(curl -f -s -X POST \ - --url "${GITHUB_API_URL}/repos/${GITHUB_REPOSITORY}/statuses/${GITHUB_SHA}" \ - -H 'accept: application/vnd.github.v3+json' \ - -H "authorization: Bearer ${GITHUB_TOKEN}" \ - -H 'content-type: application/json' \ - -d "{ \"state\": \"${STATUS}\", - \"target_url\": \"https://github.com/${GITHUB_REPOSITORY}/actions/runs/${GITHUB_RUN_ID}\", - \"description\": \"${MESSAGE}\", \"context\": \"--> Linted: ${LANGUAGE}\" - }" 2>&1) - - ####################### - # Load the error code # - ####################### - ERROR_CODE=$? - - ############################## - # Check the shell for errors # - ############################## - if [ "${ERROR_CODE}" -ne 0 ]; then - # ERROR - info "ERROR! Failed to call GitHub Status API!" - info "ERROR:[${SEND_STATUS_CMD}]" - # Not going to fail the script on this yet... - fi + if [ "${ERROR_CODE}" -ne 0 ]; then + # ERROR + info "ERROR! Failed to call GitHub Status API!" + info "ERROR:[${SEND_STATUS_CMD}]" + # Not going to fail the script on this yet... fi + fi } ################################################################################ #### Function Reports ########################################################## Reports() { - info "----------------------------------------------" - info "----------------------------------------------" - info "Generated reports:" - info "----------------------------------------------" - info "----------------------------------------------" + info "----------------------------------------------" + info "----------------------------------------------" + info "Generated reports:" + info "----------------------------------------------" + info "----------------------------------------------" - ################################### - # Prints output report if enabled # - ################################### - if [ -z "${FORMAT_REPORT}" ]; then - info "Reports generated in folder ${REPORT_OUTPUT_FOLDER}" - fi + ################################### + # Prints output report if enabled # + ################################### + if [ -z "${FORMAT_REPORT}" ]; then + info "Reports generated in folder ${REPORT_OUTPUT_FOLDER}" + fi - ################################ - # Prints for warnings if found # - ################################ - for TEST in "${WARNING_ARRAY_TEST[@]}"; do - warn "Expected file to compare with was not found for ${TEST}" - done + ################################ + # Prints for warnings if found # + ################################ + for TEST in "${WARNING_ARRAY_TEST[@]}"; do + warn "Expected file to compare with was not found for ${TEST}" + done } ################################################################################ #### Function Footer ########################################################### Footer() { - info "----------------------------------------------" - info "----------------------------------------------" - info "The script has completed" - info "----------------------------------------------" - info "----------------------------------------------" + info "----------------------------------------------" + info "----------------------------------------------" + info "The script has completed" + info "----------------------------------------------" + info "----------------------------------------------" - #################################################### - # Need to clean up the lanuage array of duplicates # - #################################################### - mapfile -t UNIQUE_LINTED_ARRAY < <(echo "${LINTED_LANGUAGES_ARRAY[@]}" | tr ' ' '\n' | sort -u | tr '\n' ' ') + #################################################### + # Need to clean up the lanuage array of duplicates # + #################################################### + mapfile -t UNIQUE_LINTED_ARRAY < <(echo "${LINTED_LANGUAGES_ARRAY[@]}" | tr ' ' '\n' | sort -u | tr '\n' ' ') - ############################## - # Prints for errors if found # - ############################## - for LANGUAGE in "${LANGUAGE_ARRAY[@]}"; do - ########################### - # Build the error counter # - ########################### - ERROR_COUNTER="ERRORS_FOUND_${LANGUAGE}" + ############################## + # Prints for errors if found # + ############################## + for LANGUAGE in "${LANGUAGE_ARRAY[@]}"; do + ########################### + # Build the error counter # + ########################### + ERROR_COUNTER="ERRORS_FOUND_${LANGUAGE}" - ################## - # Print if not 0 # - ################## - if [[ ${!ERROR_COUNTER} -ne 0 ]]; then - # We found errors in the language - ################### - # Print the goods # - ################### - error "ERRORS FOUND${NC} in ${LANGUAGE}:[${!ERROR_COUNTER}]" + ################## + # Print if not 0 # + ################## + if [[ ${!ERROR_COUNTER} -ne 0 ]]; then + # We found errors in the language + ################### + # Print the goods # + ################### + error "ERRORS FOUND${NC} in ${LANGUAGE}:[${!ERROR_COUNTER}]" - ######################################### - # Create status API for Failed language # - ######################################### - CallStatusAPI "${LANGUAGE}" "error" - ###################################### - # Check if we validated the langauge # - ###################################### - elif [[ ${!ERROR_COUNTER} -eq 0 ]] && [[ ${UNIQUE_LINTED_ARRAY[*]} =~ ${LANGUAGE} ]]; then - # No errors found when linting the language - CallStatusAPI "${LANGUAGE}" "success" - fi - done - - ################################## - # Exit with 0 if errors disabled # - ################################## - if [ "${DISABLE_ERRORS}" == "true" ]; then - warn "Exiting with exit code:[0] as:[DISABLE_ERRORS] was set to:[${DISABLE_ERRORS}]" - exit 0 + ######################################### + # Create status API for Failed language # + ######################################### + CallStatusAPI "${LANGUAGE}" "error" + ###################################### + # Check if we validated the langauge # + ###################################### + elif [[ ${!ERROR_COUNTER} -eq 0 ]] && [[ ${UNIQUE_LINTED_ARRAY[*]} =~ ${LANGUAGE} ]]; then + # No errors found when linting the language + CallStatusAPI "${LANGUAGE}" "success" fi + done - ############################### - # Exit with 1 if errors found # - ############################### - # Loop through all languages - for LANGUAGE in "${LANGUAGE_ARRAY[@]}"; do - # build the variable - ERRORS_FOUND_LANGUAGE="ERRORS_FOUND_${LANGUAGE}" - # Check if error was found - if [[ ${!ERRORS_FOUND_LANGUAGE} -ne 0 ]]; then - # Failed exit - fatal "Exiting with errors found!" - fi - done - - ######################## - # Footer prints Exit 0 # - ######################## - notice "All file(s) linted successfully with no errors detected" - info "----------------------------------------------" - # Successful exit + ################################## + # Exit with 0 if errors disabled # + ################################## + if [ "${DISABLE_ERRORS}" == "true" ]; then + warn "Exiting with exit code:[0] as:[DISABLE_ERRORS] was set to:[${DISABLE_ERRORS}]" exit 0 + fi + + ############################### + # Exit with 1 if errors found # + ############################### + # Loop through all languages + for LANGUAGE in "${LANGUAGE_ARRAY[@]}"; do + # build the variable + ERRORS_FOUND_LANGUAGE="ERRORS_FOUND_${LANGUAGE}" + # Check if error was found + if [[ ${!ERRORS_FOUND_LANGUAGE} -ne 0 ]]; then + # Failed exit + fatal "Exiting with errors found!" + fi + done + + ######################## + # Footer prints Exit 0 # + ######################## + notice "All file(s) linted successfully with no errors detected" + info "----------------------------------------------" + # Successful exit + exit 0 } ################################################################################ #### Function Cleanup ########################################################## cleanup() { - local -ri EXIT_CODE=$? + local -ri EXIT_CODE=$? - sh -c "cat ${LOG_TEMP} >> ${GITHUB_WORKSPACE}/${LOG_FILE}" || true + sh -c "cat ${LOG_TEMP} >> ${GITHUB_WORKSPACE}/${LOG_FILE}" || true - exit ${EXIT_CODE} - trap - 0 1 2 3 6 14 15 + exit ${EXIT_CODE} + trap - 0 1 2 3 6 14 15 } trap 'cleanup' 0 1 2 3 6 14 15 @@ -1057,10 +1057,10 @@ Header # check flag for validating the report folder does not exist # ############################################################## if [ -n "${OUTPUT_FORMAT}" ]; then - if [ -d "${REPORT_OUTPUT_FOLDER}" ]; then - error "ERROR! Found ${REPORT_OUTPUT_FOLDER}" - fatal "Please remove the folder and try again." - fi + if [ -d "${REPORT_OUTPUT_FOLDER}" ]; then + error "ERROR! Found ${REPORT_OUTPUT_FOLDER}" + fatal "Please remove the folder and try again." + fi fi ####################### @@ -1129,560 +1129,560 @@ GetLinterVersions ########################################### if [[ ${TEST_CASE_RUN} != "false" ]]; then - ############################################# - # Set the multi status to off for test runs # - ############################################# - MULTI_STATUS='false' + ############################################# + # Set the multi status to off for test runs # + ############################################# + MULTI_STATUS='false' - ########################### - # Run only the test cases # - ########################### - # Code will exit from inside this loop - RunTestCases + ########################### + # Run only the test cases # + ########################### + # Code will exit from inside this loop + RunTestCases fi ############################################# # check flag for validation of all codebase # ############################################# if [ "${VALIDATE_ALL_CODEBASE}" == "false" ]; then - ######################################## - # Get list of files changed if env set # - ######################################## - BuildFileList + ######################################## + # Get list of files changed if env set # + ######################################## + BuildFileList fi ################### # ANSIBLE LINTING # ################### if [ "${VALIDATE_ANSIBLE}" == "true" ]; then - ########################## - # Lint the Ansible files # - ########################## - # Due to the nature of how we want to validate Ansible, we cannot use the - # 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 + ########################## + # Lint the Ansible files # + ########################## + # Due to the nature of how we want to validate Ansible, we cannot use the + # 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 ######################## # 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' + # 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 + 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 + ########################### + # 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[@]}" + ############################### + # 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 ################ # BASH LINTING # ################ if [ "${VALIDATE_BASH}" == "true" ]; then - ####################### - # Lint the bash files # - ####################### - # LintCodebase "FILE_TYPE" "LINTER_NAME" "LINTER_CMD" "FILE_TYPES_REGEX" "FILE_ARRAY" - LintCodebase "BASH" "shellcheck" "shellcheck --color" ".*\.\(sh\|bash\|dash\|ksh\)\$" "${FILE_ARRAY_BASH[@]}" + ####################### + # Lint the bash files # + ####################### + # LintCodebase "FILE_TYPE" "LINTER_NAME" "LINTER_CMD" "FILE_TYPES_REGEX" "FILE_ARRAY" + LintCodebase "BASH" "shellcheck" "shellcheck --color" ".*\.\(sh\|bash\|dash\|ksh\)\$" "${FILE_ARRAY_BASH[@]}" fi ########################## # CLOUDFORMATION LINTING # ########################## if [ "${VALIDATE_CLOUDFORMATION}" == "true" ]; then - # If we are validating all codebase we need to build file list because not every yml/json file is an CLOUDFORMATION file - if [ "${VALIDATE_ALL_CODEBASE}" == "true" ]; then - ############################################################################### - # Set the file seperator to newline to allow for grabbing objects with spaces # - ############################################################################### - IFS=$'\n' + # If we are validating all codebase we need to build file list because not every yml/json file is an CLOUDFORMATION 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 DetectCloudFormationFile "${FILE}"; then - FILE_ARRAY_CLOUDFORMATION+=("${FILE}") - fi - done + mapfile -t LIST_FILES < <(find "${GITHUB_WORKSPACE}" -type f -regex ".*\.\(yml\|yaml\|json\)\$" 2>&1) + for FILE in "${LIST_FILES[@]}"; do + if DetectCloudFormationFile "${FILE}"; then + FILE_ARRAY_CLOUDFORMATION+=("${FILE}") + fi + done - ########################### - # Set IFS back to default # - ########################### - IFS="${DEFAULT_IFS}" - fi + ########################### + # Set IFS back to default # + ########################### + IFS="${DEFAULT_IFS}" + fi - ################################# - # Lint the CloudFormation files # - ################################# - # LintCodebase "FILE_TYPE" "LINTER_NAME" "LINTER_CMD" "FILE_TYPES_REGEX" "FILE_ARRAY" - LintCodebase "CLOUDFORMATION" "cfn-lint" "cfn-lint --config-file ${CLOUDFORMATION_LINTER_RULES}" "disabledfileext" "${FILE_ARRAY_CLOUDFORMATION[@]}" + ################################# + # Lint the CloudFormation files # + ################################# + # LintCodebase "FILE_TYPE" "LINTER_NAME" "LINTER_CMD" "FILE_TYPES_REGEX" "FILE_ARRAY" + LintCodebase "CLOUDFORMATION" "cfn-lint" "cfn-lint --config-file ${CLOUDFORMATION_LINTER_RULES}" "disabledfileext" "${FILE_ARRAY_CLOUDFORMATION[@]}" 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[@]}" + ################################# + # 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 ######################## # COFFEESCRIPT LINTING # ######################## if [ "${VALIDATE_COFFEE}" == "true" ]; then - ######################### - # Lint the coffee files # - ######################### - # LintCodebase "FILE_TYPE" "LINTER_NAME" "LINTER_CMD" "FILE_TYPES_REGEX" "FILE_ARRAY" - LintCodebase "COFFEESCRIPT" "coffeelint" "coffeelint -f ${COFFEESCRIPT_LINTER_RULES}" ".*\.\(coffee\)\$" "${FILE_ARRAY_COFFEESCRIPT[@]}" + ######################### + # Lint the coffee files # + ######################### + # LintCodebase "FILE_TYPE" "LINTER_NAME" "LINTER_CMD" "FILE_TYPES_REGEX" "FILE_ARRAY" + LintCodebase "COFFEESCRIPT" "coffeelint" "coffeelint -f ${COFFEESCRIPT_LINTER_RULES}" ".*\.\(coffee\)\$" "${FILE_ARRAY_COFFEESCRIPT[@]}" 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[@]}" + ################################# + # 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[@]}" + ####################### + # 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[@]}" + ######################### + # 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[@]}" + #################################### + # 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[@]}" + ####################### + # 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 # ################## if [ "${VALIDATE_GO}" == "true" ]; then - ######################### - # Lint the golang files # - ######################### - # LintCodebase "FILE_TYPE" "LINTER_NAME" "LINTER_CMD" "FILE_TYPES_REGEX" "FILE_ARRAY" - LintCodebase "GO" "golangci-lint" "golangci-lint run -c ${GO_LINTER_RULES}" ".*\.\(go\)\$" "${FILE_ARRAY_GO[@]}" + ######################### + # Lint the golang files # + ######################### + # LintCodebase "FILE_TYPE" "LINTER_NAME" "LINTER_CMD" "FILE_TYPES_REGEX" "FILE_ARRAY" + LintCodebase "GO" "golangci-lint" "golangci-lint run -c ${GO_LINTER_RULES}" ".*\.\(go\)\$" "${FILE_ARRAY_GO[@]}" fi ################## # GROOVY LINTING # ################## if [ "$VALIDATE_GROOVY" == "true" ]; then - ######################### - # Lint the groovy files # - ######################### - # LintCodebase "FILE_TYPE" "LINTER_NAME" "LINTER_CMD" "FILE_TYPES_REGEX" "FILE_ARRAY" - LintCodebase "GROOVY" "npm-groovy-lint" "npm-groovy-lint -c $GROOVY_LINTER_RULES --failon error" ".*\.\(groovy\|jenkinsfile\|gradle\)\$" "${FILE_ARRAY_GROOVY[@]}" + ######################### + # Lint the groovy files # + ######################### + # LintCodebase "FILE_TYPE" "LINTER_NAME" "LINTER_CMD" "FILE_TYPES_REGEX" "FILE_ARRAY" + LintCodebase "GROOVY" "npm-groovy-lint" "npm-groovy-lint -c $GROOVY_LINTER_RULES --failon error" ".*\.\(groovy\|jenkinsfile\|gradle\)\$" "${FILE_ARRAY_GROOVY[@]}" 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[@]}" + ########################### + # Get HTML standard rules # + ########################### + GetStandardRules "htmlhint" + ####################### + # Lint the HTML files # + ####################### + LintCodebase "HTML" "htmlhint" "htmlhint --config ${HTML_LINTER_RULES}" ".*\.\(html\)\$" "${FILE_ARRAY_HTML[@]}" fi ###################### # JAVASCRIPT LINTING # ###################### if [ "${VALIDATE_JAVASCRIPT_ES}" == "true" ]; then - ############################# - # Lint the Javascript files # - ############################# - # LintCodebase "FILE_TYPE" "LINTER_NAME" "LINTER_CMD" "FILE_TYPES_REGEX" "FILE_ARRAY" - LintCodebase "JAVASCRIPT_ES" "eslint" "eslint --no-eslintrc -c ${JAVASCRIPT_LINTER_RULES}" ".*\.\(js\)\$" "${FILE_ARRAY_JAVASCRIPT_ES[@]}" + ############################# + # Lint the Javascript files # + ############################# + # LintCodebase "FILE_TYPE" "LINTER_NAME" "LINTER_CMD" "FILE_TYPES_REGEX" "FILE_ARRAY" + LintCodebase "JAVASCRIPT_ES" "eslint" "eslint --no-eslintrc -c ${JAVASCRIPT_LINTER_RULES}" ".*\.\(js\)\$" "${FILE_ARRAY_JAVASCRIPT_ES[@]}" fi ###################### # JAVASCRIPT LINTING # ###################### if [ "${VALIDATE_JAVASCRIPT_STANDARD}" == "true" ]; then - ################################# - # Get Javascript standard rules # - ################################# - GetStandardRules "javascript" - ############################# - # Lint the Javascript files # - ############################# - # LintCodebase "FILE_TYPE" "LINTER_NAME" "LINTER_CMD" "FILE_TYPES_REGEX" "FILE_ARRAY" - LintCodebase "JAVASCRIPT_STANDARD" "standard" "standard ${JAVASCRIPT_STANDARD_LINTER_RULES}" ".*\.\(js\)\$" "${FILE_ARRAY_JAVASCRIPT_STANDARD[@]}" + ################################# + # Get Javascript standard rules # + ################################# + GetStandardRules "javascript" + ############################# + # Lint the Javascript files # + ############################# + # LintCodebase "FILE_TYPE" "LINTER_NAME" "LINTER_CMD" "FILE_TYPES_REGEX" "FILE_ARRAY" + LintCodebase "JAVASCRIPT_STANDARD" "standard" "standard ${JAVASCRIPT_STANDARD_LINTER_RULES}" ".*\.\(js\)\$" "${FILE_ARRAY_JAVASCRIPT_STANDARD[@]}" 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[@]}" + ####################### + # 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 # ############### if [ "${VALIDATE_JSX}" == "true" ]; then - ###################### - # Lint the JSX files # - ###################### - # LintCodebase "FILE_TYPE" "LINTER_NAME" "LINTER_CMD" "FILE_TYPES_REGEX" "FILE_ARRAY" - LintCodebase "JSX" "eslint" "eslint --no-eslintrc -c ${JAVASCRIPT_LINTER_RULES}" ".*\.\(jsx\)\$" "${FILE_ARRAY_JSX[@]}" + ###################### + # Lint the JSX files # + ###################### + # LintCodebase "FILE_TYPE" "LINTER_NAME" "LINTER_CMD" "FILE_TYPES_REGEX" "FILE_ARRAY" + LintCodebase "JSX" "eslint" "eslint --no-eslintrc -c ${JAVASCRIPT_LINTER_RULES}" ".*\.\(jsx\)\$" "${FILE_ARRAY_JSX[@]}" 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[@]}" + ####################### + # 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 ############### # LUA LINTING # ############### if [ "${VALIDATE_LUA}" == "true" ]; then - ###################### - # Lint the Lua files # - ###################### - # LintCodebase "FILE_TYPE" "LINTER_NAME" "LINTER_CMD" "FILE_TYPES_REGEX" "FILE_ARRAY" - LintCodebase "LUA" "lua" "luacheck --config ${LUA_LINTER_RULES}" ".*\.\(lua\)\$" "${FILE_ARRAY_LUA[@]}" + ###################### + # Lint the Lua files # + ###################### + # LintCodebase "FILE_TYPE" "LINTER_NAME" "LINTER_CMD" "FILE_TYPES_REGEX" "FILE_ARRAY" + LintCodebase "LUA" "lua" "luacheck --config ${LUA_LINTER_RULES}" ".*\.\(lua\)\$" "${FILE_ARRAY_LUA[@]}" 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[@]}" + ########################### + # 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' + # 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 + 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 + ########################### + # 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[@]}" + ########################## + # 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[@]}" + ####################### + # 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[@]}" + ####################### + # 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 ################### # PHPStan LINTING # ################### if [ "${VALIDATE_PHP_PHPSTAN}" == "true" ]; then - ####################### - # Lint the PHP files # - ####################### - # LintCodebase "FILE_TYPE" "LINTER_NAME" "LINTER_CMD" "FILE_TYPES_REGEX" "FILE_ARRAY" - LintCodebase "PHP_PHPSTAN" "phpstan" "phpstan analyse --no-progress --no-ansi -c ${PHPSTAN_LINTER_RULES}" ".*\.\(php\)\$" "${FILE_ARRAY_PHP_PHPSTAN[@]}" + ####################### + # Lint the PHP files # + ####################### + # LintCodebase "FILE_TYPE" "LINTER_NAME" "LINTER_CMD" "FILE_TYPES_REGEX" "FILE_ARRAY" + LintCodebase "PHP_PHPSTAN" "phpstan" "phpstan analyse --no-progress --no-ansi -c ${PHPSTAN_LINTER_RULES}" ".*\.\(php\)\$" "${FILE_ARRAY_PHP_PHPSTAN[@]}" fi ###################### # POWERSHELL LINTING # ###################### if [ "${VALIDATE_POWERSHELL}" == "true" ]; then - ############################################################### - # For POWERSHELL, ensure PSScriptAnalyzer module is available # - ############################################################### - ValidatePowershellModules + ############################################################### + # 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[@]}" + ############################# + # 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[@]}" + ####################### + # 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_PYLINT}" == "true" ]; then - ######################### - # Lint the python files # - ######################### - # LintCodebase "FILE_TYPE" "LINTER_NAME" "LINTER_CMD" "FILE_TYPES_REGEX" "FILE_ARRAY" - LintCodebase "PYTHON_PYLINT" "pylint" "pylint --rcfile ${PYTHON_PYLINT_LINTER_RULES}" ".*\.\(py\)\$" "${FILE_ARRAY_PYTHON_PYLINT[@]}" + ######################### + # Lint the python files # + ######################### + # LintCodebase "FILE_TYPE" "LINTER_NAME" "LINTER_CMD" "FILE_TYPES_REGEX" "FILE_ARRAY" + LintCodebase "PYTHON_PYLINT" "pylint" "pylint --rcfile ${PYTHON_PYLINT_LINTER_RULES}" ".*\.\(py\)\$" "${FILE_ARRAY_PYTHON_PYLINT[@]}" fi ################## # PYTHON LINTING # ################## if [ "${VALIDATE_PYTHON_FLAKE8}" == "true" ]; then - ######################### - # Lint the python files # - ######################### - # LintCodebase "FILE_TYPE" "LINTER_NAME" "LINTER_CMD" "FILE_TYPES_REGEX" "FILE_ARRAY" - LintCodebase "PYTHON_FLAKE8" "flake8" "flake8 --config=${PYTHON_FLAKE8_LINTER_RULES}" ".*\.\(py\)\$" "${FILE_ARRAY_PYTHON_FLAKE8[@]}" + ######################### + # Lint the python files # + ######################### + # LintCodebase "FILE_TYPE" "LINTER_NAME" "LINTER_CMD" "FILE_TYPES_REGEX" "FILE_ARRAY" + LintCodebase "PYTHON_FLAKE8" "flake8" "flake8 --config=${PYTHON_FLAKE8_LINTER_RULES}" ".*\.\(py\)\$" "${FILE_ARRAY_PYTHON_FLAKE8[@]}" fi ################ # RAKU LINTING # ################ if [ "${VALIDATE_RAKU}" == "true" ]; then - ####################### - # Lint the raku files # - ####################### - info "${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[@]}" + ####################### + # Lint the raku files # + ####################### + info "${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[@]}" + ####################### + # 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' + # 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 + 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 + ########################### + # 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[@]}" + ######################### + # 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[@]}" + ############################ + # 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 ############################### # TERRAFORM TERRASCAN LINTING # ############################### if [ "${VALIDATE_TERRAFORM_TERRASCAN}" == "true" ]; then - ############################ - # Lint the Terraform files # - ############################ - # LintCodebase "FILE_TYPE" "LINTER_NAME" "LINTER_CMD" "FILE_TYPES_REGEX" "FILE_ARRAY" - LintCodebase "TERRAFORM_TERRASCAN" "terrascan" "terrascan -f " ".*\.\(tf\)\$" "${FILE_ARRAY_TERRAFORM_TERRASCAN[@]}" + ############################ + # Lint the Terraform files # + ############################ + # LintCodebase "FILE_TYPE" "LINTER_NAME" "LINTER_CMD" "FILE_TYPES_REGEX" "FILE_ARRAY" + LintCodebase "TERRAFORM_TERRASCAN" "terrascan" "terrascan -f " ".*\.\(tf\)\$" "${FILE_ARRAY_TERRAFORM_TERRASCAN[@]}" fi ############### # TSX LINTING # ############### if [ "${VALIDATE_TSX}" == "true" ]; then - ###################### - # Lint the TSX files # - ###################### - LintCodebase "TSX" "eslint" "eslint --no-eslintrc -c ${TYPESCRIPT_LINTER_RULES}" ".*\.\(tsx\)\$" "${FILE_ARRAY_TSX[@]}" + ###################### + # Lint the TSX files # + ###################### + LintCodebase "TSX" "eslint" "eslint --no-eslintrc -c ${TYPESCRIPT_LINTER_RULES}" ".*\.\(tsx\)\$" "${FILE_ARRAY_TSX[@]}" fi ###################### # TYPESCRIPT LINTING # ###################### if [ "${VALIDATE_TYPESCRIPT_ES}" == "true" ]; then - ############################# - # Lint the Typescript files # - ############################# - LintCodebase "TYPESCRIPT_ES" "eslint" "eslint --no-eslintrc -c ${TYPESCRIPT_LINTER_RULES}" ".*\.\(ts\)\$" "${FILE_ARRAY_TYPESCRIPT_ES[@]}" + ############################# + # Lint the Typescript files # + ############################# + LintCodebase "TYPESCRIPT_ES" "eslint" "eslint --no-eslintrc -c ${TYPESCRIPT_LINTER_RULES}" ".*\.\(ts\)\$" "${FILE_ARRAY_TYPESCRIPT_ES[@]}" fi ###################### # TYPESCRIPT LINTING # ###################### if [ "${VALIDATE_TYPESCRIPT_STANDARD}" == "true" ]; then - ################################# - # Get Typescript standard rules # - ################################# - GetStandardRules "typescript" - ############################# - # Lint the Typescript files # - ############################# - LintCodebase "TYPESCRIPT_STANDARD" "standard" "standard --parser @typescript-eslint/parser --plugin @typescript-eslint/eslint-plugin ${TYPESCRIPT_STANDARD_LINTER_RULES}" ".*\.\(ts\)\$" "${FILE_ARRAY_TYPESCRIPT_STANDARD[@]}" + ################################# + # Get Typescript standard rules # + ################################# + GetStandardRules "typescript" + ############################# + # Lint the Typescript files # + ############################# + LintCodebase "TYPESCRIPT_STANDARD" "standard" "standard --parser @typescript-eslint/parser --plugin @typescript-eslint/eslint-plugin ${TYPESCRIPT_STANDARD_LINTER_RULES}" ".*\.\(ts\)\$" "${FILE_ARRAY_TYPESCRIPT_STANDARD[@]}" fi ############### # XML LINTING # ############### if [ "${VALIDATE_XML}" == "true" ]; then - ###################### - # Lint the XML Files # - ###################### - # LintCodebase "FILE_TYPE" "LINTER_NAME" "LINTER_CMD" "FILE_TYPES_REGEX" "FILE_ARRAY" - LintCodebase "XML" "xmllint" "xmllint" ".*\.\(xml\)\$" "${FILE_ARRAY_XML[@]}" + ###################### + # Lint the XML Files # + ###################### + # LintCodebase "FILE_TYPE" "LINTER_NAME" "LINTER_CMD" "FILE_TYPES_REGEX" "FILE_ARRAY" + LintCodebase "XML" "xmllint" "xmllint" ".*\.\(xml\)\$" "${FILE_ARRAY_XML[@]}" fi ############### # YAML LINTING # ############### if [ "${VALIDATE_YAML}" == "true" ]; then - ###################### - # Lint the Yml Files # - ###################### - # LintCodebase "FILE_TYPE" "LINTER_NAME" "LINTER_CMD" "FILE_TYPES_REGEX" "FILE_ARRAY" - LintCodebase "YAML" "yamllint" "yamllint -c ${YAML_LINTER_RULES}" ".*\.\(yml\|yaml\)\$" "${FILE_ARRAY_YAML[@]}" + ###################### + # Lint the Yml Files # + ###################### + # LintCodebase "FILE_TYPE" "LINTER_NAME" "LINTER_CMD" "FILE_TYPES_REGEX" "FILE_ARRAY" + LintCodebase "YAML" "yamllint" "yamllint -c ${YAML_LINTER_RULES}" ".*\.\(yml\|yaml\)\$" "${FILE_ARRAY_YAML[@]}" fi ########### diff --git a/lib/log.sh b/lib/log.sh index f6bd73a2..a7ab55d9 100644 --- a/lib/log.sh +++ b/lib/log.sh @@ -1,24 +1,24 @@ #!/usr/bin/env bash declare -Agr B=( - [B]=$(echo -e "\e[44m") - [C]=$(echo -e "\e[46m") - [G]=$(echo -e "\e[42m") - [K]=$(echo -e "\e[40m") - [M]=$(echo -e "\e[45m") - [R]=$(echo -e "\e[41m") - [W]=$(echo -e "\e[47m") - [Y]=$(echo -e "\e[43m") + [B]=$(echo -e "\e[44m") + [C]=$(echo -e "\e[46m") + [G]=$(echo -e "\e[42m") + [K]=$(echo -e "\e[40m") + [M]=$(echo -e "\e[45m") + [R]=$(echo -e "\e[41m") + [W]=$(echo -e "\e[47m") + [Y]=$(echo -e "\e[43m") ) declare -Agr F=( - [B]=$(echo -e "\e[0;34m") - [C]=$(echo -e "\e[0;36m") - [G]=$(echo -e "\e[0;32m") - [K]=$(echo -e "\e[0;30m") - [M]=$(echo -e "\e[0;35m") - [R]=$(echo -e "\e[0;31m") - [W]=$(echo -e "\e[0;37m") - [Y]=$(echo -e "\e[0;33m") + [B]=$(echo -e "\e[0;34m") + [C]=$(echo -e "\e[0;36m") + [G]=$(echo -e "\e[0;32m") + [K]=$(echo -e "\e[0;30m") + [M]=$(echo -e "\e[0;35m") + [R]=$(echo -e "\e[0;31m") + [W]=$(echo -e "\e[0;37m") + [Y]=$(echo -e "\e[0;33m") ) readonly NC=$(echo -e "\e[0m") @@ -31,15 +31,15 @@ LOG_TEMP=$(mktemp) || echo "Failed to create temporary log file." export LOG_TEMP echo "super-linter Log" > "${LOG_TEMP}" log() { - local TOTERM=${1:-} - local MESSAGE=${2:-} - echo -e "${MESSAGE:-}" | ( - if [[ -n ${TOTERM} ]]; then - tee -a "${LOG_TEMP}" >&2 - else - cat >> "${LOG_TEMP}" 2>&1 - fi - ) + local TOTERM=${1:-} + local MESSAGE=${2:-} + echo -e "${MESSAGE:-}" | ( + if [[ -n ${TOTERM} ]]; then + tee -a "${LOG_TEMP}" >&2 + else + cat >> "${LOG_TEMP}" 2>&1 + fi + ) } trace() { log "${LOG_TRACE:-}" "${NC}$(date +"%F %T") ${F[B]}[TRACE ]${NC} $*${NC}"; } debug() { log "${LOG_DEBUG:-}" "${NC}$(date +"%F %T") ${F[B]}[DEBUG ]${NC} $*${NC}"; } @@ -48,6 +48,6 @@ notice() { log "true" "${NC}$(date +"%F %T") ${F[G]}[NOTICE]${NC} $*${NC}"; } warn() { log "true" "${NC}$(date +"%F %T") ${F[Y]}[WARN ]${NC} $*${NC}"; } error() { log "true" "${NC}$(date +"%F %T") ${F[R]}[ERROR ]${NC} $*${NC}"; } fatal() { - log "true" "${NC}$(date +"%F %T") ${B[R]}${F[W]}[FATAL ]${NC} $*${NC}" - exit 1 + log "true" "${NC}$(date +"%F %T") ${B[R]}${F[W]}[FATAL ]${NC} $*${NC}" + exit 1 } diff --git a/lib/termColors.sh b/lib/termColors.sh index ce3e0e66..8f22a26c 100755 --- a/lib/termColors.sh +++ b/lib/termColors.sh @@ -1,24 +1,24 @@ #!/usr/bin/env bash declare -Agr B=( - [B]=$(echo -e "\e[44m") - [C]=$(echo -e "\e[46m") - [G]=$(echo -e "\e[42m") - [K]=$(echo -e "\e[40m") - [M]=$(echo -e "\e[45m") - [R]=$(echo -e "\e[41m") - [W]=$(echo -e "\e[47m") - [Y]=$(echo -e "\e[43m") + [B]=$(echo -e "\e[44m") + [C]=$(echo -e "\e[46m") + [G]=$(echo -e "\e[42m") + [K]=$(echo -e "\e[40m") + [M]=$(echo -e "\e[45m") + [R]=$(echo -e "\e[41m") + [W]=$(echo -e "\e[47m") + [Y]=$(echo -e "\e[43m") ) declare -Agr F=( - [B]=$(echo -e "\e[0;34m") - [C]=$(echo -e "\e[0;36m") - [G]=$(echo -e "\e[0;32m") - [K]=$(echo -e "\e[0;30m") - [M]=$(echo -e "\e[0;35m") - [R]=$(echo -e "\e[0;31m") - [W]=$(echo -e "\e[0;37m") - [Y]=$(echo -e "\e[0;33m") + [B]=$(echo -e "\e[0;34m") + [C]=$(echo -e "\e[0;36m") + [G]=$(echo -e "\e[0;32m") + [K]=$(echo -e "\e[0;30m") + [M]=$(echo -e "\e[0;35m") + [R]=$(echo -e "\e[0;31m") + [W]=$(echo -e "\e[0;37m") + [Y]=$(echo -e "\e[0;33m") ) readonly NC=$(echo -e "\e[0m") diff --git a/lib/validation.sh b/lib/validation.sh index fcbcd4ac..6e4105b0 100755 --- a/lib/validation.sh +++ b/lib/validation.sh @@ -10,175 +10,175 @@ ################################################################################ #### Function GetValidationInfo ################################################ function GetValidationInfo() { - ############################################ - # Print headers for user provided env vars # - ############################################ - info "--------------------------------------------" - info "Gathering user validation information..." + ############################################ + # Print headers for user provided env vars # + ############################################ + info "--------------------------------------------" + info "Gathering user validation information..." - ########################################### - # Skip validation if were running locally # - ########################################### - if [[ ${RUN_LOCAL} != "true" ]]; then - ############################### - # Convert string to lowercase # - ############################### - VALIDATE_ALL_CODEBASE="${VALIDATE_ALL_CODEBASE,,}" - ###################################### - # Validate we should check all files # - ###################################### - if [[ ${VALIDATE_ALL_CODEBASE} != "false" ]]; then - # Set to true - VALIDATE_ALL_CODEBASE="${DEFAULT_VALIDATE_ALL_CODEBASE}" - info "- Validating ALL files in code base..." - else - # Its false - info "- Only validating [new], or [edited] files in code base..." - fi - fi - - ###################### - # Create Print Array # - ###################### - PRINT_ARRAY=() - - ################################ - # Convert strings to lowercase # - ################################ - # Loop through all languages - for LANGUAGE in "${LANGUAGE_ARRAY[@]}"; do - # build the variable - VALIDATE_LANGUAGE="VALIDATE_${LANGUAGE}" - # Set the value of the var to lowercase - eval "${VALIDATE_LANGUAGE}=${!VALIDATE_LANGUAGE,,}" - done - - ################################################ - # Determine if any linters were explicitly set # - ################################################ - ANY_SET="false" - # Loop through all languages - for LANGUAGE in "${LANGUAGE_ARRAY[@]}"; do - # build the variable - VALIDATE_LANGUAGE="VALIDATE_${LANGUAGE}" - # Check to see if the variable was set - if [ -n "${!VALIDATE_LANGUAGE}" ]; then - # It was set, need to set flag - ANY_SET="true" - fi - done - - ################################################### - # Validate if we should check individual lanuages # - ################################################### - # Loop through all languages - for LANGUAGE in "${LANGUAGE_ARRAY[@]}"; do - # build the variable - VALIDATE_LANGUAGE="VALIDATE_${LANGUAGE}" - # Check if ANY_SET was set - if [[ ${ANY_SET} == "true" ]]; then - # Check to see if the variable was set - if [ -z "${!VALIDATE_LANGUAGE}" ]; then - # Flag was not set, default to false - eval "${VALIDATE_LANGUAGE}='false'" - fi - else - # No linter flags were set - default all to true - eval "${VALIDATE_LANGUAGE}='true'" - fi - done - - ####################################### - # Print which linters we are enabling # - ####################################### - # Loop through all languages - for LANGUAGE in "${LANGUAGE_ARRAY[@]}"; do - # build the variable - VALIDATE_LANGUAGE="VALIDATE_${LANGUAGE}" - if [[ ${!VALIDATE_LANGUAGE} == "true" ]]; then - # We need to validate - PRINT_ARRAY+=("- Validating [$LANGUAGE] files in code base...") - else - # We are skipping the language - PRINT_ARRAY+=("- Excluding [$LANGUAGE] files in code base...") - fi - done - - ############################## - # Validate Ansible Directory # - ############################## - if [ -z "${ANSIBLE_DIRECTORY}" ]; then - # No Value, need to default - ANSIBLE_DIRECTORY="${DEFAULT_ANSIBLE_DIRECTORY}" + ########################################### + # Skip validation if were running locally # + ########################################### + if [[ ${RUN_LOCAL} != "true" ]]; then + ############################### + # Convert string to lowercase # + ############################### + VALIDATE_ALL_CODEBASE="${VALIDATE_ALL_CODEBASE,,}" + ###################################### + # Validate we should check all files # + ###################################### + if [[ ${VALIDATE_ALL_CODEBASE} != "false" ]]; then + # Set to true + VALIDATE_ALL_CODEBASE="${DEFAULT_VALIDATE_ALL_CODEBASE}" + info "- Validating ALL files in code base..." else - # Check if first char is '/' - if [[ ${ANSIBLE_DIRECTORY:0:1} == "/" ]]; then - # Remove first char - ANSIBLE_DIRECTORY="${ANSIBLE_DIRECTORY:1}" - fi - # Need to give it full path - TEMP_ANSIBLE_DIRECTORY="${GITHUB_WORKSPACE}/${ANSIBLE_DIRECTORY}" - # Set the value - ANSIBLE_DIRECTORY="${TEMP_ANSIBLE_DIRECTORY}" + # Its false + info "- Only validating [new], or [edited] files in code base..." fi + fi - ############################### - # Get the disable errors flag # - ############################### - if [ -z "${DISABLE_ERRORS}" ]; then - ################################## - # No flag passed, set to default # - ################################## - DISABLE_ERRORS="${DEFAULT_DISABLE_ERRORS}" + ###################### + # Create Print Array # + ###################### + PRINT_ARRAY=() + + ################################ + # Convert strings to lowercase # + ################################ + # Loop through all languages + for LANGUAGE in "${LANGUAGE_ARRAY[@]}"; do + # build the variable + VALIDATE_LANGUAGE="VALIDATE_${LANGUAGE}" + # Set the value of the var to lowercase + eval "${VALIDATE_LANGUAGE}=${!VALIDATE_LANGUAGE,,}" + done + + ################################################ + # Determine if any linters were explicitly set # + ################################################ + ANY_SET="false" + # Loop through all languages + for LANGUAGE in "${LANGUAGE_ARRAY[@]}"; do + # build the variable + VALIDATE_LANGUAGE="VALIDATE_${LANGUAGE}" + # Check to see if the variable was set + if [ -n "${!VALIDATE_LANGUAGE}" ]; then + # It was set, need to set flag + ANY_SET="true" fi + done - ############################### - # Convert string to lowercase # - ############################### - DISABLE_ERRORS="${DISABLE_ERRORS,,}" - - ############################ - # Set to false if not true # - ############################ - if [ "${DISABLE_ERRORS}" != "true" ]; then - DISABLE_ERRORS="false" + ################################################### + # Validate if we should check individual lanuages # + ################################################### + # Loop through all languages + for LANGUAGE in "${LANGUAGE_ARRAY[@]}"; do + # build the variable + VALIDATE_LANGUAGE="VALIDATE_${LANGUAGE}" + # Check if ANY_SET was set + if [[ ${ANY_SET} == "true" ]]; then + # Check to see if the variable was set + if [ -z "${!VALIDATE_LANGUAGE}" ]; then + # Flag was not set, default to false + eval "${VALIDATE_LANGUAGE}='false'" + fi + else + # No linter flags were set - default all to true + eval "${VALIDATE_LANGUAGE}='true'" fi + done - ############################ - # Get the run verbose flag # - ############################ - if [ -z "${ACTIONS_RUNNER_DEBUG}" ]; then - ################################## - # No flag passed, set to default # - ################################## - ACTIONS_RUNNER_DEBUG="${DEFAULT_ACTIONS_RUNNER_DEBUG}" + ####################################### + # Print which linters we are enabling # + ####################################### + # Loop through all languages + for LANGUAGE in "${LANGUAGE_ARRAY[@]}"; do + # build the variable + VALIDATE_LANGUAGE="VALIDATE_${LANGUAGE}" + if [[ ${!VALIDATE_LANGUAGE} == "true" ]]; then + # We need to validate + PRINT_ARRAY+=("- Validating [$LANGUAGE] files in code base...") + else + # We are skipping the language + PRINT_ARRAY+=("- Excluding [$LANGUAGE] files in code base...") fi + done - ############################### - # Convert string to lowercase # - ############################### - ACTIONS_RUNNER_DEBUG="${ACTIONS_RUNNER_DEBUG,,}" - - ############################ - # Set to true if not false # - ############################ - if [ "${ACTIONS_RUNNER_DEBUG}" != "false" ]; then - ACTIONS_RUNNER_DEBUG="true" + ############################## + # Validate Ansible Directory # + ############################## + if [ -z "${ANSIBLE_DIRECTORY}" ]; then + # No Value, need to default + ANSIBLE_DIRECTORY="${DEFAULT_ANSIBLE_DIRECTORY}" + else + # Check if first char is '/' + if [[ ${ANSIBLE_DIRECTORY:0:1} == "/" ]]; then + # Remove first char + ANSIBLE_DIRECTORY="${ANSIBLE_DIRECTORY:1}" fi + # Need to give it full path + TEMP_ANSIBLE_DIRECTORY="${GITHUB_WORKSPACE}/${ANSIBLE_DIRECTORY}" + # Set the value + ANSIBLE_DIRECTORY="${TEMP_ANSIBLE_DIRECTORY}" + fi - ########################### - # Print the validate info # - ########################### - for LINE in "${PRINT_ARRAY[@]}"; do - debug "${LINE}" - done + ############################### + # Get the disable errors flag # + ############################### + if [ -z "${DISABLE_ERRORS}" ]; then + ################################## + # No flag passed, set to default # + ################################## + DISABLE_ERRORS="${DEFAULT_DISABLE_ERRORS}" + fi - debug "--- DEBUG INFO ---" - debug "---------------------------------------------" - RUNNER=$(whoami) - debug "Runner:[${RUNNER}]" - PRINTENV=$(printenv) - debug "ENV:" - debug "${PRINTENV}" - debug "---------------------------------------------" + ############################### + # Convert string to lowercase # + ############################### + DISABLE_ERRORS="${DISABLE_ERRORS,,}" + + ############################ + # Set to false if not true # + ############################ + if [ "${DISABLE_ERRORS}" != "true" ]; then + DISABLE_ERRORS="false" + fi + + ############################ + # Get the run verbose flag # + ############################ + if [ -z "${ACTIONS_RUNNER_DEBUG}" ]; then + ################################## + # No flag passed, set to default # + ################################## + ACTIONS_RUNNER_DEBUG="${DEFAULT_ACTIONS_RUNNER_DEBUG}" + fi + + ############################### + # Convert string to lowercase # + ############################### + ACTIONS_RUNNER_DEBUG="${ACTIONS_RUNNER_DEBUG,,}" + + ############################ + # Set to true if not false # + ############################ + if [ "${ACTIONS_RUNNER_DEBUG}" != "false" ]; then + ACTIONS_RUNNER_DEBUG="true" + fi + + ########################### + # Print the validate info # + ########################### + for LINE in "${PRINT_ARRAY[@]}"; do + debug "${LINE}" + done + + debug "--- DEBUG INFO ---" + debug "---------------------------------------------" + RUNNER=$(whoami) + debug "Runner:[${RUNNER}]" + PRINTENV=$(printenv) + debug "ENV:" + debug "${PRINTENV}" + debug "---------------------------------------------" } diff --git a/lib/worker.sh b/lib/worker.sh index 929b3ff9..3dbdb83c 100755 --- a/lib/worker.sh +++ b/lib/worker.sh @@ -10,883 +10,883 @@ ################################################################################ #### Function LintCodebase ##################################################### function LintCodebase() { - #################### - # Pull in the vars # - #################### - FILE_TYPE="${1}" && shift # Pull the variable and remove from array path (Example: JSON) - LINTER_NAME="${1}" && shift # Pull the variable and remove from array path (Example: jsonlint) - LINTER_COMMAND="${1}" && shift # Pull the variable and remove from array path (Example: jsonlint -c ConfigFile /path/to/file) - FILE_EXTENSIONS="${1}" && shift # Pull the variable and remove from array path (Example: *.json) - FILE_ARRAY=("$@") # Array of files to validate (Example: ${FILE_ARRAY_JSON}) + #################### + # Pull in the vars # + #################### + FILE_TYPE="${1}" && shift # Pull the variable and remove from array path (Example: JSON) + LINTER_NAME="${1}" && shift # Pull the variable and remove from array path (Example: jsonlint) + LINTER_COMMAND="${1}" && shift # Pull the variable and remove from array path (Example: jsonlint -c ConfigFile /path/to/file) + FILE_EXTENSIONS="${1}" && shift # Pull the variable and remove from array path (Example: *.json) + FILE_ARRAY=("$@") # Array of files to validate (Example: ${FILE_ARRAY_JSON}) - ###################### - # Create Print Array # - ###################### - PRINT_ARRAY=() + ###################### + # Create Print Array # + ###################### + PRINT_ARRAY=() - ################ - # print header # - ################ - PRINT_ARRAY+=("") - PRINT_ARRAY+=("----------------------------------------------") - PRINT_ARRAY+=("----------------------------------------------") - PRINT_ARRAY+=("Linting [${FILE_TYPE}] files...") - PRINT_ARRAY+=("----------------------------------------------") - PRINT_ARRAY+=("----------------------------------------------") + ################ + # print header # + ################ + PRINT_ARRAY+=("") + PRINT_ARRAY+=("----------------------------------------------") + PRINT_ARRAY+=("----------------------------------------------") + PRINT_ARRAY+=("Linting [${FILE_TYPE}] files...") + PRINT_ARRAY+=("----------------------------------------------") + PRINT_ARRAY+=("----------------------------------------------") - ##################################### - # Validate we have linter installed # - ##################################### - VALIDATE_INSTALL_CMD=$(command -v "${LINTER_NAME}" 2>&1) + ##################################### + # Validate we have linter installed # + ##################################### + VALIDATE_INSTALL_CMD=$(command -v "${LINTER_NAME}" 2>&1) - ####################### - # Load the error code # - ####################### - ERROR_CODE=$? + ####################### + # Load the error code # + ####################### + ERROR_CODE=$? - ############################## - # Check the shell for errors # - ############################## - if [ ${ERROR_CODE} -ne 0 ]; then - # Failed - error "Failed to find [${LINTER_NAME}] in system!" - fatal "[${VALIDATE_INSTALL_CMD}]" - else - # Success - debug "Successfully found binary for ${F[W]}[${LINTER_NAME}]${F[B]} in system location: ${F[W]}[${VALIDATE_INSTALL_CMD}]" - fi + ############################## + # Check the shell for errors # + ############################## + if [ ${ERROR_CODE} -ne 0 ]; then + # Failed + error "Failed to find [${LINTER_NAME}] in system!" + fatal "[${VALIDATE_INSTALL_CMD}]" + else + # Success + debug "Successfully found binary for ${F[W]}[${LINTER_NAME}]${F[B]} in system location: ${F[W]}[${VALIDATE_INSTALL_CMD}]" + fi - ########################## - # Initialize empty Array # - ########################## - LIST_FILES=() + ########################## + # Initialize empty Array # + ########################## + LIST_FILES=() - ################ - # Set the flag # - ################ - SKIP_FLAG=0 + ################ + # Set the flag # + ################ + SKIP_FLAG=0 - ############################################################ - # Check to see if we need to go through array or all files # - ############################################################ - if [ ${#FILE_ARRAY[@]} -eq 0 ] && [ "${VALIDATE_ALL_CODEBASE}" == "false" ]; then - # No files found in commit and user has asked to not validate code base - SKIP_FLAG=1 - debug " - No files found in changeset to lint for language:[${FILE_TYPE}]" - elif [ ${#FILE_ARRAY[@]} -ne 0 ]; then - # We have files added to array of files to check - LIST_FILES=("${FILE_ARRAY[@]}") # Copy the array into list - else - ############################################################################### - # Set the file seperator to newline to allow for grabbing objects with spaces # - ############################################################################### - IFS=$'\n' - - ################################# - # Get list of all files to lint # - ################################# - mapfile -t LIST_FILES < <(find "${GITHUB_WORKSPACE}" -type f -regex "${FILE_EXTENSIONS}" 2>&1) - - ########################### - # Set IFS back to default # - ########################### - IFS="${DEFAULT_IFS}" - - ############################################################ - # Set it back to empty if loaded with blanks from scanning # - ############################################################ - if [ ${#LIST_FILES[@]} -lt 1 ]; then - ###################### - # Set to empty array # - ###################### - LIST_FILES=() - ############################# - # Skip as we found no files # - ############################# - SKIP_FLAG=1 - fi - fi - - ############################### - # Check if any data was found # - ############################### - if [ ${SKIP_FLAG} -eq 0 ]; then - ###################### - # Print Header array # - ###################### - for LINE in "${PRINT_ARRAY[@]}"; do - ######################### - # Print the header info # - ######################### - info "${LINE}" - done - - ######################################## - # Prepare context if TAP format output # - ######################################## - if IsTAP; then - TMPFILE=$(mktemp -q "/tmp/super-linter-${FILE_TYPE}.XXXXXX") - INDEX=0 - mkdir -p "${REPORT_OUTPUT_FOLDER}" - REPORT_OUTPUT_FILE="${REPORT_OUTPUT_FOLDER}/super-linter-${FILE_TYPE}.${OUTPUT_FORMAT}" - fi - - ################## - # Lint the files # - ################## - for FILE in "${LIST_FILES[@]}"; do - ################################### - # Get the file name and directory # - ################################### - FILE_NAME=$(basename "${FILE}" 2>&1) - DIR_NAME=$(dirname "${FILE}" 2>&1) - - ##################################################### - # Make sure we dont lint node modules or test cases # - ##################################################### - if [[ ${FILE} == *"node_modules"* ]]; then - # This is a node modules file - continue - elif [[ ${FILE} == *"${TEST_CASE_FOLDER}"* ]]; then - # This is the test cases, we should always skip - continue - elif [[ ${FILE} == *".git"* ]]; then - # This is likely the .git folder and shouldnt be parsed - continue - fi - - ################################## - # Increase the linted file index # - ################################## - (("INDEX++")) - - ############## - # File print # - ############## - info "---------------------------" - info "File:[${FILE}]" - - ################################# - # Add the language to the array # - ################################# - LINTED_LANGUAGES_ARRAY+=("${FILE_TYPE}") - - #################### - # Set the base Var # - #################### - LINT_CMD='' - - #################################### - # Corner case for pwsh subshell # - # - PowerShell (PSScriptAnalyzer) # - # - ARM (arm-ttk) # - #################################### - if [[ ${FILE_TYPE} == "POWERSHELL" ]] || [[ ${FILE_TYPE} == "ARM" ]]; then - ################################ - # Lint the file with the rules # - ################################ - # Need to run PowerShell commands using pwsh -c, also exit with exit code from inner subshell - LINT_CMD=$( - cd "${GITHUB_WORKSPACE}" || exit - pwsh -NoProfile -NoLogo -Command "${LINTER_COMMAND} ${FILE}; if (\${Error}.Count) { exit 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 - ################################ - # Lint the file with the rules # - ################################ - LINT_CMD=$( - cd "${GITHUB_WORKSPACE}" || exit - ${LINTER_COMMAND} "${FILE}" 2>&1 - ) - fi - ####################### - # Load the error code # - ####################### - ERROR_CODE=$? - - ############################## - # Check the shell for errors # - ############################## - if [ ${ERROR_CODE} -ne 0 ]; then - ######### - # Error # - ######### - error "Found errors in [${LINTER_NAME}] linter!" - error "[${LINT_CMD}]" - error "Linter CMD:[${LINTER_COMMAND} ${FILE}]" - # Increment the error count - (("ERRORS_FOUND_${FILE_TYPE}++")) - - ####################################################### - # Store the linting as a temporary file in TAP format # - ####################################################### - if IsTAP; then - NotOkTap "${INDEX}" "${FILE}" "${TMPFILE}" - AddDetailedMessageIfEnabled "${LINT_CMD}" "${TMPFILE}" - fi - else - ########### - # Success # - ########### - info " - File:${F[W]}[${FILE_NAME}]${F[B]} was linted with ${F[W]}[${LINTER_NAME}]${F[B]} successfully" - - ####################################################### - # Store the linting as a temporary file in TAP format # - ####################################################### - if IsTAP; then - OkTap "${INDEX}" "${FILE}" "${TMPFILE}" - fi - fi - done - - ################################# - # Generate report in TAP format # - ################################# - if IsTAP && [ ${INDEX} -gt 0 ]; then - HeaderTap "${INDEX}" "${REPORT_OUTPUT_FILE}" - cat "${TMPFILE}" >> "${REPORT_OUTPUT_FILE}" - fi - fi -} -################################################################################ -#### Function TestCodebase ##################################################### -function TestCodebase() { - #################### - # Pull in the vars # - #################### - FILE_TYPE="${1}" # Pull the variable and remove from array path (Example: JSON) - LINTER_NAME="${2}" # Pull the variable and remove from array path (Example: jsonlint) - LINTER_COMMAND="${3}" # Pull the variable and remove from array path (Example: jsonlint -c ConfigFile /path/to/file) - FILE_EXTENSIONS="${4}" # Pull the variable and remove from array path (Example: *.json) - INDVIDUAL_TEST_FOLDER="${5}" # Folder for specific tests - TESTS_RAN=0 # Incremented when tests are ran, this will help find failed finds - - ################ - # print header # - ################ - info "----------------------------------------------" - info "----------------------------------------------" - info "Testing Codebase [${FILE_TYPE}] files..." - info "----------------------------------------------" - info "----------------------------------------------" - - ##################################### - # Validate we have linter installed # - ##################################### - VALIDATE_INSTALL_CMD=$(command -v "${LINTER_NAME}" 2>&1) - - ####################### - # Load the error code # - ####################### - ERROR_CODE=$? - - ############################## - # Check the shell for errors # - ############################## - if [ ${ERROR_CODE} -ne 0 ]; then - # Failed - error "Failed to find [${LINTER_NAME}] in system!" - fatal "[${VALIDATE_INSTALL_CMD}]" - else - # Success - info "Successfully found binary for ${F[W]}[${LINTER_NAME}]${F[B]} in system location: ${F[W]}[${VALIDATE_INSTALL_CMD}]" - fi - - ########################## - # Initialize empty Array # - ########################## - LIST_FILES=() + ############################################################ + # Check to see if we need to go through array or all files # + ############################################################ + if [ ${#FILE_ARRAY[@]} -eq 0 ] && [ "${VALIDATE_ALL_CODEBASE}" == "false" ]; then + # No files found in commit and user has asked to not validate code base + SKIP_FLAG=1 + debug " - No files found in changeset to lint for language:[${FILE_TYPE}]" + elif [ ${#FILE_ARRAY[@]} -ne 0 ]; then + # We have files added to array of files to check + LIST_FILES=("${FILE_ARRAY[@]}") # Copy the array into list + else + ############################################################################### + # Set the file seperator to newline to allow for grabbing objects with spaces # + ############################################################################### + IFS=$'\n' ################################# # Get list of all files to lint # ################################# - mapfile -t LIST_FILES < <(find "${GITHUB_WORKSPACE}/${TEST_CASE_FOLDER}/${INDVIDUAL_TEST_FOLDER}" -type f -regex "${FILE_EXTENSIONS}" ! -path "${GITHUB_WORKSPACE}/${TEST_CASE_FOLDER}/ansible/ghe-initialize/*" | sort 2>&1) + mapfile -t LIST_FILES < <(find "${GITHUB_WORKSPACE}" -type f -regex "${FILE_EXTENSIONS}" 2>&1) + + ########################### + # Set IFS back to default # + ########################### + IFS="${DEFAULT_IFS}" + + ############################################################ + # Set it back to empty if loaded with blanks from scanning # + ############################################################ + if [ ${#LIST_FILES[@]} -lt 1 ]; then + ###################### + # Set to empty array # + ###################### + LIST_FILES=() + ############################# + # Skip as we found no files # + ############################# + SKIP_FLAG=1 + fi + fi + + ############################### + # Check if any data was found # + ############################### + if [ ${SKIP_FLAG} -eq 0 ]; then + ###################### + # Print Header array # + ###################### + for LINE in "${PRINT_ARRAY[@]}"; do + ######################### + # Print the header info # + ######################### + info "${LINE}" + done ######################################## - # Prepare context if TAP output format # + # Prepare context if TAP format output # ######################################## if IsTAP; then - TMPFILE=$(mktemp -q "/tmp/super-linter-${FILE_TYPE}.XXXXXX") - mkdir -p "${REPORT_OUTPUT_FOLDER}" - REPORT_OUTPUT_FILE="${REPORT_OUTPUT_FOLDER}/super-linter-${FILE_TYPE}.${OUTPUT_FORMAT}" + TMPFILE=$(mktemp -q "/tmp/super-linter-${FILE_TYPE}.XXXXXX") + INDEX=0 + mkdir -p "${REPORT_OUTPUT_FOLDER}" + REPORT_OUTPUT_FILE="${REPORT_OUTPUT_FOLDER}/super-linter-${FILE_TYPE}.${OUTPUT_FORMAT}" fi ################## # Lint the files # ################## for FILE in "${LIST_FILES[@]}"; do - ##################### - # Get the file name # - ##################### - FILE_NAME=$(basename "${FILE}" 2>&1) - DIR_NAME=$(dirname "${FILE}" 2>&1) + ################################### + # Get the file name and directory # + ################################### + FILE_NAME=$(basename "${FILE}" 2>&1) + DIR_NAME=$(dirname "${FILE}" 2>&1) - ############################ - # Get the file pass status # - ############################ - # Example: markdown_good_1.md -> good - FILE_STATUS=$(echo "${FILE_NAME}" | cut -f2 -d'_') + ##################################################### + # Make sure we dont lint node modules or test cases # + ##################################################### + if [[ ${FILE} == *"node_modules"* ]]; then + # This is a node modules file + continue + elif [[ ${FILE} == *"${TEST_CASE_FOLDER}"* ]]; then + # This is the test cases, we should always skip + continue + elif [[ ${FILE} == *".git"* ]]; then + # This is likely the .git folder and shouldnt be parsed + continue + fi - ######################################################### - # If not found, assume it should be linted successfully # - ######################################################### - if [ -z "${FILE_STATUS}" ] || [[ ${FILE} == *"README"* ]]; then - ################################## - # Set to good for proper linting # - ################################## - FILE_STATUS="good" - fi + ################################## + # Increase the linted file index # + ################################## + (("INDEX++")) - ############## - # File print # - ############## - info "---------------------------" - info "File:[${FILE}]" + ############## + # File print # + ############## + info "---------------------------" + info "File:[${FILE}]" - ######################## - # Set the lint command # - ######################## - LINT_CMD='' + ################################# + # Add the language to the array # + ################################# + LINTED_LANGUAGES_ARRAY+=("${FILE_TYPE}") + #################### + # Set the base Var # + #################### + LINT_CMD='' + + #################################### + # Corner case for pwsh subshell # + # - PowerShell (PSScriptAnalyzer) # + # - ARM (arm-ttk) # + #################################### + if [[ ${FILE_TYPE} == "POWERSHELL" ]] || [[ ${FILE_TYPE} == "ARM" ]]; then + ################################ + # Lint the file with the rules # + ################################ + # Need to run PowerShell commands using pwsh -c, also exit with exit code from inner subshell + LINT_CMD=$( + cd "${GITHUB_WORKSPACE}" || exit + pwsh -NoProfile -NoLogo -Command "${LINTER_COMMAND} ${FILE}; if (\${Error}.Count) { exit 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 ####################################### - # Check if docker and get folder name # + # Lint the file with the updated path # ####################################### - if [[ ${FILE_TYPE} == "DOCKER" ]]; then - if [[ ${FILE} == *"good"* ]]; then - ############# - # Good file # - ############# - FILE_STATUS='good' - else - ############ - # Bad file # - ############ - FILE_STATUS='bad' - fi + LINT_CMD=$( + cd "${GITHUB_WORKSPACE}" || exit + ${LINTER_COMMAND} --path "${DIR_NAME}" --files "$FILE_NAME" 2>&1 + ) + else + ################################ + # Lint the file with the rules # + ################################ + LINT_CMD=$( + cd "${GITHUB_WORKSPACE}" || exit + ${LINTER_COMMAND} "${FILE}" 2>&1 + ) + fi + ####################### + # Load the error code # + ####################### + ERROR_CODE=$? + + ############################## + # Check the shell for errors # + ############################## + if [ ${ERROR_CODE} -ne 0 ]; then + ######### + # Error # + ######### + error "Found errors in [${LINTER_NAME}] linter!" + error "[${LINT_CMD}]" + error "Linter CMD:[${LINTER_COMMAND} ${FILE}]" + # Increment the error count + (("ERRORS_FOUND_${FILE_TYPE}++")) + + ####################################################### + # Store the linting as a temporary file in TAP format # + ####################################################### + if IsTAP; then + NotOkTap "${INDEX}" "${FILE}" "${TMPFILE}" + AddDetailedMessageIfEnabled "${LINT_CMD}" "${TMPFILE}" fi + else + ########### + # Success # + ########### + info " - File:${F[W]}[${FILE_NAME}]${F[B]} was linted with ${F[W]}[${LINTER_NAME}]${F[B]} successfully" - ##################### - # Check for ansible # - ##################### - if [[ ${FILE_TYPE} == "ANSIBLE" ]]; then - ######################################## - # Make sure we dont lint certain files # - ######################################## - if [[ ${FILE} == *"vault.yml"* ]] || [[ ${FILE} == *"galaxy.yml"* ]]; then - # This is a file we dont look at - continue - fi - - ################################ - # Lint the file with the rules # - ################################ - LINT_CMD=$( - cd "${GITHUB_WORKSPACE}/${TEST_CASE_FOLDER}/${INDVIDUAL_TEST_FOLDER}" || exit - ${LINTER_COMMAND} "${FILE}" 2>&1 - ) - elif [[ ${FILE_TYPE} == "POWERSHELL" ]] || [[ ${FILE_TYPE} == "ARM" ]]; then - ################################ - # Lint the file with the rules # - ################################ - # Need to run PowerShell commands using pwsh -c, also exit with exit code from inner subshell - LINT_CMD=$( - cd "${GITHUB_WORKSPACE}/${TEST_CASE_FOLDER}" || exit - pwsh -NoProfile -NoLogo -Command "${LINTER_COMMAND} ${FILE}; if (\${Error}.Count) { exit 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 - ################################ - # Lint the file with the rules # - ################################ - LINT_CMD=$( - cd "${GITHUB_WORKSPACE}/${TEST_CASE_FOLDER}" || exit - ${LINTER_COMMAND} "${FILE}" 2>&1 - ) - fi - - ####################### - # Load the error code # - ####################### - ERROR_CODE=$? - - ######################################## - # Increment counter that check was ran # - ######################################## - (("TESTS_RAN++")) - - ######################################## - # Check for if it was supposed to pass # - ######################################## - if [[ ${FILE_STATUS} == "good" ]]; then - ############################## - # Check the shell for errors # - ############################## - if [ ${ERROR_CODE} -ne 0 ]; then - ######### - # Error # - ######### - error "Found errors in [${LINTER_NAME}] linter!" - error "[${LINT_CMD}]" - error "Linter CMD:[${LINTER_COMMAND} ${FILE}]" - # Increment the error count - (("ERRORS_FOUND_${FILE_TYPE}++")) - else - ########### - # Success # - ########### - info " - File:${F[W]}[${FILE_NAME}]${F[B]} was linted with ${F[W]}[${LINTER_NAME}]${F[B]} successfully" - fi - ####################################################### - # Store the linting as a temporary file in TAP format # - ####################################################### - if IsTAP; then - OkTap "${TESTS_RAN}" "${FILE_NAME}" "${TMPFILE}" - fi - else - ####################################### - # File status = bad, this should fail # - ####################################### - ############################## - # Check the shell for errors # - ############################## - if [ ${ERROR_CODE} -eq 0 ]; then - ######### - # Error # - ######### - error "Found errors in [${LINTER_NAME}] linter!" - error "This file should have failed test case!" - error "Command run:${NC}[\$${LINT_CMD}]" - error "[${LINT_CMD}]" - error "Linter CMD:[${LINTER_COMMAND} ${FILE}]" - # Increment the error count - (("ERRORS_FOUND_${FILE_TYPE}++")) - else - ########### - # Success # - ########### - info " - File:${F[W]}[${FILE_NAME}]${F[B]} failed test case with ${F[W]}[${LINTER_NAME}]${F[B]} successfully" - fi - ####################################################### - # Store the linting as a temporary file in TAP format # - ####################################################### - if IsTAP; then - NotOkTap "${TESTS_RAN}" "${FILE_NAME}" "${TMPFILE}" - AddDetailedMessageIfEnabled "${LINT_CMD}" "${TMPFILE}" - fi + ####################################################### + # Store the linting as a temporary file in TAP format # + ####################################################### + if IsTAP; then + OkTap "${INDEX}" "${FILE}" "${TMPFILE}" fi + fi done - ########################################################################### - # Generate report in TAP format and validate with the expected TAP output # - ########################################################################### - if IsTAP && [ ${TESTS_RAN} -gt 0 ]; then - HeaderTap "${TESTS_RAN}" "${REPORT_OUTPUT_FILE}" - cat "${TMPFILE}" >> "${REPORT_OUTPUT_FILE}" - - ######################################################################## - # If expected TAP report exists then compare with the generated report # - ######################################################################## - EXPECTED_FILE="${GITHUB_WORKSPACE}/${TEST_CASE_FOLDER}/${INDVIDUAL_TEST_FOLDER}/reports/expected-${FILE_TYPE}.tap" - if [ -e "${EXPECTED_FILE}" ]; then - TMPFILE=$(mktemp -q "/tmp/diff-${FILE_TYPE}.XXXXXX") - ## Ignore white spaces, case sensitive - if ! diff -a -w -i "${EXPECTED_FILE}" "${REPORT_OUTPUT_FILE}" > "${TMPFILE}" 2>&1; then - ############################################# - # We failed to compare the reporting output # - ############################################# - error "Failed to assert TAP output:[${LINTER_NAME}]"! - info "Please validate the asserts!" - cat "${TMPFILE}" - exit 1 - else - # Success - info "Successfully validation in the expected TAP format for ${F[W]}[${LINTER_NAME}]" - fi - else - warn "No TAP expected file found at:[${EXPECTED_FILE}]" - info "skipping report assertions" - ##################################### - # Append the file type to the array # - ##################################### - WARNING_ARRAY_TEST+=("${FILE_TYPE}") - fi - fi - - ############################## - # Validate we ran some tests # - ############################## - if [ "${TESTS_RAN}" -eq 0 ]; then - ################################################# - # We failed to find files and no tests were ran # - ################################################# - error "Failed to find any tests ran for the Linter:[${LINTER_NAME}]"! - fatal "Please validate logic or that tests exist!" + ################################# + # Generate report in TAP format # + ################################# + if IsTAP && [ ${INDEX} -gt 0 ]; then + HeaderTap "${INDEX}" "${REPORT_OUTPUT_FILE}" + cat "${TMPFILE}" >> "${REPORT_OUTPUT_FILE}" fi + fi } ################################################################################ -#### Function RunTestCases ##################################################### -function RunTestCases() { - # This loop will run the test cases and exclude user code - # This is called from the automation process to validate new code - # When a PR is opened, the new code is validated with the default branch - # version of linter.sh, and a new container is built with the latest codebase - # for testing. That container is spun up, and ran, - # with the flag: TEST_CASE_RUN=true - # So that the new code can be validated against the test cases +#### Function TestCodebase ##################################################### +function TestCodebase() { + #################### + # Pull in the vars # + #################### + FILE_TYPE="${1}" # Pull the variable and remove from array path (Example: JSON) + LINTER_NAME="${2}" # Pull the variable and remove from array path (Example: jsonlint) + LINTER_COMMAND="${3}" # Pull the variable and remove from array path (Example: jsonlint -c ConfigFile /path/to/file) + FILE_EXTENSIONS="${4}" # Pull the variable and remove from array path (Example: *.json) + INDVIDUAL_TEST_FOLDER="${5}" # Folder for specific tests + TESTS_RAN=0 # Incremented when tests are ran, this will help find failed finds - ################# - # Header prints # - ################# - info "----------------------------------------------" - info "-------------- TEST CASE RUN -----------------" - info "----------------------------------------------" + ################ + # print header # + ################ + info "----------------------------------------------" + info "----------------------------------------------" + info "Testing Codebase [${FILE_TYPE}] files..." + info "----------------------------------------------" + info "----------------------------------------------" - ####################### - # Test case languages # - ####################### - # TestCodebase "Language" "Linter" "Linter-command" "Regex to find files" "Test Folder" - TestCodebase "ANSIBLE" "ansible-lint" "ansible-lint -v -c ${ANSIBLE_LINTER_RULES}" ".*\.\(yml\|yaml\)\$" "ansible" - TestCodebase "ARM" "arm-ttk" "Import-Module ${ARM_TTK_PSD1} ; \${config} = \$(Import-PowerShellDataFile -Path ${ARM_LINTER_RULES}) ; Test-AzTemplate @config -TemplatePath" ".*\.\(json\)\$" "arm" - TestCodebase "BASH" "shellcheck" "shellcheck --color" ".*\.\(sh\|bash\|dash\|ksh\)\$" "shell" - TestCodebase "CLOUDFORMATION" "cfn-lint" "cfn-lint --config-file ${CLOUDFORMATION_LINTER_RULES}" ".*\.\(json\|yml\|yaml\)\$" "cloudformation" - TestCodebase "CLOJURE" "clj-kondo" "clj-kondo --config ${CLOJURE_LINTER_RULES} --lint" ".*\.\(clj\|cljs\|cljc\|edn\)\$" "clojure" - TestCodebase "COFFEESCRIPT" "coffeelint" "coffeelint -f ${COFFEESCRIPT_LINTER_RULES}" ".*\.\(coffee\)\$" "coffeescript" - TestCodebase "CSS" "stylelint" "stylelint --config ${CSS_LINTER_RULES}" ".*\.\(css\)\$" "css" - TestCodebase "DART" "dart" "dartanalyzer --fatal-infos --fatal-warnings --options ${DART_LINTER_RULES}" ".*\.\(dart\)\$" "dart" - TestCodebase "DOCKER" "dockerfilelint" "dockerfilelint -c ${DOCKER_LINTER_RULES}" ".*\(Dockerfile\)\$" "docker" - TestCodebase "EDITORCONFIG" "editorconfig-checker" "editorconfig-checker" ".*\.ext$" "editorconfig-checker" - TestCodebase "ENV" "dotenv-linter" "dotenv-linter" ".*\.\(env\)\$" "env" - 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 "JAVASCRIPT_ES" "eslint" "eslint --no-eslintrc -c ${JAVASCRIPT_LINTER_RULES}" ".*\.\(js\)\$" "javascript" - TestCodebase "JAVASCRIPT_STANDARD" "standard" "standard ${JAVASCRIPT_STANDARD_LINTER_RULES}" ".*\.\(js\)\$" "javascript" - TestCodebase "JSON" "jsonlint" "jsonlint" ".*\.\(json\)\$" "json" - TestCodebase "KOTLIN" "ktlint" "ktlint" ".*\.\(kt\|kts\)\$" "kotlin" - TestCodebase "LUA" "lua" "luacheck" ".*\.\(lua\)\$" "lua" - TestCodebase "MARKDOWN" "markdownlint" "markdownlint -c ${MARKDOWN_LINTER_RULES}" ".*\.\(md\)\$" "markdown" - TestCodebase "PERL" "perl" "perl -Mstrict -cw" ".*\.\(pl\)\$" "perl" - TestCodebase "PHP" "php" "php -l" ".*\.\(php\)\$" "php" - TestCodebase "PHP_PHPSTAN" "phpstan" "phpstan analyse --no-progress --no-ansi -c ${PHPSTAN_LINTER_RULES}" ".*\.\(php\)\$" "php" - TestCodebase "OPENAPI" "spectral" "spectral lint -r ${OPENAPI_LINTER_RULES}" ".*\.\(ymlopenapi\|jsonopenapi\)\$" "openapi" - TestCodebase "POWERSHELL" "pwsh" "Invoke-ScriptAnalyzer -EnableExit -Settings ${POWERSHELL_LINTER_RULES} -Path" ".*\.\(ps1\|psm1\|psd1\|ps1xml\|pssc\|psrc\|cdxml\)\$" "powershell" - TestCodebase "PROTOBUF" "protolint" "protolint lint --config_path ${PROTOBUF_LINTER_RULES}" ".*\.\(proto\)\$" "protobuf" - TestCodebase "PYTHON_PYLINT" "pylint" "pylint --rcfile ${PYTHON_PYLINT_LINTER_RULES}" ".*\.\(py\)\$" "python" - TestCodebase "PYTHON_FLAKE8" "flake8" "flake8 --config ${PYTHON_FLAKE8_LINTER_RULES}" ".*\.\(py\)\$" "python" - TestCodebase "RAKU" "raku" "raku -c" ".*\.\(raku\|rakumod\|rakutest\|pm6\|pl6\|p6\)\$" "raku" - TestCodebase "RUBY" "rubocop" "rubocop -c ${RUBY_LINTER_RULES}" ".*\.\(rb\)\$" "ruby" - TestCodebase "STATES" "asl-validator" "asl-validator --json-path" ".*\.\(json\)\$" "states" - TestCodebase "TERRAFORM" "tflint" "tflint -c ${TERRAFORM_LINTER_RULES}" ".*\.\(tf\)\$" "terraform" - TestCodebase "TERRAFORM_TERRASCAN" "terrascan" "terrascan -f " ".*\.\(tf\)\$" "terraform_terrascan" - TestCodebase "TYPESCRIPT_ES" "eslint" "eslint --no-eslintrc -c ${TYPESCRIPT_LINTER_RULES}" ".*\.\(ts\)\$" "typescript" - TestCodebase "TYPESCRIPT_STANDARD" "standard" "standard --parser @typescript-eslint/parser --plugin @typescript-eslint/eslint-plugin ${TYPESCRIPT_STANDARD_LINTER_RULES}" ".*\.\(ts\)\$" "typescript" - TestCodebase "XML" "xmllint" "xmllint" ".*\.\(xml\)\$" "xml" - TestCodebase "YAML" "yamllint" "yamllint -c ${YAML_LINTER_RULES}" ".*\.\(yml\|yaml\)\$" "yml" + ##################################### + # Validate we have linter installed # + ##################################### + VALIDATE_INSTALL_CMD=$(command -v "${LINTER_NAME}" 2>&1) - ################# - # Footer prints # - ################# - # Call the footer to display run information - # and exit with error code - Footer -} -################################################################################ -#### Function LintAnsibleFiles ################################################# -function LintAnsibleFiles() { - ###################### - # Create Print Array # - ###################### - PRINT_ARRAY=() + ####################### + # Load the error code # + ####################### + ERROR_CODE=$? - ################ - # print header # - ################ - PRINT_ARRAY+=("") - PRINT_ARRAY+=("----------------------------------------------") - PRINT_ARRAY+=("----------------------------------------------") - PRINT_ARRAY+=("Linting [Ansible] files...") - PRINT_ARRAY+=("----------------------------------------------") - PRINT_ARRAY+=("----------------------------------------------") + ############################## + # Check the shell for errors # + ############################## + if [ ${ERROR_CODE} -ne 0 ]; then + # Failed + error "Failed to find [${LINTER_NAME}] in system!" + fatal "[${VALIDATE_INSTALL_CMD}]" + else + # Success + info "Successfully found binary for ${F[W]}[${LINTER_NAME}]${F[B]} in system location: ${F[W]}[${VALIDATE_INSTALL_CMD}]" + fi - ###################### - # Name of the linter # - ###################### - LINTER_NAME="ansible-lint" + ########################## + # Initialize empty Array # + ########################## + LIST_FILES=() - ########################################### - # Validate we have ansible-lint installed # - ########################################### - VALIDATE_INSTALL_CMD=$(command -v "${LINTER_NAME}" 2>&1) + ################################# + # Get list of all files to lint # + ################################# + mapfile -t LIST_FILES < <(find "${GITHUB_WORKSPACE}/${TEST_CASE_FOLDER}/${INDVIDUAL_TEST_FOLDER}" -type f -regex "${FILE_EXTENSIONS}" ! -path "${GITHUB_WORKSPACE}/${TEST_CASE_FOLDER}/ansible/ghe-initialize/*" | sort 2>&1) + + ######################################## + # Prepare context if TAP output format # + ######################################## + if IsTAP; then + TMPFILE=$(mktemp -q "/tmp/super-linter-${FILE_TYPE}.XXXXXX") + mkdir -p "${REPORT_OUTPUT_FOLDER}" + REPORT_OUTPUT_FILE="${REPORT_OUTPUT_FOLDER}/super-linter-${FILE_TYPE}.${OUTPUT_FORMAT}" + fi + + ################## + # Lint the files # + ################## + for FILE in "${LIST_FILES[@]}"; do + ##################### + # Get the file name # + ##################### + FILE_NAME=$(basename "${FILE}" 2>&1) + DIR_NAME=$(dirname "${FILE}" 2>&1) + + ############################ + # Get the file pass status # + ############################ + # Example: markdown_good_1.md -> good + FILE_STATUS=$(echo "${FILE_NAME}" | cut -f2 -d'_') + + ######################################################### + # If not found, assume it should be linted successfully # + ######################################################### + if [ -z "${FILE_STATUS}" ] || [[ ${FILE} == *"README"* ]]; then + ################################## + # Set to good for proper linting # + ################################## + FILE_STATUS="good" + fi + + ############## + # File print # + ############## + info "---------------------------" + info "File:[${FILE}]" + + ######################## + # Set the lint command # + ######################## + LINT_CMD='' + + ####################################### + # Check if docker and get folder name # + ####################################### + if [[ ${FILE_TYPE} == "DOCKER" ]]; then + if [[ ${FILE} == *"good"* ]]; then + ############# + # Good file # + ############# + FILE_STATUS='good' + else + ############ + # Bad file # + ############ + FILE_STATUS='bad' + fi + fi + + ##################### + # Check for ansible # + ##################### + if [[ ${FILE_TYPE} == "ANSIBLE" ]]; then + ######################################## + # Make sure we dont lint certain files # + ######################################## + if [[ ${FILE} == *"vault.yml"* ]] || [[ ${FILE} == *"galaxy.yml"* ]]; then + # This is a file we dont look at + continue + fi + + ################################ + # Lint the file with the rules # + ################################ + LINT_CMD=$( + cd "${GITHUB_WORKSPACE}/${TEST_CASE_FOLDER}/${INDVIDUAL_TEST_FOLDER}" || exit + ${LINTER_COMMAND} "${FILE}" 2>&1 + ) + elif [[ ${FILE_TYPE} == "POWERSHELL" ]] || [[ ${FILE_TYPE} == "ARM" ]]; then + ################################ + # Lint the file with the rules # + ################################ + # Need to run PowerShell commands using pwsh -c, also exit with exit code from inner subshell + LINT_CMD=$( + cd "${GITHUB_WORKSPACE}/${TEST_CASE_FOLDER}" || exit + pwsh -NoProfile -NoLogo -Command "${LINTER_COMMAND} ${FILE}; if (\${Error}.Count) { exit 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 + ################################ + # Lint the file with the rules # + ################################ + LINT_CMD=$( + cd "${GITHUB_WORKSPACE}/${TEST_CASE_FOLDER}" || exit + ${LINTER_COMMAND} "${FILE}" 2>&1 + ) + fi ####################### # Load the error code # ####################### ERROR_CODE=$? - ############################## - # Check the shell for errors # - ############################## - if [ ${ERROR_CODE} -ne 0 ]; then - # Failed - error "Failed to find ${LINTER_NAME} in system!" - fatal "[${VALIDATE_INSTALL_CMD}]" + ######################################## + # Increment counter that check was ran # + ######################################## + (("TESTS_RAN++")) + + ######################################## + # Check for if it was supposed to pass # + ######################################## + if [[ ${FILE_STATUS} == "good" ]]; then + ############################## + # Check the shell for errors # + ############################## + if [ ${ERROR_CODE} -ne 0 ]; then + ######### + # Error # + ######### + error "Found errors in [${LINTER_NAME}] linter!" + error "[${LINT_CMD}]" + error "Linter CMD:[${LINTER_COMMAND} ${FILE}]" + # Increment the error count + (("ERRORS_FOUND_${FILE_TYPE}++")) + else + ########### + # Success # + ########### + info " - File:${F[W]}[${FILE_NAME}]${F[B]} was linted with ${F[W]}[${LINTER_NAME}]${F[B]} successfully" + fi + ####################################################### + # Store the linting as a temporary file in TAP format # + ####################################################### + if IsTAP; then + OkTap "${TESTS_RAN}" "${FILE_NAME}" "${TMPFILE}" + fi else + ####################################### + # File status = bad, this should fail # + ####################################### + ############################## + # Check the shell for errors # + ############################## + if [ ${ERROR_CODE} -eq 0 ]; then + ######### + # Error # + ######### + error "Found errors in [${LINTER_NAME}] linter!" + error "This file should have failed test case!" + error "Command run:${NC}[\$${LINT_CMD}]" + error "[${LINT_CMD}]" + error "Linter CMD:[${LINTER_COMMAND} ${FILE}]" + # Increment the error count + (("ERRORS_FOUND_${FILE_TYPE}++")) + else + ########### + # Success # + ########### + info " - File:${F[W]}[${FILE_NAME}]${F[B]} failed test case with ${F[W]}[${LINTER_NAME}]${F[B]} successfully" + fi + ####################################################### + # Store the linting as a temporary file in TAP format # + ####################################################### + if IsTAP; then + NotOkTap "${TESTS_RAN}" "${FILE_NAME}" "${TMPFILE}" + AddDetailedMessageIfEnabled "${LINT_CMD}" "${TMPFILE}" + fi + fi + done + + ########################################################################### + # Generate report in TAP format and validate with the expected TAP output # + ########################################################################### + if IsTAP && [ ${TESTS_RAN} -gt 0 ]; then + HeaderTap "${TESTS_RAN}" "${REPORT_OUTPUT_FILE}" + cat "${TMPFILE}" >> "${REPORT_OUTPUT_FILE}" + + ######################################################################## + # If expected TAP report exists then compare with the generated report # + ######################################################################## + EXPECTED_FILE="${GITHUB_WORKSPACE}/${TEST_CASE_FOLDER}/${INDVIDUAL_TEST_FOLDER}/reports/expected-${FILE_TYPE}.tap" + if [ -e "${EXPECTED_FILE}" ]; then + TMPFILE=$(mktemp -q "/tmp/diff-${FILE_TYPE}.XXXXXX") + ## Ignore white spaces, case sensitive + if ! diff -a -w -i "${EXPECTED_FILE}" "${REPORT_OUTPUT_FILE}" > "${TMPFILE}" 2>&1; then + ############################################# + # We failed to compare the reporting output # + ############################################# + error "Failed to assert TAP output:[${LINTER_NAME}]"! + info "Please validate the asserts!" + cat "${TMPFILE}" + exit 1 + else # Success - debug "Successfully found binary in system" - debug "Location:[${VALIDATE_INSTALL_CMD}]" - fi - - ########################## - # Initialize empty Array # - ########################## - LIST_FILES=() - - ####################### - # Create flag to skip # - ####################### - SKIP_FLAG=0 - - ###################################################### - # Only go into ansible linter if we have base folder # - ###################################################### - if [ -d "${ANSIBLE_DIRECTORY}" ]; then - - ################################# - # Get list of all files to lint # - ################################# - mapfile -t LIST_FILES < <(ls "${ANSIBLE_DIRECTORY}"/*.{yaml,yml} 2>&1) - - ############################################################### - # Set the list to empty if only MD and TXT files were changed # - ############################################################### - # No need to run the full ansible checks on read only file changes - if [ "${READ_ONLY_CHANGE_FLAG}" -eq 0 ]; then - ########################## - # Set the array to empty # - ########################## - LIST_FILES=() - ################################### - # Send message that were skipping # - ################################### - debug "- Skipping Ansible lint run as file(s) that were modified were read only..." - ############################ - # Create flag to skip loop # - ############################ - SKIP_FLAG=1 - fi - - #################################### - # Check if we have data to look at # - #################################### - if [ ${SKIP_FLAG} -eq 0 ]; then - for LINE in "${PRINT_ARRAY[@]}"; do - ######################### - # Print the header line # - ######################### - info "${LINE}" - done - fi - - ######################################## - # Prepare context if TAP output format # - ######################################## - if IsTAP; then - TMPFILE=$(mktemp -q "/tmp/super-linter-${FILE_TYPE}.XXXXXX") - INDEX=0 - mkdir -p "${REPORT_OUTPUT_FOLDER}" - REPORT_OUTPUT_FILE="${REPORT_OUTPUT_FOLDER}/super-linter-${FILE_TYPE}.${OUTPUT_FORMAT}" - fi - - ################## - # Lint the files # - ################## - for FILE in "${LIST_FILES[@]}"; do - - ######################################## - # Make sure we dont lint certain files # - ######################################## - if [[ ${FILE} == *"vault.yml"* ]] || [[ ${FILE} == *"galaxy.yml"* ]]; then - # This is a file we dont look at - continue - fi - - ################################## - # Increase the linted file index # - ################################## - (("INDEX++")) - - #################### - # Get the filename # - #################### - FILE_NAME=$(basename "${ANSIBLE_DIRECTORY}/${FILE}" 2>&1) - - ############## - # File print # - ############## - info "---------------------------" - info "File:[${FILE}]" - - ################################ - # Lint the file with the rules # - ################################ - LINT_CMD=$("${LINTER_NAME}" -v -c "${ANSIBLE_LINTER_RULES}" "${ANSIBLE_DIRECTORY}/${FILE}" 2>&1) - - ####################### - # Load the error code # - ####################### - ERROR_CODE=$? - - ############################## - # Check the shell for errors # - ############################## - if [ ${ERROR_CODE} -ne 0 ]; then - ######### - # Error # - ######### - error "Found errors in [${LINTER_NAME}] linter!" - error "[${LINT_CMD}]" - # Increment error count - ((ERRORS_FOUND_ANSIBLE++)) - - ####################################################### - # Store the linting as a temporary file in TAP format # - ####################################################### - if IsTAP; then - NotOkTap "${INDEX}" "${FILE}" "${TMPFILE}" - AddDetailedMessageIfEnabled "${LINT_CMD}" "${TMPFILE}" - fi - - else - ########### - # Success # - ########### - info " - File:${F[W]}[${FILE_NAME}]${F[B]} was linted with ${F[W]}[${LINTER_NAME}]${F[B]} successfully" - - ####################################################### - # Store the linting as a temporary file in TAP format # - ####################################################### - if IsTAP; then - OkTap "${INDEX}" "${FILE}" "${TMPFILE}" - fi - fi - done - - ################################# - # Generate report in TAP format # - ################################# - if IsTAP && [ ${INDEX} -gt 0 ]; then - HeaderTap "${INDEX}" "${REPORT_OUTPUT_FILE}" - cat "${TMPFILE}" >> "${REPORT_OUTPUT_FILE}" - fi + info "Successfully validation in the expected TAP format for ${F[W]}[${LINTER_NAME}]" + fi else - ######################## - # No Ansible dir found # - ######################## - warn "No Ansible base directory found at:[${ANSIBLE_DIRECTORY}]" - debug "skipping ansible lint" + warn "No TAP expected file found at:[${EXPECTED_FILE}]" + info "skipping report assertions" + ##################################### + # Append the file type to the array # + ##################################### + WARNING_ARRAY_TEST+=("${FILE_TYPE}") fi + fi + + ############################## + # Validate we ran some tests # + ############################## + if [ "${TESTS_RAN}" -eq 0 ]; then + ################################################# + # We failed to find files and no tests were ran # + ################################################# + error "Failed to find any tests ran for the Linter:[${LINTER_NAME}]"! + fatal "Please validate logic or that tests exist!" + fi +} +################################################################################ +#### Function RunTestCases ##################################################### +function RunTestCases() { + # This loop will run the test cases and exclude user code + # This is called from the automation process to validate new code + # When a PR is opened, the new code is validated with the default branch + # version of linter.sh, and a new container is built with the latest codebase + # for testing. That container is spun up, and ran, + # with the flag: TEST_CASE_RUN=true + # So that the new code can be validated against the test cases + + ################# + # Header prints # + ################# + info "----------------------------------------------" + info "-------------- TEST CASE RUN -----------------" + info "----------------------------------------------" + + ####################### + # Test case languages # + ####################### + # TestCodebase "Language" "Linter" "Linter-command" "Regex to find files" "Test Folder" + TestCodebase "ANSIBLE" "ansible-lint" "ansible-lint -v -c ${ANSIBLE_LINTER_RULES}" ".*\.\(yml\|yaml\)\$" "ansible" + TestCodebase "ARM" "arm-ttk" "Import-Module ${ARM_TTK_PSD1} ; \${config} = \$(Import-PowerShellDataFile -Path ${ARM_LINTER_RULES}) ; Test-AzTemplate @config -TemplatePath" ".*\.\(json\)\$" "arm" + TestCodebase "BASH" "shellcheck" "shellcheck --color" ".*\.\(sh\|bash\|dash\|ksh\)\$" "shell" + TestCodebase "CLOUDFORMATION" "cfn-lint" "cfn-lint --config-file ${CLOUDFORMATION_LINTER_RULES}" ".*\.\(json\|yml\|yaml\)\$" "cloudformation" + TestCodebase "CLOJURE" "clj-kondo" "clj-kondo --config ${CLOJURE_LINTER_RULES} --lint" ".*\.\(clj\|cljs\|cljc\|edn\)\$" "clojure" + TestCodebase "COFFEESCRIPT" "coffeelint" "coffeelint -f ${COFFEESCRIPT_LINTER_RULES}" ".*\.\(coffee\)\$" "coffeescript" + TestCodebase "CSS" "stylelint" "stylelint --config ${CSS_LINTER_RULES}" ".*\.\(css\)\$" "css" + TestCodebase "DART" "dart" "dartanalyzer --fatal-infos --fatal-warnings --options ${DART_LINTER_RULES}" ".*\.\(dart\)\$" "dart" + TestCodebase "DOCKER" "dockerfilelint" "dockerfilelint -c ${DOCKER_LINTER_RULES}" ".*\(Dockerfile\)\$" "docker" + TestCodebase "EDITORCONFIG" "editorconfig-checker" "editorconfig-checker" ".*\.ext$" "editorconfig-checker" + TestCodebase "ENV" "dotenv-linter" "dotenv-linter" ".*\.\(env\)\$" "env" + 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 "JAVASCRIPT_ES" "eslint" "eslint --no-eslintrc -c ${JAVASCRIPT_LINTER_RULES}" ".*\.\(js\)\$" "javascript" + TestCodebase "JAVASCRIPT_STANDARD" "standard" "standard ${JAVASCRIPT_STANDARD_LINTER_RULES}" ".*\.\(js\)\$" "javascript" + TestCodebase "JSON" "jsonlint" "jsonlint" ".*\.\(json\)\$" "json" + TestCodebase "KOTLIN" "ktlint" "ktlint" ".*\.\(kt\|kts\)\$" "kotlin" + TestCodebase "LUA" "lua" "luacheck" ".*\.\(lua\)\$" "lua" + TestCodebase "MARKDOWN" "markdownlint" "markdownlint -c ${MARKDOWN_LINTER_RULES}" ".*\.\(md\)\$" "markdown" + TestCodebase "PERL" "perl" "perl -Mstrict -cw" ".*\.\(pl\)\$" "perl" + TestCodebase "PHP" "php" "php -l" ".*\.\(php\)\$" "php" + TestCodebase "PHP_PHPSTAN" "phpstan" "phpstan analyse --no-progress --no-ansi -c ${PHPSTAN_LINTER_RULES}" ".*\.\(php\)\$" "php" + TestCodebase "OPENAPI" "spectral" "spectral lint -r ${OPENAPI_LINTER_RULES}" ".*\.\(ymlopenapi\|jsonopenapi\)\$" "openapi" + TestCodebase "POWERSHELL" "pwsh" "Invoke-ScriptAnalyzer -EnableExit -Settings ${POWERSHELL_LINTER_RULES} -Path" ".*\.\(ps1\|psm1\|psd1\|ps1xml\|pssc\|psrc\|cdxml\)\$" "powershell" + TestCodebase "PROTOBUF" "protolint" "protolint lint --config_path ${PROTOBUF_LINTER_RULES}" ".*\.\(proto\)\$" "protobuf" + TestCodebase "PYTHON_PYLINT" "pylint" "pylint --rcfile ${PYTHON_PYLINT_LINTER_RULES}" ".*\.\(py\)\$" "python" + TestCodebase "PYTHON_FLAKE8" "flake8" "flake8 --config ${PYTHON_FLAKE8_LINTER_RULES}" ".*\.\(py\)\$" "python" + TestCodebase "RAKU" "raku" "raku -c" ".*\.\(raku\|rakumod\|rakutest\|pm6\|pl6\|p6\)\$" "raku" + TestCodebase "RUBY" "rubocop" "rubocop -c ${RUBY_LINTER_RULES}" ".*\.\(rb\)\$" "ruby" + TestCodebase "STATES" "asl-validator" "asl-validator --json-path" ".*\.\(json\)\$" "states" + TestCodebase "TERRAFORM" "tflint" "tflint -c ${TERRAFORM_LINTER_RULES}" ".*\.\(tf\)\$" "terraform" + TestCodebase "TERRAFORM_TERRASCAN" "terrascan" "terrascan -f " ".*\.\(tf\)\$" "terraform_terrascan" + TestCodebase "TYPESCRIPT_ES" "eslint" "eslint --no-eslintrc -c ${TYPESCRIPT_LINTER_RULES}" ".*\.\(ts\)\$" "typescript" + TestCodebase "TYPESCRIPT_STANDARD" "standard" "standard --parser @typescript-eslint/parser --plugin @typescript-eslint/eslint-plugin ${TYPESCRIPT_STANDARD_LINTER_RULES}" ".*\.\(ts\)\$" "typescript" + TestCodebase "XML" "xmllint" "xmllint" ".*\.\(xml\)\$" "xml" + TestCodebase "YAML" "yamllint" "yamllint -c ${YAML_LINTER_RULES}" ".*\.\(yml\|yaml\)\$" "yml" + + ################# + # Footer prints # + ################# + # Call the footer to display run information + # and exit with error code + Footer +} +################################################################################ +#### Function LintAnsibleFiles ################################################# +function LintAnsibleFiles() { + ###################### + # Create Print Array # + ###################### + PRINT_ARRAY=() + + ################ + # print header # + ################ + PRINT_ARRAY+=("") + PRINT_ARRAY+=("----------------------------------------------") + PRINT_ARRAY+=("----------------------------------------------") + PRINT_ARRAY+=("Linting [Ansible] files...") + PRINT_ARRAY+=("----------------------------------------------") + PRINT_ARRAY+=("----------------------------------------------") + + ###################### + # Name of the linter # + ###################### + LINTER_NAME="ansible-lint" + + ########################################### + # Validate we have ansible-lint installed # + ########################################### + VALIDATE_INSTALL_CMD=$(command -v "${LINTER_NAME}" 2>&1) + + ####################### + # Load the error code # + ####################### + ERROR_CODE=$? + + ############################## + # Check the shell for errors # + ############################## + if [ ${ERROR_CODE} -ne 0 ]; then + # Failed + error "Failed to find ${LINTER_NAME} in system!" + fatal "[${VALIDATE_INSTALL_CMD}]" + else + # Success + debug "Successfully found binary in system" + debug "Location:[${VALIDATE_INSTALL_CMD}]" + fi + + ########################## + # Initialize empty Array # + ########################## + LIST_FILES=() + + ####################### + # Create flag to skip # + ####################### + SKIP_FLAG=0 + + ###################################################### + # Only go into ansible linter if we have base folder # + ###################################################### + if [ -d "${ANSIBLE_DIRECTORY}" ]; then + + ################################# + # Get list of all files to lint # + ################################# + mapfile -t LIST_FILES < <(ls "${ANSIBLE_DIRECTORY}"/*.{yaml,yml} 2>&1) + + ############################################################### + # Set the list to empty if only MD and TXT files were changed # + ############################################################### + # No need to run the full ansible checks on read only file changes + if [ "${READ_ONLY_CHANGE_FLAG}" -eq 0 ]; then + ########################## + # Set the array to empty # + ########################## + LIST_FILES=() + ################################### + # Send message that were skipping # + ################################### + debug "- Skipping Ansible lint run as file(s) that were modified were read only..." + ############################ + # Create flag to skip loop # + ############################ + SKIP_FLAG=1 + fi + + #################################### + # Check if we have data to look at # + #################################### + if [ ${SKIP_FLAG} -eq 0 ]; then + for LINE in "${PRINT_ARRAY[@]}"; do + ######################### + # Print the header line # + ######################### + info "${LINE}" + done + fi + + ######################################## + # Prepare context if TAP output format # + ######################################## + if IsTAP; then + TMPFILE=$(mktemp -q "/tmp/super-linter-${FILE_TYPE}.XXXXXX") + INDEX=0 + mkdir -p "${REPORT_OUTPUT_FOLDER}" + REPORT_OUTPUT_FILE="${REPORT_OUTPUT_FOLDER}/super-linter-${FILE_TYPE}.${OUTPUT_FORMAT}" + fi + + ################## + # Lint the files # + ################## + for FILE in "${LIST_FILES[@]}"; do + + ######################################## + # Make sure we dont lint certain files # + ######################################## + if [[ ${FILE} == *"vault.yml"* ]] || [[ ${FILE} == *"galaxy.yml"* ]]; then + # This is a file we dont look at + continue + fi + + ################################## + # Increase the linted file index # + ################################## + (("INDEX++")) + + #################### + # Get the filename # + #################### + FILE_NAME=$(basename "${ANSIBLE_DIRECTORY}/${FILE}" 2>&1) + + ############## + # File print # + ############## + info "---------------------------" + info "File:[${FILE}]" + + ################################ + # Lint the file with the rules # + ################################ + LINT_CMD=$("${LINTER_NAME}" -v -c "${ANSIBLE_LINTER_RULES}" "${ANSIBLE_DIRECTORY}/${FILE}" 2>&1) + + ####################### + # Load the error code # + ####################### + ERROR_CODE=$? + + ############################## + # Check the shell for errors # + ############################## + if [ ${ERROR_CODE} -ne 0 ]; then + ######### + # Error # + ######### + error "Found errors in [${LINTER_NAME}] linter!" + error "[${LINT_CMD}]" + # Increment error count + ((ERRORS_FOUND_ANSIBLE++)) + + ####################################################### + # Store the linting as a temporary file in TAP format # + ####################################################### + if IsTAP; then + NotOkTap "${INDEX}" "${FILE}" "${TMPFILE}" + AddDetailedMessageIfEnabled "${LINT_CMD}" "${TMPFILE}" + fi + + else + ########### + # Success # + ########### + info " - File:${F[W]}[${FILE_NAME}]${F[B]} was linted with ${F[W]}[${LINTER_NAME}]${F[B]} successfully" + + ####################################################### + # Store the linting as a temporary file in TAP format # + ####################################################### + if IsTAP; then + OkTap "${INDEX}" "${FILE}" "${TMPFILE}" + fi + fi + done + + ################################# + # Generate report in TAP format # + ################################# + if IsTAP && [ ${INDEX} -gt 0 ]; then + HeaderTap "${INDEX}" "${REPORT_OUTPUT_FILE}" + cat "${TMPFILE}" >> "${REPORT_OUTPUT_FILE}" + fi + else + ######################## + # No Ansible dir found # + ######################## + warn "No Ansible base directory found at:[${ANSIBLE_DIRECTORY}]" + debug "skipping ansible lint" + fi } ################################################################################ #### Function IsTap ############################################################ function IsTAP() { - if [ "${OUTPUT_FORMAT}" == "tap" ]; then - return 0 - else - return 1 - fi + if [ "${OUTPUT_FORMAT}" == "tap" ]; then + return 0 + else + return 1 + fi } ################################################################################ #### Function TransformTAPDetails ############################################## function TransformTAPDetails() { - DATA=${1} - if [ -n "${DATA}" ] && [ "${OUTPUT_DETAILS}" == "detailed" ]; then - ######################################################### - # Transform new lines to \\n, remove colours and colons # - ######################################################### - echo "${DATA}" | awk 'BEGIN{RS="\n";ORS="\\n"}1' | sed -r "s/\x1B\[([0-9]{1,3}(;[0-9]{1,2})?)?[mGK]//g" | tr ':' ' ' - fi + DATA=${1} + if [ -n "${DATA}" ] && [ "${OUTPUT_DETAILS}" == "detailed" ]; then + ######################################################### + # Transform new lines to \\n, remove colours and colons # + ######################################################### + echo "${DATA}" | awk 'BEGIN{RS="\n";ORS="\\n"}1' | sed -r "s/\x1B\[([0-9]{1,3}(;[0-9]{1,2})?)?[mGK]//g" | tr ':' ' ' + fi } ################################################################################ #### Function HeaderTap ######################################################## function HeaderTap() { - ################ - # Pull in Vars # - ################ - INDEX="${1}" # File being validated - OUTPUT_FILE="${2}" # Output location + ################ + # Pull in Vars # + ################ + INDEX="${1}" # File being validated + OUTPUT_FILE="${2}" # Output location - ################### - # Print the goods # - ################### - printf "TAP version 13\n1..%s\n" "${INDEX}" > "${OUTPUT_FILE}" + ################### + # Print the goods # + ################### + printf "TAP version 13\n1..%s\n" "${INDEX}" > "${OUTPUT_FILE}" } ################################################################################ #### Function OkTap ############################################################ function OkTap() { - ################ - # Pull in Vars # - ################ - INDEX="${1}" # Location - FILE="${2}" # File being validated - TEMP_FILE="${3}" # Temp file location + ################ + # Pull in Vars # + ################ + INDEX="${1}" # Location + FILE="${2}" # File being validated + TEMP_FILE="${3}" # Temp file location - ################### - # Print the goods # - ################### - echo "ok ${INDEX} - ${FILE}" >> "${TEMP_FILE}" + ################### + # Print the goods # + ################### + echo "ok ${INDEX} - ${FILE}" >> "${TEMP_FILE}" } ################################################################################ #### Function NotOkTap ######################################################### function NotOkTap() { - ################ - # Pull in Vars # - ################ - INDEX="${1}" # Location - FILE="${2}" # File being validated - TEMP_FILE="${3}" # Temp file location + ################ + # Pull in Vars # + ################ + INDEX="${1}" # Location + FILE="${2}" # File being validated + TEMP_FILE="${3}" # Temp file location - ################### - # Print the goods # - ################### - echo "not ok ${INDEX} - ${FILE}" >> "${TEMP_FILE}" + ################### + # Print the goods # + ################### + echo "not ok ${INDEX} - ${FILE}" >> "${TEMP_FILE}" } ################################################################################ #### Function AddDetailedMessageIfEnabled ###################################### function AddDetailedMessageIfEnabled() { - ################ - # Pull in Vars # - ################ - LINT_CMD="${1}" # Linter command - TEMP_FILE="${2}" # Temp file + ################ + # Pull in Vars # + ################ + LINT_CMD="${1}" # Linter command + TEMP_FILE="${2}" # Temp file - #################### - # Check the return # - #################### - DETAILED_MSG=$(TransformTAPDetails "${LINT_CMD}") - if [ -n "${DETAILED_MSG}" ]; then - printf " ---\n message: %s\n ...\n" "${DETAILED_MSG}" >> "${TEMP_FILE}" - fi + #################### + # Check the return # + #################### + DETAILED_MSG=$(TransformTAPDetails "${LINT_CMD}") + if [ -n "${DETAILED_MSG}" ]; then + printf " ---\n message: %s\n ...\n" "${DETAILED_MSG}" >> "${TEMP_FILE}" + fi } From 09a51babdf63766f8608839be8e757eb76bcba9c Mon Sep 17 00:00:00 2001 From: Eric Nemchik Date: Thu, 30 Jul 2020 15:46:14 -0500 Subject: [PATCH 103/135] Cleanup --- .automation/cleanup-docker.sh | 6 ++++++ .automation/upload-docker.sh | 6 ++++++ lib/termColors.sh | 27 --------------------------- 3 files changed, 12 insertions(+), 27 deletions(-) delete mode 100755 lib/termColors.sh diff --git a/.automation/cleanup-docker.sh b/.automation/cleanup-docker.sh index d9eb6312..a91cdcd2 100755 --- a/.automation/cleanup-docker.sh +++ b/.automation/cleanup-docker.sh @@ -13,6 +13,12 @@ # - System with Docker installed # - Global variables met +######################### +# Source Function Files # +######################### +# shellcheck source=/dev/null +source /action/lib/log.sh # Source the function script(s) + ########### # Globals # ########### diff --git a/.automation/upload-docker.sh b/.automation/upload-docker.sh index f9557959..ae819fdb 100755 --- a/.automation/upload-docker.sh +++ b/.automation/upload-docker.sh @@ -14,6 +14,12 @@ # - System with Docker installed # - Global variables met +######################### +# Source Function Files # +######################### +# shellcheck source=/dev/null +source /action/lib/log.sh # Source the function script(s) + ########### # Globals # ########### diff --git a/lib/termColors.sh b/lib/termColors.sh deleted file mode 100755 index 8f22a26c..00000000 --- a/lib/termColors.sh +++ /dev/null @@ -1,27 +0,0 @@ -#!/usr/bin/env bash - -declare -Agr B=( - [B]=$(echo -e "\e[44m") - [C]=$(echo -e "\e[46m") - [G]=$(echo -e "\e[42m") - [K]=$(echo -e "\e[40m") - [M]=$(echo -e "\e[45m") - [R]=$(echo -e "\e[41m") - [W]=$(echo -e "\e[47m") - [Y]=$(echo -e "\e[43m") -) -declare -Agr F=( - [B]=$(echo -e "\e[0;34m") - [C]=$(echo -e "\e[0;36m") - [G]=$(echo -e "\e[0;32m") - [K]=$(echo -e "\e[0;30m") - [M]=$(echo -e "\e[0;35m") - [R]=$(echo -e "\e[0;31m") - [W]=$(echo -e "\e[0;37m") - [Y]=$(echo -e "\e[0;33m") -) -readonly NC=$(echo -e "\e[0m") - -export B -export F -export NC From 3c6a680bd617ac31d825d6f5b17c5725331b3962 Mon Sep 17 00:00:00 2001 From: Gabo Date: Thu, 30 Jul 2020 16:43:35 -0500 Subject: [PATCH 104/135] Fix yaml --- lib/linter.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/linter.sh b/lib/linter.sh index 09647ad9..60f02a22 100755 --- a/lib/linter.sh +++ b/lib/linter.sh @@ -118,7 +118,7 @@ LANGUAGE_ARRAY=('ANSIBLE' 'ARM' 'BASH' 'CLOUDFORMATION' 'CLOJURE' 'COFFEESCRIPT' 'DART' 'DOCKER' 'ENV' 'GO' 'GROOVY' 'HTML' 'JAVASCRIPT_ES' 'JAVASCRIPT_STANDARD' 'JSON' 'JSX' 'KOTLIN' 'LUA' 'MARKDOWN' 'OPENAPI' 'PERL' 'PHP' 'PHP_PHPSTAN' 'POWERSHELL' 'PROTOBUF' 'PYTHON_PYLINT' 'PYTHON_FLAKE8' 'RAKU' 'RUBY' 'STATES' 'TERRAFORM' - 'TERRAFORM_TERRASCAN' 'TSX' 'TYPESCRIPT_ES' 'TYPESCRIPT_STANDARD' 'XML' 'YML') + 'TERRAFORM_TERRASCAN' 'TSX' 'TYPESCRIPT_ES' 'TYPESCRIPT_STANDARD' 'XML' 'YAML') ############################################ # Array for all languages that were linted # From 4a2bf935b7d423955364d3e3fd3326f22701fe77 Mon Sep 17 00:00:00 2001 From: Gabo Date: Thu, 30 Jul 2020 18:12:17 -0500 Subject: [PATCH 105/135] Remane tests --- .automation/test/{yml => yaml}/README.md | 4 ++-- .automation/test/{yml => yaml}/reports/expected-YML.tap | 0 .automation/test/{yml => yaml}/yml_bad_1.yml | 0 .automation/test/{yml => yaml}/yml_good_1.yml | 0 lib/worker.sh | 2 +- 5 files changed, 3 insertions(+), 3 deletions(-) rename .automation/test/{yml => yaml}/README.md (87%) rename .automation/test/{yml => yaml}/reports/expected-YML.tap (100%) rename .automation/test/{yml => yaml}/yml_bad_1.yml (100%) rename .automation/test/{yml => yaml}/yml_good_1.yml (100%) diff --git a/.automation/test/yml/README.md b/.automation/test/yaml/README.md similarity index 87% rename from .automation/test/yml/README.md rename to .automation/test/yaml/README.md index 8016e848..3f42a5fa 100644 --- a/.automation/test/yml/README.md +++ b/.automation/test/yaml/README.md @@ -1,6 +1,6 @@ -# Yml Test Cases +# Yaml Test Cases -This folder holds the test cases for **Yml**. +This folder holds the test cases for **Yaml**. ## Additional Docs diff --git a/.automation/test/yml/reports/expected-YML.tap b/.automation/test/yaml/reports/expected-YML.tap similarity index 100% rename from .automation/test/yml/reports/expected-YML.tap rename to .automation/test/yaml/reports/expected-YML.tap diff --git a/.automation/test/yml/yml_bad_1.yml b/.automation/test/yaml/yml_bad_1.yml similarity index 100% rename from .automation/test/yml/yml_bad_1.yml rename to .automation/test/yaml/yml_bad_1.yml diff --git a/.automation/test/yml/yml_good_1.yml b/.automation/test/yaml/yml_good_1.yml similarity index 100% rename from .automation/test/yml/yml_good_1.yml rename to .automation/test/yaml/yml_good_1.yml diff --git a/lib/worker.sh b/lib/worker.sh index 3dbdb83c..31617599 100755 --- a/lib/worker.sh +++ b/lib/worker.sh @@ -604,7 +604,7 @@ function RunTestCases() { TestCodebase "TYPESCRIPT_ES" "eslint" "eslint --no-eslintrc -c ${TYPESCRIPT_LINTER_RULES}" ".*\.\(ts\)\$" "typescript" TestCodebase "TYPESCRIPT_STANDARD" "standard" "standard --parser @typescript-eslint/parser --plugin @typescript-eslint/eslint-plugin ${TYPESCRIPT_STANDARD_LINTER_RULES}" ".*\.\(ts\)\$" "typescript" TestCodebase "XML" "xmllint" "xmllint" ".*\.\(xml\)\$" "xml" - TestCodebase "YAML" "yamllint" "yamllint -c ${YAML_LINTER_RULES}" ".*\.\(yml\|yaml\)\$" "yml" + TestCodebase "YAML" "yamllint" "yamllint -c ${YAML_LINTER_RULES}" ".*\.\(yml\|yaml\)\$" "yaml" ################# # Footer prints # From 3de60e71cc5278b9be88f18c387688c9bbff96a5 Mon Sep 17 00:00:00 2001 From: Eric Nemchik Date: Thu, 30 Jul 2020 18:27:34 -0500 Subject: [PATCH 106/135] Fix log sources in docker scripts --- .automation/cleanup-docker.sh | 2 +- .automation/upload-docker.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.automation/cleanup-docker.sh b/.automation/cleanup-docker.sh index a91cdcd2..3115fa84 100755 --- a/.automation/cleanup-docker.sh +++ b/.automation/cleanup-docker.sh @@ -17,7 +17,7 @@ # Source Function Files # ######################### # shellcheck source=/dev/null -source /action/lib/log.sh # Source the function script(s) +source ../lib/log.sh # Source the function script(s) ########### # Globals # diff --git a/.automation/upload-docker.sh b/.automation/upload-docker.sh index ae819fdb..c31ffbde 100755 --- a/.automation/upload-docker.sh +++ b/.automation/upload-docker.sh @@ -18,7 +18,7 @@ # Source Function Files # ######################### # shellcheck source=/dev/null -source /action/lib/log.sh # Source the function script(s) +source ../lib/log.sh # Source the function script(s) ########### # Globals # From 94ab073fe31eb865a047ad0c2cdca9a9a7f9495e Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 31 Jul 2020 05:22:25 +0000 Subject: [PATCH 107/135] Bump eslint-plugin-jest from 23.19.0 to 23.20.0 in /dependencies Bumps [eslint-plugin-jest](https://github.com/jest-community/eslint-plugin-jest) from 23.19.0 to 23.20.0. - [Release notes](https://github.com/jest-community/eslint-plugin-jest/releases) - [Changelog](https://github.com/jest-community/eslint-plugin-jest/blob/master/CHANGELOG.md) - [Commits](https://github.com/jest-community/eslint-plugin-jest/compare/v23.19.0...v23.20.0) Signed-off-by: dependabot[bot] --- dependencies/package-lock.json | 6 +++--- dependencies/package.json | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/dependencies/package-lock.json b/dependencies/package-lock.json index 8bf1fc2f..53ab1099 100644 --- a/dependencies/package-lock.json +++ b/dependencies/package-lock.json @@ -1925,9 +1925,9 @@ } }, "eslint-plugin-jest": { - "version": "23.19.0", - "resolved": "https://registry.npmjs.org/eslint-plugin-jest/-/eslint-plugin-jest-23.19.0.tgz", - "integrity": "sha512-l5PLflALqnODl8Yy0H5hDs18aKJS1KTf66VZGXRpIhmbLbPLaTuMB2P+65fBpkdseSpnTVcIlBYvTvJSBi/itg==", + "version": "23.20.0", + "resolved": "https://registry.npmjs.org/eslint-plugin-jest/-/eslint-plugin-jest-23.20.0.tgz", + "integrity": "sha512-+6BGQt85OREevBDWCvhqj1yYA4+BFK4XnRZSGJionuEYmcglMZYLNNBBemwzbqUAckURaHdJSBcjHPyrtypZOw==", "requires": { "@typescript-eslint/experimental-utils": "^2.5.0" }, diff --git a/dependencies/package.json b/dependencies/package.json index 3cec01fc..77513b78 100644 --- a/dependencies/package.json +++ b/dependencies/package.json @@ -9,7 +9,7 @@ "dockerfilelint": "^1.5.0", "eslint": "^7.5.0", "eslint-config-prettier": "^6.11.0", - "eslint-plugin-jest": "^23.19.0", + "eslint-plugin-jest": "^23.20.0", "htmlhint": "^0.14.1", "jsonlint": "^1.6.3", "markdownlint-cli": "^0.23.2", From a6e4fc879b37dae2316b5827cd78bc120cbd26cf Mon Sep 17 00:00:00 2001 From: Michikawa Masayoshi Date: Fri, 31 Jul 2020 19:56:36 +0900 Subject: [PATCH 108/135] Add rubocop-rspec to ruby linter dependencies --- dependencies/Gemfile | 1 + dependencies/Gemfile.lock | 3 +++ 2 files changed, 4 insertions(+) diff --git a/dependencies/Gemfile b/dependencies/Gemfile index ab2a0684..ea9d82b6 100644 --- a/dependencies/Gemfile +++ b/dependencies/Gemfile @@ -8,3 +8,4 @@ gem "rubocop", "~> 0.82.0" gem "rubocop-github", "~> 0.16.0" gem "rubocop-performance", "~>1.7.1" gem "rubocop-rails", "~> 2.5" +gem "rubocop-rspec", "~> 1.41.0" diff --git a/dependencies/Gemfile.lock b/dependencies/Gemfile.lock index 9df0518b..076e8a5e 100644 --- a/dependencies/Gemfile.lock +++ b/dependencies/Gemfile.lock @@ -37,6 +37,8 @@ GEM activesupport (>= 4.2.0) rack (>= 1.1) rubocop (>= 0.82.0) + rubocop-rspec (1.41.0) + rubocop (>= 0.68.1) ruby-progressbar (1.10.1) thread_safe (0.3.6) tzinfo (1.2.7) @@ -52,6 +54,7 @@ DEPENDENCIES rubocop-github (~> 0.16.0) rubocop-performance (~> 1.7.1) rubocop-rails (~> 2.5) + rubocop-rspec (~> 1.41.0) BUNDLED WITH 2.1.4 From 8d8bc80de18354467551a60bed846643306e1f61 Mon Sep 17 00:00:00 2001 From: Lukas Gravley Date: Fri, 31 Jul 2020 09:07:44 -0500 Subject: [PATCH 109/135] Update linter.sh --- lib/linter.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/linter.sh b/lib/linter.sh index de9d129b..88bec682 100755 --- a/lib/linter.sh +++ b/lib/linter.sh @@ -23,6 +23,7 @@ source /action/lib/worker.sh # Source the function script(s) ########### # Default Vars DEFAULT_RULES_LOCATION='/action/lib/.automation' # Default rules files location +GITHUB_API_URL='https://api.github.com' # GitHub API root url # Ansible Vars ANSIBLE_FILE_NAME='.ansible-lint.yml' # Name of the file ANSIBLE_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${ANSIBLE_FILE_NAME}" # Path to the Ansible lint rules From d1827a81f7882d176f70baef09d80380103f3719 Mon Sep 17 00:00:00 2001 From: Lucas Gravley <29484535+admiralAwkbar@users.noreply.github.com> Date: Fri, 31 Jul 2020 09:17:04 -0500 Subject: [PATCH 110/135] fixin it --- lib/linter.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/linter.sh b/lib/linter.sh index 8e3d9e10..3d4eb9ef 100755 --- a/lib/linter.sh +++ b/lib/linter.sh @@ -268,7 +268,6 @@ FILE_ARRAY_LUA=() # Array of files to check FILE_ARRAY_MARKDOWN=() # Array of files to check FILE_ARRAY_OPENAPI=() # Array of files to check FILE_ARRAY_PERL=() # Array of files to check -FILE_ARRAY_PHP=() # Array of files to check FILE_ARRAY_PHP_BUILTIN=() # Array of files to check FILE_ARRAY_PHP_PHPCS=() # Array of files to check FILE_ARRAY_PHP_PSALM=() # Array of files to check From 84926171fb98a5d17246bc01b7b2d7c9778d6648 Mon Sep 17 00:00:00 2001 From: Lucas Gravley <29484535+admiralAwkbar@users.noreply.github.com> Date: Fri, 31 Jul 2020 09:54:58 -0500 Subject: [PATCH 111/135] fix arrays and add tests --- lib/buildFileList.sh | 4 +++- lib/possum.sh | 12 ++++++------ lib/worker.sh | 2 ++ 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/lib/buildFileList.sh b/lib/buildFileList.sh index 3e52de0f..b9b3de27 100755 --- a/lib/buildFileList.sh +++ b/lib/buildFileList.sh @@ -230,7 +230,9 @@ function BuildFileList() { ################################ # Append the file to the array # ################################ - FILE_ARRAY_PHP+=("${FILE}") + FILE_ARRAY_PHP_BUILTIN+=("${FILE}") + FILE_ARRAY_PHP_PHPCS+=("${FILE}") + FILE_ARRAY_PHP_PSALM+=("${FILE}") FILE_ARRAY_PHP_PHPSTAN+=("${FILE}") ########################################################## # Set the READ_ONLY_CHANGE_FLAG since this could be exec # diff --git a/lib/possum.sh b/lib/possum.sh index d867332b..172ccc00 100755 --- a/lib/possum.sh +++ b/lib/possum.sh @@ -8,12 +8,12 @@ cat << EOF @///////@///////////////@@@@ ( @, @/(&/@//////////////////// @ @////////////////////////@@ @ - @%////////(//////////%/////&@ @@ *,@ - @@@@@/@/#/////(&////////////////// .@ - *@@@@@. .%///(//@//////////////////&. .@@, @% - @@% .&@&&/@.@//&/////(////////// @@@@@@@@@ .. &@ - @@% @@@@@ @&/////////////////# @/ V @@/ ,@@@ @ -@@@% @@@@ .%@@@@//////#@ @ @@ @ .,. + @%////////(//////////%/////&@ @@ *,@ ______________ + @@@@@/@/#/////(&////////////////// .@ / \ + *@@@@@. .%///(//@//////////////////&. .@@, @% / Don't mind me \ + @@% .&@&&/@.@//&/////(////////// @@@@@@@@@ .. &@ / I'm just looking \ + @@% @@@@@ @&/////////////////# @/ V @@/ ,@@@ @ < for some trash... | +@@@% @@@@ .%@@@@//////#@ @ @@ @ .,. \__________________/ @@@/@( (@@@@% @/\ % @@@@( . .@@/\ # @ %@% diff --git a/lib/worker.sh b/lib/worker.sh index 31617599..3d35f1c7 100755 --- a/lib/worker.sh +++ b/lib/worker.sh @@ -590,6 +590,8 @@ function RunTestCases() { TestCodebase "MARKDOWN" "markdownlint" "markdownlint -c ${MARKDOWN_LINTER_RULES}" ".*\.\(md\)\$" "markdown" TestCodebase "PERL" "perl" "perl -Mstrict -cw" ".*\.\(pl\)\$" "perl" TestCodebase "PHP" "php" "php -l" ".*\.\(php\)\$" "php" + TestCodebase "PHP_PHPCS" "phpcs" "phpcs --standard=${PHP_PHPCS_LINTER_RULES}" ".*\.\(php\)\$" "php" + TestCodebase "PHP_PSALM" "psalm" "psalm --config=${PHP_PSALM_LINTER_RULES}" ".*\.\(php\)\$" "php" TestCodebase "PHP_PHPSTAN" "phpstan" "phpstan analyse --no-progress --no-ansi -c ${PHPSTAN_LINTER_RULES}" ".*\.\(php\)\$" "php" TestCodebase "OPENAPI" "spectral" "spectral lint -r ${OPENAPI_LINTER_RULES}" ".*\.\(ymlopenapi\|jsonopenapi\)\$" "openapi" TestCodebase "POWERSHELL" "pwsh" "Invoke-ScriptAnalyzer -EnableExit -Settings ${POWERSHELL_LINTER_RULES} -Path" ".*\.\(ps1\|psm1\|psd1\|ps1xml\|pssc\|psrc\|cdxml\)\$" "powershell" From 68dc0cb9932f4b6dda6c8e0c790d9dc208973c34 Mon Sep 17 00:00:00 2001 From: Arto Bendiken Date: Sat, 1 Aug 2020 18:27:21 +0300 Subject: [PATCH 112/135] Fixed typos regarding the Dart configuration path. --- docs/disabling-linters.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/disabling-linters.md b/docs/disabling-linters.md index 599bf126..15ddb185 100644 --- a/docs/disabling-linters.md +++ b/docs/disabling-linters.md @@ -243,7 +243,7 @@ a { - `.github/linters/.dart-lint.yml` - You can pass multiple rules and overwrite default rules -- File should be located at: `.github/linters/anaylsis_options.yaml` +- File should be located at: `.github/linters/analysis_options.yaml` ### dartanalyzer disable single line @@ -261,7 +261,7 @@ int x = ''; // ignore: invalid_assignment ### dartanalyzer disable entire file -- You can disable entire files with the `analyzer.exclude` property in `anaylsis_options.yaml` +- You can disable entire files with the `analyzer.exclude` property in `analysis_options.yaml` ```dart analyzer: From 54a277e0c23650f03c0273b474b4f9fff040fd9d Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 3 Aug 2020 06:21:35 +0000 Subject: [PATCH 113/135] Bump golangci/golangci-lint from v1.29.0 to v1.30.0 Bumps golangci/golangci-lint from v1.29.0 to v1.30.0. Signed-off-by: dependabot[bot] --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 3533b1d8..cbf06664 100644 --- a/Dockerfile +++ b/Dockerfile @@ -10,7 +10,7 @@ FROM borkdude/clj-kondo:2020.07.29 as clj-kondo FROM dotenvlinter/dotenv-linter:2.1.0 as dotenv-linter FROM mstruebing/editorconfig-checker:2.1.0 as editorconfig-checker -FROM golangci/golangci-lint:v1.29.0 as golangci-lint +FROM golangci/golangci-lint:v1.30.0 as golangci-lint FROM yoheimuta/protolint:v0.26.0 as protolint FROM koalaman/shellcheck:v0.7.1 as shellcheck FROM wata727/tflint:0.18.0 as tflint From f93e245e5a112e6a2222cdae27e89fb99cf154fb Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 3 Aug 2020 06:25:32 +0000 Subject: [PATCH 114/135] Bump eslint from 7.5.0 to 7.6.0 in /dependencies Bumps [eslint](https://github.com/eslint/eslint) from 7.5.0 to 7.6.0. - [Release notes](https://github.com/eslint/eslint/releases) - [Changelog](https://github.com/eslint/eslint/blob/master/CHANGELOG.md) - [Commits](https://github.com/eslint/eslint/compare/v7.5.0...v7.6.0) Signed-off-by: dependabot[bot] --- dependencies/package-lock.json | 6 +++--- dependencies/package.json | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/dependencies/package-lock.json b/dependencies/package-lock.json index 53ab1099..1e438d15 100644 --- a/dependencies/package-lock.json +++ b/dependencies/package-lock.json @@ -1609,9 +1609,9 @@ } }, "eslint": { - "version": "7.5.0", - "resolved": "https://registry.npmjs.org/eslint/-/eslint-7.5.0.tgz", - "integrity": "sha512-vlUP10xse9sWt9SGRtcr1LAC67BENcQMFeV+w5EvLEoFe3xJ8cF1Skd0msziRx/VMC+72B4DxreCE+OR12OA6Q==", + "version": "7.6.0", + "resolved": "https://registry.npmjs.org/eslint/-/eslint-7.6.0.tgz", + "integrity": "sha512-QlAManNtqr7sozWm5TF4wIH9gmUm2hE3vNRUvyoYAa4y1l5/jxD/PQStEjBMQtCqZmSep8UxrcecI60hOpe61w==", "requires": { "@babel/code-frame": "^7.0.0", "ajv": "^6.10.0", diff --git a/dependencies/package.json b/dependencies/package.json index 77513b78..b789a501 100644 --- a/dependencies/package.json +++ b/dependencies/package.json @@ -7,7 +7,7 @@ "@typescript-eslint/parser": "^3.7.1", "babel-eslint": "^10.1.0", "dockerfilelint": "^1.5.0", - "eslint": "^7.5.0", + "eslint": "^7.6.0", "eslint-config-prettier": "^6.11.0", "eslint-plugin-jest": "^23.20.0", "htmlhint": "^0.14.1", From 64c4cc0d5dc63ec9961cff212b3f7c4820ad3f93 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 3 Aug 2020 06:26:21 +0000 Subject: [PATCH 115/135] Bump npm-groovy-lint from 5.7.0 to 5.8.0 in /dependencies Bumps [npm-groovy-lint](https://github.com/nvuillam/npm-groovy-lint) from 5.7.0 to 5.8.0. - [Release notes](https://github.com/nvuillam/npm-groovy-lint/releases) - [Changelog](https://github.com/nvuillam/npm-groovy-lint/blob/master/CHANGELOG.md) - [Commits](https://github.com/nvuillam/npm-groovy-lint/compare/v5.7.0...v5.8.0) Signed-off-by: dependabot[bot] --- dependencies/package-lock.json | 12 ++++++------ dependencies/package.json | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/dependencies/package-lock.json b/dependencies/package-lock.json index 53ab1099..99407836 100644 --- a/dependencies/package-lock.json +++ b/dependencies/package-lock.json @@ -3613,9 +3613,9 @@ "integrity": "sha1-0LFF62kRicY6eNIB3E/bEpPvDAM=" }, "npm-groovy-lint": { - "version": "5.7.0", - "resolved": "https://registry.npmjs.org/npm-groovy-lint/-/npm-groovy-lint-5.7.0.tgz", - "integrity": "sha512-Cq/ncgmNMI6USeazp2gingZj73ia6M+rpR5LfBK8ATSEdRZuIsnKTIGTuqMc/hrZyU4oMN0C/PYQj4DTO+TRFQ==", + "version": "5.8.0", + "resolved": "https://registry.npmjs.org/npm-groovy-lint/-/npm-groovy-lint-5.8.0.tgz", + "integrity": "sha512-GeBeH97fEy/YwSztmERx96X52c7WrWu80iyNWqNnNZKUjkY6LFMXhNCzb18WCKmPZRTypcSbjxFN3TUDl0/sMw==", "requires": { "@amplitude/node": "^0.3.3", "ansi-colors": "^4.1.1", @@ -3637,9 +3637,9 @@ }, "dependencies": { "uuid": { - "version": "8.2.0", - "resolved": "https://registry.npmjs.org/uuid/-/uuid-8.2.0.tgz", - "integrity": "sha512-CYpGiFTUrmI6OBMkAdjSDM0k5h8SkkiTP4WAjQgDgNB1S3Ou9VBEvr6q0Kv2H1mMk7IWfxYGpMH5sd5AvcIV2Q==" + "version": "8.3.0", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.0.tgz", + "integrity": "sha512-fX6Z5o4m6XsXBdli9g7DtWgAx+osMsRRZFKma1mIUsLCz6vRvv+pz5VNbyu9UEDzpMWulZfvpgb/cmDXVulYFQ==" } } }, diff --git a/dependencies/package.json b/dependencies/package.json index 77513b78..8dcb4df4 100644 --- a/dependencies/package.json +++ b/dependencies/package.json @@ -18,7 +18,7 @@ "standard": "^14.3.4", "stylelint": "^13.6.1", "stylelint-config-standard": "^20.0.0", - "npm-groovy-lint": "^5.5.0", + "npm-groovy-lint": "^5.8.0", "typescript": "^3.9.7", "asl-validator": "^1.7.0" From 6fcc297102e3ff3643780760fe8542c64b4ac474 Mon Sep 17 00:00:00 2001 From: Lucas Gravley <29484535+admiralAwkbar@users.noreply.github.com> Date: Mon, 3 Aug 2020 08:12:14 -0500 Subject: [PATCH 116/135] fix default token --- .github/workflows/automerge-dependabot.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/automerge-dependabot.yml b/.github/workflows/automerge-dependabot.yml index 10942d09..dce77f76 100644 --- a/.github/workflows/automerge-dependabot.yml +++ b/.github/workflows/automerge-dependabot.yml @@ -44,4 +44,4 @@ jobs: repo: context.payload.repository.name, pull_number: context.payload.pull_request.number }) - github-token: ${{github.token}} + github-token: ${{ secrets.GITHUB_TOKEN }} From 56894ef49a2388137fe3ead1bd4bef743e7a4584 Mon Sep 17 00:00:00 2001 From: Lucas Gravley <29484535+admiralAwkbar@users.noreply.github.com> Date: Mon, 3 Aug 2020 14:14:54 -0500 Subject: [PATCH 117/135] fixed the cool guy --- lib/possum.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/possum.sh b/lib/possum.sh index 172ccc00..92944cdd 100755 --- a/lib/possum.sh +++ b/lib/possum.sh @@ -9,11 +9,11 @@ cat << EOF @/(&/@//////////////////// @ @////////////////////////@@ @ @%////////(//////////%/////&@ @@ *,@ ______________ - @@@@@/@/#/////(&////////////////// .@ / \ - *@@@@@. .%///(//@//////////////////&. .@@, @% / Don't mind me \ - @@% .&@&&/@.@//&/////(////////// @@@@@@@@@ .. &@ / I'm just looking \ + @@@@@/@/#/////(&////////////////// .@ / \\ + *@@@@@. .%///(//@//////////////////&. .@@, @% / Don't mind me \\ + @@% .&@&&/@.@//&/////(////////// @@@@@@@@@ .. &@ / I'm just looking \\ @@% @@@@@ @&/////////////////# @/ V @@/ ,@@@ @ < for some trash... | -@@@% @@@@ .%@@@@//////#@ @ @@ @ .,. \__________________/ +@@@% @@@@ .%@@@@//////#@ @ @@ @ .,. \\__________________/ @@@/@( (@@@@% @/\ % @@@@( . .@@/\ # @ %@% From 12a064d4097813139d8f82ef9c380b75ca56da57 Mon Sep 17 00:00:00 2001 From: Lucas Gravley <29484535+admiralAwkbar@users.noreply.github.com> Date: Mon, 3 Aug 2020 14:17:54 -0500 Subject: [PATCH 118/135] add lib --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 9e1a9559..22d9a952 100644 --- a/Dockerfile +++ b/Dockerfile @@ -65,7 +65,7 @@ RUN apk add --update --no-cache \ npm nodejs-current \ openjdk8-jre \ perl \ - php7 php7-phar php7-json php7-mbstring \ + php7 php7-phar php7-json php7-mbstring php-xmlwriter \ php7-tokenizer php7-ctype php7-curl php7-dom \ py3-setuptools \ readline-dev \ From 7abb1db30b049bc0b4fbb75fc9e3de24bb1897b9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Filip=20=C5=A0?= Date: Sun, 26 Jul 2020 21:30:45 +0200 Subject: [PATCH 119/135] Support for PHPCS and Psalm config files --- TEMPLATES/phpcs.xml | 6 ++++++ TEMPLATES/psalm.xml | 4 ++++ lib/linter.sh | 10 ++++++++-- 3 files changed, 18 insertions(+), 2 deletions(-) create mode 100755 TEMPLATES/phpcs.xml create mode 100755 TEMPLATES/psalm.xml diff --git a/TEMPLATES/phpcs.xml b/TEMPLATES/phpcs.xml new file mode 100755 index 00000000..db39fed5 --- /dev/null +++ b/TEMPLATES/phpcs.xml @@ -0,0 +1,6 @@ + + + + The default coding standard for usage with GitHub Super-Linter. It just includes PSR12. + + diff --git a/TEMPLATES/psalm.xml b/TEMPLATES/psalm.xml new file mode 100755 index 00000000..0eb2e126 --- /dev/null +++ b/TEMPLATES/psalm.xml @@ -0,0 +1,4 @@ + + + + diff --git a/lib/linter.sh b/lib/linter.sh index 17aa4e98..c5a829fa 100755 --- a/lib/linter.sh +++ b/lib/linter.sh @@ -68,6 +68,12 @@ MARKDOWN_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${MARKDOWN_FILE_NAME}" # OpenAPI Vars OPENAPI_FILE_NAME='.openapirc.yml' # Name of the file OPENAPI_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${OPENAPI_FILE_NAME}" # Path to the OpenAPI lint rules +# PHPCS Vars +PHP_PHPCS_FILE_NAME='phpcs.xml' # Name of the file +PHP_PHPCS_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${PHP_PHPCS_FILE_NAME}" # Path to the PHP CodeSniffer lint rules +# Psalm Vars +PHP_PSALM_FILE_NAME='psalm.xml' # Name of the file +PHP_PSALM_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${PHP_PSALM_FILE_NAME}" # Path to the Psalm lint rules # Powershell Vars POWERSHELL_FILE_NAME='.powershell-psscriptanalyzer.psd1' # Name of the file POWERSHELL_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${POWERSHELL_FILE_NAME}" # Path to the Powershell lint rules @@ -1474,7 +1480,7 @@ 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[@]}" + LintCodebase "PHP_PHPCS" "phpcs" "phpcs --standard=${PHP_PHPCS_LINTER_RULES}" ".*\.\(php\)\$" "${FILE_ARRAY_PHP_PHPCS[@]}" fi if [ "${VALIDATE_PHP_PSALM}" == "true" ]; then @@ -1482,7 +1488,7 @@ 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[@]}" + LintCodebase "PHP_PSALM" "psalm" "psalm --config=${PHP_PSALM_LINTER_RULES}" ".*\.\(php\)\$" "${FILE_ARRAY_PHP_PSALM[@]}" fi ###################### From a4fec5d53b31091901cc9071d67e70bafca78622 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Filip=20=C5=A0?= Date: Mon, 27 Jul 2020 21:36:31 +0200 Subject: [PATCH 120/135] Support for testing PHPCS and Psalm --- .automation/test/local-storage.json | 1 + .automation/test/php/php_bad_2.php | 15 +++++++++++ .automation/test/php/php_good_2.php | 25 +++++++++++++++++++ .automation/test/php/reports/expected-PHP.tap | 7 ------ .../test/php/reports/expected-PHP_BUILTIN.tap | 12 +++++++++ .../test/php/reports/expected-PHP_PHPCS.tap | 12 +++++++++ .../test/php/reports/expected-PHP_PSALM.tap | 12 +++++++++ lib/buildFileList.sh | 4 ++- lib/worker.sh | 4 ++- 9 files changed, 83 insertions(+), 9 deletions(-) create mode 100644 .automation/test/local-storage.json create mode 100755 .automation/test/php/php_bad_2.php create mode 100755 .automation/test/php/php_good_2.php delete mode 100644 .automation/test/php/reports/expected-PHP.tap create mode 100755 .automation/test/php/reports/expected-PHP_BUILTIN.tap create mode 100755 .automation/test/php/reports/expected-PHP_PHPCS.tap create mode 100755 .automation/test/php/reports/expected-PHP_PSALM.tap diff --git a/.automation/test/local-storage.json b/.automation/test/local-storage.json new file mode 100644 index 00000000..782cb651 --- /dev/null +++ b/.automation/test/local-storage.json @@ -0,0 +1 @@ +{"anonymousUserId":"8f97180e-e0e9-4d33-a52d-f45c9fec4000"} diff --git a/.automation/test/php/php_bad_2.php b/.automation/test/php/php_bad_2.php new file mode 100755 index 00000000..106fe977 --- /dev/null +++ b/.automation/test/php/php_bad_2.php @@ -0,0 +1,15 @@ + + */ +function takesAnInt(int $i) { + return [$i, "hello"]; +} + +$data = ["some text", 5]; +takesAnInt($data[0]); + +$condition = rand(0, 5); +iff ($condition) { +} elseif ($condition) {} diff --git a/.automation/test/php/php_good_2.php b/.automation/test/php/php_good_2.php new file mode 100755 index 00000000..35348ec0 --- /dev/null +++ b/.automation/test/php/php_good_2.php @@ -0,0 +1,25 @@ + + */ +function helloName(string $name): array +{ + return ["hello", $name]; +} + +function helloSuperLinter(): void +{ + $hello = helloName("Super-Linter"); + echo implode(" ", $hello) . PHP_EOL; +} + +function helloOrWorld(): void +{ + $random = rand(0, 10); + if ($random >= 5) { + echo "Hello"; + } else { + echo "World"; + } +} diff --git a/.automation/test/php/reports/expected-PHP.tap b/.automation/test/php/reports/expected-PHP.tap deleted file mode 100644 index 48408065..00000000 --- a/.automation/test/php/reports/expected-PHP.tap +++ /dev/null @@ -1,7 +0,0 @@ -TAP version 13 -1..2 -not ok 1 - php_bad_1.php - --- - message: PHP Parse error syntax error, unexpected 'pe98y' (T_STRING) in /tmp/lint/.automation/test/php/php_bad_1.php on line 3\nErrors parsing /tmp/lint/.automation/test/php/php_bad_1.php\n - ... -ok 2 - php_good_1.php diff --git a/.automation/test/php/reports/expected-PHP_BUILTIN.tap b/.automation/test/php/reports/expected-PHP_BUILTIN.tap new file mode 100755 index 00000000..beb3656e --- /dev/null +++ b/.automation/test/php/reports/expected-PHP_BUILTIN.tap @@ -0,0 +1,12 @@ +TAP version 13 +1..4 +not ok 1 - php_bad_1.php + --- + message: PHP Parse error syntax error, unexpected 'pe98y' (T_STRING) in /tmp/lint/.automation/test/php/php_bad_1.php on line 3\nErrors parsing /tmp/lint/.automation/test/php/php_bad_1.php\n + ... +not ok 2 - php_bad_2.php + --- + message: PHP Parse error syntax error, unexpected '}' in /tmp/lint/.automation/test/php/php_bad_2.php on line 15\nErrors parsing /tmp/lint/.automation/test/php/php_bad_2.php\n + ... +ok 3 - php_good_1.php +ok 4 - php_good_2.php diff --git a/.automation/test/php/reports/expected-PHP_PHPCS.tap b/.automation/test/php/reports/expected-PHP_PHPCS.tap new file mode 100755 index 00000000..bf7e541d --- /dev/null +++ b/.automation/test/php/reports/expected-PHP_PHPCS.tap @@ -0,0 +1,12 @@ +TAP version 13 +1..4 +not ok 1 - php_bad_1.php + --- + message: \nFILE /tmp/lint/.automation/test/php/php_bad_1.php\n----------------------------------------------------------------------\nFOUND 7 ERRORS AFFECTING 1 LINE\n----------------------------------------------------------------------\n 3 | ERROR | [x] Expected at least 1 space before "-"; 0 found\n 3 | ERROR | [x] Expected at least 1 space after "-"; 0 found\n 3 | ERROR | [x] Expected at least 1 space before "="; 0 found\n 3 | ERROR | [x] Expected at least 1 space after "="; 0 found\n 3 | ERROR | [x] Expected at least 1 space before "-"; 0 found\n 3 | ERROR | [x] Expected at least 1 space before "-"; 0 found\n 3 | ERROR | [x] Expected at least 1 space after "-"; 0 found\n----------------------------------------------------------------------\nPHPCBF CAN FIX THE 7 MARKED SNIFF VIOLATIONS AUTOMATICALLY\n----------------------------------------------------------------------\n\n + ... +not ok 2 - php_bad_2.php + --- + message: \nFILE /tmp/lint/.automation/test/php/php_bad_2.php\n----------------------------------------------------------------------\nFOUND 4 ERRORS AND 1 WARNING AFFECTING 4 LINES\n----------------------------------------------------------------------\n 1 | WARNING | [ ] A file should declare new symbols (classes,\n | | functions, constants, etc.) and cause no other\n | | side effects, or it should execute logic with\n | | side effects, but should not do both. The first\n | | symbol is defined on line 6 and the first side\n | | effect is on line 10.\n 6 | ERROR | [x] Opening brace should be on a new line\n 14 | ERROR | [x] Space before opening parenthesis of function call\n | | prohibited\n 15 | ERROR | [x] Newline required after opening brace\n 15 | ERROR | [x] Closing brace must be on a line by itself\n----------------------------------------------------------------------\nPHPCBF CAN FIX THE 4 MARKED SNIFF VIOLATIONS AUTOMATICALLY\n----------------------------------------------------------------------\n\n + ... +ok 3 - php_good_1.php +ok 4 - php_good_2.php diff --git a/.automation/test/php/reports/expected-PHP_PSALM.tap b/.automation/test/php/reports/expected-PHP_PSALM.tap new file mode 100755 index 00000000..57baa89a --- /dev/null +++ b/.automation/test/php/reports/expected-PHP_PSALM.tap @@ -0,0 +1,12 @@ +TAP version 13 +1..4 +not ok 1 - php_bad_1.php + --- + message: Scanning files...\nAnalyzing files...\n\nE\n\nERROR ParseError - php/php_bad_1.php 3 2 - Syntax error, unexpected T_STRING on line 3 (see https //psalm.dev/173)\n2pe98y r-n0u823n=r 092u3- r08u2q098ry 09nq2yr09n2yr9 y2n-93yr 298yr3 29\n\n\nERROR UndefinedConstant - php/php_bad_1.php 3 2 - Const pe98y is not defined (see https //psalm.dev/020)\n2pe98y r-n0u823n=r 092u3- r08u2q098ry 09nq2yr09n2yr9 y2n-93yr 298yr3 29\n\n\nERROR UndefinedConstant - php/php_bad_1.php 3 8 - Const r is not defined (see https //psalm.dev/020)\n2pe98y r-n0u823n=r 092u3- r08u2q098ry 09nq2yr09n2yr9 y2n-93yr 298yr3 29\n\n\nERROR UndefinedConstant - php/php_bad_1.php 3 10 - Const n0u823n is not defined (see https //psalm.dev/020)\n2pe98y r-n0u823n=r 092u3- r08u2q098ry 09nq2yr09n2yr9 y2n-93yr 298yr3 29\n\n\nERROR ParseError - php/php_bad_1.php 3 17 - Syntax error, unexpected '=' on line 3 (see https //psalm.dev/173)\n2pe98y r-n0u823n=r 092u3- r08u2q098ry 09nq2yr09n2yr9 y2n-93yr 298yr3 29\n\n\nERROR UndefinedConstant - php/php_bad_1.php 3 18 - Const r is not defined (see https //psalm.dev/020)\n2pe98y r-n0u823n=r 092u3- r08u2q098ry 09nq2yr09n2yr9 y2n-93yr 298yr3 29\n\n\nERROR ParseError - php/php_bad_1.php 3 21 - Invalid numeric literal on line 3 (see https //psalm.dev/173)\n2pe98y r-n0u823n=r 092u3- r08u2q098ry 09nq2yr09n2yr9 y2n-93yr 298yr3 29\n\n\nERROR UndefinedConstant - php/php_bad_1.php 3 24 - Const u3 is not defined (see https //psalm.dev/020)\n2pe98y r-n0u823n=r 092u3- r08u2q098ry 09nq2yr09n2yr9 y2n-93yr 298yr3 29\n\n\nERROR UndefinedConstant - php/php_bad_1.php 3 28 - Const r08u2q098ry is not defined (see https //psalm.dev/020)\n2pe98y r-n0u823n=r 092u3- r08u2q098ry 09nq2yr09n2yr9 y2n-93yr 298yr3 29\n\n\nERROR ParseError - php/php_bad_1.php 3 40 - Syntax error, unexpected T_LNUMBER on line 3 (see https //psalm.dev/173)\n2pe98y r-n0u823n=r 092u3- r08u2q098ry 09nq2yr09n2yr9 y2n-93yr 298yr3 29\n\n\nERROR UndefinedConstant - php/php_bad_1.php 3 42 - Const nq2yr09n2yr9 is not defined (see https //psalm.dev/020)\n2pe98y r-n0u823n=r 092u3- r08u2q098ry 09nq2yr09n2yr9 y2n-93yr 298yr3 29\n\n\nERROR UndefinedConstant - php/php_bad_1.php 3 55 - Const y2n is not defined (see https //psalm.dev/020)\n2pe98y r-n0u823n=r 092u3- r08u2q098ry 09nq2yr09n2yr9 y2n-93yr 298yr3 29\n\n\nERROR ParseError - php/php_bad_1.php 3 61 - Syntax error, unexpected T_STRING on line 3 (see https //psalm.dev/173)\n2pe98y r-n0u823n=r 092u3- r08u2q098ry 09nq2yr09n2yr9 y2n-93yr 298yr3 29\n\n\nERROR UndefinedConstant - php/php_bad_1.php 3 61 - Const yr is not defined (see https //psalm.dev/020)\n2pe98y r-n0u823n=r 092u3- r08u2q098ry 09nq2yr09n2yr9 y2n-93yr 298yr3 29\n\n\nERROR UndefinedConstant - php/php_bad_1.php 3 68 - Const yr3 is not defined (see https //psalm.dev/020)\n2pe98y r-n0u823n=r 092u3- r08u2q098ry 09nq2yr09n2yr9 y2n-93yr 298yr3 29\n\n\n------------------------------\n15 errors found\n------------------------------\n\n + ... +not ok 2 - php_bad_2.php + --- + message: Scanning files...\nAnalyzing files...\n\nE\n\nERROR InvalidReturnType - php/php_bad_2.php 4 12 - The declared return type 'array' for takesAnInt is incorrect, got 'array{int, string(hello)}' (see https //psalm.dev/011)\n * @return array\n\n\nERROR InvalidReturnStatement - php/php_bad_2.php 7 12 - The inferred type 'array{int, string(hello)}' does not match the declared return type 'array' for takesAnInt (see https //psalm.dev/128)\n return [$i, "hello"];\n\n\nERROR InvalidScalarArgument - php/php_bad_2.php 11 12 - Argument 1 of takesAnInt expects int, string(some text) provided (see https //psalm.dev/012)\ntakesAnInt($data[0]);\n\n\nERROR ParseError - php/php_bad_2.php 15 1 - Syntax error, unexpected '}' on line 15 (see https //psalm.dev/173)\n} elseif ($condition) {}\n\n\n------------------------------\n4 errors found\n------------------------------\nPsalm can automatically fix 1 of these issues.\nRun Psalm again with \n--alter --issues=InvalidReturnType --dry-run\nto see what it can fix.\n------------------------------\n\n + ... +ok 3 - php_good_1.php +ok 4 - php_good_2.php diff --git a/lib/buildFileList.sh b/lib/buildFileList.sh index 00aebf1f..3cfea4a4 100755 --- a/lib/buildFileList.sh +++ b/lib/buildFileList.sh @@ -239,7 +239,9 @@ function BuildFileList() { ################################ # Append the file to the array # ################################ - FILE_ARRAY_PHP+=("${FILE}") + FILE_ARRAY_PHP_BUILTIN+=("${FILE}") + FILE_ARRAY_PHP_PHPCS+=("${FILE}") + FILE_ARRAY_PHP_PSALM+=("${FILE}") ########################################################## # Set the READ_ONLY_CHANGE_FLAG since this could be exec # ########################################################## diff --git a/lib/worker.sh b/lib/worker.sh index a7da7f04..bfee1023 100755 --- a/lib/worker.sh +++ b/lib/worker.sh @@ -597,7 +597,9 @@ function RunTestCases() { TestCodebase "KOTLIN" "ktlint" "ktlint" ".*\.\(kt\|kts\)\$" "kotlin" TestCodebase "MARKDOWN" "markdownlint" "markdownlint -c ${MARKDOWN_LINTER_RULES}" ".*\.\(md\)\$" "markdown" TestCodebase "PERL" "perl" "perl -Mstrict -cw" ".*\.\(pl\)\$" "perl" - TestCodebase "PHP" "php" "php -l" ".*\.\(php\)\$" "php" + TestCodebase "PHP_BUILTIN" "php" "php -l" ".*\.\(php\)\$" "php" + TestCodebase "PHP_PHPCS" "phpcs" "phpcs --standard=${PHP_PHPCS_LINTER_RULES}" ".*\.\(php\)\$" "php" + TestCodebase "PHP_PSALM" "psalm" "psalm --config=${PHP_PSALM_LINTER_RULES}" ".*\.\(php\)\$" "php" TestCodebase "OPENAPI" "spectral" "spectral lint -r ${OPENAPI_LINTER_RULES}" ".*\.\(ymlopenapi\|jsonopenapi\)\$" "openapi" TestCodebase "POWERSHELL" "pwsh" "Invoke-ScriptAnalyzer -EnableExit -Settings ${POWERSHELL_LINTER_RULES} -Path" ".*\.\(ps1\|psm1\|psd1\|ps1xml\|pssc\|psrc\|cdxml\)\$" "powershell" TestCodebase "PROTOBUF" "protolint" "protolint lint --config_path ${PROTOBUF_LINTER_RULES}" ".*\.\(proto\)\$" "protobuf" From 4f916eaf981ca65ef93fee983265ef560d10063d Mon Sep 17 00:00:00 2001 From: Lucas Gravley <29484535+admiralAwkbar@users.noreply.github.com> Date: Mon, 3 Aug 2020 14:28:50 -0500 Subject: [PATCH 121/135] mas deps --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 22d9a952..cd7db4d7 100644 --- a/Dockerfile +++ b/Dockerfile @@ -66,7 +66,7 @@ RUN apk add --update --no-cache \ openjdk8-jre \ perl \ php7 php7-phar php7-json php7-mbstring php-xmlwriter \ - php7-tokenizer php7-ctype php7-curl php7-dom \ + php7-tokenizer php7-ctype php7-curl php7-dom php7-simplexml \ py3-setuptools \ readline-dev \ ruby ruby-dev ruby-bundler ruby-rdoc \ From eee9c118af87f4c01e74ba625c068fca6f3dd22f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Filip=20=C5=A0?= Date: Mon, 3 Aug 2020 21:48:23 +0200 Subject: [PATCH 122/135] Install PHPStan with phive.xml --- Dockerfile | 15 ++------------- dependencies/phive.xml | 7 ++++--- 2 files changed, 6 insertions(+), 16 deletions(-) diff --git a/Dockerfile b/Dockerfile index cd7db4d7..2e76904f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -110,8 +110,8 @@ RUN wget -O phive.phar https://phar.io/releases/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 + && phive install --trust-gpg-keys 31C7E470E2138192,CF1A108D0E7AE720,8A03EA3B385DBAA1 +# Trusted GPG keys for PHP linters: phpcs, phpstan, psalm ######################################### # Install Powershell + PSScriptAnalyzer # @@ -218,17 +218,6 @@ RUN wget https://github.com/cvega/luarocks/archive/v3.3.1-super-linter.tar.gz -O RUN luarocks install luacheck -############################# -# Install Phive and PHPStan # -############################# -RUN wget -O phive.phar https://phar.io/releases/phive.phar \ - && wget -O phive.phar.asc https://phar.io/releases/phive.phar.asc \ - && gpg --keyserver pool.sks-keyservers.net --recv-keys 0x9D8A98B29B2D5D79 \ - && gpg --verify phive.phar.asc phive.phar \ - && chmod +x phive.phar \ - && mv phive.phar /usr/local/bin/phive \ - && yes | phive install -g phpstan - ########################################### # Load GitHub Env Vars for GitHub Actions # ########################################### diff --git a/dependencies/phive.xml b/dependencies/phive.xml index af2d5187..8d1b31d4 100755 --- a/dependencies/phive.xml +++ b/dependencies/phive.xml @@ -1,6 +1,7 @@ - - - + + + + From 6bd724519b3d3175ba660c23ee2e5a626ce92cc0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Filip=20=C5=A0?= Date: Mon, 3 Aug 2020 21:50:30 +0200 Subject: [PATCH 123/135] Remove old PHP report --- .automation/test/php/reports/expected-PHP.tap | 11 ----------- 1 file changed, 11 deletions(-) delete mode 100644 .automation/test/php/reports/expected-PHP.tap diff --git a/.automation/test/php/reports/expected-PHP.tap b/.automation/test/php/reports/expected-PHP.tap deleted file mode 100644 index 652ad276..00000000 --- a/.automation/test/php/reports/expected-PHP.tap +++ /dev/null @@ -1,11 +0,0 @@ -TAP version 13 -1..3 -not ok 1 - php_bad_1.php - --- - message: PHP Parse error syntax error, unexpected 'pe98y' (T_STRING) in /tmp/lint/.automation/test/php/php_bad_1.php on line 3\nErrors parsing /tmp/lint/.automation/test/php/php_bad_1.php\n - ... -not ok 2 - php_bad_2.php - --- - message: PHP Parse error syntax error, unexpected end of file, expecting variable (T_VARIABLE) or ${ (T_DOLLAR_OPEN_CURLY_BRACES) or {$ (T_CURLY_OPEN) in /tmp/lint/.automation/test/php/php_bad_2.php on line 5\nErrors parsing /tmp/lint/.automation/test/php/php_bad_2.php\n - ... -ok 3 - php_good_1.php From a9d494c57aed24ccae162b7266012d824e629ca9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Filip=20=C5=A0?= Date: Mon, 3 Aug 2020 21:54:33 +0200 Subject: [PATCH 124/135] Remvoe useless file --- .automation/test/local-storage.json | 1 - 1 file changed, 1 deletion(-) delete mode 100644 .automation/test/local-storage.json diff --git a/.automation/test/local-storage.json b/.automation/test/local-storage.json deleted file mode 100644 index 782cb651..00000000 --- a/.automation/test/local-storage.json +++ /dev/null @@ -1 +0,0 @@ -{"anonymousUserId":"8f97180e-e0e9-4d33-a52d-f45c9fec4000"} From db2dc2cea2b16870276da4a1a6778210723caefe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Filip=20=C5=A0?= Date: Mon, 3 Aug 2020 22:07:15 +0200 Subject: [PATCH 125/135] Add docs and backward compatibility --- README.md | 73 +++++++++++++++++++++++++++------------------------ lib/linter.sh | 2 +- 2 files changed, 39 insertions(+), 36 deletions(-) diff --git a/README.md b/README.md index 68c4c1ed..eec27ebb 100644 --- a/README.md +++ b/README.md @@ -41,39 +41,39 @@ The design of the **Super-Linter** is currently to allow linting to occur in **G Developers on **GitHub** can call the **GitHub Action** to lint their code base with the following list of linters: -| _Language_ | _Linter_ | -| -------------------------------- | -------------------------------------------------------------------------------------------------------- | -| **Ansible** | [ansible-lint](https://github.com/ansible/ansible-lint) | -| **Azure Resource Manager (ARM)** | [arm-ttk](https://github.com/azure/arm-ttk) | -| **AWS CloudFormation templates** | [cfn-lint](https://github.com/aws-cloudformation/cfn-python-lint/) | -| **CSS** | [stylelint](https://stylelint.io/) | -| **Clojure** | [clj-kondo](https://github.com/borkdude/clj-kondo) | -| **CoffeeScript** | [coffeelint](https://coffeelint.github.io/) | -| **Dart** | [dartanalyzer](https://dart.dev/guides/language/analysis-options) | -| **Dockerfile** | [dockerfilelint](https://github.com/replicatedhq/dockerfilelint.git) | -| **EDITORCONFIG** | [editorconfig-checker](https://github.com/editorconfig-checker/editorconfig-checker) | -| **ENV** | [dotenv-linter](https://github.com/dotenv-linter/dotenv-linter) | -| **Golang** | [golangci-lint](https://github.com/golangci/golangci-lint) | -| **Groovy** | [npm-groovy-lint](https://github.com/nvuillam/npm-groovy-lint) | -| **HTMLHint** | [HTMLHint](https://github.com/htmlhint/HTMLHint) | -| **JavaScript** | [eslint](https://eslint.org/) [standard js](https://standardjs.com/) | -| **JSON** | [jsonlint](https://github.com/zaach/jsonlint) | -| **Kotlin** | [ktlint](https://github.com/pinterest/ktlint) | -| **Lua** | [luacheck](https://github.com/luarocks/luacheck) | -| **Markdown** | [markdownlint](https://github.com/igorshubovych/markdownlint-cli#readme) | -| **OpenAPI** | [spectral](https://github.com/stoplightio/spectral) | -| **Perl** | [perl](https://pkgs.alpinelinux.org/package/edge/main/x86/perl) | -| **PHP** | [PHP](https://www.php.net/) | -| **PowerShell** | [PSScriptAnalyzer](https://github.com/PowerShell/Psscriptanalyzer) | -| **Protocol Buffers** | [protolint](https://github.com/yoheimuta/protolint) | -| **Python3** | [pylint](https://www.pylint.org/) [flake8](https://flake8.pycqa.org/en/latest/) | -| **Raku** | [raku](https://raku.org) | -| **Ruby** | [RuboCop](https://github.com/rubocop-hq/rubocop) | -| **Shell** | [Shellcheck](https://github.com/koalaman/shellcheck) | -| **Terraform** | [tflint](https://github.com/terraform-linters/tflint) [terrascan](https://github.com/accurics/terrascan) | -| **TypeScript** | [eslint](https://eslint.org/) [standard js](https://standardjs.com/) | -| **XML** | [LibXML](http://xmlsoft.org/) | -| **YAML** | [YamlLint](https://github.com/adrienverge/yamllint) | +| _Language_ | _Linter_ | +| -------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | +| **Ansible** | [ansible-lint](https://github.com/ansible/ansible-lint) | +| **Azure Resource Manager (ARM)** | [arm-ttk](https://github.com/azure/arm-ttk) | +| **AWS CloudFormation templates** | [cfn-lint](https://github.com/aws-cloudformation/cfn-python-lint/) | +| **CSS** | [stylelint](https://stylelint.io/) | +| **Clojure** | [clj-kondo](https://github.com/borkdude/clj-kondo) | +| **CoffeeScript** | [coffeelint](https://coffeelint.github.io/) | +| **Dart** | [dartanalyzer](https://dart.dev/guides/language/analysis-options) | +| **Dockerfile** | [dockerfilelint](https://github.com/replicatedhq/dockerfilelint.git) | +| **EDITORCONFIG** | [editorconfig-checker](https://github.com/editorconfig-checker/editorconfig-checker) | +| **ENV** | [dotenv-linter](https://github.com/dotenv-linter/dotenv-linter) | +| **Golang** | [golangci-lint](https://github.com/golangci/golangci-lint) | +| **Groovy** | [npm-groovy-lint](https://github.com/nvuillam/npm-groovy-lint) | +| **HTMLHint** | [HTMLHint](https://github.com/htmlhint/HTMLHint) | +| **JavaScript** | [eslint](https://eslint.org/) [standard js](https://standardjs.com/) | +| **JSON** | [jsonlint](https://github.com/zaach/jsonlint) | +| **Kotlin** | [ktlint](https://github.com/pinterest/ktlint) | +| **Lua** | [luacheck](https://github.com/luarocks/luacheck) | +| **Markdown** | [markdownlint](https://github.com/igorshubovych/markdownlint-cli#readme) | +| **OpenAPI** | [spectral](https://github.com/stoplightio/spectral) | +| **Perl** | [perl](https://pkgs.alpinelinux.org/package/edge/main/x86/perl) | +| **PHP** | [PHP built-in linter](https://www.php.net/) [PHP CodeSniffer](https://github.com/squizlabs/PHP_CodeSniffer) [PHPStan](https://phpstan.org/n) [Psalm](https://psalm.dev/) | +| **PowerShell** | [PSScriptAnalyzer](https://github.com/PowerShell/Psscriptanalyzer) | +| **Protocol Buffers** | [protolint](https://github.com/yoheimuta/protolint) | +| **Python3** | [pylint](https://www.pylint.org/) [flake8](https://flake8.pycqa.org/en/latest/) | +| **Raku** | [raku](https://raku.org) | +| **Ruby** | [RuboCop](https://github.com/rubocop-hq/rubocop) | +| **Shell** | [Shellcheck](https://github.com/koalaman/shellcheck) | +| **Terraform** | [tflint](https://github.com/terraform-linters/tflint) [terrascan](https://github.com/accurics/terrascan) | +| **TypeScript** | [eslint](https://eslint.org/) [standard js](https://standardjs.com/) | +| **XML** | [LibXML](http://xmlsoft.org/) | +| **YAML** | [YamlLint](https://github.com/adrienverge/yamllint) | ## How to use @@ -210,8 +210,11 @@ and won't run anything unexpected. | **VALIDATE_MD** | `true` | Flag to enable or disable the linting process of the Markdown language. | | **VALIDATE_OPENAPI** | `true` | Flag to enable or disable the linting process of the OpenAPI language. | | **VALIDATE_PERL** | `true` | Flag to enable or disable the linting process of the Perl language. | -| **VALIDATE_PHP** | `true` | Flag to enable or disable the linting process of the PHP language. | -| **VALIDATE_PHP_PHPSTAN** | `true` | Flag to enable or disable the linting process of the PHP language (Utilizing: PHPStan). | +| **VALIDATE_PHP** | `true` | Flag to enable or disable the linting process of the PHP language. (Utilizing: PHP built-in linter) (keep for backward compatibility) | +| **VALIDATE_PHP_BUILTIN** | `true` | Flag to enable or disable the linting process of the PHP language. (Utilizing: PHP built-in linter) | +| **VALIDATE_PHP_PHPCS** | `true` | Flag to enable or disable the linting process of the PHP language. (Utilizing: PHP CodeSniffer) | +| **VALIDATE_PHP_PHPSTAN** | `true` | Flag to enable or disable the linting process of the PHP language. (Utilizing: PHPStan) | +| **VALIDATE_PHP_PSALM** | `true` | Flag to enable or disable the linting process of the PHP language. (Utilizing: PSalm) | | **VALIDATE_PROTOBUF** | `true` | Flag to enable or disable the linting process of the Protobuf language. | | **VALIDATE_PYTHON** | `true` | Flag to enable or disable the linting process of the Python language. (Utilizing: pylint) (keep for backward compatibility) | | **VALIDATE_PYTHON_PYLINT** | `true` | Flag to enable or disable the linting process of the Python language. (Utilizing: pylint) | diff --git a/lib/linter.sh b/lib/linter.sh index 7c8e3586..8dc6d46a 100755 --- a/lib/linter.sh +++ b/lib/linter.sh @@ -179,7 +179,7 @@ VALIDATE_LUA="${VALIDATE_LUA}" # Boolean t VALIDATE_MARKDOWN="${VALIDATE_MD:-}" # Boolean to validate language VALIDATE_OPENAPI="${VALIDATE_OPENAPI}" # Boolean to validate language VALIDATE_PERL="${VALIDATE_PERL}" # Boolean to validate language -VALIDATE_PHP_BUILTIN="${VALIDATE_PHP_BUILTIN}" # Boolean to validate language +VALIDATE_PHP_BUILTIN="${VALIDATE_PHP:-VALIDATE_PHP_BUILTIN}" # Boolean to validate language VALIDATE_PHP_PHPCS="${VALIDATE_PHP_PHPCS}" # Boolean to validate language VALIDATE_PHP_PHPSTAN="${VALIDATE_PHP_PHPSTAN}" # Boolean to validate language VALIDATE_PHP_PSALM="${VALIDATE_PHP_PSALM}" # Boolean to validate language From a49fddb924cc80943689e1bd2d683ba3fc215fb0 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 4 Aug 2020 06:33:08 +0000 Subject: [PATCH 126/135] Bump cfn-lint from 0.34.0 to 0.34.1 in /dependencies Bumps [cfn-lint](https://github.com/aws-cloudformation/cfn-python-lint) from 0.34.0 to 0.34.1. - [Release notes](https://github.com/aws-cloudformation/cfn-python-lint/releases) - [Changelog](https://github.com/aws-cloudformation/cfn-python-lint/blob/master/CHANGELOG.md) - [Commits](https://github.com/aws-cloudformation/cfn-python-lint/compare/v0.34.0...v0.34.1) Signed-off-by: dependabot[bot] --- dependencies/Pipfile.lock | 29 +++++++++-------------------- 1 file changed, 9 insertions(+), 20 deletions(-) diff --git a/dependencies/Pipfile.lock b/dependencies/Pipfile.lock index 962c1041..e8e7a7e8 100644 --- a/dependencies/Pipfile.lock +++ b/dependencies/Pipfile.lock @@ -28,7 +28,6 @@ "sha256:2f4078c2a41bf377eea06d71c9d2ba4eb8f6b1af2135bec27bbbb7d8f12bb703", "sha256:bc58d83eb610252fd8de6363e39d4f1d0619c894b0ed24603b881c02e64c7386" ], - "markers": "python_version >= '3.5'", "version": "==2.4.2" }, "attrs": { @@ -36,7 +35,6 @@ "sha256:08a96c641c3a74e44eb59afb61a24f2cb9f4d7188748e76ba4bb5edfa3cb7d1c", "sha256:f7b7ce16570fe9965acd6d30101a28f62fb4a7f9e926b3bbc9b61f8b04247e72" ], - "markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3'", "version": "==19.3.0" }, "aws-sam-translator": { @@ -49,25 +47,25 @@ }, "boto3": { "hashes": [ - "sha256:65c131b72c2a75e3cc6044e5fd6426719051b9b1f28bd026b4a5490648d13019", - "sha256:e1e09587763671cc07c9e6d349d93bf53a140f83947cb6cf1ec4cb9f07b0ff95" + "sha256:726937b33b5bf6036a3889ea6ecad632439d1a53c3dd4497c1c426d348e2dae3", + "sha256:781f5d1bbec6c2fe902e8855c1c8a576845eaa06630e817b0e422afa4788620e" ], - "version": "==1.14.27" + "version": "==1.14.34" }, "botocore": { "hashes": [ - "sha256:994a9f50e0e770c0f9ea74659f501848f7d12b22186026c219cde8a481ede298", - "sha256:acd955f0315b5d17e3e8ddc2ef74d7f03c4ef37f0ceb042058637f7edfbbad4e" + "sha256:8170f6a236cdfd053275be7b2f1531c90c517d903d38b21d064dc6ba23f20870", + "sha256:ff39ec54893397df3c14dd516aedeaff12bb7c363051d8b9bd5fc86bc3e68231" ], - "version": "==1.17.27" + "version": "==1.17.34" }, "cfn-lint": { "hashes": [ - "sha256:443e7c1a57a8909050b51873cbf53628e253b6a2ab00fba9d25f89e75f13f1b6", - "sha256:b2a7b9a84688d87d0d49d1dad2602382ba2a8be9d20d87278f4d42c59f71eddc" + "sha256:85df66deca0319003b4af3efbd4689e5004608b4e9ee7cc54c7a27e5c0ca1685", + "sha256:f7c63a4bf6c32c56cbe1af023ff93eb88a4bad784368dcb25724941981e92f16" ], "index": "pypi", - "version": "==0.34.0" + "version": "==0.34.1" }, "decorator": { "hashes": [ @@ -82,7 +80,6 @@ "sha256:9e4d7ecfc600058e07ba661411a2b7de2fd0fafa17d1a7f7361cd47b1175c827", "sha256:a2aeea129088da402665e92e0b25b04b073c04b2dce4ab65caaa38b7ce2e1a99" ], - "markers": "python_version >= '2.6' and python_version not in '3.0, 3.1, 3.2'", "version": "==0.15.2" }, "flake8": { @@ -98,7 +95,6 @@ "sha256:54da7e92468955c4fceacd0c86bd0ec997b0e1ee80d97f67c35a78b719dccab1", "sha256:6e811fcb295968434526407adb8796944f1988c5b65e8139058f2014cbe100fd" ], - "markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3'", "version": "==4.3.21" }, "jmespath": { @@ -106,7 +102,6 @@ "sha256:b85d0567b8666149a93172712e68920734333c0ce7e89b78b3e987f71e5ed4f9", "sha256:cdf6525904cc597730141d61b36f2e4b8ecc257c420fa2f4549bac2c2d0cb72f" ], - "markers": "python_version >= '2.6' and python_version not in '3.0, 3.1, 3.2'", "version": "==0.10.0" }, "jsonpatch": { @@ -122,7 +117,6 @@ "sha256:c192ba86648e05fdae4f08a17ec25180a9aef5008d973407b581798a83975362", "sha256:ff379fa021d1b81ab539f5ec467c7745beb1a5671463f9dcc2b2d458bd361c1e" ], - "markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3'", "version": "==2.0" }, "jsonschema": { @@ -162,7 +156,6 @@ "sha256:efa1909120ce98bbb3777e8b6f92237f5d5c8ea6758efea36a473e1d38f7d3e4", "sha256:f3900e8a5de27447acbf900b4750b0ddfd7ec1ea7fbaf11dfa911141bc522af0" ], - "markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3'", "version": "==1.4.3" }, "mccabe": { @@ -192,7 +185,6 @@ "sha256:2295e7b2f6b5bd100585ebcb1f616591b652db8a741695b3d8f5d28bdc934367", "sha256:c58a7d2815e0e8d7972bf1803331fb0152f867bd89adf8a01dfd55085434192e" ], - "markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3'", "version": "==2.6.0" }, "pyflakes": { @@ -200,7 +192,6 @@ "sha256:0d94e0e05a19e57a99444b6ddcf9a6eb2e5c68d3ca1e98e90707af8152c90a92", "sha256:35b2d75ee967ea93b55750aa9edbbf72813e06a66ba54438df2cfac9e3c27fc8" ], - "markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3'", "version": "==2.2.0" }, "pyhcl": { @@ -228,7 +219,6 @@ "sha256:73ebfe9dbf22e832286dafa60473e4cd239f8592f699aa5adaf10050e6e1823c", "sha256:75bb3f31ea686f1197762692a9ee6a7550b59fc6ca3a1f4b5d7e32fb98e2da2a" ], - "markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2'", "version": "==2.8.1" }, "pyyaml": { @@ -260,7 +250,6 @@ "sha256:30639c035cdb23534cd4aa2dd52c3bf48f06e5f4a941509c8bafd8ce11080259", "sha256:8b74bedcbbbaca38ff6d7491d76f2b06b3592611af620f8426e82dddb04a5ced" ], - "markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2'", "version": "==1.15.0" }, "terrascan": { From b4a334be3d3a22364e76c5ac68ab966cb4741931 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 4 Aug 2020 06:36:30 +0000 Subject: [PATCH 127/135] Bump npm-groovy-lint from 5.8.0 to 6.1.0 in /dependencies Bumps [npm-groovy-lint](https://github.com/nvuillam/npm-groovy-lint) from 5.8.0 to 6.1.0. - [Release notes](https://github.com/nvuillam/npm-groovy-lint/releases) - [Changelog](https://github.com/nvuillam/npm-groovy-lint/blob/master/CHANGELOG.md) - [Commits](https://github.com/nvuillam/npm-groovy-lint/compare/v5.8.0...v6.1.0) Signed-off-by: dependabot[bot] --- dependencies/package-lock.json | 28 ++++------------------------ dependencies/package.json | 2 +- 2 files changed, 5 insertions(+), 25 deletions(-) diff --git a/dependencies/package-lock.json b/dependencies/package-lock.json index f80885b4..4102ba5e 100644 --- a/dependencies/package-lock.json +++ b/dependencies/package-lock.json @@ -3613,9 +3613,9 @@ "integrity": "sha1-0LFF62kRicY6eNIB3E/bEpPvDAM=" }, "npm-groovy-lint": { - "version": "5.8.0", - "resolved": "https://registry.npmjs.org/npm-groovy-lint/-/npm-groovy-lint-5.8.0.tgz", - "integrity": "sha512-GeBeH97fEy/YwSztmERx96X52c7WrWu80iyNWqNnNZKUjkY6LFMXhNCzb18WCKmPZRTypcSbjxFN3TUDl0/sMw==", + "version": "6.1.0", + "resolved": "https://registry.npmjs.org/npm-groovy-lint/-/npm-groovy-lint-6.1.0.tgz", + "integrity": "sha512-IVU9mPARZflUWXkWq4wt+qBTJDeEAmhH+5Nl89mI3eIKiPlMEOriAq/iXXwsA5IT4CaS+848Ea5sd3yTQqEIOw==", "requires": { "@amplitude/node": "^0.3.3", "ansi-colors": "^4.1.1", @@ -3632,8 +3632,7 @@ "optionator": "^0.8.3", "semver": "^7.1.3", "strip-json-comments": "^3.0.1", - "uuid": "^8.2.0", - "xml2js": "^0.4.23" + "uuid": "^8.2.0" }, "dependencies": { "uuid": { @@ -4616,11 +4615,6 @@ "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz", "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==" }, - "sax": { - "version": "1.2.4", - "resolved": "https://registry.npmjs.org/sax/-/sax-1.2.4.tgz", - "integrity": "sha512-NqVDv9TpANUjFm0N8uM5GxL36UgKi9/atZw+x7YFnQ8ckwFGKrl4xX4yWtrey3UJm5nP1kUbnYgLopqWNSRhWw==" - }, "semver": { "version": "7.3.2", "resolved": "https://registry.npmjs.org/semver/-/semver-7.3.2.tgz", @@ -5632,20 +5626,6 @@ "resolved": "https://registry.npmjs.org/xml/-/xml-1.0.1.tgz", "integrity": "sha1-eLpyAgApxbyHuKgaPPzXS0ovweU=" }, - "xml2js": { - "version": "0.4.23", - "resolved": "https://registry.npmjs.org/xml2js/-/xml2js-0.4.23.tgz", - "integrity": "sha512-ySPiMjM0+pLDftHgXY4By0uswI3SPKLDw/i3UXbnO8M/p28zqexCUoPmQFrYD+/1BzhGJSs2i1ERWKJAtiLrug==", - "requires": { - "sax": ">=0.6.0", - "xmlbuilder": "~11.0.0" - } - }, - "xmlbuilder": { - "version": "11.0.1", - "resolved": "https://registry.npmjs.org/xmlbuilder/-/xmlbuilder-11.0.1.tgz", - "integrity": "sha512-fDlsI/kFEx7gLvbecc0/ohLG50fugQp8ryHzMTuW9vSa1GJ0XYWKnhsUx7oie3G98+r56aTQIUB4kht42R3JvA==" - }, "xregexp": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/xregexp/-/xregexp-2.0.0.tgz", diff --git a/dependencies/package.json b/dependencies/package.json index fcf41323..d55e8c4a 100644 --- a/dependencies/package.json +++ b/dependencies/package.json @@ -18,7 +18,7 @@ "standard": "^14.3.4", "stylelint": "^13.6.1", "stylelint-config-standard": "^20.0.0", - "npm-groovy-lint": "^5.8.0", + "npm-groovy-lint": "^6.1.0", "typescript": "^3.9.7", "asl-validator": "^1.7.0" From e68a6374c29da322e61799c2725ca2f2ff3c60f5 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 4 Aug 2020 06:37:02 +0000 Subject: [PATCH 128/135] Bump @typescript-eslint/parser from 3.7.1 to 3.8.0 in /dependencies Bumps [@typescript-eslint/parser](https://github.com/typescript-eslint/typescript-eslint/tree/HEAD/packages/parser) from 3.7.1 to 3.8.0. - [Release notes](https://github.com/typescript-eslint/typescript-eslint/releases) - [Changelog](https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/parser/CHANGELOG.md) - [Commits](https://github.com/typescript-eslint/typescript-eslint/commits/v3.8.0/packages/parser) Signed-off-by: dependabot[bot] --- dependencies/package-lock.json | 44 +++++++++++++++++----------------- dependencies/package.json | 2 +- 2 files changed, 23 insertions(+), 23 deletions(-) diff --git a/dependencies/package-lock.json b/dependencies/package-lock.json index f80885b4..3668e06f 100644 --- a/dependencies/package-lock.json +++ b/dependencies/package-lock.json @@ -538,41 +538,41 @@ } }, "@typescript-eslint/parser": { - "version": "3.7.1", - "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-3.7.1.tgz", - "integrity": "sha512-W4QV/gXvfIsccN8225784LNOorcm7ch68Fi3V4Wg7gmkWSQRKevO4RrRqWo6N/Z/myK1QAiGgeaXN57m+R/8iQ==", + "version": "3.8.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-3.8.0.tgz", + "integrity": "sha512-u5vjOBaCsnMVQOvkKCXAmmOhyyMmFFf5dbkM3TIbg3MZ2pyv5peE4gj81UAbTHwTOXEwf7eCQTUMKrDl/+qGnA==", "requires": { "@types/eslint-visitor-keys": "^1.0.0", - "@typescript-eslint/experimental-utils": "3.7.1", - "@typescript-eslint/types": "3.7.1", - "@typescript-eslint/typescript-estree": "3.7.1", + "@typescript-eslint/experimental-utils": "3.8.0", + "@typescript-eslint/types": "3.8.0", + "@typescript-eslint/typescript-estree": "3.8.0", "eslint-visitor-keys": "^1.1.0" }, "dependencies": { "@typescript-eslint/experimental-utils": { - "version": "3.7.1", - "resolved": "https://registry.npmjs.org/@typescript-eslint/experimental-utils/-/experimental-utils-3.7.1.tgz", - "integrity": "sha512-TqE97pv7HrqWcGJbLbZt1v59tcqsSVpWTOf1AqrWK7n8nok2sGgVtYRuGXeNeLw3wXlLEbY1MKP3saB2HsO/Ng==", + "version": "3.8.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/experimental-utils/-/experimental-utils-3.8.0.tgz", + "integrity": "sha512-o8T1blo1lAJE0QDsW7nSyvZHbiDzQDjINJKyB44Z3sSL39qBy5L10ScI/XwDtaiunoyKGLiY9bzRk4YjsUZl8w==", "requires": { "@types/json-schema": "^7.0.3", - "@typescript-eslint/types": "3.7.1", - "@typescript-eslint/typescript-estree": "3.7.1", + "@typescript-eslint/types": "3.8.0", + "@typescript-eslint/typescript-estree": "3.8.0", "eslint-scope": "^5.0.0", "eslint-utils": "^2.0.0" } }, "@typescript-eslint/types": { - "version": "3.7.1", - "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-3.7.1.tgz", - "integrity": "sha512-PZe8twm5Z4b61jt7GAQDor6KiMhgPgf4XmUb9zdrwTbgtC/Sj29gXP1dws9yEn4+aJeyXrjsD9XN7AWFhmnUfg==" + "version": "3.8.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-3.8.0.tgz", + "integrity": "sha512-8kROmEQkv6ss9kdQ44vCN1dTrgu4Qxrd2kXr10kz2NP5T8/7JnEfYNxCpPkArbLIhhkGLZV3aVMplH1RXQRF7Q==" }, "@typescript-eslint/typescript-estree": { - "version": "3.7.1", - "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-3.7.1.tgz", - "integrity": "sha512-m97vNZkI08dunYOr2lVZOHoyfpqRs0KDpd6qkGaIcLGhQ2WPtgHOd/eVbsJZ0VYCQvupKrObAGTOvk3tfpybYA==", + "version": "3.8.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-3.8.0.tgz", + "integrity": "sha512-MTv9nPDhlKfclwnplRNDL44mP2SY96YmPGxmMbMy6x12I+pERcxpIUht7DXZaj4mOKKtet53wYYXU0ABaiXrLw==", "requires": { - "@typescript-eslint/types": "3.7.1", - "@typescript-eslint/visitor-keys": "3.7.1", + "@typescript-eslint/types": "3.8.0", + "@typescript-eslint/visitor-keys": "3.8.0", "debug": "^4.1.1", "glob": "^7.1.6", "is-glob": "^4.0.1", @@ -582,9 +582,9 @@ } }, "@typescript-eslint/visitor-keys": { - "version": "3.7.1", - "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-3.7.1.tgz", - "integrity": "sha512-xn22sQbEya+Utj2IqJHGLA3i1jDzR43RzWupxojbSWnj3nnPLavaQmWe5utw03CwYao3r00qzXfgJMGNkrzrAA==", + "version": "3.8.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-3.8.0.tgz", + "integrity": "sha512-gfqQWyVPpT9NpLREXNR820AYwgz+Kr1GuF3nf1wxpHD6hdxI62tq03ToomFnDxY0m3pUB39IF7sil7D5TQexLA==", "requires": { "eslint-visitor-keys": "^1.1.0" } diff --git a/dependencies/package.json b/dependencies/package.json index fcf41323..984d5c14 100644 --- a/dependencies/package.json +++ b/dependencies/package.json @@ -4,7 +4,7 @@ "@coffeelint/cli": "^3.2.10", "@stoplight/spectral": "^5.4.0", "@typescript-eslint/eslint-plugin": "^3.7.1", - "@typescript-eslint/parser": "^3.7.1", + "@typescript-eslint/parser": "^3.8.0", "babel-eslint": "^10.1.0", "dockerfilelint": "^1.5.0", "eslint": "^7.6.0", From f2ddc9489fc1314d0f4bee66b0e0012e01bb2826 Mon Sep 17 00:00:00 2001 From: Lukas Gravley Date: Tue, 4 Aug 2020 08:35:04 -0500 Subject: [PATCH 129/135] no token needed --- .github/workflows/automerge-dependabot.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/automerge-dependabot.yml b/.github/workflows/automerge-dependabot.yml index dce77f76..bd579821 100644 --- a/.github/workflows/automerge-dependabot.yml +++ b/.github/workflows/automerge-dependabot.yml @@ -44,4 +44,3 @@ jobs: repo: context.payload.repository.name, pull_number: context.payload.pull_request.number }) - github-token: ${{ secrets.GITHUB_TOKEN }} From 2898e49402f9a86fc3f2a4e7442cc4c28fcaf8a4 Mon Sep 17 00:00:00 2001 From: Lucas Gravley <29484535+admiralAwkbar@users.noreply.github.com> Date: Tue, 4 Aug 2020 08:43:07 -0500 Subject: [PATCH 130/135] ignore php tap reports --- .../{expected-PHP_PHPCS.tap => expected-PHP_PHPCS.tap.ignored} | 0 ...{expected-PHP_PHPSTAN.tap => expected-PHP_PHPSTAN.tap.ignored} | 0 .../{expected-PHP_PSALM.tap => expected-PHP_PSALM.tap.ignored} | 0 3 files changed, 0 insertions(+), 0 deletions(-) rename .automation/test/php/reports/{expected-PHP_PHPCS.tap => expected-PHP_PHPCS.tap.ignored} (100%) rename .automation/test/php/reports/{expected-PHP_PHPSTAN.tap => expected-PHP_PHPSTAN.tap.ignored} (100%) rename .automation/test/php/reports/{expected-PHP_PSALM.tap => expected-PHP_PSALM.tap.ignored} (100%) diff --git a/.automation/test/php/reports/expected-PHP_PHPCS.tap b/.automation/test/php/reports/expected-PHP_PHPCS.tap.ignored similarity index 100% rename from .automation/test/php/reports/expected-PHP_PHPCS.tap rename to .automation/test/php/reports/expected-PHP_PHPCS.tap.ignored diff --git a/.automation/test/php/reports/expected-PHP_PHPSTAN.tap b/.automation/test/php/reports/expected-PHP_PHPSTAN.tap.ignored similarity index 100% rename from .automation/test/php/reports/expected-PHP_PHPSTAN.tap rename to .automation/test/php/reports/expected-PHP_PHPSTAN.tap.ignored diff --git a/.automation/test/php/reports/expected-PHP_PSALM.tap b/.automation/test/php/reports/expected-PHP_PSALM.tap.ignored similarity index 100% rename from .automation/test/php/reports/expected-PHP_PSALM.tap rename to .automation/test/php/reports/expected-PHP_PSALM.tap.ignored From 2dcb0dd600d44446b1cff6fa923806a6f5b8a09d Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 4 Aug 2020 13:45:04 +0000 Subject: [PATCH 131/135] Bump @typescript-eslint/eslint-plugin in /dependencies Bumps [@typescript-eslint/eslint-plugin](https://github.com/typescript-eslint/typescript-eslint/tree/HEAD/packages/eslint-plugin) from 3.7.1 to 3.8.0. - [Release notes](https://github.com/typescript-eslint/typescript-eslint/releases) - [Changelog](https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/CHANGELOG.md) - [Commits](https://github.com/typescript-eslint/typescript-eslint/commits/v3.8.0/packages/eslint-plugin) Signed-off-by: dependabot[bot] --- dependencies/package-lock.json | 40 +++++++++++++++++----------------- dependencies/package.json | 2 +- 2 files changed, 21 insertions(+), 21 deletions(-) diff --git a/dependencies/package-lock.json b/dependencies/package-lock.json index e1487a44..07207187 100644 --- a/dependencies/package-lock.json +++ b/dependencies/package-lock.json @@ -513,11 +513,11 @@ "integrity": "sha512-/tiJyrc0GPcsReHzgC0SXwOmoPjLqYe01W7dLYB0yasQXMbcRee+ZIk+g8MIQhoBS8fPoBQO3Y93+aeBrI93Ug==" }, "@typescript-eslint/eslint-plugin": { - "version": "3.7.1", - "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-3.7.1.tgz", - "integrity": "sha512-3DB9JDYkMrc8Au00rGFiJLK2Ja9CoMP6Ut0sHsXp3ZtSugjNxvSSHTnKLfo4o+QmjYBJqEznDqsG1zj4F2xnsg==", + "version": "3.8.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-3.8.0.tgz", + "integrity": "sha512-lFb4VCDleFSR+eo4Ew+HvrJ37ZH1Y9ZyE+qyP7EiwBpcCVxwmUc5PAqhShCQ8N8U5vqYydm74nss+a0wrrCErw==", "requires": { - "@typescript-eslint/experimental-utils": "3.7.1", + "@typescript-eslint/experimental-utils": "3.8.0", "debug": "^4.1.1", "functional-red-black-tree": "^1.0.1", "regexpp": "^3.0.0", @@ -526,13 +526,13 @@ } }, "@typescript-eslint/experimental-utils": { - "version": "3.7.1", - "resolved": "https://registry.npmjs.org/@typescript-eslint/experimental-utils/-/experimental-utils-3.7.1.tgz", - "integrity": "sha512-TqE97pv7HrqWcGJbLbZt1v59tcqsSVpWTOf1AqrWK7n8nok2sGgVtYRuGXeNeLw3wXlLEbY1MKP3saB2HsO/Ng==", + "version": "3.8.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/experimental-utils/-/experimental-utils-3.8.0.tgz", + "integrity": "sha512-o8T1blo1lAJE0QDsW7nSyvZHbiDzQDjINJKyB44Z3sSL39qBy5L10ScI/XwDtaiunoyKGLiY9bzRk4YjsUZl8w==", "requires": { "@types/json-schema": "^7.0.3", - "@typescript-eslint/types": "3.7.1", - "@typescript-eslint/typescript-estree": "3.7.1", + "@typescript-eslint/types": "3.8.0", + "@typescript-eslint/typescript-estree": "3.8.0", "eslint-scope": "^5.0.0", "eslint-utils": "^2.0.0" } @@ -592,17 +592,17 @@ } }, "@typescript-eslint/types": { - "version": "3.7.1", - "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-3.7.1.tgz", - "integrity": "sha512-PZe8twm5Z4b61jt7GAQDor6KiMhgPgf4XmUb9zdrwTbgtC/Sj29gXP1dws9yEn4+aJeyXrjsD9XN7AWFhmnUfg==" + "version": "3.8.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-3.8.0.tgz", + "integrity": "sha512-8kROmEQkv6ss9kdQ44vCN1dTrgu4Qxrd2kXr10kz2NP5T8/7JnEfYNxCpPkArbLIhhkGLZV3aVMplH1RXQRF7Q==" }, "@typescript-eslint/typescript-estree": { - "version": "3.7.1", - "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-3.7.1.tgz", - "integrity": "sha512-m97vNZkI08dunYOr2lVZOHoyfpqRs0KDpd6qkGaIcLGhQ2WPtgHOd/eVbsJZ0VYCQvupKrObAGTOvk3tfpybYA==", + "version": "3.8.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-3.8.0.tgz", + "integrity": "sha512-MTv9nPDhlKfclwnplRNDL44mP2SY96YmPGxmMbMy6x12I+pERcxpIUht7DXZaj4mOKKtet53wYYXU0ABaiXrLw==", "requires": { - "@typescript-eslint/types": "3.7.1", - "@typescript-eslint/visitor-keys": "3.7.1", + "@typescript-eslint/types": "3.8.0", + "@typescript-eslint/visitor-keys": "3.8.0", "debug": "^4.1.1", "glob": "^7.1.6", "is-glob": "^4.0.1", @@ -612,9 +612,9 @@ } }, "@typescript-eslint/visitor-keys": { - "version": "3.7.1", - "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-3.7.1.tgz", - "integrity": "sha512-xn22sQbEya+Utj2IqJHGLA3i1jDzR43RzWupxojbSWnj3nnPLavaQmWe5utw03CwYao3r00qzXfgJMGNkrzrAA==", + "version": "3.8.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-3.8.0.tgz", + "integrity": "sha512-gfqQWyVPpT9NpLREXNR820AYwgz+Kr1GuF3nf1wxpHD6hdxI62tq03ToomFnDxY0m3pUB39IF7sil7D5TQexLA==", "requires": { "eslint-visitor-keys": "^1.1.0" } diff --git a/dependencies/package.json b/dependencies/package.json index ca11de29..ffa549c9 100644 --- a/dependencies/package.json +++ b/dependencies/package.json @@ -3,7 +3,7 @@ "dependencies": { "@coffeelint/cli": "^3.2.10", "@stoplight/spectral": "^5.4.0", - "@typescript-eslint/eslint-plugin": "^3.7.1", + "@typescript-eslint/eslint-plugin": "^3.8.0", "@typescript-eslint/parser": "^3.8.0", "babel-eslint": "^10.1.0", "dockerfilelint": "^1.5.0", From 3d55ba70f3a512328e7c42148ae7b11bd58377dc Mon Sep 17 00:00:00 2001 From: Lukas Gravley Date: Tue, 4 Aug 2020 11:05:11 -0500 Subject: [PATCH 132/135] Update automerge-dependabot.yml --- .github/workflows/automerge-dependabot.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/automerge-dependabot.yml b/.github/workflows/automerge-dependabot.yml index bd579821..5caaa35e 100644 --- a/.github/workflows/automerge-dependabot.yml +++ b/.github/workflows/automerge-dependabot.yml @@ -33,13 +33,13 @@ jobs: uses: actions/github-script@v2 with: script: | - github.pullRequests.createReview({ + github.pulls.createReview({ owner: context.payload.repository.owner.login, repo: context.payload.repository.name, pull_number: context.payload.pull_request.number, event: 'APPROVE' }) - github.pullRequests.merge({ + github.pulls.merge({ owner: context.payload.repository.owner.login, repo: context.payload.repository.name, pull_number: context.payload.pull_request.number From 54ac2166004553ba4fc3921d435bdd7d1c7136be Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Filip=20=C5=A0?= Date: Tue, 4 Aug 2020 18:43:36 +0200 Subject: [PATCH 133/135] Fix file modes and re-add report --- .automation/test/php/php_bad_2.php | 0 .automation/test/php/php_good_2.php | 0 .automation/test/php/reports/expected-PHP_BUILTIN.tap | 0 .../test/php/reports/expected-PHP_PHPCS.tap.ignored | 0 ...ed-PHP_PHPSTAN.tap.ignored => expected-PHP_PHPSTAN.tap} | 7 ++++--- .../test/php/reports/expected-PHP_PSALM.tap.ignored | 0 TEMPLATES/phpcs.xml | 0 TEMPLATES/psalm.xml | 0 dependencies/phive.xml | 0 9 files changed, 4 insertions(+), 3 deletions(-) mode change 100755 => 100644 .automation/test/php/php_bad_2.php mode change 100755 => 100644 .automation/test/php/php_good_2.php mode change 100755 => 100644 .automation/test/php/reports/expected-PHP_BUILTIN.tap mode change 100755 => 100644 .automation/test/php/reports/expected-PHP_PHPCS.tap.ignored rename .automation/test/php/reports/{expected-PHP_PHPSTAN.tap.ignored => expected-PHP_PHPSTAN.tap} (59%) mode change 100755 => 100644 .automation/test/php/reports/expected-PHP_PSALM.tap.ignored mode change 100755 => 100644 TEMPLATES/phpcs.xml mode change 100755 => 100644 TEMPLATES/psalm.xml mode change 100755 => 100644 dependencies/phive.xml diff --git a/.automation/test/php/php_bad_2.php b/.automation/test/php/php_bad_2.php old mode 100755 new mode 100644 diff --git a/.automation/test/php/php_good_2.php b/.automation/test/php/php_good_2.php old mode 100755 new mode 100644 diff --git a/.automation/test/php/reports/expected-PHP_BUILTIN.tap b/.automation/test/php/reports/expected-PHP_BUILTIN.tap old mode 100755 new mode 100644 diff --git a/.automation/test/php/reports/expected-PHP_PHPCS.tap.ignored b/.automation/test/php/reports/expected-PHP_PHPCS.tap.ignored old mode 100755 new mode 100644 diff --git a/.automation/test/php/reports/expected-PHP_PHPSTAN.tap.ignored b/.automation/test/php/reports/expected-PHP_PHPSTAN.tap similarity index 59% rename from .automation/test/php/reports/expected-PHP_PHPSTAN.tap.ignored rename to .automation/test/php/reports/expected-PHP_PHPSTAN.tap index 053f0eb0..03f22dd1 100644 --- a/.automation/test/php/reports/expected-PHP_PHPSTAN.tap.ignored +++ b/.automation/test/php/reports/expected-PHP_PHPSTAN.tap @@ -1,11 +1,12 @@ TAP version 13 -1..3 +1..4 not ok 1 - php_bad_1.php --- message: ------ ---------------------------------------------- \n Line php_bad_1.php \n ------ ---------------------------------------------- \n 3 Invalid numeric literal on line 3 \n 3 Invalid numeric literal on line 3 \n 3 Syntax error, unexpected '=' on line 3 \n 3 Syntax error, unexpected T_LNUMBER on line 3 \n 3 Syntax error, unexpected T_STRING on line 3 \n 3 Syntax error, unexpected T_STRING on line 3 \n ------ ---------------------------------------------- \n\n [ERROR] Found 6 errors \n ... not ok 2 - php_bad_2.php --- - message: ------ ------------------------------------------------------- \n Line php_bad_2.php \n ------ ------------------------------------------------------- \n 5 Syntax error, unexpected EOF, expecting T_VARIABLE or \n T_DOLLAR_OPEN_CURLY_BRACES or T_CURLY_OPEN on line 5 \n ------ ------------------------------------------------------- \n\n [ERROR] Found 1 error \n + message: ------ ----------------------------------------- \n Line php_bad_2.php \n ------ ----------------------------------------- \n 15 Syntax error, unexpected '}' on line 15 \n ------ ----------------------------------------- \n\n [ERROR] Found 1 error \n ... -ok 3 - php_good_1.php \ No newline at end of file +ok 3 - php_good_1.php +ok 4 - php_good_2.php diff --git a/.automation/test/php/reports/expected-PHP_PSALM.tap.ignored b/.automation/test/php/reports/expected-PHP_PSALM.tap.ignored old mode 100755 new mode 100644 diff --git a/TEMPLATES/phpcs.xml b/TEMPLATES/phpcs.xml old mode 100755 new mode 100644 diff --git a/TEMPLATES/psalm.xml b/TEMPLATES/psalm.xml old mode 100755 new mode 100644 diff --git a/dependencies/phive.xml b/dependencies/phive.xml old mode 100755 new mode 100644 From 0c84fd5120dad6573506e196ab97524b6517363a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Filip=20=C5=A0?= Date: Tue, 4 Aug 2020 19:07:18 +0200 Subject: [PATCH 134/135] Fix PHPStan config --- lib/worker.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/worker.sh b/lib/worker.sh index 0212f151..3cde38b6 100755 --- a/lib/worker.sh +++ b/lib/worker.sh @@ -591,7 +591,7 @@ function RunTestCases() { TestCodebase "PERL" "perl" "perl -Mstrict -cw" ".*\.\(pl\)\$" "perl" TestCodebase "PHP_BUILTIN" "php" "php -l" ".*\.\(php\)\$" "php" TestCodebase "PHP_PHPCS" "phpcs" "phpcs --standard=${PHP_PHPCS_LINTER_RULES}" ".*\.\(php\)\$" "php" - TestCodebase "PHP_PHPSTAN" "phpstan" "phpstan analyse --no-progress --no-ansi -c ${PHPSTAN_LINTER_RULES}" ".*\.\(php\)\$" "php" + TestCodebase "PHP_PHPSTAN" "phpstan" "phpstan analyse --no-progress --no-ansi -c ${PHP_PHPSTAN_LINTER_RULES}" ".*\.\(php\)\$" "php" TestCodebase "PHP_PSALM" "psalm" "psalm --config=${PHP_PSALM_LINTER_RULES}" ".*\.\(php\)\$" "php" TestCodebase "OPENAPI" "spectral" "spectral lint -r ${OPENAPI_LINTER_RULES}" ".*\.\(ymlopenapi\|jsonopenapi\)\$" "openapi" TestCodebase "POWERSHELL" "pwsh" "Invoke-ScriptAnalyzer -EnableExit -Settings ${POWERSHELL_LINTER_RULES} -Path" ".*\.\(ps1\|psm1\|psd1\|ps1xml\|pssc\|psrc\|cdxml\)\$" "powershell" From 8063ed91f516bc0d59bac6524b30603aa7bf55f5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Filip=20=C5=A0?= Date: Tue, 4 Aug 2020 19:24:15 +0200 Subject: [PATCH 135/135] Fix PHPStan config again --- lib/linter.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/linter.sh b/lib/linter.sh index 8dc6d46a..e044726d 100755 --- a/lib/linter.sh +++ b/lib/linter.sh @@ -1526,7 +1526,7 @@ if [ "${VALIDATE_PHP_PHPSTAN}" == "true" ]; then # Lint the PHP files using PHPStan # ####################### # LintCodebase "FILE_TYPE" "LINTER_NAME" "LINTER_CMD" "FILE_TYPES_REGEX" "FILE_ARRAY" - LintCodebase "PHP_PHPSTAN" "phpstan" "phpstan analyse --no-progress --no-ansi -c ${PHPSTAN_LINTER_RULES}" ".*\.\(php\)\$" "${FILE_ARRAY_PHP_PHPSTAN[@]}" + LintCodebase "PHP_PHPSTAN" "phpstan" "phpstan analyse --no-progress --no-ansi -c ${PHP_PHPSTAN_LINTER_RULES}" ".*\.\(php\)\$" "${FILE_ARRAY_PHP_PHPSTAN[@]}" fi if [ "${VALIDATE_PHP_PSALM}" == "true" ]; then