From 3547fa99c9ef73f2f0dc66328ccd91d381df2466 Mon Sep 17 00:00:00 2001 From: Guillaume Lambert Date: Tue, 4 May 2021 13:46:48 +0200 Subject: [PATCH] Fix: bashate E006 warnings for lines > 120 chars 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 Change-Id: Ibbb171353fd960ea93145f7913e62e327bd6a86b --- shell/gerrit-fetch-dependencies.sh | 4 +++- shell/jenkins-configure-global-vars.sh | 5 ++++- shell/license-check.sh | 6 +++++- shell/maven-central.sh | 5 ++++- shell/nexus-iq-python-cli.sh | 4 +++- shell/openstack-cleanup-orphaned-stacks.sh | 5 ++++- shell/packer-build.sh | 5 +++-- shell/packer-install.sh | 3 ++- shell/python-tools-install.sh | 3 ++- shell/release-job.sh | 8 ++++++-- 10 files changed, 36 insertions(+), 12 deletions(-) diff --git a/shell/gerrit-fetch-dependencies.sh b/shell/gerrit-fetch-dependencies.sh index 5cff012b..c897f552 100644 --- a/shell/gerrit-fetch-dependencies.sh +++ b/shell/gerrit-fetch-dependencies.sh @@ -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 diff --git a/shell/jenkins-configure-global-vars.sh b/shell/jenkins-configure-global-vars.sh index 1e2f95ea..86b1bcde 100644 --- a/shell/jenkins-configure-global-vars.sh +++ b/shell/jenkins-configure-global-vars.sh @@ -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 diff --git a/shell/license-check.sh b/shell/license-check.sh index 5b430723..31290c3a 100644 --- a/shell/license-check.sh +++ b/shell/license-check.sh @@ -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" diff --git a/shell/maven-central.sh b/shell/maven-central.sh index da36d36f..88c3bc14 100644 --- a/shell/maven-central.sh +++ b/shell/maven-central.sh @@ -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" diff --git a/shell/nexus-iq-python-cli.sh b/shell/nexus-iq-python-cli.sh index b47bf74d..7e105c94 100644 --- a/shell/nexus-iq-python-cli.sh +++ b/shell/nexus-iq-python-cli.sh @@ -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}" diff --git a/shell/openstack-cleanup-orphaned-stacks.sh b/shell/openstack-cleanup-orphaned-stacks.sh index ccc29969..e4f457ae 100644 --- a/shell/openstack-cleanup-orphaned-stacks.sh +++ b/shell/openstack-cleanup-orphaned-stacks.sh @@ -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}') diff --git a/shell/packer-build.sh b/shell/packer-build.sh index 73e74965..b85c31a7 100644 --- a/shell/packer-build.sh +++ b/shell/packer-build.sh @@ -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 diff --git a/shell/packer-install.sh b/shell/packer-install.sh index 49077a10..a98ba9ac 100644 --- a/shell/packer-install.sh +++ b/shell/packer-install.sh @@ -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." diff --git a/shell/python-tools-install.sh b/shell/python-tools-install.sh index 72baf8a3..e2a84a52 100644 --- a/shell/python-tools-install.sh +++ b/shell/python-tools-install.sh @@ -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 diff --git a/shell/release-job.sh b/shell/release-job.sh index 3a732e0b..a4194388 100644 --- a/shell/release-job.sh +++ b/shell/release-job.sh @@ -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 : --upload-file "${NEXUS_URL}"/content/repositories/releases/org/"${ORG}"/"${VERSION}"/"${name}" \; + curl -v -u : --upload-file \ + "${NEXUS_URL}"/content/repositories/releases/org/"${ORG}"/"${VERSION}"/"${name}" \; fi echo "#########################" fi -- 2.16.6