Lint the whole code base with JSCPD (#2180)

* Lint the whole code base with JSCPD if VALIDATE_ALL_CODEBASE is true

* Use VALIDATE_JSCPD_ALL_CODEBASE

Co-authored-by: Lukas Gravley <admiralawkbar@github.com>
This commit is contained in:
Marco Ferrari 2021-12-08 21:28:30 +01:00 committed by GitHub
parent de35dfbf5a
commit e4b08ec842
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 18 additions and 6 deletions

View file

@ -323,6 +323,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`) | | **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 | | **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_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_ANSIBLE** | `true` | Flag to enable or disable the linting process of the Ansible language. | | **VALIDATE_ANSIBLE** | `true` | Flag to enable or disable the linting process of the Ansible language. |
| **VALIDATE_ARM** | `true` | Flag to enable or disable the linting process of the ARM language. | | **VALIDATE_ARM** | `true` | Flag to enable or disable the linting process of the ARM language. |
| **VALIDATE_BASH** | `true` | Flag to enable or disable the linting process of the Bash language. | | **VALIDATE_BASH** | `true` | Flag to enable or disable the linting process of the Bash language. |

View file

@ -54,19 +54,21 @@ function BuildFileList() {
# Pull in vars # # Pull in vars #
################ ################
VALIDATE_ALL_CODEBASE="${1}" VALIDATE_ALL_CODEBASE="${1}"
debug "Validate all code base: ${VALIDATE_ALL_CODEBASE}..." debug "VALIDATE_ALL_CODEBASE: ${VALIDATE_ALL_CODEBASE}"
TEST_CASE_RUN="${2}" TEST_CASE_RUN="${2}"
debug "TEST_CASE_RUN: ${TEST_CASE_RUN}..." debug "TEST_CASE_RUN: ${TEST_CASE_RUN}"
ANSIBLE_DIRECTORY="${3}" ANSIBLE_DIRECTORY="${3}"
debug "ANSIBLE_DIRECTORY: ${ANSIBLE_DIRECTORY}..." debug "ANSIBLE_DIRECTORY: ${ANSIBLE_DIRECTORY}"
debug "IGNORE_GITIGNORED_FILES: ${IGNORE_GITIGNORED_FILES}..." debug "IGNORE_GITIGNORED_FILES: ${IGNORE_GITIGNORED_FILES}"
debug "IGNORE_GENERATED_FILES: ${IGNORE_GENERATED_FILES}..." debug "IGNORE_GENERATED_FILES: ${IGNORE_GENERATED_FILES}"
debug "USE_FIND_ALGORITHM: ${USE_FIND_ALGORITHM}..." debug "USE_FIND_ALGORITHM: ${USE_FIND_ALGORITHM}"
debug "VALIDATE_JSCPD_ALL_CODEBASE: ${VALIDATE_JSCPD_ALL_CODEBASE}"
if [ "${VALIDATE_ALL_CODEBASE}" == "false" ] && [ "${TEST_CASE_RUN}" != "true" ]; then if [ "${VALIDATE_ALL_CODEBASE}" == "false" ] && [ "${TEST_CASE_RUN}" != "true" ]; then
# Need to build a list of all files changed # Need to build a list of all files changed
@ -854,6 +856,11 @@ function BuildFileList() {
debug "" debug ""
done done
if [ "${VALIDATE_JSCPD_ALL_CODEBASE}" == "true" ]; then
debug "Adding the root of the workspaces to the list of files and directories to lint with JSCPD..."
FILE_ARRAY_JSCPD+=("${GITHUB_WORKSPACE}")
fi
################ ################
# Footer print # # Footer print #
################ ################

View file

@ -953,6 +953,10 @@ debug "---------------------------------------------"
################################# #################################
CheckSSLCert CheckSSLCert
# Check if we need to lint the whole codebase with JSCPD
VALIDATE_JSCPD_ALL_CODEBASE="${VALIDATE_JSCPD_ALL_CODEBASE:-"false"}"
export VALIDATE_JSCPD_ALL_CODEBASE
########################################### ###########################################
# Build the list of files for each linter # # Build the list of files for each linter #
########################################### ###########################################