From 5b44f9d0665918894199411616721184d91a7458 Mon Sep 17 00:00:00 2001 From: Lucas Gravley <29484535+admiralAwkbar@users.noreply.github.com> Date: Thu, 6 Aug 2020 10:30:10 -0500 Subject: [PATCH 1/5] Adding secondary name --- lib/linter.sh | 43 +++++++++++++++++++++++++++++++++++++++---- 1 file changed, 39 insertions(+), 4 deletions(-) diff --git a/lib/linter.sh b/lib/linter.sh index e8526a64..4e8562f6 100755 --- a/lib/linter.sh +++ b/lib/linter.sh @@ -477,6 +477,28 @@ GetLinterRules() { LANGUAGE_FILE_NAME="${LANGUAGE_NAME}_FILE_NAME" LANGUAGE_LINTER_RULES="${LANGUAGE_NAME}_LINTER_RULES" + ########################## + # Get the file extension # + ########################## + FILE_EXTENSION=$(echo "${!LANGUAGE_FILE_NAME}" | rev | cut -d'.' -f1 | rev) + FILE_NAME=$(echo "${!LANGUAGE_FILE_NAME}" | rev | cut -d'.' -f2 | rev) + + ############################### + # Set the secondary file name # + ############################### + SECONDARY_FILE_NAME='' + + ################################# + # Check for secondary file name # + ################################# + if [[ $FILE_EXTENSION == 'yml' ]]; then + # Need to see if yaml also exists + SECONDARY_FILE_NAME="$FILE_NAME.yaml" + elif [[ $FILE_EXTENSION == 'yaml' ]]; then + # need to see if yml also exists + SECONDARY_FILE_NAME="$FILE_NAME.yml" + fi + ##################################### # Validate we have the linter rules # ##################################### @@ -489,10 +511,23 @@ GetLinterRules() { ######################################## 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}]" + # Check if we have secondary name to check + if [ -n "$SECONDARY_FILE_NAME" ]; then + # We have a secondary name to validate + if [ -f "${GITHUB_WORKSPACE}/${LINTER_RULES_PATH}/${SECONDARY_FILE_NAME}" ]; then + info "----------------------------------------------" + info "User provided file:[${SECONDARY_FILE_NAME}], setting rules file..." + + ######################################## + # Update the path to the file location # + ######################################## + eval "${LANGUAGE_LINTER_RULES}=${GITHUB_WORKSPACE}/${LINTER_RULES_PATH}/${SECONDARY_FILE_NAME}" + fi + fi + ######################################################## + # 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 } ################################################################################ From 2beb30e939b26c7bf3126f2ef19382800e7ef170 Mon Sep 17 00:00:00 2001 From: Lucas Gravley <29484535+admiralAwkbar@users.noreply.github.com> Date: Thu, 6 Aug 2020 10:42:57 -0500 Subject: [PATCH 2/5] cleanup --- lib/linter.sh | 28 ++++++++++++++-------------- lib/worker.sh | 2 +- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/lib/linter.sh b/lib/linter.sh index 4e8562f6..49b8acc9 100755 --- a/lib/linter.sh +++ b/lib/linter.sh @@ -25,13 +25,13 @@ source /action/lib/worker.sh # Source the function script(s) 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_FILE_NAME='.ansible-lint.yaml' # 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 -CLOUDFORMATION_FILE_NAME='.cfnlintrc.yml' # Name of the file +CLOUDFORMATION_FILE_NAME='.cfnlintrc.yaml' # 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 @@ -43,16 +43,16 @@ COFFEESCRIPT_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${COFFEE_FILE_NAME}" # Path 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 # Docker Vars DOCKERFILE_NAME='.dockerfilelintrc' # Name of the file DOCKERFILE_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${DOCKERFILE_NAME}" # Path to the Docker lint rules # Dockerfile Hadolint -DOCKERFILE_HADOLINT_NAME='.hadolint.yml' # Name of the file +DOCKERFILE_HADOLINT_NAME='.hadolint.yaml' # Name of the file DOCKERFILE_HADOLINT_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${DOCKERFILE_HADOLINT_NAME}" # Path to the Docker lint rules # Golang Vars -GO_FILE_NAME='.golangci.yml' # Name of the file +GO_FILE_NAME='.golangci.yaml' # 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 @@ -64,7 +64,7 @@ HTML_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${HTML_FILE_NAME}" # Path to the CS JAVA_FILE_NAME="sun_checks.xml" # Name of the Java config file JAVA_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${JAVA_FILE_NAME}" # Path to the Java 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.yaml}" # 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 @@ -73,10 +73,10 @@ LINTER_RULES_PATH="${LINTER_RULES_PATH:-.github/linters}" # Linter Path Director 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_FILE_NAME='.markdown-lint.yaml' # 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.yaml' # 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 @@ -100,7 +100,7 @@ fi 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.yaml' # 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 @@ -108,17 +108,17 @@ PYTHON_PYLINT_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${PYTHON_PYLINT_FILE_NAME} 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_FILE_NAME="${RUBY_CONFIG_FILE:-.ruby-lint.yaml}" # 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_FILE_NAME="${TYPESCRIPT_ES_CONFIG_FILE:-.eslintrc.yaml}" # 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_FILE_NAME="${YAML_CONFIG_FILE:-.yaml-lint.yaml}" # Name of the file YAML_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${YAML_FILE_NAME}" # Path to the yaml lint rules ####################################### @@ -1789,9 +1789,9 @@ if [ "${VALIDATE_XML}" == "true" ]; then LintCodebase "XML" "xmllint" "xmllint" ".*\.\(xml\)\$" "${FILE_ARRAY_XML[@]}" fi -############### +################ # YAML LINTING # -############### +################ if [ "${VALIDATE_YAML}" == "true" ]; then ###################### # Lint the Yml Files # diff --git a/lib/worker.sh b/lib/worker.sh index b5bf969e..300355c9 100755 --- a/lib/worker.sh +++ b/lib/worker.sh @@ -732,7 +732,7 @@ function LintAnsibleFiles() { ######################################## # Make sure we dont lint certain files # ######################################## - if [[ ${FILE} == *"vault.yml"* ]] || [[ ${FILE} == *"galaxy.yml"* ]]; then + if [[ ${FILE} == *"vault.yml"* ]] || [[ ${FILE} == *"galaxy.yml"* ]] || [[ ${FILE} == *"vault.yaml"* ]] || [[ ${FILE} == *"galaxy.yaml"* ]]; then # This is a file we dont look at continue fi From f5532f9cd60b5242e03b2f4e956574109adc30f1 Mon Sep 17 00:00:00 2001 From: Lucas Gravley <29484535+admiralAwkbar@users.noreply.github.com> Date: Thu, 6 Aug 2020 10:53:42 -0500 Subject: [PATCH 3/5] put them back lol --- lib/linter.sh | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/lib/linter.sh b/lib/linter.sh index 49b8acc9..78baf38f 100755 --- a/lib/linter.sh +++ b/lib/linter.sh @@ -25,13 +25,13 @@ source /action/lib/worker.sh # Source the function script(s) 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.yaml' # Name of the file +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 -CLOUDFORMATION_FILE_NAME='.cfnlintrc.yaml' # Name of the file +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 @@ -43,16 +43,16 @@ COFFEESCRIPT_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${COFFEE_FILE_NAME}" # Path 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.yml' # Name of the file DART_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${DART_FILE_NAME}" # Path to the DART lint rules # Docker Vars DOCKERFILE_NAME='.dockerfilelintrc' # Name of the file DOCKERFILE_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${DOCKERFILE_NAME}" # Path to the Docker lint rules # Dockerfile Hadolint -DOCKERFILE_HADOLINT_NAME='.hadolint.yaml' # Name of the file +DOCKERFILE_HADOLINT_NAME='.hadolint.yml' # Name of the file DOCKERFILE_HADOLINT_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${DOCKERFILE_HADOLINT_NAME}" # Path to the Docker lint rules # Golang Vars -GO_FILE_NAME='.golangci.yaml' # 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 # Groovy Vars GROOVY_FILE_NAME='.groovylintrc.json' # Name of the file @@ -64,7 +64,7 @@ HTML_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${HTML_FILE_NAME}" # Path to the CS JAVA_FILE_NAME="sun_checks.xml" # Name of the Java config file JAVA_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${JAVA_FILE_NAME}" # Path to the Java lint rules # Javascript Vars -JAVASCRIPT_FILE_NAME="${JAVASCRIPT_ES_CONFIG_FILE:-.eslintrc.yaml}" # 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 # Default linter path @@ -73,10 +73,10 @@ LINTER_RULES_PATH="${LINTER_RULES_PATH:-.github/linters}" # Linter Path Director 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.yaml' # 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.yaml' # 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 # PHPCS Vars PHP_PHPCS_FILE_NAME='phpcs.xml' # Name of the file @@ -100,7 +100,7 @@ fi 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.yaml' # 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_PYLINT_FILE_NAME="${PYTHON_PYLINT_CONFIG_FILE:-.python-lint}" # Name of the file @@ -108,7 +108,7 @@ PYTHON_PYLINT_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${PYTHON_PYLINT_FILE_NAME} 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.yaml}" # 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 From 5ffa5518db2903371a187b9ff6f140e8ac40135f Mon Sep 17 00:00:00 2001 From: Lucas Gravley <29484535+admiralAwkbar@users.noreply.github.com> Date: Thu, 6 Aug 2020 10:56:06 -0500 Subject: [PATCH 4/5] fixed it real good --- .../linters/{analysis_options.yaml => analysis_options.yml} | 0 TEMPLATES/{analysis_options.yaml => analysis_options.yml} | 0 lib/linter.sh | 4 ++-- 3 files changed, 2 insertions(+), 2 deletions(-) rename .github/linters/{analysis_options.yaml => analysis_options.yml} (100%) rename TEMPLATES/{analysis_options.yaml => analysis_options.yml} (100%) diff --git a/.github/linters/analysis_options.yaml b/.github/linters/analysis_options.yml similarity index 100% rename from .github/linters/analysis_options.yaml rename to .github/linters/analysis_options.yml diff --git a/TEMPLATES/analysis_options.yaml b/TEMPLATES/analysis_options.yml similarity index 100% rename from TEMPLATES/analysis_options.yaml rename to TEMPLATES/analysis_options.yml diff --git a/lib/linter.sh b/lib/linter.sh index 78baf38f..5beac264 100755 --- a/lib/linter.sh +++ b/lib/linter.sh @@ -114,11 +114,11 @@ RUBY_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${RUBY_FILE_NAME}" # Path to the ru 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.yaml}" # 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 # YAML Vars -YAML_FILE_NAME="${YAML_CONFIG_FILE:-.yaml-lint.yaml}" # 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 af7c3071d341e8626d52b5f7aa9f3a07b1cc4aba Mon Sep 17 00:00:00 2001 From: Lukas Gravley Date: Thu, 6 Aug 2020 11:14:01 -0500 Subject: [PATCH 5/5] Update disabling-linters.md --- docs/disabling-linters.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/disabling-linters.md b/docs/disabling-linters.md index 455f37f2..7a3c9b33 100644 --- a/docs/disabling-linters.md +++ b/docs/disabling-linters.md @@ -243,9 +243,9 @@ a { ### dartanalyzer standard Config file -- `.github/linters/.dart-lint.yml` +- `.github/linters/analysis_options.yml` - You can pass multiple rules and overwrite default rules -- File should be located at: `.github/linters/analysis_options.yaml` +- File should be located at: `.github/linters/analysis_options.yml` ### dartanalyzer disable single line @@ -263,7 +263,7 @@ int x = ''; // ignore: invalid_assignment ### dartanalyzer disable entire file -- You can disable entire files with the `analyzer.exclude` property in `analysis_options.yaml` +- You can disable entire files with the `analyzer.exclude` property in `analysis_options.yml` ```dart analyzer: