From cee9d3a95695554eb1b4664f1de5d585eb7761f9 Mon Sep 17 00:00:00 2001 From: Victor Martinez Date: Wed, 15 Jul 2020 22:37:46 +0100 Subject: [PATCH] refactored AddDetailedMessageIfEnabled --- lib/worker.sh | 34 ++++++++++++---------------------- 1 file changed, 12 insertions(+), 22 deletions(-) diff --git a/lib/worker.sh b/lib/worker.sh index 1fe46a02..36ea789b 100755 --- a/lib/worker.sh +++ b/lib/worker.sh @@ -220,13 +220,7 @@ function LintCodebase() { ####################################################### if IsTAP ; then NotOkTap "${INDEX}" "${FILE}" "${TMPFILE}" - ########################################## - # Report the detailed message if enabled # - ########################################## - DETAILED_MSG=$(TransformTAPDetails "$LINT_CMD") - if [ -n "${DETAILED_MSG}" ] ; then - printf " ---\n message: %s\n ...\n" "$DETAILED_MSG" >> "${TMPFILE}" - fi + AddDetailedMessageIfEnabled "$LINT_CMD" "${TMPFILE}" fi else ########### @@ -476,13 +470,7 @@ function TestCodebase() { ####################################################### if IsTAP ; then NotOkTap "${TESTS_RAN}" "${FILE_NAME}" "${TMPFILE}" - ########################################## - # Report the detailed message if enabled # - ########################################## - DETAILED_MSG=$(TransformTAPDetails "$LINT_CMD") - if [ -n "${DETAILED_MSG}" ] ; then - printf " ---\n message: %s\n ...\n" "${DETAILED_MSG}" >> "${TMPFILE}" - fi + AddDetailedMessageIfEnabled "$LINT_CMD" "${TMPFILE}" fi fi done @@ -760,13 +748,7 @@ function LintAnsibleFiles() { ####################################################### if IsTAP ; then NotOkTap "${INDEX}" "${FILE}" "${TMPFILE}" - ########################################## - # Report the detailed message if enabled # - ########################################## - DETAILED_MSG=$(TransformTAPDetails "$LINT_CMD") - if [ -n "${DETAILED_MSG}" ] ; then - printf " ---\n message: %s\n ...\n" "$DETAILED_MSG" >> "${TMPFILE}" - fi + AddDetailedMessageIfEnabled "${LINT_CMD}" "${TMPFILE}" fi else @@ -838,4 +820,12 @@ function OkTap() { #### Function NotOkTap ######################################################### function NotOkTap() { echo "not ok ${1} - ${2}" >> "${3}" -} \ No newline at end of file +} +################################################################################ +#### Function AddDetailedMessageIfEnabled ###################################### +function AddDetailedMessageIfEnabled() { + DETAILED_MSG=$(TransformTAPDetails "${1}") + if [ -n "${DETAILED_MSG}" ] ; then + printf " ---\n message: %s\n ...\n" "$DETAILED_MSG" >> "${2}" + fi +}