Format code

This commit is contained in:
Eric Nemchik 2020-07-30 15:18:24 -05:00
parent c541a221bb
commit 2d2fafef1b
6 changed files with 2562 additions and 2559 deletions

View file

@ -212,9 +212,9 @@ function BuildFileList() {
###################### ######################
# Get the RAKU files # # Get the RAKU files #
###################### ######################
elif [ "${FILE_TYPE}" == "raku" ] || [ "${FILE_TYPE}" == "rakumod" ] \ elif [ "${FILE_TYPE}" == "raku" ] || [ "${FILE_TYPE}" == "rakumod" ] ||
|| [ "${FILE_TYPE}" == "rakutest" ] || [ "${FILE_TYPE}" == "pm6" ] \ [ "${FILE_TYPE}" == "rakutest" ] || [ "${FILE_TYPE}" == "pm6" ] ||
|| [ "${FILE_TYPE}" == "pl6" ] || [ "${FILE_TYPE}" == "p6" ] ; then [ "${FILE_TYPE}" == "pl6" ] || [ "${FILE_TYPE}" == "p6" ]; then
################################ ################################
# Append the file to the array # # Append the file to the array #
################################ ################################

View file

@ -190,11 +190,15 @@ ACTIONS_RUNNER_DEBUG="${ACTIONS_RUNNER_DEBUG:-false}" # Boolean to see even more
############ ############
# Log Vars # # Log Vars #
############ ############
LOG_TRACE=$(if [[ ${LOG_LEVEL} == "TRACE" ]]; then echo "true";fi) # Boolean to see trace logs if [[ ${ACTIONS_RUNNER_DEBUG} == true ]]; then LOG_LEVEL="DEBUG"; fi
# Boolean to see trace logs
LOG_TRACE=$(if [[ ${LOG_LEVEL} == "TRACE" ]]; then echo "true"; fi)
export LOG_TRACE export LOG_TRACE
LOG_DEBUG=$(if [[ ${LOG_LEVEL} == "DEBUG" || ${ACTIONS_RUNNER_DEBUG} == true ]]; then echo "true";fi) # Boolean to see debug logs # Boolean to see debug logs
LOG_DEBUG=$(if [[ ${LOG_LEVEL} == "DEBUG" || ${LOG_LEVEL} == "TRACE" ]]; then echo "true"; fi)
export LOG_DEBUG export LOG_DEBUG
LOG_VERBOSE=$(if [[ ${LOG_LEVEL} == "VERBOSE" ]]; then echo "true";fi) # Boolean to see verbose logs (info function) # Boolean to see verbose logs (info function)
LOG_VERBOSE=$(if [[ ${LOG_LEVEL} == "VERBOSE" || ${LOG_LEVEL} == "DEBUG" || ${LOG_LEVEL} == "TRACE" ]]; then echo "true"; fi)
export LOG_VERBOSE export LOG_VERBOSE
################ ################
@ -388,10 +392,10 @@ GetLinterVersions() {
#################### ####################
# Get the versions # # Get the versions #
#################### ####################
if [[ "${LINTER}" == "arm-ttk" ]]; then if [[ ${LINTER} == "arm-ttk" ]]; then
# Need specific command for ARM # Need specific command for ARM
mapfile -t GET_VERSION_CMD < <(grep -iE 'version' "${ARM_TTK_PSD1}" | xargs 2>&1) mapfile -t GET_VERSION_CMD < <(grep -iE 'version' "${ARM_TTK_PSD1}" | xargs 2>&1)
elif [[ "${LINTER}" == "protolint" ]]; then elif [[ ${LINTER} == "protolint" ]]; then
# Need specific command for Protolint # Need specific command for Protolint
mapfile -t GET_VERSION_CMD < <(echo "--version not supported") mapfile -t GET_VERSION_CMD < <(echo "--version not supported")
else else
@ -939,7 +943,7 @@ Reports() {
################################### ###################################
# Prints output report if enabled # # Prints output report if enabled #
################################### ###################################
if [ -z "${FORMAT_REPORT}" ] ; then if [ -z "${FORMAT_REPORT}" ]; then
info "Reports generated in folder ${REPORT_OUTPUT_FOLDER}" info "Reports generated in folder ${REPORT_OUTPUT_FOLDER}"
fi fi
@ -977,7 +981,7 @@ Footer() {
################## ##################
# Print if not 0 # # Print if not 0 #
################## ##################
if [[ "${!ERROR_COUNTER}" -ne 0 ]]; then if [[ ${!ERROR_COUNTER} -ne 0 ]]; then
# We found errors in the language # We found errors in the language
################### ###################
# Print the goods # # Print the goods #
@ -991,7 +995,7 @@ Footer() {
###################################### ######################################
# Check if we validated the langauge # # Check if we validated the langauge #
###################################### ######################################
elif [[ "${!ERROR_COUNTER}" -eq 0 ]] && [[ "${UNIQUE_LINTED_ARRAY[*]}" =~ ${LANGUAGE} ]]; then elif [[ ${!ERROR_COUNTER} -eq 0 ]] && [[ ${UNIQUE_LINTED_ARRAY[*]} =~ ${LANGUAGE} ]]; then
# No errors found when linting the language # No errors found when linting the language
CallStatusAPI "${LANGUAGE}" "success" CallStatusAPI "${LANGUAGE}" "success"
fi fi
@ -1013,7 +1017,7 @@ Footer() {
# build the variable # build the variable
ERRORS_FOUND_LANGUAGE="ERRORS_FOUND_${LANGUAGE}" ERRORS_FOUND_LANGUAGE="ERRORS_FOUND_${LANGUAGE}"
# Check if error was found # Check if error was found
if [[ "${!ERRORS_FOUND_LANGUAGE}" -ne 0 ]]; then if [[ ${!ERRORS_FOUND_LANGUAGE} -ne 0 ]]; then
# Failed exit # Failed exit
fatal "Exiting with errors found!" fatal "Exiting with errors found!"
fi fi
@ -1028,7 +1032,6 @@ Footer() {
exit 0 exit 0
} }
################################################################################ ################################################################################
#### Function Cleanup ########################################################## #### Function Cleanup ##########################################################
cleanup() { cleanup() {
@ -1054,7 +1057,7 @@ Header
# check flag for validating the report folder does not exist # # check flag for validating the report folder does not exist #
############################################################## ##############################################################
if [ -n "${OUTPUT_FORMAT}" ]; then if [ -n "${OUTPUT_FORMAT}" ]; then
if [ -d "${REPORT_OUTPUT_FOLDER}" ] ; then if [ -d "${REPORT_OUTPUT_FOLDER}" ]; then
error "ERROR! Found ${REPORT_OUTPUT_FOLDER}" error "ERROR! Found ${REPORT_OUTPUT_FOLDER}"
fatal "Please remove the folder and try again." fatal "Please remove the folder and try again."
fi fi

View file

@ -124,7 +124,7 @@ function LintCodebase() {
######################################## ########################################
# Prepare context if TAP format output # # Prepare context if TAP format output #
######################################## ########################################
if IsTAP ; then if IsTAP; then
TMPFILE=$(mktemp -q "/tmp/super-linter-${FILE_TYPE}.XXXXXX") TMPFILE=$(mktemp -q "/tmp/super-linter-${FILE_TYPE}.XXXXXX")
INDEX=0 INDEX=0
mkdir -p "${REPORT_OUTPUT_FOLDER}" mkdir -p "${REPORT_OUTPUT_FOLDER}"
@ -232,7 +232,7 @@ function LintCodebase() {
####################################################### #######################################################
# Store the linting as a temporary file in TAP format # # Store the linting as a temporary file in TAP format #
####################################################### #######################################################
if IsTAP ; then if IsTAP; then
NotOkTap "${INDEX}" "${FILE}" "${TMPFILE}" NotOkTap "${INDEX}" "${FILE}" "${TMPFILE}"
AddDetailedMessageIfEnabled "${LINT_CMD}" "${TMPFILE}" AddDetailedMessageIfEnabled "${LINT_CMD}" "${TMPFILE}"
fi fi
@ -245,7 +245,7 @@ function LintCodebase() {
####################################################### #######################################################
# Store the linting as a temporary file in TAP format # # Store the linting as a temporary file in TAP format #
####################################################### #######################################################
if IsTAP ; then if IsTAP; then
OkTap "${INDEX}" "${FILE}" "${TMPFILE}" OkTap "${INDEX}" "${FILE}" "${TMPFILE}"
fi fi
fi fi
@ -254,7 +254,7 @@ function LintCodebase() {
################################# #################################
# Generate report in TAP format # # Generate report in TAP format #
################################# #################################
if IsTAP && [ ${INDEX} -gt 0 ] ; then if IsTAP && [ ${INDEX} -gt 0 ]; then
HeaderTap "${INDEX}" "${REPORT_OUTPUT_FILE}" HeaderTap "${INDEX}" "${REPORT_OUTPUT_FILE}"
cat "${TMPFILE}" >> "${REPORT_OUTPUT_FILE}" cat "${TMPFILE}" >> "${REPORT_OUTPUT_FILE}"
fi fi
@ -317,7 +317,7 @@ function TestCodebase() {
######################################## ########################################
# Prepare context if TAP output format # # Prepare context if TAP output format #
######################################## ########################################
if IsTAP ; then if IsTAP; then
TMPFILE=$(mktemp -q "/tmp/super-linter-${FILE_TYPE}.XXXXXX") TMPFILE=$(mktemp -q "/tmp/super-linter-${FILE_TYPE}.XXXXXX")
mkdir -p "${REPORT_OUTPUT_FOLDER}" mkdir -p "${REPORT_OUTPUT_FOLDER}"
REPORT_OUTPUT_FILE="${REPORT_OUTPUT_FOLDER}/super-linter-${FILE_TYPE}.${OUTPUT_FORMAT}" REPORT_OUTPUT_FILE="${REPORT_OUTPUT_FOLDER}/super-linter-${FILE_TYPE}.${OUTPUT_FORMAT}"
@ -462,7 +462,7 @@ function TestCodebase() {
####################################################### #######################################################
# Store the linting as a temporary file in TAP format # # Store the linting as a temporary file in TAP format #
####################################################### #######################################################
if IsTAP ; then if IsTAP; then
OkTap "${TESTS_RAN}" "${FILE_NAME}" "${TMPFILE}" OkTap "${TESTS_RAN}" "${FILE_NAME}" "${TMPFILE}"
fi fi
else else
@ -492,7 +492,7 @@ function TestCodebase() {
####################################################### #######################################################
# Store the linting as a temporary file in TAP format # # Store the linting as a temporary file in TAP format #
####################################################### #######################################################
if IsTAP ; then if IsTAP; then
NotOkTap "${TESTS_RAN}" "${FILE_NAME}" "${TMPFILE}" NotOkTap "${TESTS_RAN}" "${FILE_NAME}" "${TMPFILE}"
AddDetailedMessageIfEnabled "${LINT_CMD}" "${TMPFILE}" AddDetailedMessageIfEnabled "${LINT_CMD}" "${TMPFILE}"
fi fi
@ -502,7 +502,7 @@ function TestCodebase() {
########################################################################### ###########################################################################
# Generate report in TAP format and validate with the expected TAP output # # Generate report in TAP format and validate with the expected TAP output #
########################################################################### ###########################################################################
if IsTAP && [ ${TESTS_RAN} -gt 0 ] ; then if IsTAP && [ ${TESTS_RAN} -gt 0 ]; then
HeaderTap "${TESTS_RAN}" "${REPORT_OUTPUT_FILE}" HeaderTap "${TESTS_RAN}" "${REPORT_OUTPUT_FILE}"
cat "${TMPFILE}" >> "${REPORT_OUTPUT_FILE}" cat "${TMPFILE}" >> "${REPORT_OUTPUT_FILE}"
@ -510,7 +510,7 @@ function TestCodebase() {
# If expected TAP report exists then compare with the generated report # # If expected TAP report exists then compare with the generated report #
######################################################################## ########################################################################
EXPECTED_FILE="${GITHUB_WORKSPACE}/${TEST_CASE_FOLDER}/${INDVIDUAL_TEST_FOLDER}/reports/expected-${FILE_TYPE}.tap" EXPECTED_FILE="${GITHUB_WORKSPACE}/${TEST_CASE_FOLDER}/${INDVIDUAL_TEST_FOLDER}/reports/expected-${FILE_TYPE}.tap"
if [ -e "${EXPECTED_FILE}" ] ; then if [ -e "${EXPECTED_FILE}" ]; then
TMPFILE=$(mktemp -q "/tmp/diff-${FILE_TYPE}.XXXXXX") TMPFILE=$(mktemp -q "/tmp/diff-${FILE_TYPE}.XXXXXX")
## Ignore white spaces, case sensitive ## Ignore white spaces, case sensitive
if ! diff -a -w -i "${EXPECTED_FILE}" "${REPORT_OUTPUT_FILE}" > "${TMPFILE}" 2>&1; then if ! diff -a -w -i "${EXPECTED_FILE}" "${REPORT_OUTPUT_FILE}" > "${TMPFILE}" 2>&1; then
@ -713,7 +713,7 @@ function LintAnsibleFiles() {
######################################## ########################################
# Prepare context if TAP output format # # Prepare context if TAP output format #
######################################## ########################################
if IsTAP ; then if IsTAP; then
TMPFILE=$(mktemp -q "/tmp/super-linter-${FILE_TYPE}.XXXXXX") TMPFILE=$(mktemp -q "/tmp/super-linter-${FILE_TYPE}.XXXXXX")
INDEX=0 INDEX=0
mkdir -p "${REPORT_OUTPUT_FOLDER}" mkdir -p "${REPORT_OUTPUT_FOLDER}"
@ -774,7 +774,7 @@ function LintAnsibleFiles() {
####################################################### #######################################################
# Store the linting as a temporary file in TAP format # # Store the linting as a temporary file in TAP format #
####################################################### #######################################################
if IsTAP ; then if IsTAP; then
NotOkTap "${INDEX}" "${FILE}" "${TMPFILE}" NotOkTap "${INDEX}" "${FILE}" "${TMPFILE}"
AddDetailedMessageIfEnabled "${LINT_CMD}" "${TMPFILE}" AddDetailedMessageIfEnabled "${LINT_CMD}" "${TMPFILE}"
fi fi
@ -788,7 +788,7 @@ function LintAnsibleFiles() {
####################################################### #######################################################
# Store the linting as a temporary file in TAP format # # Store the linting as a temporary file in TAP format #
####################################################### #######################################################
if IsTAP ; then if IsTAP; then
OkTap "${INDEX}" "${FILE}" "${TMPFILE}" OkTap "${INDEX}" "${FILE}" "${TMPFILE}"
fi fi
fi fi
@ -797,7 +797,7 @@ function LintAnsibleFiles() {
################################# #################################
# Generate report in TAP format # # Generate report in TAP format #
################################# #################################
if IsTAP && [ ${INDEX} -gt 0 ] ; then if IsTAP && [ ${INDEX} -gt 0 ]; then
HeaderTap "${INDEX}" "${REPORT_OUTPUT_FILE}" HeaderTap "${INDEX}" "${REPORT_OUTPUT_FILE}"
cat "${TMPFILE}" >> "${REPORT_OUTPUT_FILE}" cat "${TMPFILE}" >> "${REPORT_OUTPUT_FILE}"
fi fi
@ -812,7 +812,7 @@ function LintAnsibleFiles() {
################################################################################ ################################################################################
#### Function IsTap ############################################################ #### Function IsTap ############################################################
function IsTAP() { function IsTAP() {
if [ "${OUTPUT_FORMAT}" == "tap" ] ; then if [ "${OUTPUT_FORMAT}" == "tap" ]; then
return 0 return 0
else else
return 1 return 1
@ -822,7 +822,7 @@ function IsTAP() {
#### Function TransformTAPDetails ############################################## #### Function TransformTAPDetails ##############################################
function TransformTAPDetails() { function TransformTAPDetails() {
DATA=${1} DATA=${1}
if [ -n "${DATA}" ] && [ "${OUTPUT_DETAILS}" == "detailed" ] ; then if [ -n "${DATA}" ] && [ "${OUTPUT_DETAILS}" == "detailed" ]; then
######################################################### #########################################################
# Transform new lines to \\n, remove colours and colons # # Transform new lines to \\n, remove colours and colons #
######################################################### #########################################################
@ -886,7 +886,7 @@ function AddDetailedMessageIfEnabled() {
# Check the return # # Check the return #
#################### ####################
DETAILED_MSG=$(TransformTAPDetails "${LINT_CMD}") DETAILED_MSG=$(TransformTAPDetails "${LINT_CMD}")
if [ -n "${DETAILED_MSG}" ] ; then if [ -n "${DETAILED_MSG}" ]; then
printf " ---\n message: %s\n ...\n" "${DETAILED_MSG}" >> "${TEMP_FILE}" printf " ---\n message: %s\n ...\n" "${DETAILED_MSG}" >> "${TEMP_FILE}"
fi fi
} }