From d7cefe279b22fe8ab56cd1382f6cc0b8467e4c33 Mon Sep 17 00:00:00 2001 From: Marco Ferrari Date: Mon, 14 Mar 2022 15:22:23 +0100 Subject: [PATCH] Don't populate FILE_ARRAY_JSCPD with single files when scanning the whole codebase (#2580) --- README.md | 2 +- lib/functions/buildFileList.sh | 9 +++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index e5229424..d81dd733 100644 --- a/README.md +++ b/README.md @@ -329,7 +329,7 @@ But if you wish to select or exclude specific linters, we give you full control | **TYPESCRIPT_ES_CONFIG_FILE** | `.eslintrc.yml` | Filename for [ESLint configuration](https://eslint.org/docs/user-guide/configuring#configuration-file-formats) (ex: `.eslintrc.yml`, `.eslintrc.json`) | | **USE_FIND_ALGORITHM** | `false` | By default, we use `git diff` to find all files in the workspace and what has been updated, this would enable the Linux `find` method instead to find all files to lint | | **VALIDATE_ALL_CODEBASE** | `true` | Will parse the entire repository and find all files to validate across all types. **NOTE:** When set to `false`, only **new** or **edited** files will be parsed for validation. | -| **VALIDATE_JSCPD_ALL_CODEBASE** | `false` | If set to `true`, will lint the whole codebase with JSCPD, in addition to linting files with JSCPD one by one. If set to `false`, JSCPD will only lint files one by one. | +| **VALIDATE_JSCPD_ALL_CODEBASE** | `false` | If set to `true`, will lint the whole codebase with JSCPD. If set to `false`, JSCPD will only lint files one by one. | | **VALIDATE_ANSIBLE** | `true` | Flag to enable or disable the linting process of the Ansible language. | | **VALIDATE_ARM** | `true` | Flag to enable or disable the linting process of the ARM language. | | **VALIDATE_BASH** | `true` | Flag to enable or disable the linting process of the Bash language. | diff --git a/lib/functions/buildFileList.sh b/lib/functions/buildFileList.sh index 43d68dec..5a64e9da 100755 --- a/lib/functions/buildFileList.sh +++ b/lib/functions/buildFileList.sh @@ -316,8 +316,13 @@ function BuildFileList() { # Editorconfig-checker should check every file FILE_ARRAY_EDITORCONFIG+=("${FILE}") - # jscpd also runs an all files - FILE_ARRAY_JSCPD+=("${FILE}") + + if [ "${VALIDATE_JSCPD_ALL_CODEBASE}" == "true" ]; then + debug "Not adding ${FILE} to FILE_ARRAY_JSCPD because we're going to lint the whole codebase anyway." + else + # jscpd also runs an all files + FILE_ARRAY_JSCPD+=("${FILE}") + fi # Need to make sure we dont check the secrets paterns # for secrets, as it will pop! if [ "${BASE_FILE}" != ".gitleaks.toml" ]; then