You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit d2d7334
Browse filesBrowse the repository at this point in the historyBrowse files
chore: split validation logic in smaller functions (#5892)
- Move USE_FIND_ALGORITHM and VALIDATE_ALL_CODEBASE validation in a
dedicated function (ValidateFindMode).
- Move ANSIBLE_DIRECTORY validation to a dedicated function
(ValidateAnsibleDirectory).
- Move VALIDATE_xxxx variables validation to a dedicated function
(ValidateValidationVariables).
- Mark ANY_SET, ANY_TRUE, ANY_FALSE as local because we don't need to
reference them anywhere outside ValidateValidationVariables.
- Add some debug statements in validation functions.
- Merge the loops to initialize VALIDATE_xxx variables and to print
enable/disable language debug messages.
- Add tests for these validation functions.
- Add test start message for all tests.
if [[ "${USE_FIND_ALGORITHM}"=="true" ]] && [[ "${VALIDATE_ALL_CODEBASE}"=="false" ]];then
48
-
fatal "Setting USE_FIND_ALGORITHM to true and VALIDATE_ALL_CODEBASE to false is not supported because super-linter relies on Git to validate changed files."
46
+
error "Setting USE_FIND_ALGORITHM to true and VALIDATE_ALL_CODEBASE to false is not supported because super-linter relies on Git to validate changed files."
47
+
return 1
48
+
fi
49
+
}
50
+
51
+
functionValidateAnsibleDirectory() {
52
+
if [ -z"${ANSIBLE_DIRECTORY:-}" ];then
53
+
ANSIBLE_DIRECTORY="${GITHUB_WORKSPACE}/ansible"
54
+
debug "Set ANSIBLE_DIRECTORY to the default: ${ANSIBLE_DIRECTORY}"
55
+
else
56
+
debug "ANSIBLE_DIRECTORY before considering corner cases: ${ANSIBLE_DIRECTORY}"
57
+
# Check if first char is '/'
58
+
if [[ ${ANSIBLE_DIRECTORY:0:1}=="/" ]];then
59
+
# Remove first char
60
+
ANSIBLE_DIRECTORY="${ANSIBLE_DIRECTORY:1}"
61
+
fi
62
+
63
+
if [ -z"${ANSIBLE_DIRECTORY}" ] || [[ ${ANSIBLE_DIRECTORY}=="." ]];then
64
+
# Catches the case where ANSIBLE_DIRECTORY="/" or ANSIBLE_DIRECTORY="."
@@ -85,60 +116,26 @@ function GetValidationInfo() {
85
116
local VALIDATE_LANGUAGE
86
117
VALIDATE_LANGUAGE="VALIDATE_${LANGUAGE}"
87
118
if [[ ${ANY_SET}=="true" ]];then
119
+
debug "Configuration contains at least one custom value to enable or disable linters."
88
120
if [ -z"${!VALIDATE_LANGUAGE:-}" ];then
89
121
# Flag was not set, default to:
90
122
# if ANY_TRUE then set to false
91
123
# if ANY_FALSE then set to true
92
124
eval"${VALIDATE_LANGUAGE}='$ANY_FALSE'"
93
125
fi
94
126
else
95
-
# No linter flags were set - default all to true
96
127
eval"${VALIDATE_LANGUAGE}='true'"
128
+
debug "Configuration doesn't include any custom values to enable or disable linters. Setting VALIDATE variable for ${LANGUAGE} to: ${!VALIDATE_LANGUAGE}"
97
129
fi
98
-
eval"export ${VALIDATE_LANGUAGE}"
99
-
done
100
130
101
-
#######################################
102
-
# Print which linters we are enabling #
103
-
#######################################
104
-
# Loop through all languages
105
-
forLANGUAGEin"${LANGUAGE_ARRAY[@]}";do
106
-
local VALIDATE_LANGUAGE
107
-
VALIDATE_LANGUAGE="VALIDATE_${LANGUAGE}"
108
-
if [[ ${!VALIDATE_LANGUAGE}=="true" ]];then
131
+
if [[ "${!VALIDATE_LANGUAGE}"=="true" ]];then
109
132
debug "- Validating [${LANGUAGE}] files in code base..."
110
133
else
111
134
debug "- Excluding [$LANGUAGE] files in code base..."
112
135
fi
113
-
done
114
-
115
-
##############################
116
-
# Validate Ansible Directory #
117
-
##############################
118
-
if [ -z"${ANSIBLE_DIRECTORY:-}" ];then
119
-
ANSIBLE_DIRECTORY="${GITHUB_WORKSPACE}/ansible"
120
-
debug "Set ANSIBLE_DIRECTORY to the default: ${ANSIBLE_DIRECTORY}"
121
-
else
122
-
debug "ANSIBLE_DIRECTORY before considering corner cases: ${ANSIBLE_DIRECTORY}"
123
-
# Check if first char is '/'
124
-
if [[ ${ANSIBLE_DIRECTORY:0:1}=="/" ]];then
125
-
# Remove first char
126
-
ANSIBLE_DIRECTORY="${ANSIBLE_DIRECTORY:1}"
127
-
fi
128
-
129
-
if [ -z"${ANSIBLE_DIRECTORY}" ] || [[ ${ANSIBLE_DIRECTORY}=="." ]];then
130
-
# Catches the case where ANSIBLE_DIRECTORY="/" or ANSIBLE_DIRECTORY="."
0 commit comments