Fix: bashate E006 warnings for lines > 120 chars 76/67576/14
authorGuillaume Lambert <guillaume.lambert@orange.com>
Tue, 4 May 2021 11:46:48 +0000 (13:46 +0200)
committerGuillaume Lambert <guillaume.lambert@orange.com>
Wed, 12 May 2021 08:50:12 +0000 (08:50 +0000)
Lines too long can not only cause problems when reading/writing code,
but also often indicates a bad smell,
e.g. too many levels of indentation due to overly complex functions
which requires refactoring into smaller chunks.

Note that the bashate current profile reports every line > 80 chars.
After this commit, 211 warnings of this category will still remain.

Signed-off-by: Guillaume Lambert <guillaume.lambert@orange.com>
Change-Id: Ibbb171353fd960ea93145f7913e62e327bd6a86b

shell/gerrit-fetch-dependencies.sh
shell/jenkins-configure-global-vars.sh
shell/license-check.sh
shell/maven-central.sh
shell/nexus-iq-python-cli.sh
shell/openstack-cleanup-orphaned-stacks.sh
shell/packer-build.sh
shell/packer-install.sh
shell/python-tools-install.sh
shell/release-job.sh

index 5cff012..c897f55 100644 (file)
@@ -25,7 +25,9 @@ set -eu -o pipefail
 
 REPOS_DIR="$WORKSPACE/.repos"
 
-IFS=" " read -r -a PATCHES <<< "$(echo "$GERRIT_EVENT_COMMENT_TEXT" | grep -E '(recheck:|reverify:)' | awk -F: '{print $2}')"
+IFS=" " read -r -a PATCHES <<< \
+        "$(echo "$GERRIT_EVENT_COMMENT_TEXT" | \
+            grep -E '(recheck:|reverify:)' | awk -F: '{print $2}')"
 
 # shellcheck disable=SC1090
 source ~/lf-env.sh
index 1e2f95e..86b1bcd 100644 (file)
@@ -28,7 +28,10 @@ for silo in $silos; do
     if [ ! -f "$WORKSPACE/jenkins-config/global-vars-$silo.sh" ]; then
         echo "WARN: jenkins-config/global-vars-$silo.sh does not exist. Skipping cloud management..."
         echo "We highly recommend setting up global-vars-$silo.sh to manage the Jenkins global variables."
-        echo "Refer to https://docs.releng.linuxfoundation.org/projects/global-jjb/en/latest/jjb/lf-ci-jobs.html#global-environment-variables for details."
+        # shellcheck disable=SC2140
+        echo "Refer to https://docs.releng.linuxfoundation.org/"\
+"projects/global-jjb/en/latest/jjb/lf-ci-jobs.html"\
+"#global-environment-variables for details."
         continue
     fi
 
index 5b43072..31290c3 100644 (file)
@@ -45,7 +45,11 @@ if hash lhc 2>/dev/null; then
 else
     echo "License Header Checker is not installed. Installing..."
     mkdir "$WORKSPACE/bin"
-    wget -nv -O "/tmp/lhc.tar.gz" "https://nexus.opendaylight.org/content/repositories/hosted_installers/org/linuxfoundation/lhc/${lhc_version}/lhc-${lhc_version}.tar.gz"
+    NEXUS_BASEURL="https://nexus.opendaylight.org/"
+    NEXUS_PATH="content/repositories/hosted_installers/org/linuxfoundation/"
+    NEXUS_LHC="lhc/${lhc_version}/lhc-${lhc_version}.tar.gz"
+    NEXUS_URL="${NEXUS_BASEURL}${NEXUS_PATH}${NEXUS_LHC}"
+    wget -nv -O "/tmp/lhc.tar.gz" "$NEXUS_URL"
     tar -zxvf /tmp/lhc.tar.gz -C "$WORKSPACE/bin"
     chmod +x "$WORKSPACE/bin/lhc"
     export PATH="$WORKSPACE/bin:$PATH"
index da36d36..88c3bc1 100644 (file)
@@ -21,4 +21,7 @@ lftools deploy nexus-stage "https://oss.sonatype.org" "$profile_id" "$WORKSPACE/
 mc_staging_repo=$(sed -n -e 's/Staging repository \(.*\) created\./\1/p' "$MC_TMP_FILE")
 rm -f "$MC_TMP_FILE"
 
-echo "$mc_staging_repo https://oss.sonatype.org/content/repositories/$mc_staging_repo" | tee -a "$WORKSPACE/archives/staging-repo.txt"
+# shellcheck disable=SC2140
+echo "$mc_staging_repo "\
+"https://oss.sonatype.org/content/repositories/$mc_staging_repo" | \
+    tee -a "$WORKSPACE/archives/staging-repo.txt"
index b47bf74..7e105c9 100644 (file)
@@ -29,7 +29,9 @@ echo "-a" > cli-auth.txt
 echo "${NEXUS_IQ_USER}:${NEXUS_IQ_PASSWORD}" >> cli-auth.txt
 echo "INFO: running nexus-iq-cli on project $NEXUS_IQ_PROJECT_NAME and file $REQUIREMENTS_FILE"
 # result.json is a mystery
-java -jar "${CLI_LOCATION}" @cli-auth.txt -s https://nexus-iq.wl.linuxfoundation.org -i "${NEXUS_IQ_PROJECT_NAME}" -t build -r result.json "${REQUIREMENTS_FILE}"
+java -jar "${CLI_LOCATION}" @cli-auth.txt \
+    -s https://nexus-iq.wl.linuxfoundation.org -i "${NEXUS_IQ_PROJECT_NAME}" \
+    -t build -r result.json "${REQUIREMENTS_FILE}"
 rm cli-auth.txt
 rm "${CLI_LOCATION}"
 
index ccc2996..e4f457a 100644 (file)
@@ -22,7 +22,10 @@ stack_in_jenkins() {
 
     builds=()
     for jenkins in "${@:2}"; do
-        JENKINS_URL="$jenkins/computer/api/json?tree=computer[executors[currentExecutable[url]],oneOffExecutors[currentExecutable[url]]]&xpath=//url&wrapper=builds"
+        PARAMS="tree=computer[executors[currentExecutable[url]],"
+        PARAMS=$PARAMS"oneOffExecutors[currentExecutable[url]]]"
+        PARAMS=$PARAMS"&xpath=//url&wrapper=builds"
+        JENKINS_URL="$jenkins/computer/api/json?$PARAMS"
         resp=$(curl -s -w "\\n\\n%{http_code}" --globoff -H "Content-Type:application/json" "$JENKINS_URL")
         json_data=$(echo "$resp" | head -n1)
         status=$(echo "$resp" | awk 'END {print $NF}')
index 73e7496..b85c31a 100644 (file)
@@ -53,8 +53,9 @@ then
 elif [[ "${GIT_BASE:-}" =~ https://github.com ]]; then
     LAST_CHANGE_SHA=$(git log --no-merges -1 --format=%H)
     API_BASE=$(echo "$GIT_BASE" | sed -E 's#(www.)?github.com#api.github.com/repos#')
-    STATUS=$(curl "${API_BASE}/statuses/${LAST_CHANGE_SHA}" \
-        | jq ".[] | select(.state == \"success\" and .context == \"Packer ${PACKER_PLATFORM}-${PACKER_TEMPLATE} Verify Build\")")
+    CONTEXT_VALUE="\"Packer ${PACKER_PLATFORM}-${PACKER_TEMPLATE} Verify Build\""
+    JQ_QUERY=".[] | select(.state == \"success\" and .context == ${CONTEXT_VALUE})"
+    STATUS=$(curl "${API_BASE}/statuses/${LAST_CHANGE_SHA}" | jq "${JQ_QUERY}")
     if [[ -n ${STATUS} ]]; then
         echo "Build already successful for this patch set. Skipping merge build..."
         exit
index 49077a1..a98ba9a 100644 (file)
@@ -42,7 +42,8 @@ if hash packer.io 2>/dev/null; then
         echo "Packer version $CURRENT_VERSION installed is less than $PACKER_VERSION available, updating Packer."
         packer_install
     else
-        echo "Packer version installed $CURRENT_VERSION is greater than or equal to the required minimum version $PACKER_VERSION."
+        echo "Packer version installed $CURRENT_VERSION is greater than or equal to"\
+        "the required minimum version $PACKER_VERSION."
     fi
 else
     echo "Packer binary not available, installing Packer version $PACKER_VERSION."
index 72baf8a..e2a84a5 100644 (file)
@@ -53,7 +53,8 @@ EOF
 
     python3 -m pip install --user --quiet --upgrade pip
     python3 -m pip install --user --quiet --no-warn-script-location --upgrade setuptools
-    python3 -m pip install --user --quiet --no-warn-script-location --upgrade --upgrade-strategy eager -r "$requirements_file"
+    python3 -m pip install --user --quiet --no-warn-script-location --upgrade \
+        --upgrade-strategy eager -r "$requirements_file"
     # installs are silent, show version details in log
     python3 --version
     python3 -m pip --version
index 3a732e0..a419438 100644 (file)
@@ -280,7 +280,10 @@ verify_version(){
     OVERRIDE_SEMVER_REGEX="${OVERRIDE_SEMVER_REGEX:-None}"
     if [[ $OVERRIDE_SEMVER_REGEX == "None" ]]; then
         # Use the semver regex taken from https://github.com/fsaintjacques/semver-tool
-        semver_regex="^[vV]?(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)(\-(0|[1-9][0-9]*|[0-9]*[A-Za-z-][0-9A-Za-z-]*)(\.(0|[1-9][0-9]*|[0-9]*[A-Za-z-][0-9A-Za-z-]*))*)?(\+[0-9A-Za-z-]+(\.[0-9A-Za-z-]+)*)?$"
+        pat1="(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)"
+        pat2="(0|[1-9][0-9]*|[0-9]*[A-Za-z-][0-9A-Za-z-]*)"
+        pat3="(\+[0-9A-Za-z-]+(\.[0-9A-Za-z-]+)*)"
+        semver_regex="^[vV]?${pat1}(\-${pat2}(\.${pat2})*)?${pat3}?$"
     else
         semver_regex="${OVERRIDE_SEMVER_REGEX}"
     fi
@@ -396,7 +399,8 @@ artifact_release_file(){
             wget "${path}"/"${name}" -o artifacts/"${name}"
             if [[ "$JOB_NAME" =~ "merge" ]] && [[ "$DRY_RUN" = false ]]; then
                 #lftools sign sigul artifacts
-                curl -v -u <NEXUSUSER>:<NEXUSPASS> --upload-file "${NEXUS_URL}"/content/repositories/releases/org/"${ORG}"/"${VERSION}"/"${name}" \;
+                curl -v -u <NEXUSUSER>:<NEXUSPASS> --upload-file \
+                    "${NEXUS_URL}"/content/repositories/releases/org/"${ORG}"/"${VERSION}"/"${name}" \;
             fi
             echo "#########################"
         fi