From 5b7cbb36eba2adbc38eb68660ed7617b9cb4609c Mon Sep 17 00:00:00 2001 From: Ishan Goel Date: Wed, 22 Jul 2020 09:49:31 +0400 Subject: [PATCH 01/23] Work on adding Java --- Dockerfile | 1 + README.md | 9 ++++++--- lib/linter.sh | 22 +++++++++++++++++++--- 3 files changed, 26 insertions(+), 6 deletions(-) diff --git a/Dockerfile b/Dockerfile index 242e066c..7ba76bd6 100644 --- a/Dockerfile +++ b/Dockerfile @@ -222,6 +222,7 @@ ENV GITHUB_SHA=${GITHUB_SHA} \ VALIDATE_KOTLIN=${VALIDATE_KOTLIN} \ VALIDATE_DART=${VALIDATE_DART} \ VALIDATE_POWERSHELL=${VALIDATE_POWERSHELL} \ + VALIDATE_JAVA=${VALIDATE_JAVA} \ VALIDATE_ARM=${VALIDATE_ARM} \ VALIDATE_OPENAPI=${VALIDATE_OPENAPI} \ VALIDATE_PROTOBUF=${VALIDATE_PROTOBUF} \ diff --git a/README.md b/README.md index 14396934..86697eef 100644 --- a/README.md +++ b/README.md @@ -33,19 +33,21 @@ 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/) | | **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) | +| **CSS** | [stylelint](https://stylelint.io/) | +| **Java** | [Spotless](https://github.com/diffplug/spotless) | | **Kotlin** | [ktlint](https://github.com/pinterest/ktlint) | | **Markdown** | [markdownlint](https://github.com/igorshubovych/markdownlint-cli#readme) | | **OpenAPI** | [spectral](https://github.com/stoplightio/spectral) | @@ -183,6 +185,7 @@ and won't run anything unexpected. | **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_JAVA** | `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. | diff --git a/lib/linter.sh b/lib/linter.sh index b57fc05f..26d9f500 100755 --- a/lib/linter.sh +++ b/lib/linter.sh @@ -94,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" "dart" "htmlhint") + "spectral" "cfn-lint" "dart" "htmlhint" "spotless") ############################# # Language array for prints # @@ -103,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' 'DART' 'HTML') + 'CFN' 'DART' 'HTML' 'JAVA') ################### # GitHub ENV Vars # @@ -142,12 +142,14 @@ VALIDATE_TERRAFORM="${VALIDATE_TERRAFORM}" # Boolean to vali VALIDATE_POWERSHELL="${VALIDATE_POWERSHELL}" # Boolean to validate language VALIDATE_ARM="${VALIDATE_ARM}" # Boolean to validate language VALIDATE_KOTLIN="${VALIDATE_KOTLIN}" # Boolean to validate language +VALIDATE_JAVA="${VALIDATE_JAVA}" # Boolean to validate language VALIDATE_OPENAPI="${VALIDATE_OPENAPI}" # Boolean to validate language VALIDATE_DART="${VALIDATE_DART}" # Boolean to validate language +VALIDATE_HTML="${VALIDATE_HTML}" # Boolean to validate language VALIDATE_EDITORCONFIG="${VALIDATE_EDITORCONFIG}" # Boolean to validate files with editorconfig 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 + ############## # Debug Vars # @@ -217,6 +219,7 @@ FILE_ARRAY_ARM=() # Array of files to check FILE_ARRAY_CSS=() # Array of files to check FILE_ARRAY_ENV=() # Array of files to check FILE_ARRAY_CLOJURE=() # Array of files to check +FILE_ARRAY_JAVA=() # Array of files to check FILE_ARRAY_KOTLIN=() # Array of files to check FILE_ARRAY_PROTOBUF=() # Array of files to check FILE_ARRAY_OPENAPI=() # Array of files to check @@ -253,6 +256,7 @@ ERRORS_FOUND_ARM=0 # Count of errors found ERRORS_FOUND_CSS=0 # Count of errors found ERRORS_FOUND_ENV=0 # Count of errors found ERRORS_FOUND_CLOJURE=0 # Count of errors found +ERRORS_FOUND_JAVA=0 # Count of errors found ERRORS_FOUND_KOTLIN=0 # Count of errors found ERRORS_FOUND_PROTOBUF=0 # Count of errors found ERRORS_FOUND_OPENAPI=0 # Count of errors found @@ -831,6 +835,7 @@ Footer() { [ "$ERRORS_FOUND_OPENAPI" -ne 0 ] || [ "$ERRORS_FOUND_PROTOBUF" -ne 0 ] || [ "$ERRORS_FOUND_CLOJURE" -ne 0 ] || + [ "$ERRORS_FOUND_JAVA" -ne 0 ] || [ "$ERRORS_FOUND_KOTLIN" -ne 0 ] || [ "$ERRORS_FOUND_DART" -ne 0 ] || [ "$ERRORS_FOUND_HTML" -ne 0 ]; then @@ -1218,6 +1223,17 @@ if [ "$VALIDATE_ENV" == "true" ]; then LintCodebase "ENV" "dotenv-linter" "dotenv-linter" ".*\.\(env\).*\$" "${FILE_ARRAY_ENV[@]}" fi +################ +# JAVA LINTING # +################ +if [ "$VALIDATE_JAVA" == "true" ]; then + ####################### + # Lint the JAVA files # + ####################### + # LintCodebase "FILE_TYPE" "LINTER_NAME" "LINTER_CMD" "FILE_TYPES_REGEX" "FILE_ARRAY" + LintCodebase "JAVA" "spotless" "spotless" ".*\.\(java\)\$" "${FILE_ARRAY_JAVA[@]}" +fi + ################## # KOTLIN LINTING # ################## From 16985c1cdb04b6ef21e24652b0b4c60718786d0c Mon Sep 17 00:00:00 2001 From: Ishan Goel Date: Wed, 22 Jul 2020 11:47:33 +0400 Subject: [PATCH 02/23] Small formatting change --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 76aaf2d6..8001e749 100644 --- a/README.md +++ b/README.md @@ -202,7 +202,7 @@ and won't run anything unexpected. | **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_JAVA** | `true` | Flag to enable or disable the linting process of the language. +| **VALIDATE_JAVA** | `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. | From 91eb58e61aa630fd0f8cbdc294129bf92290c3b6 Mon Sep 17 00:00:00 2001 From: sirReeall <35725129+sirReeall@users.noreply.github.com> Date: Fri, 24 Jul 2020 17:49:49 +0100 Subject: [PATCH 03/23] added checkstyle --- Dockerfile | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/Dockerfile b/Dockerfile index 98e0c1db..08d12dcc 100644 --- a/Dockerfile +++ b/Dockerfile @@ -187,6 +187,17 @@ 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 CheckStyle # +###################### + +RUN CHECKSTYLE_LATEST=$(curl -s https://api.github.com/repos/checkstyle/checkstyle/releases/latest \ + | grep browser_download_url \ + | grep ".jar" \ + | cut -d '"' -f 4) \ + && curl -sSL $CHECKSTYLE_LATEST \ + --output /usr/bin/checkstyle.jar + ########################################### # Load GitHub Env Vars for GitHub Actions # ########################################### From c0626d00fa070305cdaf5450656b1a6eb888556e Mon Sep 17 00:00:00 2001 From: Ishan Goel Date: Mon, 3 Aug 2020 14:48:32 +0400 Subject: [PATCH 04/23] Change spotless to checkstyle --- README.md | 2 +- lib/linter.sh | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 8001e749..b817f997 100644 --- a/README.md +++ b/README.md @@ -58,7 +58,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) | | **CSS** | [stylelint](https://stylelint.io/) | -| **Java** | [Spotless](https://github.com/diffplug/spotless) | +| **Java** | [checkstyle](https://checkstyle.org) | | **Kotlin** | [ktlint](https://github.com/pinterest/ktlint) | | **Markdown** | [markdownlint](https://github.com/igorshubovych/markdownlint-cli#readme) | | **OpenAPI** | [spectral](https://github.com/stoplightio/spectral) | diff --git a/lib/linter.sh b/lib/linter.sh index 386ee9e6..8119313f 100755 --- a/lib/linter.sh +++ b/lib/linter.sh @@ -94,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" "dart" "htmlhint" "spotless") + "spectral" "cfn-lint" "dart" "htmlhint" "checkstyle") ############################# # Language array for prints # @@ -940,7 +940,7 @@ Footer() { ############################### # Exit with 1 if errors found # ############################### - + elif [ "${ERRORS_FOUND_YML}" -ne 0 ] || [ "${ERRORS_FOUND_JSON}" -ne 0 ] || [ "${ERRORS_FOUND_XML}" -ne 0 ] || @@ -1373,7 +1373,7 @@ if [ "$VALIDATE_JAVA" == "true" ]; then # Lint the JAVA files # ####################### # LintCodebase "FILE_TYPE" "LINTER_NAME" "LINTER_CMD" "FILE_TYPES_REGEX" "FILE_ARRAY" - LintCodebase "JAVA" "spotless" "spotless" ".*\.\(java\)\$" "${FILE_ARRAY_JAVA[@]}" + LintCodebase "JAVA" "checkstyle" "java -jar /usr/bin/checksytle.jar" ".*\.\(java\)\$" "${FILE_ARRAY_JAVA[@]}" fi ################## From f9e2e5a74a8dc3ebc5683e8c4045d1489964809e Mon Sep 17 00:00:00 2001 From: sirReeall <35725129+sirReeall@users.noreply.github.com> Date: Mon, 3 Aug 2020 16:28:07 +0100 Subject: [PATCH 05/23] hardcoded template file Might need to figure out how to change this at a later date --- lib/linter.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/linter.sh b/lib/linter.sh index 8119313f..ec63966c 100755 --- a/lib/linter.sh +++ b/lib/linter.sh @@ -1373,7 +1373,7 @@ if [ "$VALIDATE_JAVA" == "true" ]; then # Lint the JAVA files # ####################### # LintCodebase "FILE_TYPE" "LINTER_NAME" "LINTER_CMD" "FILE_TYPES_REGEX" "FILE_ARRAY" - LintCodebase "JAVA" "checkstyle" "java -jar /usr/bin/checksytle.jar" ".*\.\(java\)\$" "${FILE_ARRAY_JAVA[@]}" + LintCodebase "JAVA" "checkstyle" "java -jar /usr/bin/checksytle.jar -c sun_checks.xml" ".*\.\(java\)\$" "${FILE_ARRAY_JAVA[@]}" fi ################## From 5527dab3fa8f592d4881c295c107fcf883795015 Mon Sep 17 00:00:00 2001 From: Ishan Goel Date: Wed, 5 Aug 2020 20:00:51 +0400 Subject: [PATCH 06/23] Fix some merge conflicts --- lib/linter.sh | 111 +++----------------------------------------------- 1 file changed, 5 insertions(+), 106 deletions(-) diff --git a/lib/linter.sh b/lib/linter.sh index 19831687..e56ad69a 100755 --- a/lib/linter.sh +++ b/lib/linter.sh @@ -118,38 +118,21 @@ YAML_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${YAML_FILE_NAME}" # Path to the ya ####################################### # Linter array for information prints # ####################################### -<<<<<<< HEAD -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" "checkstyle") -======= -LINTER_ARRAY=('ansible-lint' 'arm-ttk' 'asl-validator' 'cfn-lint' 'clj-kondo' 'coffeelint' +LINTER_ARRAY=('ansible-lint' 'arm-ttk' 'asl-validator' 'cfn-lint' 'checkstyle' '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') ->>>>>>> master ############################# # Language array for prints # ############################# -<<<<<<< HEAD - -LANGUAGE_ARRAY=('ANSIBLE' 'ARM' 'BASH' 'CFN' 'CLOJURE' 'COFFEESCRIPT' - 'CSS' 'DART' 'DOCKER' 'ENV' 'GO' 'HTML' - 'JAVA' 'JAVASCRIPT_ES' 'JAVASCRIPT_STANDARD' 'JSON' 'JSX' 'KOTLIN' 'OPENAPI' - 'MARKDOWN' 'PERL' 'PHP' 'POWERSHELL' 'PROTOBUF' 'PYTHON' 'RAKU' 'RUBY' - 'TERRAFORM' 'TSX' 'TYPESCRIPT_ES' 'TYPESCRIPT_STANDARD' 'XML' 'YML' ) -======= LANGUAGE_ARRAY=('ANSIBLE' 'ARM' 'BASH' 'CLOUDFORMATION' 'CLOJURE' 'COFFEESCRIPT' 'CSS' - 'DART' 'DOCKER' 'ENV' 'GO' 'GROOVY' 'HTML' 'JAVASCRIPT_ES' 'JAVASCRIPT_STANDARD' + 'DART' 'DOCKER' 'ENV' 'GO' 'GROOVY' 'HTML' 'JAVA' 'JAVASCRIPT_ES' 'JAVASCRIPT_STANDARD' 'JSON' 'JSX' 'KOTLIN' 'LUA' 'MARKDOWN' 'OPENAPI' 'PERL' 'PHP_BUILTIN' 'PHP_PHPCS' 'PHP_PHPSTAN' 'PHP_PSALM' 'POWERSHELL' 'PROTOBUF' 'PYTHON_PYLINT' 'PYTHON_FLAKE8' 'RAKU' 'RUBY' 'STATES' 'TERRAFORM' 'TERRAFORM_TERRASCAN' 'TSX' 'TYPESCRIPT_ES' 'TYPESCRIPT_STANDARD' 'XML' 'YAML') ->>>>>>> master ############################################ # Array for all languages that were linted # @@ -159,53 +142,6 @@ LINTED_LANGUAGES_ARRAY=() # Will be filled at run time with all languages that w ################### # GitHub ENV Vars # ################### -<<<<<<< HEAD -GITHUB_SHA="${GITHUB_SHA}" # GitHub sha from the commit -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) -MULTI_STATUS="${MULTI_STATUS:-true}" # Multiple status are created for each check ran -ANSIBLE_DIRECTORY="${ANSIBLE_DIRECTORY}" # Ansible Directory -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_CFN="${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_HTML="${VALIDATE_HTML}" # Boolean to validate language -VALIDATE_JAVA="${VALIDATE_JAVA}" # 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_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="${VALIDATE_PYTHON}" # Boolean to validate language -VALIDATE_RAKU="${VALIDATE_RAKU}" # Boolean to validate language -VALIDATE_RUBY="${VALIDATE_RUBY}" # 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 -======= 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 @@ -234,6 +170,7 @@ VALIDATE_ENV="${VALIDATE_ENV}" # Boolean t 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_JAVA="${VALIDATE_JAVA}" # 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 @@ -260,7 +197,6 @@ VALIDATE_TYPESCRIPT_ES="${VALIDATE_TYPESCRIPT_ES}" # Boolean t 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 ->>>>>>> master ############## # Debug Vars # @@ -361,41 +297,6 @@ FILE_ARRAY_YAML=() # Array of files to check ############ # Counters # ############ -<<<<<<< HEAD -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_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_JAVA=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_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 @@ -422,6 +323,8 @@ ERRORS_FOUND_GROOVY=0 # Count of errors found export ERRORS_FOUND_GROOVY # Workaround SC2034 ERRORS_FOUND_HTML=0 # Count of errors found export ERRORS_FOUND_HTML # Workaround SC2034 +ERRORS_FOUND_JAVA=0 +export ERRORS_FOUND_JAVA 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 @@ -476,7 +379,6 @@ ERRORS_FOUND_XML=0 # Count of errors found export ERRORS_FOUND_XML # Workaround SC2034 ERRORS_FOUND_YAML=0 # Count of errors found export ERRORS_FOUND_YAML # Workaround SC2034 ->>>>>>> master ################################################################################ ########################## FUNCTIONS BELOW ##################################### @@ -1136,8 +1038,6 @@ Footer() { ############################### # Exit with 1 if errors found # ############################### -<<<<<<< HEAD - elif [ "${ERRORS_FOUND_YML}" -ne 0 ] || [ "${ERRORS_FOUND_JSON}" -ne 0 ] || [ "${ERRORS_FOUND_XML}" -ne 0 ] || @@ -1186,7 +1086,6 @@ Footer() { # Successful exit exit 0 fi -======= # Loop through all languages for LANGUAGE in "${LANGUAGE_ARRAY[@]}"; do # build the variable From e638e3d8ac90b53146c51d13966091b8a4a00776 Mon Sep 17 00:00:00 2001 From: Lucas Gravley <29484535+admiralAwkbar@users.noreply.github.com> Date: Wed, 5 Aug 2020 13:16:49 -0500 Subject: [PATCH 07/23] Fix shell errors --- README.md | 2 +- lib/linter.sh | 48 ------------------------------------------------ 2 files changed, 1 insertion(+), 49 deletions(-) diff --git a/README.md b/README.md index 71f8a276..6836a75f 100644 --- a/README.md +++ b/README.md @@ -50,7 +50,7 @@ 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/) | | **Dart** | [dartanalyzer](https://dart.dev/guides/language/analysis-options) | -| **Dockerfile** | [dockerfilelint](https://github.com/replicatedhq/dockerfilelint.git) https://github.com/hadolint/hadolint | +| **Dockerfile** | [dockerfilelint](https://github.com/replicatedhq/dockerfilelint.git) https://github.com/hadolint/hadolint) | | **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) | diff --git a/lib/linter.sh b/lib/linter.sh index 30cf6231..137ab107 100755 --- a/lib/linter.sh +++ b/lib/linter.sh @@ -1044,54 +1044,6 @@ 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 ] || - [ "${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_COFFEESCRIPT}" -ne 0 ] || - [ "${ERRORS_FOUND_ANSIBLE}" -ne 0 ] || - [ "$ERRORS_FOUND_JAVA" -ne 0 ] || - [ "${ERRORS_FOUND_JAVASCRIPT_ES}" -ne 0 ] || - [ "${ERRORS_FOUND_JAVASCRIPT_STANDARD}" -ne 0 ] || - [ "${ERRORS_FOUND_JSX}" -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 - - # Failed exit - echo -e "${NC}${F[R]}Exiting with errors found!${NC}" - exit 1 - 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 From a216a6623a9296518cdc85462c427690fc0b46d7 Mon Sep 17 00:00:00 2001 From: Lucas Gravley <29484535+admiralAwkbar@users.noreply.github.com> Date: Wed, 5 Aug 2020 13:35:14 -0500 Subject: [PATCH 08/23] adding some good code --- .automation/test/java/README.md | 19 +++ .automation/test/java/java_bad_1.java | 11 ++ .automation/test/java/java_good_1.java | 11 ++ .github/linters/sun_checks.xml | 198 +++++++++++++++++++++++++ TEMPLATES/sun_checks.xml | 198 +++++++++++++++++++++++++ docs/disabling-linters.md | 22 +++ lib/buildFileList.sh | 12 ++ lib/linter.sh | 27 ++-- lib/worker.sh | 1 + 9 files changed, 488 insertions(+), 11 deletions(-) create mode 100644 .automation/test/java/README.md create mode 100644 .automation/test/java/java_bad_1.java create mode 100644 .automation/test/java/java_good_1.java create mode 100644 .github/linters/sun_checks.xml create mode 100644 TEMPLATES/sun_checks.xml diff --git a/.automation/test/java/README.md b/.automation/test/java/README.md new file mode 100644 index 00000000..c51155cc --- /dev/null +++ b/.automation/test/java/README.md @@ -0,0 +1,19 @@ +# Java Test Cases + +This folder holds the test cases for **Java**. + +## 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/java/java_bad_1.java b/.automation/test/java/java_bad_1.java new file mode 100644 index 00000000..6d3c5be1 --- /dev/null +++ b/.automation/test/java/java_bad_1.java @@ -0,0 +1,11 @@ +/* This is a simple Java program. + FileName : "HelloWorld.java". */ +class HelloWorld +{ + // Your program begins with a call to main(). + // Prints "Hello, World" to the terminal window. + public static void main(String args[]) + { + System.out.println("Hello, World) + } +} diff --git a/.automation/test/java/java_good_1.java b/.automation/test/java/java_good_1.java new file mode 100644 index 00000000..2d789a3e --- /dev/null +++ b/.automation/test/java/java_good_1.java @@ -0,0 +1,11 @@ +/* This is a simple Java program. + FileName : "HelloWorld.java". */ +class java_good +{ + // Your program begins with a call to main(). + // Prints "Hello, World" to the terminal window. + public static void main(String args[]) + { + System.out.println("Hello, World"); + } +} diff --git a/.github/linters/sun_checks.xml b/.github/linters/sun_checks.xml new file mode 100644 index 00000000..adfd1b1c --- /dev/null +++ b/.github/linters/sun_checks.xml @@ -0,0 +1,198 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/TEMPLATES/sun_checks.xml b/TEMPLATES/sun_checks.xml new file mode 100644 index 00000000..adfd1b1c --- /dev/null +++ b/TEMPLATES/sun_checks.xml @@ -0,0 +1,198 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/docs/disabling-linters.md b/docs/disabling-linters.md index 00b246a2..455f37f2 100644 --- a/docs/disabling-linters.md +++ b/docs/disabling-linters.md @@ -29,6 +29,7 @@ For some linters it is also possible to override rules on a case by case level w - [Golang](#golang) - [Groovy](#groovy) - [HTML](#html) + - [Java](#java) - [Javascript eslint](#javascript-eslint) - [Javascript standard](#javascript-standard) - [JSON](#json) @@ -461,6 +462,27 @@ def variable = 1; --- +## Java + +- [checkstyle](https://github.com/checkstyle/checkstyle) + +### Java Config file + +- `.github/linters/sun_checks.xml` +- You can pass multiple rules and overwrite default rules +- File should be located at: `.github/linters/sun_checks.xml` + +### Java disable single line +- There is currently **No** way to disable rules inline of the file(s) + +### Java disable code block +- There is currently **No** way to disable rules inline of the file(s) + +### Java disable entire file +- There is currently **No** way to disable rules inline of the file(s) + +--- + ## Javascript eslint - [eslint](https://eslint.org/) diff --git a/lib/buildFileList.sh b/lib/buildFileList.sh index d98e7e6f..c878a3be 100755 --- a/lib/buildFileList.sh +++ b/lib/buildFileList.sh @@ -275,6 +275,18 @@ function BuildFileList() { # Set the READ_ONLY_CHANGE_FLAG since this could be exec # ########################################################## READ_ONLY_CHANGE_FLAG=1 + ###################### + # Get the Java files # + ###################### + elif [ "${FILE_TYPE}" == "java" ]; then + ################################ + # Append the file to the array # + ################################ + FILE_ARRAY_JAVA+=("${FILE}") + ########################################################## + # Set the READ_ONLY_CHANGE_FLAG since this could be exec # + ########################################################## + READ_ONLY_CHANGE_FLAG=1 ############################ # Get the JavaScript files # ############################ diff --git a/lib/linter.sh b/lib/linter.sh index 137ab107..7671b0fd 100755 --- a/lib/linter.sh +++ b/lib/linter.sh @@ -60,6 +60,9 @@ GROOVY_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${GROOVY_FILE_NAME}" # Path to th # 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 +# Java Vars +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_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${JAVASCRIPT_FILE_NAME}" # Path to the Javascript lint rules @@ -1132,6 +1135,8 @@ GetLinterRules "GO" GetLinterRules "GROOVY" # Get HTML rules GetLinterRules "HTML" +# get Java rules +etLinterRules "JAVA" # Get JavaScript rules GetLinterRules "JAVASCRIPT" # Get LUA rules @@ -1402,6 +1407,17 @@ if [ "${VALIDATE_HTML}" == "true" ]; then LintCodebase "HTML" "htmlhint" "htmlhint --config ${HTML_LINTER_RULES}" ".*\.\(html\)\$" "${FILE_ARRAY_HTML[@]}" fi +################ +# JAVA LINTING # +################ +if [ "$VALIDATE_JAVA" == "true" ]; then + ####################### + # Lint the JAVA files # + ####################### + # LintCodebase "FILE_TYPE" "LINTER_NAME" "LINTER_CMD" "FILE_TYPES_REGEX" "FILE_ARRAY" + LintCodebase "JAVA" "checkstyle" "java -jar /usr/bin/checksytle.jar -c ${JAVA_LINTER_RULES}" ".*\.\(java\)\$" "${FILE_ARRAY_JAVA[@]}" +fi + ###################### # JAVASCRIPT LINTING # ###################### @@ -1450,17 +1466,6 @@ if [ "${VALIDATE_JSX}" == "true" ]; then LintCodebase "JSX" "eslint" "eslint --no-eslintrc -c ${JAVASCRIPT_LINTER_RULES}" ".*\.\(jsx\)\$" "${FILE_ARRAY_JSX[@]}" fi -################ -# JAVA LINTING # -################ -if [ "$VALIDATE_JAVA" == "true" ]; then - ####################### - # Lint the JAVA files # - ####################### - # LintCodebase "FILE_TYPE" "LINTER_NAME" "LINTER_CMD" "FILE_TYPES_REGEX" "FILE_ARRAY" - LintCodebase "JAVA" "checkstyle" "java -jar /usr/bin/checksytle.jar -c sun_checks.xml" ".*\.\(java\)\$" "${FILE_ARRAY_JAVA[@]}" -fi - ################## # KOTLIN LINTING # ################## diff --git a/lib/worker.sh b/lib/worker.sh index 8caefd05..ba7d9f15 100755 --- a/lib/worker.sh +++ b/lib/worker.sh @@ -583,6 +583,7 @@ function RunTestCases() { 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 "JAVA" "checkstyle" "java -jar /usr/bin/checksytle.jar -c ${JAVA_LINTER_RULES}" ".*\.\(java\)\$" "java" 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" From eaca27d508351fe1526d10d3f2ca1fe506da95b9 Mon Sep 17 00:00:00 2001 From: Lucas Gravley <29484535+admiralAwkbar@users.noreply.github.com> Date: Wed, 5 Aug 2020 13:38:35 -0500 Subject: [PATCH 09/23] Fix typo --- lib/linter.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/linter.sh b/lib/linter.sh index 7671b0fd..db084878 100755 --- a/lib/linter.sh +++ b/lib/linter.sh @@ -1136,7 +1136,7 @@ GetLinterRules "GROOVY" # Get HTML rules GetLinterRules "HTML" # get Java rules -etLinterRules "JAVA" +GetLinterRules "JAVA" # Get JavaScript rules GetLinterRules "JAVASCRIPT" # Get LUA rules From 4c1ec55a0028b4989557089305935303f8b90ea7 Mon Sep 17 00:00:00 2001 From: Lucas Gravley <29484535+admiralAwkbar@users.noreply.github.com> Date: Wed, 5 Aug 2020 13:41:49 -0500 Subject: [PATCH 10/23] fixing my mistakes --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 6836a75f..66fffc84 100644 --- a/README.md +++ b/README.md @@ -50,7 +50,7 @@ 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/) | | **Dart** | [dartanalyzer](https://dart.dev/guides/language/analysis-options) | -| **Dockerfile** | [dockerfilelint](https://github.com/replicatedhq/dockerfilelint.git) https://github.com/hadolint/hadolint) | +| **Dockerfile** | [dockerfilelint](https://github.com/replicatedhq/dockerfilelint.git) [hadolint](https://github.com/hadolint/hadolint) | | **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) | From 3d7e7d1073335cc9035eb5c500bc6775aa927377 Mon Sep 17 00:00:00 2001 From: Lucas Gravley <29484535+admiralAwkbar@users.noreply.github.com> Date: Wed, 5 Aug 2020 14:28:43 -0500 Subject: [PATCH 11/23] Fix checkstyle --- Dockerfile | 2 +- lib/linter.sh | 2 +- lib/worker.sh | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Dockerfile b/Dockerfile index d4140b57..5adfa969 100644 --- a/Dockerfile +++ b/Dockerfile @@ -215,7 +215,7 @@ RUN CHECKSTYLE_LATEST=$(curl -s https://api.github.com/repos/checkstyle/checksty | grep ".jar" \ | cut -d '"' -f 4) \ && curl -sSL $CHECKSTYLE_LATEST \ - --output /usr/bin/checkstyle.jar + --output /usr/bin/checkstyle #################### # Install luacheck # diff --git a/lib/linter.sh b/lib/linter.sh index db084878..e18dbe67 100755 --- a/lib/linter.sh +++ b/lib/linter.sh @@ -1415,7 +1415,7 @@ if [ "$VALIDATE_JAVA" == "true" ]; then # Lint the JAVA files # ####################### # LintCodebase "FILE_TYPE" "LINTER_NAME" "LINTER_CMD" "FILE_TYPES_REGEX" "FILE_ARRAY" - LintCodebase "JAVA" "checkstyle" "java -jar /usr/bin/checksytle.jar -c ${JAVA_LINTER_RULES}" ".*\.\(java\)\$" "${FILE_ARRAY_JAVA[@]}" + LintCodebase "JAVA" "checkstyle" "java -jar checksytle -c ${JAVA_LINTER_RULES}" ".*\.\(java\)\$" "${FILE_ARRAY_JAVA[@]}" fi ###################### diff --git a/lib/worker.sh b/lib/worker.sh index ba7d9f15..ce0b9d12 100755 --- a/lib/worker.sh +++ b/lib/worker.sh @@ -583,7 +583,7 @@ function RunTestCases() { 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 "JAVA" "checkstyle" "java -jar /usr/bin/checksytle.jar -c ${JAVA_LINTER_RULES}" ".*\.\(java\)\$" "java" + TestCodebase "JAVA" "checkstyle" "java -jar checksytle -c ${JAVA_LINTER_RULES}" ".*\.\(java\)\$" "java" 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" From c3e5cb0ef13e55effa0da6079e79f2c7e39064b6 Mon Sep 17 00:00:00 2001 From: Lucas Gravley <29484535+admiralAwkbar@users.noreply.github.com> Date: Wed, 5 Aug 2020 14:37:38 -0500 Subject: [PATCH 12/23] Fix the pathing --- lib/linter.sh | 2 +- lib/worker.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/linter.sh b/lib/linter.sh index e18dbe67..f7a9c20a 100755 --- a/lib/linter.sh +++ b/lib/linter.sh @@ -1415,7 +1415,7 @@ if [ "$VALIDATE_JAVA" == "true" ]; then # Lint the JAVA files # ####################### # LintCodebase "FILE_TYPE" "LINTER_NAME" "LINTER_CMD" "FILE_TYPES_REGEX" "FILE_ARRAY" - LintCodebase "JAVA" "checkstyle" "java -jar checksytle -c ${JAVA_LINTER_RULES}" ".*\.\(java\)\$" "${FILE_ARRAY_JAVA[@]}" + LintCodebase "JAVA" "checkstyle" "java -jar /usr/bin/checksytle -c ${JAVA_LINTER_RULES}" ".*\.\(java\)\$" "${FILE_ARRAY_JAVA[@]}" fi ###################### diff --git a/lib/worker.sh b/lib/worker.sh index ce0b9d12..8637ca79 100755 --- a/lib/worker.sh +++ b/lib/worker.sh @@ -583,7 +583,7 @@ function RunTestCases() { 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 "JAVA" "checkstyle" "java -jar checksytle -c ${JAVA_LINTER_RULES}" ".*\.\(java\)\$" "java" + TestCodebase "JAVA" "checkstyle" "java -jar /usr/bin/checksytle -c ${JAVA_LINTER_RULES}" ".*\.\(java\)\$" "java" 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" From 3a1535e413d299570610db466d96c5b1ef2cfe89 Mon Sep 17 00:00:00 2001 From: Lucas Gravley <29484535+admiralAwkbar@users.noreply.github.com> Date: Wed, 5 Aug 2020 14:53:48 -0500 Subject: [PATCH 13/23] fix typo --- lib/linter.sh | 2 +- lib/worker.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/linter.sh b/lib/linter.sh index f7a9c20a..b3c15c91 100755 --- a/lib/linter.sh +++ b/lib/linter.sh @@ -1415,7 +1415,7 @@ if [ "$VALIDATE_JAVA" == "true" ]; then # Lint the JAVA files # ####################### # LintCodebase "FILE_TYPE" "LINTER_NAME" "LINTER_CMD" "FILE_TYPES_REGEX" "FILE_ARRAY" - LintCodebase "JAVA" "checkstyle" "java -jar /usr/bin/checksytle -c ${JAVA_LINTER_RULES}" ".*\.\(java\)\$" "${FILE_ARRAY_JAVA[@]}" + LintCodebase "JAVA" "checkstyle" "java -jar /usr/bin/checkstyle -c ${JAVA_LINTER_RULES}" ".*\.\(java\)\$" "${FILE_ARRAY_JAVA[@]}" fi ###################### diff --git a/lib/worker.sh b/lib/worker.sh index 8637ca79..b5bf969e 100755 --- a/lib/worker.sh +++ b/lib/worker.sh @@ -583,7 +583,7 @@ function RunTestCases() { 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 "JAVA" "checkstyle" "java -jar /usr/bin/checksytle -c ${JAVA_LINTER_RULES}" ".*\.\(java\)\$" "java" + TestCodebase "JAVA" "checkstyle" "java -jar /usr/bin/checkstyle -c ${JAVA_LINTER_RULES}" ".*\.\(java\)\$" "java" 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" From 3472359b2b03d92061c78a9107c80e9d65177dd7 Mon Sep 17 00:00:00 2001 From: Thomas Hughes Date: Wed, 5 Aug 2020 16:04:04 -0500 Subject: [PATCH 14/23] Fix good java file? --- .automation/test/java/java_good_1.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.automation/test/java/java_good_1.java b/.automation/test/java/java_good_1.java index 2d789a3e..ec96e2ce 100644 --- a/.automation/test/java/java_good_1.java +++ b/.automation/test/java/java_good_1.java @@ -1,11 +1,11 @@ /* This is a simple Java program. FileName : "HelloWorld.java". */ -class java_good -{ - // Your program begins with a call to main(). + +package com.super-linter.JavaGood + +public class JavaGood { // Prints "Hello, World" to the terminal window. - public static void main(String args[]) - { + public static void main(String[] args) { System.out.println("Hello, World"); } } From 4e725cba042515ecd7431ade7784103f4d793a4e Mon Sep 17 00:00:00 2001 From: Thomas Hughes Date: Wed, 5 Aug 2020 16:14:13 -0500 Subject: [PATCH 15/23] Fix good java file? --- .automation/test/java/java_good_1.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.automation/test/java/java_good_1.java b/.automation/test/java/java_good_1.java index ec96e2ce..f910417a 100644 --- a/.automation/test/java/java_good_1.java +++ b/.automation/test/java/java_good_1.java @@ -1,11 +1,11 @@ /* This is a simple Java program. FileName : "HelloWorld.java". */ -package com.super-linter.JavaGood +package com.superlinter.JavaGood public class JavaGood { // Prints "Hello, World" to the terminal window. - public static void main(String[] args) { + public static void main(final String[] args) { System.out.println("Hello, World"); } } From a1dd6f3835e22ed094c7ec583e6b65e52669f9d0 Mon Sep 17 00:00:00 2001 From: Thomas Hughes Date: Wed, 5 Aug 2020 16:24:37 -0500 Subject: [PATCH 16/23] Fix good java file --- .automation/test/java/java_good_1.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.automation/test/java/java_good_1.java b/.automation/test/java/java_good_1.java index f910417a..540029fe 100644 --- a/.automation/test/java/java_good_1.java +++ b/.automation/test/java/java_good_1.java @@ -1,7 +1,7 @@ /* This is a simple Java program. FileName : "HelloWorld.java". */ -package com.superlinter.JavaGood +package com.superlinter.JavaGood; public class JavaGood { // Prints "Hello, World" to the terminal window. From 59badeabdd494a11df332b1b131f586d83d29af6 Mon Sep 17 00:00:00 2001 From: Thomas Hughes Date: Wed, 5 Aug 2020 16:50:12 -0500 Subject: [PATCH 17/23] fix xml check, add javadoc --- .automation/test/java/java_good_1.java | 8 +++++--- .github/linters/sun_checks.xml | 2 +- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/.automation/test/java/java_good_1.java b/.automation/test/java/java_good_1.java index 540029fe..56f8c880 100644 --- a/.automation/test/java/java_good_1.java +++ b/.automation/test/java/java_good_1.java @@ -1,9 +1,11 @@ +package com.superlinter.JavaGood; /* This is a simple Java program. FileName : "HelloWorld.java". */ -package com.superlinter.JavaGood; - -public class JavaGood { +/** + * Represents a good Java file +*/ +class JavaGood { // Prints "Hello, World" to the terminal window. public static void main(final String[] args) { System.out.println("Hello, World"); diff --git a/.github/linters/sun_checks.xml b/.github/linters/sun_checks.xml index adfd1b1c..8bff099a 100644 --- a/.github/linters/sun_checks.xml +++ b/.github/linters/sun_checks.xml @@ -58,7 +58,7 @@ - + From 621244f8dfe868eb042d7dcc8eb3f72b04215700 Mon Sep 17 00:00:00 2001 From: Thomas Hughes Date: Wed, 5 Aug 2020 17:04:13 -0500 Subject: [PATCH 18/23] fix linter errors --- .automation/test/java/java_good_1.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.automation/test/java/java_good_1.java b/.automation/test/java/java_good_1.java index 56f8c880..3b9810e5 100644 --- a/.automation/test/java/java_good_1.java +++ b/.automation/test/java/java_good_1.java @@ -1,13 +1,13 @@ package com.superlinter.JavaGood; /* This is a simple Java program. - FileName : "HelloWorld.java". */ + FileName : "HelloWorld.java" */ /** * Represents a good Java file */ -class JavaGood { - // Prints "Hello, World" to the terminal window. - public static void main(final String[] args) { +public static class JavaGood { + // Prints "Hello, World" to the terminal window + private void JavaGood() { System.out.println("Hello, World"); } } From a6bdf858f29db33deb26f3682e68694b6be0494e Mon Sep 17 00:00:00 2001 From: Thomas Hughes Date: Wed, 5 Aug 2020 17:39:49 -0500 Subject: [PATCH 19/23] fix javadoc error --- .automation/test/java/java_good_1.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.automation/test/java/java_good_1.java b/.automation/test/java/java_good_1.java index 3b9810e5..e2d0d7e3 100644 --- a/.automation/test/java/java_good_1.java +++ b/.automation/test/java/java_good_1.java @@ -3,11 +3,11 @@ package com.superlinter.JavaGood; FileName : "HelloWorld.java" */ /** - * Represents a good Java file + * Represents a good Java file. */ public static class JavaGood { - // Prints "Hello, World" to the terminal window - private void JavaGood() { + // Prints "Hello, World" to the terminal window. + private void helloWorld() { System.out.println("Hello, World"); } } From ef62a7081c7b10dfee20b640e4e5489593e46778 Mon Sep 17 00:00:00 2001 From: Ishan Goel Date: Thu, 6 Aug 2020 13:13:46 +0400 Subject: [PATCH 20/23] Make JavaGood compile-able and improve java_bad_1.java --- .automation/test/java/{java_good_1.java => JavaGood.java} | 4 ---- .automation/test/java/java_bad_1.java | 8 +++----- 2 files changed, 3 insertions(+), 9 deletions(-) rename .automation/test/java/{java_good_1.java => JavaGood.java} (66%) diff --git a/.automation/test/java/java_good_1.java b/.automation/test/java/JavaGood.java similarity index 66% rename from .automation/test/java/java_good_1.java rename to .automation/test/java/JavaGood.java index e2d0d7e3..70f50e7c 100644 --- a/.automation/test/java/java_good_1.java +++ b/.automation/test/java/JavaGood.java @@ -1,7 +1,3 @@ -package com.superlinter.JavaGood; -/* This is a simple Java program. - FileName : "HelloWorld.java" */ - /** * Represents a good Java file. */ diff --git a/.automation/test/java/java_bad_1.java b/.automation/test/java/java_bad_1.java index 6d3c5be1..56d75863 100644 --- a/.automation/test/java/java_bad_1.java +++ b/.automation/test/java/java_bad_1.java @@ -1,11 +1,9 @@ -/* This is a simple Java program. - FileName : "HelloWorld.java". */ -class HelloWorld +class java_bad_1 // first letter of classname is not capitalized { - // Your program begins with a call to main(). - // Prints "Hello, World" to the terminal window. + public static void main(String args[]) { + System.out.println("Hello, World) } } From 0b80e1f288e11c60ab9526353b16266c5918ee65 Mon Sep 17 00:00:00 2001 From: Ishan Goel Date: Thu, 6 Aug 2020 17:14:18 +0400 Subject: [PATCH 21/23] Revert filename change --- .automation/test/java/{JavaGood.java => java_good_1.java} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename .automation/test/java/{JavaGood.java => java_good_1.java} (100%) diff --git a/.automation/test/java/JavaGood.java b/.automation/test/java/java_good_1.java similarity index 100% rename from .automation/test/java/JavaGood.java rename to .automation/test/java/java_good_1.java From 680a1e93f5b5ad8297ae40343ead829dfefc8e31 Mon Sep 17 00:00:00 2001 From: Lukas Gravley Date: Thu, 6 Aug 2020 08:24:02 -0500 Subject: [PATCH 22/23] make compile --- .automation/test/java/java_bad_1.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.automation/test/java/java_bad_1.java b/.automation/test/java/java_bad_1.java index 56d75863..e068b12a 100644 --- a/.automation/test/java/java_bad_1.java +++ b/.automation/test/java/java_bad_1.java @@ -3,7 +3,6 @@ class java_bad_1 // first letter of classname is not capitalized public static void main(String args[]) { - - System.out.println("Hello, World) + System.out.println("Hello, World") } } From 4861c105542ddd03dfed592208a151596ed6c783 Mon Sep 17 00:00:00 2001 From: Lukas Gravley Date: Thu, 6 Aug 2020 08:29:15 -0500 Subject: [PATCH 23/23] forgot it... --- .automation/test/java/java_bad_1.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.automation/test/java/java_bad_1.java b/.automation/test/java/java_bad_1.java index e068b12a..1d4127e9 100644 --- a/.automation/test/java/java_bad_1.java +++ b/.automation/test/java/java_bad_1.java @@ -3,6 +3,6 @@ class java_bad_1 // first letter of classname is not capitalized public static void main(String args[]) { - System.out.println("Hello, World") + System.out.println("Hello, World"); } }