diff --git a/Dockerfile b/Dockerfile index 67ecffee..089580af 100644 --- a/Dockerfile +++ b/Dockerfile @@ -78,7 +78,7 @@ ARG GLIBC_VERSION='2.31-r0' #################### # Run APK installs # #################### -RUN apk add --update --no-cache \ +RUN apk add --no-cache \ ansible-lint \ bash \ coreutils \ @@ -264,7 +264,7 @@ RUN printf '#!/bin/bash \n\nif [[ -x "$1" ]]; then exit 0; else echo "Error: Fil ################################################# # Basic setup, programs and init RUN echo "http://dl-cdn.alpinelinux.org/alpine/edge/testing/" >> /etc/apk/repositories \ - && apk add --update --no-cache rakudo zef + && apk add --no-cache rakudo zef ###################### # Install CheckStyle # diff --git a/README.md b/README.md index bdcedfc7..84fe50d3 100644 --- a/README.md +++ b/README.md @@ -209,7 +209,6 @@ But if you wish to select or exclude specific linters, we give you full control | **FILTER_REGEX_EXCLUDE** | `none` | Regular expression defining which files will be excluded from linting (ex: `.*src/test.*`) | | **FILTER_REGEX_INCLUDE** | `all` | Regular expression defining which files will be processed by linters (ex: `.*src/.*`) | | **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`) | -| **KUBERNETES_DIRECTORY** | `/kubernetes` | The path to the root directory for Kubernetes descriptors, relative to `DEFAULT_WORKSPACE`. | | **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`. | @@ -251,7 +250,7 @@ But if you wish to select or exclude specific linters, we give you full control | **VALIDATE_KUBERNETES_KUBEVAL** | `true` | Flag to enable or disable the linting process of Kubernetes descriptors with Kubeval | | **VALIDATE_LATEX** | `true` | Flag to enable or disable the linting process of the LaTeX 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_MARKDOWN** | `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. (Utilizing: PHP built-in linter) (keep for backward compatibility) | diff --git a/dependencies/Pipfile.lock b/dependencies/Pipfile.lock index 9f42cd9f..55bb1be7 100644 --- a/dependencies/Pipfile.lock +++ b/dependencies/Pipfile.lock @@ -18,9 +18,10 @@ "default": { "amply": { "hashes": [ - "sha256:6e5d53af62772790ba82a989a3de72b8ce5c1cd809613c06f7cb061f7ec34dc8" + "sha256:cb12dcb49d16b168c02be128a1527ecde50211e4bd94af76ff4e67707f5a2d38", + "sha256:f8a846a544750493f45e75e9b44c393144be5728701df4f596b1fa5595d263fd" ], - "version": "==0.1.2" + "version": "==0.1.4" }, "appdirs": { "hashes": [ @@ -68,17 +69,16 @@ }, "boto3": { "hashes": [ - "sha256:02f5f7a2b1349760b030c34f90a9cb4600bf8fe3cbc76b801d122bc4cecf3a7f", - "sha256:e0a1dbc0a0e460dc6de2f4144b5015edad3ab5c17ee83c6194b1a010d815bc60" + "sha256:329178bd505b5d1dbb5eab25e9697c0e592c45548c895f451a91772d0e5a9329" ], - "version": "==1.15.9" + "version": "==1.15.13" }, "botocore": { "hashes": [ - "sha256:35b06b8801eb2dd7e708de35581f9c0304740645874f3af5b8b0c1648f8d6365", - "sha256:dc3244170254cbba7dfde00b0489f830069d93dd6a9e555178d989072d7ee7c2" + "sha256:570609095c992732cf6158c3dd0a38619c77818fa700d6779b27277b34f98959", + "sha256:90e76683807896a28bbefd6e9bc3a2dc44ecd88fc6f6737fa0e3b20d5b7223ea" ], - "version": "==1.18.9" + "version": "==1.18.13" }, "certifi": { "hashes": [ @@ -89,11 +89,11 @@ }, "cfn-lint": { "hashes": [ - "sha256:0e219f5affa2ed24cd588faf599eeef1a2b32172572708a52dbba0ec5517cd9a", - "sha256:5178595b7ccbbafb8b2b6fe9d3bc6215007387145ddf29812ecee70bb8500801" + "sha256:2b47c74df569ffedd747dfc0535ce40db120d91584f02073a7bd6ab89b24fc97", + "sha256:38973fb861986270b9ecaa72aa65b26f21bf8c14c075a3dd8b584b2b3a164dad" ], "index": "pypi", - "version": "==0.37.0" + "version": "==0.37.1" }, "chardet": { "hashes": [ @@ -161,11 +161,11 @@ }, "flake8": { "hashes": [ - "sha256:15e351d19611c887e482fb960eae4d44845013cc142d42896e9862f775d8cf5c", - "sha256:f04b9fcbac03b0a3e58c0ab3a0ecc462e023a9faf046d57794184028123aa208" + "sha256:749dbbd6bfd0cf1318af27bf97a14e28e5ff548ef8e5b1566ccfb25a11e7c839", + "sha256:aadae8761ec651813c24be05c6f7b4680857ef6afaae4651a4eccaef97ce6c3b" ], "index": "pypi", - "version": "==3.8.3" + "version": "==3.8.4" }, "gitdb": { "hashes": [ @@ -399,12 +399,17 @@ "hashes": [ "sha256:088afc8c63e7bd187a3c70a94b9e50ab3f17e1d3f52a32750b5b77dbe99ef5ef", "sha256:1fe0a41437bbd06063aa184c34804efa886bcc128222e9916310c92cd54c3b4c", + "sha256:3d20024a70b97b4f9546696cbf2fd30bae5f42229fbddf8661261b1eaff0deb7", "sha256:41bb65f54bba392643557e617316d0d899ed5b4946dccee1cb6696152b29844b", "sha256:4318d56bccfe7d43e5addb272406ade7a2274da4b70eb15922a071c58ab0108c", "sha256:4707f3695b34335afdfb09be3802c87fa0bc27030471dbc082f815f23688bc63", + "sha256:49f23ebd5ac073765ecbcf046edc10d63dcab2f4ae2bce160982cb30df0c0302", "sha256:5533a959a1748a5c042a6da71fe9267a908e21eded7a4f373efd23a2cbdb0ecc", + "sha256:5d892a4f1c999834eaa3c32bc9e8b976c5825116cde553928c4c8e7e48ebda67", "sha256:5f18875ac23d9aa2f060838e8b79093e8bb2313dbaaa9f54c6d8e52a5df097be", "sha256:60b0e9e6dc45683e569ec37c55ac20c582973841927a85f2d8a7d20ee80216ab", + "sha256:816064fc915796ea1f26966163f6845de5af78923dfcecf6551e095f00983650", + "sha256:84cada8effefe9a9f53f9b0d2ba9b7b6f5edf8d2155f9fdbe34616e06ececf81", "sha256:84e9407db1b2eb368b7ecc283121b5e592c9aaedbe8c78b1a2f1102eb2e21d19", "sha256:8d69cef61fa50c8133382e61fd97439de1ae623fe943578e477e76a9d9471637", "sha256:9a02d0ae31d35e1ec12a4ea4d4cca990800f66a917d0fb997b20fbc13f5321fc", @@ -412,6 +417,7 @@ "sha256:a6f32aea4260dfe0e55dc9733ea162ea38f0ea86aa7d0f77b15beac5bf7b369d", "sha256:ae91972f8ac958039920ef6e8769277c084971a142ce2b660691793ae44aae6b", "sha256:c570f6fa14b9c4c8a4924aaad354652366577b4f98213cf76305067144f7b100", + "sha256:c9443124c67b1515e4fe0bb0aa18df640965e1030f468a2a5dc2589b26d130ad", "sha256:d23a18037313714fb3bb5a94434d3151ee4300bae631894b1ac08111abeaa4a3", "sha256:eaf548d117b6737df379fdd53bdde4f08870e66d7ea653e230477f071f861121", "sha256:ebbe29186a3d9b0c591e71b7393f1ae08c83cb2d8e517d2a822b8f7ec99dfd8b", @@ -451,19 +457,19 @@ }, "snakefmt": { "hashes": [ - "sha256:6569cf849719b5383261250cf0d82effe0bc57b58f412a196a5daeadfa201ed6", - "sha256:adb3c7a512e4ceff557057e25f87f4792436c17d24db7441722c3e153e89626c" + "sha256:632ec6d1765e0eb7e3c4569d6cc0086207dae92c06d7ab379ff55f2ccbb8c6fd", + "sha256:e0a5df6cacc37899a5ed47d9e7e0dc39921923cb3f247226d63437df980df95b" ], "index": "pypi", - "version": "==0.2.1" + "version": "==0.2.2" }, "snakemake": { "hashes": [ - "sha256:0ed361c00d2192dd0cb24b1d613456a2e0e65e6c8a6bca7b94d2f980dc5ba075", - "sha256:c6a8a66fe5ee04a074480844ff5ca5d0871143eaa2ad292ed2c7cdc73cdf8fb7" + "sha256:4290ee7bf3917440b098d0eae3bd9d74d92575d3bd47c96fadf14ca43ebd39aa", + "sha256:94cfed2f47f6441cca6cf9d53cffdc11eb78dd1758d96c0af9cd5e453247363e" ], "index": "pypi", - "version": "==5.26.0" + "version": "==5.26.1" }, "toml": { "hashes": [ @@ -560,10 +566,10 @@ }, "zipp": { "hashes": [ - "sha256:43f4fa8d8bb313e65d8323a3952ef8756bf40f9a5c3ea7334be23ee4ec8278b6", - "sha256:b52f22895f4cfce194bc8172f3819ee8de7540aa6d873535a8668b730b8b411f" + "sha256:64ad89efee774d1897a58607895d80789c59778ea02185dd846ac38394a8642b", + "sha256:eed8ec0b8d1416b2ca33516a37a08892442f3954dee131e92cfd92d8fe3e7066" ], - "version": "==3.2.0" + "version": "==3.3.0" } }, "develop": {} diff --git a/dependencies/package-lock.json b/dependencies/package-lock.json index ea3b4f63..c542f42b 100644 --- a/dependencies/package-lock.json +++ b/dependencies/package-lock.json @@ -2332,47 +2332,47 @@ } }, "eslint-plugin-jest": { - "version": "24.0.2", - "resolved": "https://registry.npmjs.org/eslint-plugin-jest/-/eslint-plugin-jest-24.0.2.tgz", - "integrity": "sha512-DSBLNpkKDOpUJQkTGSs5sVJWsu0nDyQ2rYxkr0Eh7nrkc5bMUr/dlDbtTj3l8y6UaCVsem6rryF1OZrKnz1S5g==", + "version": "24.1.0", + "resolved": "https://registry.npmjs.org/eslint-plugin-jest/-/eslint-plugin-jest-24.1.0.tgz", + "integrity": "sha512-827YJ+E8B9PvXu/0eiVSNFfxxndbKv+qE/3GSMhdorCaeaOehtqHGX2YDW9B85TEOre9n/zscledkFW/KbnyGg==", "requires": { "@typescript-eslint/experimental-utils": "^4.0.1" }, "dependencies": { "@typescript-eslint/experimental-utils": { - "version": "4.1.1", - "resolved": "https://registry.npmjs.org/@typescript-eslint/experimental-utils/-/experimental-utils-4.1.1.tgz", - "integrity": "sha512-jzYsNciHoa4Z3c1URtmeT/bamYm8Dwfw6vuN3WHIE/BXb1iC4KveAnXDErTAZtPVxTYBaYn3n2gbt6F6D2rm1A==", + "version": "4.4.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/experimental-utils/-/experimental-utils-4.4.0.tgz", + "integrity": "sha512-01+OtK/oWeSJTjQcyzDztfLF1YjvKpLFo+JZmurK/qjSRcyObpIecJ4rckDoRCSh5Etw+jKfdSzVEHevh9gJ1w==", "requires": { "@types/json-schema": "^7.0.3", - "@typescript-eslint/scope-manager": "4.1.1", - "@typescript-eslint/types": "4.1.1", - "@typescript-eslint/typescript-estree": "4.1.1", + "@typescript-eslint/scope-manager": "4.4.0", + "@typescript-eslint/types": "4.4.0", + "@typescript-eslint/typescript-estree": "4.4.0", "eslint-scope": "^5.0.0", "eslint-utils": "^2.0.0" } }, "@typescript-eslint/scope-manager": { - "version": "4.1.1", - "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-4.1.1.tgz", - "integrity": "sha512-0W8TTobCvIIQ2FsrYTffyZGAAFUyIbEHq5EYJb1m7Rpd005jrnOvKOo8ywCLhs/Bm17C+KsrUboBvBAARQVvyA==", + "version": "4.4.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-4.4.0.tgz", + "integrity": "sha512-r2FIeeU1lmW4K3CxgOAt8djI5c6Q/5ULAgdVo9AF3hPMpu0B14WznBAtxrmB/qFVbVIB6fSx2a+EVXuhSVMEyA==", "requires": { - "@typescript-eslint/types": "4.1.1", - "@typescript-eslint/visitor-keys": "4.1.1" + "@typescript-eslint/types": "4.4.0", + "@typescript-eslint/visitor-keys": "4.4.0" } }, "@typescript-eslint/types": { - "version": "4.1.1", - "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-4.1.1.tgz", - "integrity": "sha512-zrBiqOKYerMTllKcn+BP+i1b7LW/EbMMYytroXMxUTvFPn1smkCu0D7lSAx29fTUO4jnwV0ljSvYQtn2vNrNxA==" + "version": "4.4.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-4.4.0.tgz", + "integrity": "sha512-nU0VUpzanFw3jjX+50OTQy6MehVvf8pkqFcURPAE06xFNFenMj1GPEI6IESvp7UOHAnq+n/brMirZdR+7rCrlA==" }, "@typescript-eslint/typescript-estree": { - "version": "4.1.1", - "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-4.1.1.tgz", - "integrity": "sha512-2AUg5v0liVBsqbGxBphbJ0QbGqSRVaF5qPoTPWcxop+66vMdU1h4CCvHxTC47+Qb+Pr4l2RhXDd41JNpwcQEKw==", + "version": "4.4.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-4.4.0.tgz", + "integrity": "sha512-Fh85feshKXwki4nZ1uhCJHmqKJqCMba+8ZicQIhNi5d5jSQFteWiGeF96DTjO8br7fn+prTP+t3Cz/a/3yOKqw==", "requires": { - "@typescript-eslint/types": "4.1.1", - "@typescript-eslint/visitor-keys": "4.1.1", + "@typescript-eslint/types": "4.4.0", + "@typescript-eslint/visitor-keys": "4.4.0", "debug": "^4.1.1", "globby": "^11.0.1", "is-glob": "^4.0.1", @@ -2382,11 +2382,11 @@ } }, "@typescript-eslint/visitor-keys": { - "version": "4.1.1", - "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-4.1.1.tgz", - "integrity": "sha512-/EOOXbA2ferGLG6RmCHEQ0lTTLkOlXYDgblCmQk3tIU7mTPLm4gKhFMeeUSe+bcchTUsKeCk8xcpbop5Zr/8Rw==", + "version": "4.4.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-4.4.0.tgz", + "integrity": "sha512-oBWeroUZCVsHLiWRdcTXJB7s1nB3taFY8WGvS23tiAlT6jXVvsdAV4rs581bgdEjOhn43q6ro7NkOiLKu6kFqA==", "requires": { - "@typescript-eslint/types": "4.1.1", + "@typescript-eslint/types": "4.4.0", "eslint-visitor-keys": "^2.0.0" } }, @@ -3660,9 +3660,9 @@ "integrity": "sha1-HADHQ7QzzQpOgHWPe2SldEDZ/wA=" }, "linkify-it": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/linkify-it/-/linkify-it-2.2.0.tgz", - "integrity": "sha512-GnAl/knGn+i1U/wjBz3akz2stz+HrHLsxMwHQGofCDfPvlf+gDKN58UtfmUquTY4/MXeE2x7k19KQmeoZi94Iw==", + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/linkify-it/-/linkify-it-3.0.2.tgz", + "integrity": "sha512-gDBO4aHNZS6coiZCKVhSNh43F9ioIL4JwRjLZPkoLIY4yZFwg264Y5lu2x6rb1Js42Gh6Yqm2f6L2AJcnkzinQ==", "requires": { "uc.micro": "^1.0.1" } @@ -3738,13 +3738,13 @@ "integrity": "sha512-8z4efJYk43E0upd0NbVXwgSTQs6cT3T06etieCMEg7dRbzCbxUCK/GHlX8mhHRDcp+OLlHkPKsvqQTCvsRl2cg==" }, "markdown-it": { - "version": "10.0.0", - "resolved": "https://registry.npmjs.org/markdown-it/-/markdown-it-10.0.0.tgz", - "integrity": "sha512-YWOP1j7UbDNz+TumYP1kpwnP0aEa711cJjrAQrzd0UXlbJfc5aAq0F/PZHjiioqDC1NKgvIMX+o+9Bk7yuM2dg==", + "version": "11.0.0", + "resolved": "https://registry.npmjs.org/markdown-it/-/markdown-it-11.0.0.tgz", + "integrity": "sha512-+CvOnmbSubmQFSA9dKz1BRiaSMV7rhexl3sngKqFyXSagoA3fBdJQ8oZWtRy2knXdpDXaBw44euz37DeJQ9asg==", "requires": { "argparse": "^1.0.7", "entities": "~2.0.0", - "linkify-it": "^2.0.0", + "linkify-it": "^3.0.1", "mdurl": "^1.0.1", "uc.micro": "^1.0.5" } @@ -3758,17 +3758,17 @@ } }, "markdownlint": { - "version": "0.20.4", - "resolved": "https://registry.npmjs.org/markdownlint/-/markdownlint-0.20.4.tgz", - "integrity": "sha512-jpfaPgjT0OpeBbemjYNZbzGG3hCLcAIvrm/pEY3+q/szDScG6ZonDacqySVRJAv9glbo8y4wBPJ0wgW17+9GGA==", + "version": "0.21.0", + "resolved": "https://registry.npmjs.org/markdownlint/-/markdownlint-0.21.0.tgz", + "integrity": "sha512-rTxr0fbCFmS65oxXBD0HNy3/+PSukLS+b7Z6rGDWbjdRJp/e2dKj538r3KTn8oXrusx+ZtuYOozV2Knpnn0pkQ==", "requires": { - "markdown-it": "10.0.0" + "markdown-it": "11.0.0" } }, "markdownlint-cli": { - "version": "0.23.2", - "resolved": "https://registry.npmjs.org/markdownlint-cli/-/markdownlint-cli-0.23.2.tgz", - "integrity": "sha512-OSl5OZ8xzGN6z355cqRkiq67zPi3reJimklaF72p0554q85Dng5ToOjjSB9tDKZebSt85jX8cp+ruoQlPqOsPA==", + "version": "0.24.0", + "resolved": "https://registry.npmjs.org/markdownlint-cli/-/markdownlint-cli-0.24.0.tgz", + "integrity": "sha512-AusUxaX4sFayUBFTCKeHc8+fq73KFqIUW+ZZZYyQ/BvY0MoGAnE2C/3xiawSE7WXmpmguaWzhrXRuY6IrOLX7A==", "requires": { "commander": "~2.9.0", "deep-extend": "~0.5.1", @@ -3779,8 +3779,8 @@ "jsonc-parser": "~2.2.0", "lodash.differencewith": "~4.5.0", "lodash.flatten": "~4.4.0", - "markdownlint": "~0.20.4", - "markdownlint-rule-helpers": "~0.11.0", + "markdownlint": "~0.21.0", + "markdownlint-rule-helpers": "~0.12.0", "minimatch": "~3.0.4", "minimist": "~1.2.5", "rc": "~1.2.7" @@ -3816,9 +3816,9 @@ } }, "markdownlint-rule-helpers": { - "version": "0.11.0", - "resolved": "https://registry.npmjs.org/markdownlint-rule-helpers/-/markdownlint-rule-helpers-0.11.0.tgz", - "integrity": "sha512-PhGii9dOiDJDXxiRMpK8N0FM9powprvRPsXALgkjlSPTwLh6ymH+iF3iUe3nq8KGu26tclFBlLL5xAGy/zb7FA==" + "version": "0.12.0", + "resolved": "https://registry.npmjs.org/markdownlint-rule-helpers/-/markdownlint-rule-helpers-0.12.0.tgz", + "integrity": "sha512-Q7qfAk+AJvx82ZY52OByC4yjoQYryOZt6D8TKrZJIwCfhZvcj8vCQNuwDqILushtDBTvGFmUPq+uhOb1KIMi6A==" }, "mathml-tag-names": { "version": "2.1.3", diff --git a/dependencies/package.json b/dependencies/package.json index 4d73706b..f87fdf4e 100644 --- a/dependencies/package.json +++ b/dependencies/package.json @@ -11,11 +11,11 @@ "eslint": "^7.10.0", "eslint-config-airbnb": "^18.2.0", "eslint-config-prettier": "^6.12.0", - "eslint-plugin-jest": "^24.0.2", + "eslint-plugin-jest": "^24.1.0", "eslint-plugin-prettier": "^3.1.4", "htmlhint": "^0.14.1", "jsonlint": "^1.6.3", - "markdownlint-cli": "^0.23.2", + "markdownlint-cli": "^0.24.0", "npm-groovy-lint": "^7.6.3", "prettier": "^2.1.2", "prettyjson": "^1.2.1", diff --git a/lib/buildFileList.sh b/lib/buildFileList.sh index dcabd062..d2c3fbc8 100755 --- a/lib/buildFileList.sh +++ b/lib/buildFileList.sh @@ -10,48 +10,70 @@ ################################################################################ #### Function BuildFileList #################################################### function BuildFileList() { - # Need to build a list of all files changed - # This can be pulled from the GITHUB_EVENT_PATH payload + debug "Building file list..." ################ - # print header # + # Pull in vars # ################ - debug "----------------------------------------------" - debug "Pulling in code history and branches..." + VALIDATE_ALL_CODEBASE="${1}" + debug "Validate all code base: ${VALIDATE_ALL_CODEBASE}..." - ################################################################################# - # 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 - ) + if [ "${VALIDATE_ALL_CODEBASE}" == "false" ]; then + # Need to build a list of all files changed + # This can be pulled from the GITHUB_EVENT_PATH payload - ####################### - # Load the error code # - ####################### - ERROR_CODE=$? + ################ + # print header # + ################ + debug "----------------------------------------------" + debug "Pulling in code history and branches..." - ############################## - # 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}]" + ################################################################################# + # 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=$? + + ############################## + # 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) + else + ################ + # print header # + ################ + debug "----------------------------------------------" + debug "Populating the file list with all the files in the ${GITHUB_WORKSPACE} workspace" + mapfile -t RAW_FILE_ARRAY < <(find "${GITHUB_WORKSPACE}" \ + -path "*/node_modules" -prune -o \ + -path "*/.git" -prune -o \ + -path "*/.venv" -prune -o \ + -path "*/.rbenv" -prune -o \ + -type f 2>&1) 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 # ####################### @@ -69,24 +91,22 @@ function BuildFileList() { ################################################ # Iterate through the array of all files found # ################################################ - info "----------------------------------------------" - info "------ Files modified in the commit(s): ------" - info "----------------------------------------------" + info "---------------------------------" + info "------ File list to check: ------" + info "---------------------------------" for FILE in "${RAW_FILE_ARRAY[@]}"; do # Extract just the file extension FILE_TYPE="$(GetFileExtension "$FILE")" - # get the baseFile for additonal logic + # get the baseFile for additonal logic, lowercase BASE_FILE=$(basename "${FILE,,}") ############## # Print file # ############## - info "File:[${FILE}], File_type:[${FILE_TYPE}], Base_file:[${BASE_FILE}]" + debug "File:[${FILE}], File_type:[${FILE_TYPE}], Base_file:[${BASE_FILE}]" - ######### - # DEBUG # - ######### - debug "FILE_TYPE:[${FILE_TYPE}]" + # Editorconfig-checker should check every file + FILE_ARRAY_EDITORCONFIG+=("${FILE}") ###################### # Get the shell files # @@ -96,6 +116,8 @@ function BuildFileList() { # Append the file to the array # ################################ FILE_ARRAY_BASH+=("${FILE}") + FILE_ARRAY_BASH_EXEC+=("${FILE}") + FILE_ARRAY_SHELL_SHFMT+=("${FILE}") ######################### # Get the CLOJURE files # @@ -147,11 +169,13 @@ function BuildFileList() { ######################## # Get the DOCKER files # ######################## - elif [ "${FILE_TYPE}" == "dockerfile" ] || [[ "${BASE_FILE}" == *"dockerfile."* ]]; then + # Use BASE_FILE here because FILE_TYPE is not reliable when there is no file extension + elif [[ "${FILE_TYPE}" != "dockerfilelintrc" ]] && [[ "${BASE_FILE}" == *"dockerfile"* ]]; then ################################ # Append the file to the array # ################################ - FILE_ARRAY_DOCKER+=("${FILE}") + FILE_ARRAY_DOCKERFILE+=("${FILE}") + FILE_ARRAY_DOCKERFILE_HADOLINT+=("${FILE}") ##################### # Get the ENV files # @@ -325,7 +349,13 @@ function BuildFileList() { ############################ # Get the Powershell files # ############################ - elif [ "${FILE_TYPE}" == "ps1" ]; then + elif [ "${FILE_TYPE}" == "ps1" ] || + [ "${FILE_TYPE}" == "psm1" ] || + [ "${FILE_TYPE}" == "psd1" ] || + [ "${FILE_TYPE}" == "ps1xml" ] || + [ "${FILE_TYPE}" == "pssc" ] || + [ "${FILE_TYPE}" == "psrc" ] || + [ "${FILE_TYPE}" == "cdxml" ]; then ################################ # Append the file to the array # ################################ @@ -347,6 +377,7 @@ function BuildFileList() { ################################ # Append the file to the array # ################################ + FILE_ARRAY_PYTHON_BLACK+=("${FILE}") FILE_ARRAY_PYTHON_PYLINT+=("${FILE}") FILE_ARRAY_PYTHON_FLAKE8+=("${FILE}") @@ -382,11 +413,12 @@ function BuildFileList() { ########################### # Get the SNAKEMAKE files # ########################### - elif [ "${FILE_TYPE}" == "smk" ] || [ "${BASE_FILE}" == "Snakefile" ]; then + elif [ "${FILE_TYPE}" == "smk" ] || [ "${BASE_FILE}" == "snakefile" ]; then ################################ # Append the file to the array # ################################ - FILE_ARRAY_SNAKEMAKE+=("${FILE}") + FILE_ARRAY_SNAKEMAKE_LINT+=("${FILE}") + FILE_ARRAY_SNAKEMAKE_SNAKEFMT+=("${FILE}") ##################### # Get the SQL files # @@ -461,9 +493,8 @@ function BuildFileList() { ################################ # Append the file to the array # ################################ - FILE_ARRAY_KUBERNETES+=("${FILE}") + FILE_ARRAY_KUBERNETES_KUBEVAL+=("${FILE}") fi - ######################################################################## # We have something that we need to try to check file type another way # ######################################################################## @@ -475,23 +506,25 @@ function BuildFileList() { fi done - ######################################### - # Need to switch back to branch of code # - ######################################### - SWITCH2_CMD=$(git -C "${GITHUB_WORKSPACE}" checkout --progress --force "${GITHUB_SHA}" 2>&1) + if [ "${VALIDATE_ALL_CODEBASE}" == "false" ]; then + ######################################### + # 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=$? + ####################### + # 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}]" + ############################## + # Check the shell for errors # + ############################## + if [ ${ERROR_CODE} -ne 0 ]; then + # Error + error "Failed to switch back to branch!" + fatal "[${SWITCH2_CMD}]" + fi fi ################ @@ -534,15 +567,7 @@ function CheckFileType() { ################# GET_FILE_TYPE_CMD="$(GetFileType "$FILE")" - ################# - # Check if bash # - ################# - if IsValidShellScript "$FILE"; then - ################################ - # Append the file to the array # - ################################ - FILE_ARRAY_BASH+=("${FILE}") - elif [[ ${GET_FILE_TYPE_CMD} == *"Ruby script"* ]]; then + if [[ ${GET_FILE_TYPE_CMD} == *"Ruby script"* ]]; then ####################### # It is a Ruby script # ####################### @@ -619,31 +644,3 @@ function IsValidShellScript() { trace "$FILE is NOT a supported shell script. Skipping" return 1 } -################################################################################ -#### Function IsValidShellScript ############################################### -function PopulateShellScriptsList() { - debug "Populating shell script file list. Source: ${GITHUB_WORKSPACE}" - - ############################################################################### - # Set the file seperator to newline to allow for grabbing objects with spaces # - ############################################################################### - IFS=$'\n' - - mapfile -t LIST_FILES < <(find "${GITHUB_WORKSPACE}" \ - -path "*/node_modules" -prune -o \ - -path "*/.git" -prune -o \ - -path "*/.venv" -prune -o \ - -path "*/.rbenv" -prune -o \ - -type f 2>&1) - for FILE in "${LIST_FILES[@]}"; do - if IsValidShellScript "${FILE}"; then - debug "Adding ${FILE} to shell script files list" - FILE_ARRAY_BASH+=("${FILE}") - fi - done - - ########################### - # Set IFS back to default # - ########################### - IFS="${DEFAULT_IFS}" -} diff --git a/lib/linter.sh b/lib/linter.sh index 7f25dcbf..38d4f361 100755 --- a/lib/linter.sh +++ b/lib/linter.sh @@ -191,7 +191,6 @@ GITHUB_RUN_ID="${GITHUB_RUN_ID}" # GitHub RU GITHUB_SHA="${GITHUB_SHA}" # GitHub sha from the commit GITHUB_TOKEN="${GITHUB_TOKEN}" # GitHub Token passed from environment GITHUB_WORKSPACE="${GITHUB_WORKSPACE}" # Github Workspace -KUBERNETES_DIRECTORY="${KUBERNETES_DIRECTORY}" # Kubernetes directory 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 @@ -203,7 +202,6 @@ DEFAULT_VALIDATE_ALL_CODEBASE='true' # Default value for validate 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 # @@ -229,52 +227,11 @@ OUTPUT_DETAILS="${OUTPUT_DETAILS:-simpler}" # What level of deta ########################## # Array of changed files # ########################## -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_CLOJURE=() # Array of files to check -FILE_ARRAY_COFFEESCRIPT=() # Array of files to check -FILE_ARRAY_CSHARP=() # Array of files to check -FILE_ARRAY_CSS=() # Array of files to check -FILE_ARRAY_DART=() # Array of files to check -FILE_ARRAY_DOCKERFILE=() # Array of files to check -FILE_ARRAY_ENV=() # Array of files to check -FILE_ARRAY_GO=() # Array of files to check -FILE_ARRAY_GROOVY=() # Array of files to check -FILE_ARRAY_HTML=() # Array of files to check -FILE_ARRAY_JAVA=() # Array of files to check -FILE_ARRAY_JAVASCRIPT_ES=() # Array of files to check -FILE_ARRAY_JAVASCRIPT_STANDARD=() # Array of files to check -FILE_ARRAY_JSON=() # Array of files to check -FILE_ARRAY_JSX=() # Array of files to check -FILE_ARRAY_KUBERNETES=() -FILE_ARRAY_KOTLIN=() # Array of files to check -FILE_ARRAY_LATEX=() # 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 -FILE_ARRAY_PHP_BUILTIN=() # Array of files to check -FILE_ARRAY_PHP_PHPCS=() # Array of files to check -FILE_ARRAY_PHP_PHPSTAN=() # 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_BLACK=() # 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_R=() # Array of files to check -FILE_ARRAY_RAKU=() # Array of files to check -FILE_ARRAY_RUBY=() # Array of files to check -FILE_ARRAY_SNAKEMAKE=() # Array of files to check -FILE_ARRAY_STATES=() # Array of files to check -FILE_ARRAY_SQL=() # 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 -FILE_ARRAY_TYPESCRIPT_STANDARD=() # Array of files to check -FILE_ARRAY_XML=() # Array of files to check -FILE_ARRAY_YAML=() # Array of files to check +for LANGUAGE in "${LANGUAGE_ARRAY[@]}"; do + FILE_ARRAY_VARIABLE_NAME="FILE_ARRAY_${LANGUAGE}" + debug "Setting ${FILE_ARRAY_VARIABLE_NAME} variable..." + eval "${FILE_ARRAY_VARIABLE_NAME}=()" +done ################################################################################ ########################## FUNCTIONS BELOW ##################################### @@ -354,6 +311,14 @@ GetLinterRules() { LANGUAGE_LINTER_RULES="${LANGUAGE_NAME}_LINTER_RULES" debug "Variable names for language file name: ${LANGUAGE_FILE_NAME}, language linter rules: ${LANGUAGE_LINTER_RULES}" + ##################################################### + # Check if the language rules variables are defined # + ##################################################### + if [ -z "${!LANGUAGE_FILE_NAME+x}" ]; then + debug "${LANGUAGE_FILE_NAME} is not set. Skipping loading rules for ${LANGUAGE_NAME}..." + return + fi + ########################## # Get the file extension # ########################## @@ -615,7 +580,7 @@ DetectAWSStatesFIle() { ############################### # check if file has resources # ############################### - if grep '"Resource": *"arn"*' "${FILE}"; then + if grep -q '"Resource": *"arn"*' "${FILE}"; then # Found it return 0 fi @@ -1091,8 +1056,6 @@ GetGitHubVars ######################################################## DEFAULT_ANSIBLE_DIRECTORY="${GITHUB_WORKSPACE}/ansible" # Default Ansible Directory export DEFAULT_ANSIBLE_DIRECTORY # Workaround SC2034 -DEFAULT_KUBERNETES_DIRECTORY="${GITHUB_WORKSPACE}/kubernetes" # Default Kubernetes Directory -export DEFAULT_KUBERNETES_DIRECTORY # Workaround SC2034 REPORT_OUTPUT_FOLDER="${GITHUB_WORKSPACE}/${OUTPUT_FOLDER}" # Location for the report folder ######################################### @@ -1103,70 +1066,10 @@ GetValidationInfo ######################## # Get the linter rules # ######################## -# Get Ansible rules -GetLinterRules "ANSIBLE" -# Get ARM rules -GetLinterRules "ARM" -# Get CLOUDFORMATION rules -GetLinterRules "CLOUDFORMATION" -# Get Coffeescript rules -GetLinterRules "COFFEESCRIPT" -# Get CSS rules -GetLinterRules "CSS" -# Get DART rules -GetLinterRules "DART" -# Get Docker rules -GetLinterRules "DOCKERFILE" -# Get Docker rules -GetLinterRules "DOCKERFILE_HADOLINT" -# Get Golang rules -GetLinterRules "GO" -# Get Groovy rules -GetLinterRules "GROOVY" -# Get HTML rules -GetLinterRules "HTML" -# get Java rules -GetLinterRules "JAVA" -# Get JavaScript rules -GetLinterRules "JAVASCRIPT" -# Get LATEX rules -GetLinterRules "LATEX" -# Get LUA rules -GetLinterRules "LUA" -# Get Markdown rules -GetLinterRules "MARKDOWN" -# Get PHPCS rules -GetLinterRules "PHP_PHPCS" -# Get PHP_PHPSTAN rules -GetLinterRules "PHP_PHPSTAN" -# Get PHP_PSALM rules -GetLinterRules "PHP_PSALM" -# Get PowerShell rules -GetLinterRules "POWERSHELL" -# Get Protobuff linter rules -GetLinterRules "PROTOBUF" -# Get Python pylint rules -GetLinterRules "PYTHON_PYLINT" -# Get Python flake8 rules -GetLinterRules "PYTHON_FLAKE8" -# Get Python black rules -GetLinterRules "PYTHON_BLACK" -# Get R rules -GetLinterRules "R" -# Get Ruby rules -GetLinterRules "RUBY" -# Get Snakemake lint rules -GetLinterRules "SNAKEMAKE_LINT" -# Get Snakemake snakefmt rules -GetLinterRules "SNAKEMAKE_SNAKEFMT" -# Get SQL rules -GetLinterRules "SQL" -# Get Terraform rules -GetLinterRules "TERRAFORM" -# Get TypeScript rules -GetLinterRules "TYPESCRIPT" -# Get YAML rules -GetLinterRules "YAML" +for LANGUAGE in "${LANGUAGE_ARRAY[@]}"; do + debug "Loading rules for ${LANGUAGE}..." + eval "GetLinterRules ${LANGUAGE}" +done ################################## # Get and print all version info # @@ -1190,15 +1093,10 @@ if [[ ${TEST_CASE_RUN} != "false" ]]; then RunTestCases fi -############################################# -# check flag for validation of all codebase # -############################################# -if [ "${VALIDATE_ALL_CODEBASE}" == "false" ]; then - ######################################## - # Get list of files changed if env set # - ######################################## - BuildFileList -fi +########################################### +# Build the list of files for each linter # +########################################### +BuildFileList "${VALIDATE_ALL_CODEBASE}" ################### # ANSIBLE LINTING # @@ -1217,31 +1115,10 @@ 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}" -path "*/node_modules" -prune -o -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" "FILTER_REGEX_INCLUDE" "FILTER_REGEX_EXCLUDE" "FILE_ARRAY" - LintCodebase "ARM" "arm-ttk" "Import-Module ${ARM_TTK_PSD1} ; \${config} = \$(Import-PowerShellDataFile -Path ${ARM_LINTER_RULES}) ; Test-AzTemplate @config -TemplatePath" "disabledfileext" "${FILTER_REGEX_INCLUDE}" "${FILTER_REGEX_EXCLUDE}" "${FILE_ARRAY_ARM[@]}" + LintCodebase "ARM" "arm-ttk" "Import-Module ${ARM_TTK_PSD1} ; \${config} = \$(Import-PowerShellDataFile -Path ${ARM_LINTER_RULES}) ; Test-AzTemplate @config -TemplatePath" "${FILTER_REGEX_INCLUDE}" "${FILTER_REGEX_EXCLUDE}" "${FILE_ARRAY_ARM[@]}" fi ################ @@ -1251,8 +1128,7 @@ if [ "${VALIDATE_BASH}" == "true" ]; then ####################### # Lint the bash files # ####################### - # LintCodebase "FILE_TYPE" "LINTER_NAME" "LINTER_CMD" "FILE_TYPES_REGEX" "FILTER_REGEX_INCLUDE" "FILTER_REGEX_EXCLUDE" "FILE_ARRAY" - LintCodebase "BASH" "shellcheck" "shellcheck --color --external-sources" "disabledfileext" "${FILTER_REGEX_INCLUDE}" "${FILTER_REGEX_EXCLUDE}" "${FILE_ARRAY_BASH[@]}" + LintCodebase "BASH" "shellcheck" "shellcheck --color --external-sources" "${FILTER_REGEX_INCLUDE}" "${FILTER_REGEX_EXCLUDE}" "${FILE_ARRAY_BASH[@]}" fi ##################### @@ -1262,39 +1138,17 @@ if [ "${VALIDATE_BASH_EXEC}" == "true" ]; then ####################### # Lint the bash files # ####################### - # LintCodebase "FILE_TYPE" "LINTER_NAME" "LINTER_CMD" "FILE_TYPES_REGEX" "FILTER_REGEX_INCLUDE" "FILTER_REGEX_EXCLUDE" "FILE_ARRAY" - LintCodebase "BASH_EXEC" "bash-exec" "bash-exec" "disabledfileext" "${FILTER_REGEX_INCLUDE}" "${FILTER_REGEX_EXCLUDE}" "${FILE_ARRAY_BASH[@]}" + LintCodebase "BASH_EXEC" "bash-exec" "bash-exec" "${FILTER_REGEX_INCLUDE}" "${FILTER_REGEX_EXCLUDE}" "${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' - - mapfile -t LIST_FILES < <(find "${GITHUB_WORKSPACE}" -path "*/node_modules" -prune -o -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 - ################################# # Lint the CloudFormation files # ################################# - # LintCodebase "FILE_TYPE" "LINTER_NAME" "LINTER_CMD" "FILE_TYPES_REGEX" "FILTER_REGEX_INCLUDE" "FILTER_REGEX_EXCLUDE" "FILE_ARRAY" - LintCodebase "CLOUDFORMATION" "cfn-lint" "cfn-lint --config-file ${CLOUDFORMATION_LINTER_RULES}" "disabledfileext" "${FILTER_REGEX_INCLUDE}" "${FILTER_REGEX_EXCLUDE}" "${FILE_ARRAY_CLOUDFORMATION[@]}" + LintCodebase "CLOUDFORMATION" "cfn-lint" "cfn-lint --config-file ${CLOUDFORMATION_LINTER_RULES}" "${FILTER_REGEX_INCLUDE}" "${FILTER_REGEX_EXCLUDE}" "${FILE_ARRAY_CLOUDFORMATION[@]}" fi ################### @@ -1308,7 +1162,7 @@ if [ "${VALIDATE_CLOJURE}" == "true" ]; then ######################### # Lint the Clojure files # ######################### - LintCodebase "CLOJURE" "clj-kondo" "clj-kondo --config ${CLOJURE_LINTER_RULES} --lint" ".*\.\(clj\|cljs\|cljc\|edn\)\$" "${FILTER_REGEX_INCLUDE}" "${FILTER_REGEX_EXCLUDE}" "${FILE_ARRAY_CLOJURE[@]}" + LintCodebase "CLOJURE" "clj-kondo" "clj-kondo --config ${CLOJURE_LINTER_RULES} --lint" "${FILTER_REGEX_INCLUDE}" "${FILTER_REGEX_EXCLUDE}" "${FILE_ARRAY_CLOJURE[@]}" fi ######################## @@ -1318,8 +1172,7 @@ if [ "${VALIDATE_COFFEE}" == "true" ]; then ######################### # Lint the coffee files # ######################### - # LintCodebase "FILE_TYPE" "LINTER_NAME" "LINTER_CMD" "FILE_TYPES_REGEX" "FILTER_REGEX_INCLUDE" "FILTER_REGEX_EXCLUDE" "FILE_ARRAY" - LintCodebase "COFFEESCRIPT" "coffeelint" "coffeelint -f ${COFFEESCRIPT_LINTER_RULES}" ".*\.\(coffee\)\$" "${FILTER_REGEX_INCLUDE}" "${FILTER_REGEX_EXCLUDE}" "${FILE_ARRAY_COFFEESCRIPT[@]}" + LintCodebase "COFFEESCRIPT" "coffeelint" "coffeelint -f ${COFFEESCRIPT_LINTER_RULES}" "${FILTER_REGEX_INCLUDE}" "${FILTER_REGEX_EXCLUDE}" "${FILE_ARRAY_COFFEESCRIPT[@]}" fi ################## @@ -1329,8 +1182,7 @@ if [ "${VALIDATE_CSHARP}" == "true" ]; then ######################### # Lint the C# files # ######################### - # LintCodebase "FILE_TYPE" "LINTER_NAME" "LINTER_CMD" "FILE_TYPES_REGEX" "FILTER_REGEX_INCLUDE" "FILTER_REGEX_EXCLUDE" "FILE_ARRAY" - LintCodebase "CSHARP" "dotnet-format" "dotnet-format --folder --check --exclude / --include" ".*\.\(cs\)\$" "${FILTER_REGEX_INCLUDE}" "${FILTER_REGEX_EXCLUDE}" "${FILE_ARRAY_CSHARP[@]}" + LintCodebase "CSHARP" "dotnet-format" "dotnet-format --folder --check --exclude / --include" "${FILTER_REGEX_INCLUDE}" "${FILTER_REGEX_EXCLUDE}" "${FILE_ARRAY_CSHARP[@]}" fi ############### @@ -1344,7 +1196,7 @@ if [ "${VALIDATE_CSS}" == "true" ]; then ############################# # Lint the CSS files # ############################# - LintCodebase "CSS" "stylelint" "stylelint --config ${CSS_LINTER_RULES}" ".*\.\(css\|scss\|sass\)\$" "${FILTER_REGEX_INCLUDE}" "${FILTER_REGEX_EXCLUDE}" "${FILE_ARRAY_CSS[@]}" + LintCodebase "CSS" "stylelint" "stylelint --config ${CSS_LINTER_RULES}" "${FILTER_REGEX_INCLUDE}" "${FILTER_REGEX_EXCLUDE}" "${FILE_ARRAY_CSS[@]}" fi ################ @@ -1354,8 +1206,7 @@ if [ "${VALIDATE_DART}" == "true" ]; then ####################### # Lint the Dart files # ####################### - # LintCodebase "FILE_TYPE" "LINTER_NAME" "LINTER_CMD" "FILE_TYPES_REGEX" "FILTER_REGEX_INCLUDE" "FILTER_REGEX_EXCLUDE" "FILE_ARRAY" - LintCodebase "DART" "dart" "dartanalyzer --fatal-infos --fatal-warnings --options ${DART_LINTER_RULES}" ".*\.\(dart\)\$" "${FILTER_REGEX_INCLUDE}" "${FILTER_REGEX_EXCLUDE}" "${FILE_ARRAY_DART[@]}" + LintCodebase "DART" "dart" "dartanalyzer --fatal-infos --fatal-warnings --options ${DART_LINTER_RULES}" "${FILTER_REGEX_INCLUDE}" "${FILTER_REGEX_EXCLUDE}" "${FILE_ARRAY_DART[@]}" fi ################## @@ -1365,9 +1216,8 @@ if [ "${VALIDATE_DOCKERFILE}" == "true" ]; then ######################### # Lint the docker files # ######################### - # LintCodebase "FILE_TYPE" "LINTER_NAME" "LINTER_CMD" "FILE_TYPES_REGEX" "FILTER_REGEX_INCLUDE" "FILTER_REGEX_EXCLUDE" "FILE_ARRAY" # NOTE: dockerfilelint's "-c" option expects the folder *containing* the DOCKER_LINTER_RULES file - LintCodebase "DOCKERFILE" "dockerfilelint" "dockerfilelint -c $(dirname ${DOCKERFILE_LINTER_RULES})" ".*\(Dockerfile\)\$" "${FILTER_REGEX_INCLUDE}" "${FILTER_REGEX_EXCLUDE}" "${FILE_ARRAY_DOCKERFILE[@]}" + LintCodebase "DOCKERFILE" "dockerfilelint" "dockerfilelint -c $(dirname ${DOCKERFILE_LINTER_RULES})" "${FILTER_REGEX_INCLUDE}" "${FILTER_REGEX_EXCLUDE}" "${FILE_ARRAY_DOCKERFILE[@]}" fi ########################### @@ -1377,8 +1227,7 @@ if [ "${VALIDATE_DOCKERFILE_HADOLINT}" == "true" ]; then ######################### # Lint the docker files # ######################### - # LintCodebase "FILE_TYPE" "LINTER_NAME" "LINTER_CMD" "FILE_TYPES_REGEX" "FILTER_REGEX_INCLUDE" "FILTER_REGEX_EXCLUDE" "FILE_ARRAY" - LintCodebase "DOCKERFILE_HADOLINT" "hadolint" "hadolint -c ${DOCKERFILE_HADOLINT_LINTER_RULES}" ".*\(Dockerfile\)\$" "${FILTER_REGEX_INCLUDE}" "${FILTER_REGEX_EXCLUDE}" "${FILE_ARRAY_DOCKERFILE[@]}" + LintCodebase "DOCKERFILE_HADOLINT" "hadolint" "hadolint -c ${DOCKERFILE_HADOLINT_LINTER_RULES}" "${FILTER_REGEX_INCLUDE}" "${FILTER_REGEX_EXCLUDE}" "${FILE_ARRAY_DOCKERFILE_HADOLINT[@]}" fi ######################## @@ -1388,8 +1237,7 @@ if [ "${VALIDATE_EDITORCONFIG}" == "true" ]; then #################################### # Lint the files with editorconfig # #################################### - # LintCodebase "FILE_TYPE" "LINTER_NAME" "LINTER_CMD" "FILE_TYPES_REGEX" "FILTER_REGEX_INCLUDE" "FILTER_REGEX_EXCLUDE" "FILE_ARRAY" - LintCodebase "EDITORCONFIG" "editorconfig-checker" "editorconfig-checker" "^.*$" "${FILTER_REGEX_INCLUDE}" "${FILTER_REGEX_EXCLUDE}" "${RAW_FILE_ARRAY[@]}" + LintCodebase "EDITORCONFIG" "editorconfig-checker" "editorconfig-checker" "${FILTER_REGEX_INCLUDE}" "${FILTER_REGEX_EXCLUDE}" "${FILE_ARRAY_EDITORCONFIG[@]}" fi ############### @@ -1399,8 +1247,7 @@ if [ "${VALIDATE_ENV}" == "true" ]; then ####################### # Lint the env files # ####################### - # LintCodebase "FILE_TYPE" "LINTER_NAME" "LINTER_CMD" "FILE_TYPES_REGEX" "FILTER_REGEX_INCLUDE" "FILTER_REGEX_EXCLUDE" "FILE_ARRAY" - LintCodebase "ENV" "dotenv-linter" "dotenv-linter" ".*\.\(env\).*\$" "${FILTER_REGEX_INCLUDE}" "${FILTER_REGEX_EXCLUDE}" "${FILE_ARRAY_ENV[@]}" + LintCodebase "ENV" "dotenv-linter" "dotenv-linter" "${FILTER_REGEX_INCLUDE}" "${FILTER_REGEX_EXCLUDE}" "${FILE_ARRAY_ENV[@]}" fi ################## @@ -1410,8 +1257,7 @@ if [ "${VALIDATE_GO}" == "true" ]; then ######################### # Lint the golang files # ######################### - # LintCodebase "FILE_TYPE" "LINTER_NAME" "LINTER_CMD" "FILE_TYPES_REGEX" "FILTER_REGEX_INCLUDE" "FILTER_REGEX_EXCLUDE" "FILE_ARRAY" - LintCodebase "GO" "golangci-lint" "golangci-lint run -c ${GO_LINTER_RULES}" ".*\.\(go\)\$" "${FILTER_REGEX_INCLUDE}" "${FILTER_REGEX_EXCLUDE}" "${FILE_ARRAY_GO[@]}" + LintCodebase "GO" "golangci-lint" "golangci-lint run -c ${GO_LINTER_RULES}" "${FILTER_REGEX_INCLUDE}" "${FILTER_REGEX_EXCLUDE}" "${FILE_ARRAY_GO[@]}" fi ################## @@ -1421,8 +1267,7 @@ if [ "$VALIDATE_GROOVY" == "true" ]; then ######################### # Lint the groovy files # ######################### - # LintCodebase "FILE_TYPE" "LINTER_NAME" "LINTER_CMD" "FILE_TYPES_REGEX" "FILTER_REGEX_INCLUDE" "FILTER_REGEX_EXCLUDE" "FILE_ARRAY" - LintCodebase "GROOVY" "npm-groovy-lint" "npm-groovy-lint -c $GROOVY_LINTER_RULES --failon warning" ".*\.\(groovy\|jenkinsfile\|gradle\|nf\)\$" "${FILTER_REGEX_INCLUDE}" "${FILTER_REGEX_EXCLUDE}" "${FILE_ARRAY_GROOVY[@]}" + LintCodebase "GROOVY" "npm-groovy-lint" "npm-groovy-lint -c $GROOVY_LINTER_RULES --failon warning" "${FILTER_REGEX_INCLUDE}" "${FILTER_REGEX_EXCLUDE}" "${FILE_ARRAY_GROOVY[@]}" fi ################ @@ -1436,7 +1281,7 @@ if [ "${VALIDATE_HTML}" == "true" ]; then ####################### # Lint the HTML files # ####################### - LintCodebase "HTML" "htmlhint" "htmlhint --config ${HTML_LINTER_RULES}" ".*\.\(html\)\$" "${FILTER_REGEX_INCLUDE}" "${FILTER_REGEX_EXCLUDE}" "${FILE_ARRAY_HTML[@]}" + LintCodebase "HTML" "htmlhint" "htmlhint --config ${HTML_LINTER_RULES}" "${FILTER_REGEX_INCLUDE}" "${FILTER_REGEX_EXCLUDE}" "${FILE_ARRAY_HTML[@]}" fi ################ @@ -1446,8 +1291,7 @@ if [ "$VALIDATE_JAVA" == "true" ]; then ####################### # Lint the JAVA files # ####################### - # LintCodebase "FILE_TYPE" "LINTER_NAME" "LINTER_CMD" "FILE_TYPES_REGEX" "FILTER_REGEX_INCLUDE" "FILTER_REGEX_EXCLUDE" "FILE_ARRAY" - LintCodebase "JAVA" "checkstyle" "java -jar /usr/bin/checkstyle -c ${JAVA_LINTER_RULES}" ".*\.\(java\)\$" "${FILTER_REGEX_INCLUDE}" "${FILTER_REGEX_EXCLUDE}" "${FILE_ARRAY_JAVA[@]}" + LintCodebase "JAVA" "checkstyle" "java -jar /usr/bin/checkstyle -c ${JAVA_LINTER_RULES}" "${FILTER_REGEX_INCLUDE}" "${FILTER_REGEX_EXCLUDE}" "${FILE_ARRAY_JAVA[@]}" fi ###################### @@ -1457,8 +1301,7 @@ if [ "${VALIDATE_JAVASCRIPT_ES}" == "true" ]; then ############################# # Lint the Javascript files # ############################# - # LintCodebase "FILE_TYPE" "LINTER_NAME" "LINTER_CMD" "FILE_TYPES_REGEX" "FILTER_REGEX_INCLUDE" "FILTER_REGEX_EXCLUDE" "FILE_ARRAY" - LintCodebase "JAVASCRIPT_ES" "eslint" "eslint --no-eslintrc -c ${JAVASCRIPT_LINTER_RULES}" ".*\.\(js\)\$" "${FILTER_REGEX_INCLUDE}" "${FILTER_REGEX_EXCLUDE}" "${FILE_ARRAY_JAVASCRIPT_ES[@]}" + LintCodebase "JAVASCRIPT_ES" "eslint" "eslint --no-eslintrc -c ${JAVASCRIPT_LINTER_RULES}" "${FILTER_REGEX_INCLUDE}" "${FILTER_REGEX_EXCLUDE}" "${FILE_ARRAY_JAVASCRIPT_ES[@]}" fi ###################### @@ -1472,8 +1315,7 @@ if [ "${VALIDATE_JAVASCRIPT_STANDARD}" == "true" ]; then ############################# # Lint the Javascript files # ############################# - # LintCodebase "FILE_TYPE" "LINTER_NAME" "LINTER_CMD" "FILE_TYPES_REGEX" "FILTER_REGEX_INCLUDE" "FILTER_REGEX_EXCLUDE" "FILE_ARRAY" - LintCodebase "JAVASCRIPT_STANDARD" "standard" "standard ${JAVASCRIPT_STANDARD_LINTER_RULES}" ".*\.\(js\)\$" "${FILTER_REGEX_INCLUDE}" "${FILTER_REGEX_EXCLUDE}" "${FILE_ARRAY_JAVASCRIPT_STANDARD[@]}" + LintCodebase "JAVASCRIPT_STANDARD" "standard" "standard ${JAVASCRIPT_STANDARD_LINTER_RULES}" "${FILTER_REGEX_INCLUDE}" "${FILTER_REGEX_EXCLUDE}" "${FILE_ARRAY_JAVASCRIPT_STANDARD[@]}" fi ################ @@ -1483,8 +1325,7 @@ if [ "${VALIDATE_JSON}" == "true" ]; then ####################### # Lint the json files # ####################### - # LintCodebase "FILE_TYPE" "LINTER_NAME" "LINTER_CMD" "FILE_TYPES_REGEX" "FILTER_REGEX_INCLUDE" "FILTER_REGEX_EXCLUDE" "FILE_ARRAY" - LintCodebase "JSON" "jsonlint" "jsonlint" ".*\.\(json\)\$" "${FILTER_REGEX_INCLUDE}" "${FILTER_REGEX_EXCLUDE}" "${FILE_ARRAY_JSON[@]}" + LintCodebase "JSON" "jsonlint" "jsonlint" "${FILTER_REGEX_INCLUDE}" "${FILTER_REGEX_EXCLUDE}" "${FILE_ARRAY_JSON[@]}" fi ############### @@ -1494,50 +1335,24 @@ if [ "${VALIDATE_JSX}" == "true" ]; then ###################### # Lint the JSX files # ###################### - # LintCodebase "FILE_TYPE" "LINTER_NAME" "LINTER_CMD" "FILE_TYPES_REGEX" "FILTER_REGEX_INCLUDE" "FILTER_REGEX_EXCLUDE" "FILE_ARRAY" - LintCodebase "JSX" "eslint" "eslint --no-eslintrc -c ${JAVASCRIPT_LINTER_RULES}" ".*\.\(jsx\)\$" "${FILTER_REGEX_INCLUDE}" "${FILTER_REGEX_EXCLUDE}" "${FILE_ARRAY_JSX[@]}" + LintCodebase "JSX" "eslint" "eslint --no-eslintrc -c ${JAVASCRIPT_LINTER_RULES}" "${FILTER_REGEX_INCLUDE}" "${FILTER_REGEX_EXCLUDE}" "${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" "FILTER_REGEX_INCLUDE" "FILTER_REGEX_EXCLUDE" "FILE_ARRAY" - LintCodebase "KOTLIN" "ktlint" "ktlint" ".*\.\(kt\|kts\)\$" "${FILTER_REGEX_INCLUDE}" "${FILTER_REGEX_EXCLUDE}" "${FILE_ARRAY_KOTLIN[@]}" + ######################### + LintCodebase "KOTLIN" "ktlint" "ktlint" "${FILTER_REGEX_INCLUDE}" "${FILTER_REGEX_EXCLUDE}" "${FILE_ARRAY_KOTLIN[@]}" fi ############################## # KUBERNETES Kubeval LINTING # ############################## if [ "${VALIDATE_KUBERNETES_KUBEVAL}" == "true" ]; then - if [ -d "${KUBERNETES_DIRECTORY}" ]; then - 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 "${KUBERNETES_DIRECTORY}" -path "*/node_modules" -prune -o -type f -regex ".*\.\(yml\|yaml\|json\)\$" 2>&1) - for FILE in "${LIST_FILES[@]}"; do - if DetectKubernetesFile "${FILE}"; then - FILE_ARRAY_KUBERNETES+=("${FILE}") - fi - done - - ########################### - # Set IFS back to default # - ########################### - IFS="${DEFAULT_IFS}" - fi - - LintCodebase "KUBERNETES_KUBEVAL" "kubeval" "kubeval --strict" ".*\.\(yml\|yaml\|json\)\$" "${FILTER_REGEX_INCLUDE}" "${FILTER_REGEX_EXCLUDE}" "${FILE_ARRAY_KUBERNETES[@]}" - else - warn "No Kubernetes directory found at:[${KUBERNETES_DIRECTORY}]" - debug "skipping Kubeval lint" - fi + LintCodebase "KUBERNETES_KUBEVAL" "kubeval" "kubeval --strict" "${FILTER_REGEX_INCLUDE}" "${FILTER_REGEX_EXCLUDE}" "${FILE_ARRAY_KUBERNETES_KUBEVAL[@]}" fi ################# @@ -1547,8 +1362,7 @@ if [ "${VALIDATE_LATEX}" == "true" ]; then ######################## # Lint the LATEX files # ######################## - # LintCodebase "FILE_TYPE" "LINTER_NAME" "LINTER_CMD" "FILE_TYPES_REGEX" "FILTER_REGEX_INCLUDE" "FILTER_REGEX_EXCLUDE" "FILE_ARRAY" - LintCodebase "LATEX" "chktex" "chktex -q -l ${LATEX_LINTER_RULES}" ".*\.\(tex\)\$" "${FILTER_REGEX_INCLUDE}" "${FILTER_REGEX_EXCLUDE}" "${FILE_ARRAY_LATEX[@]}" + LintCodebase "LATEX" "chktex" "chktex -q -l ${LATEX_LINTER_RULES}" "${FILTER_REGEX_INCLUDE}" "${FILTER_REGEX_EXCLUDE}" "${FILE_ARRAY_LATEX[@]}" fi ############### @@ -1558,8 +1372,7 @@ if [ "${VALIDATE_LUA}" == "true" ]; then ###################### # Lint the Lua files # ###################### - # LintCodebase "FILE_TYPE" "LINTER_NAME" "LINTER_CMD" "FILE_TYPES_REGEX" "FILTER_REGEX_INCLUDE" "FILTER_REGEX_EXCLUDE" "FILE_ARRAY" - LintCodebase "LUA" "lua" "luacheck --config ${LUA_LINTER_RULES}" ".*\.\(lua\)\$" "${FILTER_REGEX_INCLUDE}" "${FILTER_REGEX_EXCLUDE}" "${FILE_ARRAY_LUA[@]}" + LintCodebase "LUA" "lua" "luacheck --config ${LUA_LINTER_RULES}" "${FILTER_REGEX_INCLUDE}" "${FILTER_REGEX_EXCLUDE}" "${FILE_ARRAY_LUA[@]}" fi #################### @@ -1569,39 +1382,17 @@ if [ "${VALIDATE_MARKDOWN}" == "true" ]; then ########################### # Lint the Markdown Files # ########################### - # LintCodebase "FILE_TYPE" "LINTER_NAME" "LINTER_CMD" "FILE_TYPES_REGEX" "FILTER_REGEX_INCLUDE" "FILTER_REGEX_EXCLUDE" "FILE_ARRAY" - LintCodebase "MARKDOWN" "markdownlint" "markdownlint -c ${MARKDOWN_LINTER_RULES}" ".*\.\(md\)\$" "${FILTER_REGEX_INCLUDE}" "${FILTER_REGEX_EXCLUDE}" "${FILE_ARRAY_MARKDOWN[@]}" + LintCodebase "MARKDOWN" "markdownlint" "markdownlint -c ${MARKDOWN_LINTER_RULES}" "${FILTER_REGEX_INCLUDE}" "${FILTER_REGEX_EXCLUDE}" "${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}" -path "*/node_modules" -prune -o -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" "FILTER_REGEX_INCLUDE" "FILTER_REGEX_EXCLUDE" "FILE_ARRAY" - LintCodebase "OPENAPI" "spectral" "spectral lint -r ${OPENAPI_LINTER_RULES}" "disabledfileext" "${FILTER_REGEX_INCLUDE}" "${FILTER_REGEX_EXCLUDE}" "${FILE_ARRAY_OPENAPI[@]}" + LintCodebase "OPENAPI" "spectral" "spectral lint -r ${OPENAPI_LINTER_RULES}" "${FILTER_REGEX_INCLUDE}" "${FILTER_REGEX_EXCLUDE}" "${FILE_ARRAY_OPENAPI[@]}" fi ################ @@ -1611,8 +1402,7 @@ if [ "${VALIDATE_PERL}" == "true" ]; then ####################### # Lint the perl files # ####################### - # LintCodebase "FILE_TYPE" "LINTER_NAME" "LINTER_CMD" "FILE_TYPES_REGEX" "FILTER_REGEX_INCLUDE" "FILTER_REGEX_EXCLUDE" "FILE_ARRAY" - LintCodebase "PERL" "perl" "perlcritic" ".*\.\(pl\|pm\|t\)\$" "${FILTER_REGEX_INCLUDE}" "${FILTER_REGEX_EXCLUDE}" "${FILE_ARRAY_PERL[@]}" + LintCodebase "PERL" "perl" "perlcritic" "${FILTER_REGEX_INCLUDE}" "${FILTER_REGEX_EXCLUDE}" "${FILE_ARRAY_PERL[@]}" fi ################ @@ -1622,32 +1412,28 @@ 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" "FILTER_REGEX_INCLUDE" "FILTER_REGEX_EXCLUDE" "FILE_ARRAY" - LintCodebase "PHP_BUILTIN" "php" "php -l" ".*\.\(php\)\$" "${FILTER_REGEX_INCLUDE}" "${FILTER_REGEX_EXCLUDE}" "${FILE_ARRAY_PHP_BUILTIN[@]}" + LintCodebase "PHP_BUILTIN" "php" "php -l" "${FILTER_REGEX_INCLUDE}" "${FILTER_REGEX_EXCLUDE}" "${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" "FILTER_REGEX_INCLUDE" "FILTER_REGEX_EXCLUDE" "FILE_ARRAY" - LintCodebase "PHP_PHPCS" "phpcs" "phpcs --standard=${PHP_PHPCS_LINTER_RULES}" ".*\.\(php\)\$" "${FILTER_REGEX_INCLUDE}" "${FILTER_REGEX_EXCLUDE}" "${FILE_ARRAY_PHP_PHPCS[@]}" + LintCodebase "PHP_PHPCS" "phpcs" "phpcs --standard=${PHP_PHPCS_LINTER_RULES}" "${FILTER_REGEX_INCLUDE}" "${FILTER_REGEX_EXCLUDE}" "${FILE_ARRAY_PHP_PHPCS[@]}" fi if [ "${VALIDATE_PHP_PHPSTAN}" == "true" ]; then ####################### # Lint the PHP files using PHPStan # ####################### - # LintCodebase "FILE_TYPE" "LINTER_NAME" "LINTER_CMD" "FILE_TYPES_REGEX" "FILTER_REGEX_INCLUDE" "FILTER_REGEX_EXCLUDE" "FILE_ARRAY" - LintCodebase "PHP_PHPSTAN" "phpstan" "phpstan analyse --no-progress --no-ansi -c ${PHP_PHPSTAN_LINTER_RULES}" ".*\.\(php\)\$" "${FILTER_REGEX_INCLUDE}" "${FILTER_REGEX_EXCLUDE}" "${FILE_ARRAY_PHP_PHPSTAN[@]}" + LintCodebase "PHP_PHPSTAN" "phpstan" "phpstan analyse --no-progress --no-ansi -c ${PHP_PHPSTAN_LINTER_RULES}" "${FILTER_REGEX_INCLUDE}" "${FILTER_REGEX_EXCLUDE}" "${FILE_ARRAY_PHP_PHPSTAN[@]}" fi if [ "${VALIDATE_PHP_PSALM}" == "true" ]; then ################################## # Lint the PHP files using Psalm # ################################## - # LintCodebase "FILE_TYPE" "LINTER_NAME" "LINTER_CMD" "FILE_TYPES_REGEX" "FILTER_REGEX_INCLUDE" "FILTER_REGEX_EXCLUDE" "FILE_ARRAY" - LintCodebase "PHP_PSALM" "psalm" "psalm --config=${PHP_PSALM_LINTER_RULES}" ".*\.\(php\)\$" "${FILTER_REGEX_INCLUDE}" "${FILTER_REGEX_EXCLUDE}" "${FILE_ARRAY_PHP_PSALM[@]}" + LintCodebase "PHP_PSALM" "psalm" "psalm --config=${PHP_PSALM_LINTER_RULES}" "${FILTER_REGEX_INCLUDE}" "${FILTER_REGEX_EXCLUDE}" "${FILE_ARRAY_PHP_PSALM[@]}" fi ###################### @@ -1662,8 +1448,7 @@ if [ "${VALIDATE_POWERSHELL}" == "true" ]; then ############################# # Lint the powershell files # ############################# - # LintCodebase "FILE_TYPE" "LINTER_NAME" "LINTER_CMD" "FILE_TYPES_REGEX" "FILTER_REGEX_INCLUDE" "FILTER_REGEX_EXCLUDE" "FILE_ARRAY" - LintCodebase "POWERSHELL" "pwsh" "Invoke-ScriptAnalyzer -EnableExit -Settings ${POWERSHELL_LINTER_RULES} -Path" ".*\.\(ps1\|psm1\|psd1\|ps1xml\|pssc\|psrc\|cdxml\)\$" "${FILTER_REGEX_INCLUDE}" "${FILTER_REGEX_EXCLUDE}" "${FILE_ARRAY_POWERSHELL[@]}" + LintCodebase "POWERSHELL" "pwsh" "Invoke-ScriptAnalyzer -EnableExit -Settings ${POWERSHELL_LINTER_RULES} -Path" "${FILTER_REGEX_INCLUDE}" "${FILTER_REGEX_EXCLUDE}" "${FILE_ARRAY_POWERSHELL[@]}" fi #################### @@ -1673,8 +1458,7 @@ if [ "${VALIDATE_PROTOBUF}" == "true" ]; then ####################### # Lint the Protocol Buffers files # ####################### - # LintCodebase "FILE_TYPE" "LINTER_NAME" "LINTER_CMD" "FILE_TYPES_REGEX" "FILTER_REGEX_INCLUDE" "FILTER_REGEX_EXCLUDE" "FILE_ARRAY" - LintCodebase "PROTOBUF" "protolint" "protolint lint --config_path ${PROTOBUF_LINTER_RULES}" ".*\.\(proto\)\$" "${FILTER_REGEX_INCLUDE}" "${FILTER_REGEX_EXCLUDE}" "${FILE_ARRAY_PROTOBUF[@]}" + LintCodebase "PROTOBUF" "protolint" "protolint lint --config_path ${PROTOBUF_LINTER_RULES}" "${FILTER_REGEX_INCLUDE}" "${FILTER_REGEX_EXCLUDE}" "${FILE_ARRAY_PROTOBUF[@]}" fi ######################## @@ -1684,8 +1468,7 @@ if [ "${VALIDATE_PYTHON_BLACK}" == "true" ]; then ######################### # Lint the python files # ######################### - # LintCodebase "FILE_TYPE" "LINTER_NAME" "LINTER_CMD" "FILE_TYPES_REGEX" "FILTER_REGEX_INCLUDE" "FILTER_REGEX_EXCLUDE" "FILE_ARRAY" - LintCodebase "PYTHON_BLACK" "black" "black --config ${PYTHON_BLACK_LINTER_RULES} --diff --check" ".*\.\(py\)\$" "${FILTER_REGEX_INCLUDE}" "${FILTER_REGEX_EXCLUDE}" "${FILE_ARRAY_PYTHON_BLACK[@]}" + LintCodebase "PYTHON_BLACK" "black" "black --config ${PYTHON_BLACK_LINTER_RULES} --diff --check" "${FILTER_REGEX_INCLUDE}" "${FILTER_REGEX_EXCLUDE}" "${FILE_ARRAY_PYTHON_BLACK[@]}" fi ######################### @@ -1695,8 +1478,7 @@ if [ "${VALIDATE_PYTHON_PYLINT}" == "true" ]; then ######################### # Lint the python files # ######################### - # LintCodebase "FILE_TYPE" "LINTER_NAME" "LINTER_CMD" "FILE_TYPES_REGEX" "FILTER_REGEX_INCLUDE" "FILTER_REGEX_EXCLUDE" "FILE_ARRAY" - LintCodebase "PYTHON_PYLINT" "pylint" "pylint --rcfile ${PYTHON_PYLINT_LINTER_RULES}" ".*\.\(py\)\$" "${FILTER_REGEX_INCLUDE}" "${FILTER_REGEX_EXCLUDE}" "${FILE_ARRAY_PYTHON_PYLINT[@]}" + LintCodebase "PYTHON_PYLINT" "pylint" "pylint --rcfile ${PYTHON_PYLINT_LINTER_RULES}" "${FILTER_REGEX_INCLUDE}" "${FILTER_REGEX_EXCLUDE}" "${FILE_ARRAY_PYTHON_PYLINT[@]}" fi ######################### @@ -1706,8 +1488,7 @@ if [ "${VALIDATE_PYTHON_FLAKE8}" == "true" ]; then ######################### # Lint the python files # ######################### - # LintCodebase "FILE_TYPE" "LINTER_NAME" "LINTER_CMD" "FILE_TYPES_REGEX" "FILTER_REGEX_INCLUDE" "FILTER_REGEX_EXCLUDE" "FILE_ARRAY" - LintCodebase "PYTHON_FLAKE8" "flake8" "flake8 --config=${PYTHON_FLAKE8_LINTER_RULES}" ".*\.\(py\)\$" "${FILTER_REGEX_INCLUDE}" "${FILTER_REGEX_EXCLUDE}" "${FILE_ARRAY_PYTHON_FLAKE8[@]}" + LintCodebase "PYTHON_FLAKE8" "flake8" "flake8 --config=${PYTHON_FLAKE8_LINTER_RULES}" "${FILTER_REGEX_INCLUDE}" "${FILTER_REGEX_EXCLUDE}" "${FILE_ARRAY_PYTHON_FLAKE8[@]}" fi ############# @@ -1717,6 +1498,7 @@ if [ "${VALIDATE_R}" == "true" ]; then ########################## # Check for local config # ########################## + # shellcheck disable=SC2153 if [ ! -f "${GITHUB_WORKSPACE}/.lintr" ] && ((${#FILE_ARRAY_R[@]})); then info "No .lintr configuration file found, using defaults." cp $R_LINTER_RULES "$GITHUB_WORKSPACE" @@ -1725,7 +1507,7 @@ if [ "${VALIDATE_R}" == "true" ]; then ###################### # Lint the R files # ###################### - LintCodebase "R" "lintr" "lintr::lint(File)" ".*\.\(r\|R\|Rmd\|rmd\)\$" "${FILTER_REGEX_INCLUDE}" "${FILTER_REGEX_EXCLUDE}" "${FILE_ARRAY_R[@]}" + LintCodebase "R" "lintr" "lintr::lint(File)" "${FILTER_REGEX_INCLUDE}" "${FILTER_REGEX_EXCLUDE}" "${FILE_ARRAY_R[@]}" fi ################ @@ -1738,8 +1520,7 @@ if [ "${VALIDATE_RAKU}" == "true" ]; then 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" "FILTER_REGEX_INCLUDE" "FILTER_REGEX_EXCLUDE" "FILE_ARRAY" - LintCodebase "RAKU" "raku" "raku -I ${GITHUB_WORKSPACE}/lib -c" ".*\.\(raku\|rakumod\|rakutest\|pm6\|pl6\|p6\)\$" "${FILTER_REGEX_INCLUDE}" "${FILTER_REGEX_EXCLUDE}" "${FILE_ARRAY_RAKU[@]}" + LintCodebase "RAKU" "raku" "raku -I ${GITHUB_WORKSPACE}/lib -c" "${FILTER_REGEX_INCLUDE}" "${FILTER_REGEX_EXCLUDE}" "${FILE_ARRAY_RAKU[@]}" fi ################ @@ -1749,8 +1530,7 @@ if [ "${VALIDATE_RUBY}" == "true" ]; then ####################### # Lint the ruby files # ####################### - # LintCodebase "FILE_TYPE" "LINTER_NAME" "LINTER_CMD" "FILE_TYPES_REGEX" "FILTER_REGEX_INCLUDE" "FILTER_REGEX_EXCLUDE" "FILE_ARRAY" - LintCodebase "RUBY" "rubocop" "rubocop -c ${RUBY_LINTER_RULES} --force-exclusion" ".*\.\(rb\)\$" "${FILTER_REGEX_INCLUDE}" "${FILTER_REGEX_EXCLUDE}" "${FILE_ARRAY_RUBY[@]}" + LintCodebase "RUBY" "rubocop" "rubocop -c ${RUBY_LINTER_RULES} --force-exclusion" "${FILTER_REGEX_INCLUDE}" "${FILTER_REGEX_EXCLUDE}" "${FILE_ARRAY_RUBY[@]}" fi ################# @@ -1762,8 +1542,7 @@ if [ "${VALIDATE_SHELL_SHFMT}" == "true" ]; then #################################### EDITORCONFIG_FILE_PATH="${GITHUB_WORKSPACE}"/.editorconfig if [ -e "$EDITORCONFIG_FILE_PATH" ]; then - # LintCodebase "FILE_TYPE" "LINTER_NAME" "LINTER_CMD" "FILE_TYPES_REGEX" "FILTER_REGEX_INCLUDE" "FILTER_REGEX_EXCLUDE" "FILE_ARRAY" - LintCodebase "SHELL_SHFMT" "shfmt" "shfmt -d" ".*\.\(sh\|bash\|dash\|ksh\)\$" "${FILTER_REGEX_INCLUDE}" "${FILTER_REGEX_EXCLUDE}" "${FILE_ARRAY_BASH[@]}" + LintCodebase "SHELL_SHFMT" "shfmt" "shfmt -d" "${FILTER_REGEX_INCLUDE}" "${FILTER_REGEX_EXCLUDE}" "${FILE_ARRAY_SHELL_SHFMT[@]}" else ############################### # No .editorconfig file found # @@ -1777,53 +1556,24 @@ fi # SNAKEMAKE LINT # ################## if [ "${VALIDATE_SNAKEMAKE_LINT}" == "true" ]; then - ################################ - # Lint the files with snakefmt # - ################################ - # LintCodebase "FILE_TYPE" "LINTER_NAME" "LINTER_CMD" "FILE_TYPES_REGEX" "FILTER_REGEX_INCLUDE" "FILTER_REGEX_EXCLUDE" "FILE_ARRAY" - LintCodebase "SNAKEMAKE_LINT" "snakemake" "snakemake --lint -s" ".*\(Snakefile\|\.smk\)\$" "${FILTER_REGEX_INCLUDE}" "${FILTER_REGEX_EXCLUDE}" "${FILE_ARRAY_SNAKEMAKE[@]}" - + LintCodebase "SNAKEMAKE_LINT" "snakemake" "snakemake --lint -s" "${FILTER_REGEX_INCLUDE}" "${FILTER_REGEX_EXCLUDE}" "${FILE_ARRAY_SNAKEMAKE_LINT[@]}" fi ###################### # SNAKEMAKE SNAKEFMT # ###################### if [ "${VALIDATE_SNAKEMAKE_SNAKEFMT}" == "true" ]; then - ################################ - # Lint the files with snakefmt # - ################################ - # LintCodebase "FILE_TYPE" "LINTER_NAME" "LINTER_CMD" "FILE_TYPES_REGEX" "FILTER_REGEX_INCLUDE" "FILTER_REGEX_EXCLUDE" "FILE_ARRAY" - LintCodebase "SNAKEMAKE_SNAKEFMT" "snakefmt" "snakefmt --config ${SNAKEMAKE_SNAKEFMT_LINTER_RULES} --check --compact-diff" ".*\(Snakefile\|\.smk\)\$" "${FILTER_REGEX_INCLUDE}" "${FILTER_REGEX_EXCLUDE}" "${FILE_ARRAY_SNAKEMAKE[@]}" + LintCodebase "SNAKEMAKE_SNAKEFMT" "snakefmt" "snakefmt --config ${SNAKEMAKE_SNAKEFMT_LINTER_RULES} --check --compact-diff" "${FILTER_REGEX_INCLUDE}" "${FILTER_REGEX_EXCLUDE}" "${FILE_ARRAY_SNAKEMAKE_SNAKEFMT[@]}" 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}" -path "*/node_modules" -prune -o -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" "${FILTER_REGEX_INCLUDE}" "${FILTER_REGEX_EXCLUDE}" "${FILE_ARRAY_STATES[@]}" + LintCodebase "STATES" "asl-validator" "asl-validator --json-path" "${FILTER_REGEX_INCLUDE}" "${FILTER_REGEX_EXCLUDE}" "${FILE_ARRAY_STATES[@]}" fi ############### @@ -1833,8 +1583,7 @@ if [ "${VALIDATE_SQL}" == "true" ]; then ###################### # Lint the SQL files # ###################### - # LintCodebase "FILE_TYPE" "LINTER_NAME" "LINTER_CMD" "FILE_TYPES_REGEX" "FILTER_REGEX_INCLUDE" "FILTER_REGEX_EXCLUDE" "FILE_ARRAY" - LintCodebase "SQL" "sql-lint" "sql-lint --config ${SQL_LINTER_RULES}" ".*\.\(sql\)\$" "${FILTER_REGEX_INCLUDE}" "${FILTER_REGEX_EXCLUDE}" "${FILE_ARRAY_SQL[@]}" + LintCodebase "SQL" "sql-lint" "sql-lint --config ${SQL_LINTER_RULES}" "${FILTER_REGEX_INCLUDE}" "${FILTER_REGEX_EXCLUDE}" "${FILE_ARRAY_SQL[@]}" fi ##################### @@ -1844,8 +1593,7 @@ if [ "${VALIDATE_TERRAFORM}" == "true" ]; then ############################ # Lint the Terraform files # ############################ - # LintCodebase "FILE_TYPE" "LINTER_NAME" "LINTER_CMD" "FILE_TYPES_REGEX" "FILTER_REGEX_INCLUDE" "FILTER_REGEX_EXCLUDE" "FILE_ARRAY" - LintCodebase "TERRAFORM" "tflint" "tflint -c ${TERRAFORM_LINTER_RULES}" ".*\.\(tf\)\$" "${FILTER_REGEX_INCLUDE}" "${FILTER_REGEX_EXCLUDE}" "${FILE_ARRAY_TERRAFORM[@]}" + LintCodebase "TERRAFORM" "tflint" "tflint -c ${TERRAFORM_LINTER_RULES}" "${FILTER_REGEX_INCLUDE}" "${FILTER_REGEX_EXCLUDE}" "${FILE_ARRAY_TERRAFORM[@]}" fi ############################### @@ -1855,8 +1603,7 @@ if [ "${VALIDATE_TERRAFORM_TERRASCAN}" == "true" ]; then ############################ # Lint the Terraform files # ############################ - # LintCodebase "FILE_TYPE" "LINTER_NAME" "LINTER_CMD" "FILE_TYPES_REGEX" "FILTER_REGEX_INCLUDE" "FILTER_REGEX_EXCLUDE" "FILE_ARRAY" - LintCodebase "TERRAFORM_TERRASCAN" "terrascan" "terrascan scan -p /root/.terrascan/pkg/policies/opa/rego/ -t aws -f " ".*\.\(tf\)\$" "${FILTER_REGEX_INCLUDE}" "${FILTER_REGEX_EXCLUDE}" "${FILE_ARRAY_TERRAFORM_TERRASCAN[@]}" + LintCodebase "TERRAFORM_TERRASCAN" "terrascan" "terrascan scan -p /root/.terrascan/pkg/policies/opa/rego/ -t aws -f " "${FILTER_REGEX_INCLUDE}" "${FILTER_REGEX_EXCLUDE}" "${FILE_ARRAY_TERRAFORM_TERRASCAN[@]}" fi ############### @@ -1866,7 +1613,7 @@ if [ "${VALIDATE_TSX}" == "true" ]; then ###################### # Lint the TSX files # ###################### - LintCodebase "TSX" "eslint" "eslint --no-eslintrc -c ${TYPESCRIPT_LINTER_RULES}" ".*\.\(tsx\)\$" "${FILTER_REGEX_INCLUDE}" "${FILTER_REGEX_EXCLUDE}" "${FILE_ARRAY_TSX[@]}" + LintCodebase "TSX" "eslint" "eslint --no-eslintrc -c ${TYPESCRIPT_LINTER_RULES}" "${FILTER_REGEX_INCLUDE}" "${FILTER_REGEX_EXCLUDE}" "${FILE_ARRAY_TSX[@]}" fi ###################### @@ -1876,7 +1623,7 @@ if [ "${VALIDATE_TYPESCRIPT_ES}" == "true" ]; then ############################# # Lint the Typescript files # ############################# - LintCodebase "TYPESCRIPT_ES" "eslint" "eslint --no-eslintrc -c ${TYPESCRIPT_LINTER_RULES}" ".*\.\(ts\)\$" "${FILTER_REGEX_INCLUDE}" "${FILTER_REGEX_EXCLUDE}" "${FILE_ARRAY_TYPESCRIPT_ES[@]}" + LintCodebase "TYPESCRIPT_ES" "eslint" "eslint --no-eslintrc -c ${TYPESCRIPT_LINTER_RULES}" "${FILTER_REGEX_INCLUDE}" "${FILTER_REGEX_EXCLUDE}" "${FILE_ARRAY_TYPESCRIPT_ES[@]}" fi ###################### @@ -1890,7 +1637,7 @@ if [ "${VALIDATE_TYPESCRIPT_STANDARD}" == "true" ]; then ############################# # Lint the Typescript files # ############################# - LintCodebase "TYPESCRIPT_STANDARD" "standard" "standard --parser @typescript-eslint/parser --plugin @typescript-eslint/eslint-plugin ${TYPESCRIPT_STANDARD_LINTER_RULES}" ".*\.\(ts\)\$" "${FILTER_REGEX_INCLUDE}" "${FILTER_REGEX_EXCLUDE}" "${FILE_ARRAY_TYPESCRIPT_STANDARD[@]}" + LintCodebase "TYPESCRIPT_STANDARD" "standard" "standard --parser @typescript-eslint/parser --plugin @typescript-eslint/eslint-plugin ${TYPESCRIPT_STANDARD_LINTER_RULES}" "${FILTER_REGEX_INCLUDE}" "${FILTER_REGEX_EXCLUDE}" "${FILE_ARRAY_TYPESCRIPT_STANDARD[@]}" fi ############### @@ -1900,8 +1647,7 @@ if [ "${VALIDATE_XML}" == "true" ]; then ###################### # Lint the XML Files # ###################### - # LintCodebase "FILE_TYPE" "LINTER_NAME" "LINTER_CMD" "FILE_TYPES_REGEX" "FILTER_REGEX_INCLUDE" "FILTER_REGEX_EXCLUDE" "FILE_ARRAY" - LintCodebase "XML" "xmllint" "xmllint" ".*\.\(xml\)\$" "${FILTER_REGEX_INCLUDE}" "${FILTER_REGEX_EXCLUDE}" "${FILE_ARRAY_XML[@]}" + LintCodebase "XML" "xmllint" "xmllint" "${FILTER_REGEX_INCLUDE}" "${FILTER_REGEX_EXCLUDE}" "${FILE_ARRAY_XML[@]}" fi ################ @@ -1911,8 +1657,7 @@ if [ "${VALIDATE_YAML}" == "true" ]; then ###################### # Lint the Yml Files # ###################### - # LintCodebase "FILE_TYPE" "LINTER_NAME" "LINTER_CMD" "FILE_TYPES_REGEX" "FILTER_REGEX_INCLUDE" "FILTER_REGEX_EXCLUDE" "FILE_ARRAY" - LintCodebase "YAML" "yamllint" "yamllint -c ${YAML_LINTER_RULES}" ".*\.\(yml\|yaml\)\$" "${FILTER_REGEX_INCLUDE}" "${FILTER_REGEX_EXCLUDE}" "${FILE_ARRAY_YAML[@]}" + LintCodebase "YAML" "yamllint" "yamllint -c ${YAML_LINTER_RULES}" "${FILTER_REGEX_INCLUDE}" "${FILTER_REGEX_EXCLUDE}" "${FILE_ARRAY_YAML[@]}" fi ########### diff --git a/lib/validation.sh b/lib/validation.sh index 129a0aad..1f0e04b0 100755 --- a/lib/validation.sh +++ b/lib/validation.sh @@ -99,6 +99,7 @@ function GetValidationInfo() { # No linter flags were set - default all to true eval "${VALIDATE_LANGUAGE}='true'" fi + eval "export ${VALIDATE_LANGUAGE}" done ####################################### @@ -145,26 +146,6 @@ function GetValidationInfo() { debug "Setting Ansible directory to: ${ANSIBLE_DIRECTORY}" fi - ################################# - # Validate Kubernetes Directory # - ################################# - if [ -z "${KUBERNETES_DIRECTORY}" ]; then - # No Value, need to default - KUBERNETES_DIRECTORY="${DEFAULT_KUBERNETES_DIRECTORY}" - debug "Setting Kubernetes directory to the default: ${DEFAULT_KUBERNETES_DIRECTORY}" - else - # Check if first char is '/' - if [[ ${KUBERNETES_DIRECTORY:0:1} == "/" ]]; then - # Remove first char - KUBERNETES_DIRECTORY="${KUBERNETES_DIRECTORY:1}" - fi - # Need to give it full path - TEMP_KUBERNETES_DIRECTORY="${GITHUB_WORKSPACE}/${KUBERNETES_DIRECTORY}" - # Set the value - KUBERNETES_DIRECTORY="${TEMP_KUBERNETES_DIRECTORY}" - debug "Setting Kubernetes directory to: ${KUBERNETES_DIRECTORY}" - fi - ############################### # Get the disable errors flag # ############################### diff --git a/lib/worker.sh b/lib/worker.sh index 36768ac1..9b45809e 100755 --- a/lib/worker.sh +++ b/lib/worker.sh @@ -16,7 +16,6 @@ function LintCodebase() { 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) FILTER_REGEX_INCLUDE="${1}" && shift # Pull the variable and remove from array path (Example: */src/*,*/test/*) FILTER_REGEX_EXCLUDE="${1}" && shift # Pull the variable and remove from array path (Example: */examples/*,*/test/*.test) FILE_ARRAY=("$@") # Array of files to validate (Example: ${FILE_ARRAY_JSON}) @@ -75,54 +74,12 @@ function LintCodebase() { ############################################################ # 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 + if [ ${#FILE_ARRAY[@]} -eq 0 ]; then SKIP_FLAG=1 debug " - No files found in changeset to lint for language:[${FILE_TYPE}]" - elif [ ${#FILE_ARRAY[@]} -ne 0 ]; then + else # We have files added to array of files to check LIST_FILES=("${FILE_ARRAY[@]}") # Copy the array into list - else - if [[ ${FILE_TYPE} == "BASH" ]] || - [[ ${FILE_TYPE} == "BASH_EXEC" ]] || - [[ ${FILE_TYPE} == "SHELL_SHFMT" ]]; then - # Populate a list of valid shell scripts. - PopulateShellScriptsList - else - ############################################################################### - # Set the file separator 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}" \ - -path "*/node_modules" -prune -o \ - -path "*/.git" -prune -o \ - -path "*/.venv" -prune -o \ - -path "*/.rbenv" -prune -o \ - -type f -regex "${FILE_EXTENSIONS}" 2>&1) - - ########################### - # Set IFS back to default # - ########################### - IFS="${DEFAULT_IFS}" - fi - - ############################################################ - # 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 #################################################