Skip to content
Permalink
Browse files

Fix some SC2086 warnings

  • Loading branch information
nyalldawson committed Jun 21, 2018
1 parent 78b07cd commit 2104b563d61233fcf537f7abbd20fce334cac2a7
@@ -20,14 +20,14 @@ source $(git rev-parse --show-toplevel)/.ci/travis/scripts/travis_envvar_helper.

DOCKER_QGIS_IMAGE_BUILD_PUSH=$(create_qgis_image)

mkdir -p $CCACHE_DIR
mkdir -p "$CCACHE_DIR"

if [[ $DOCKER_QGIS_IMAGE_BUILD_PUSH =~ true ]]; then
DIR=$(git rev-parse --show-toplevel)/.docker
pushd "${DIR}"
echo "${bold}Building QGIS Docker image '${DOCKER_TAG}'...${endbold}"
docker build --build-arg CACHE_DIR=/root/.ccache \
--build-arg DOCKER_TAG=${DOCKER_TAG} \
--build-arg DOCKER_TAG="${DOCKER_TAG}" \
--cache-from "qgis/qgis:${DOCKER_TAG}" \
-t "qgis/qgis:${DOCKER_TAG}" \
-f qgis.dockerfile ..
@@ -33,7 +33,7 @@ TIMEOUT=$((40 * 60 - $(date +%s) + $(cat /tmp/travis_timestamp)))
export CTEST_BUILD_COMMAND=/usr/local/bin/ninja
export CTEST_BUILD_DIR=${TRAVIS_BUILD_DIR}

gtimeout "${TIMEOUT}s" ctest -V -E "$(cat ${DIR}/blacklist.txt | gsed -r '/^(#.*?)?$/d' | gpaste -sd '|' -)" -S "${DIR}/../travis.ctest" --output-on-failure
gtimeout "${TIMEOUT}s" ctest -V -E "$(cat "${DIR}"/blacklist.txt | gsed -r '/^(#.*?)?$/d' | gpaste -sd '|' -)" -S "${DIR}/../travis.ctest" --output-on-failure

rv=$?

@@ -26,7 +26,7 @@ declare -a EXT=("cpp" "h")
for i in "${EXT[@]}"
do
DESTFILE=$DIR/../src/customwidgets/${CLASSLOWER}plugin.$i
cp $DIR/customwidget.$i.template $DESTFILE
cp "$DIR"/customwidget."$i".template "$DESTFILE"
sed -i s/%DATE%/"$TODAY"/g "$DESTFILE"
sed -i s/%YEAR%/"$YEAR"/g "$DESTFILE"
sed -i s/%AUTHOR%/"$AUTHOR"/g "$DESTFILE"
@@ -22,7 +22,7 @@ if ! tty -s && [[ "$0" =~ /pre-commit ]]; then
exec </dev/tty
fi

cd $TOPLEVEL
cd "$TOPLEVEL"

# GNU prefix command for mac os support (gsed, gsplit)
GP=
@@ -57,25 +57,25 @@ if [ -z "$MODIFIED" ]; then
exit 0
fi

if [[ -n "$QGIS_CHECK_SPELLING" && -x ${TOPLEVEL}/scripts/spell_check/check_spelling.sh ]]; then ${TOPLEVEL}/scripts/spell_check/check_spelling.sh $MODIFIED; fi
if [[ -n "$QGIS_CHECK_SPELLING" && -x "${TOPLEVEL}"/scripts/spell_check/check_spelling.sh ]]; then "${TOPLEVEL}"/scripts/spell_check/check_spelling.sh "$MODIFIED"; fi


# save original changes
REV=$(git log -n1 --pretty=%H)
git diff >sha-$REV.diff
git diff >sha-"$REV".diff

ASTYLEDIFF=astyle.$REV.diff
true > $ASTYLEDIFF
true > "$ASTYLEDIFF"

# reformat
i=0
N=$(echo $MODIFIED | wc -w)
N=$(echo "$MODIFIED" | wc -w)
for f in $MODIFIED; do
(( i++ )) || true

case "$f" in
src/core/gps/qextserialport/*|src/plugins/globe/osgEarthQt/*|src/plugins/globe/osgEarthUtil/*|src/3d/poly2tri/*)
echo $f skipped
echo "$f" skipped
continue
;;

@@ -89,59 +89,59 @@ for f in $MODIFIED; do

m=$f.$REV.prepare

cp $f $m
ASTYLEPROGRESS=" [$i/$N]" astyle.sh $f
if diff -u $m $f >>$ASTYLEDIFF; then
cp "$f" "$m"
ASTYLEPROGRESS=" [$i/$N]" astyle.sh "$f"
if diff -u "$m" "$f" >>"$ASTYLEDIFF"; then
# no difference found
rm $m
rm "$m"
fi
done

if [ -s "$ASTYLEDIFF" ]; then
if tty -s; then
# review astyle changes
colordiff <$ASTYLEDIFF | less -r
colordiff <"$ASTYLEDIFF" | less -r
else
echo "Files changed (see $ASTYLEDIFF)"
fi
else
rm $ASTYLEDIFF
rm "$ASTYLEDIFF"
fi


# verify SIP files
SIPIFYDIFF=sipify.$REV.diff
true > $SIPIFYDIFF
true > "$SIPIFYDIFF"
for f in $MODIFIED; do
# if cpp header
if [[ $f =~ ^src\/(core|gui|analysis|server)\/.*\.h$ ]]; then
# look if corresponding SIP file
sip_file=$(${GP}sed -r 's@^src/(core|gui|analysis|server)/@@; s@\.h$@.sip@' <<<$f )
pyfile=$(${GP}sed -E 's@([^\/]+\/)*([^\/]+)\.sip@\2.py@;' <<< $sip_file)
module=$(${GP}sed -r 's@src/(core|gui|analysis|server)/.*$@\1@' <<<$f )
if grep -Fq "$sip_file" ${TOPLEVEL}/python/${module}/${module}_auto.sip; then
sip_file=$(${GP}sed -r 's@^src/(core|gui|analysis|server)@\1/auto_generated@; s@\.h$@.sip.in@' <<<$f )
sip_file=$(${GP}sed -r 's@^src/(core|gui|analysis|server)/@@; s@\.h$@.sip@' <<<"$f" )
pyfile=$(${GP}sed -E 's@([^\/]+\/)*([^\/]+)\.sip@\2.py@;' <<< "$sip_file")
module=$(${GP}sed -r 's@src/(core|gui|analysis|server)/.*$@\1@' <<<"$f" )
if grep -Fq "$sip_file" "${TOPLEVEL}"/python/"${module}"/"${module}"_auto.sip; then
sip_file=$(${GP}sed -r 's@^src/(core|gui|analysis|server)@\1/auto_generated@; s@\.h$@.sip.in@' <<<"$f" )
m=python/$sip_file.$REV.prepare
touch python/$sip_file
cp python/$sip_file $m
${TOPLEVEL}/scripts/sipify.pl -s python/$sip_file -p python/${module}/auto_additions/${pyfile} $f
if ! diff -u $m python/$sip_file >>$SIPIFYDIFF; then
touch python/"$sip_file"
cp python/"$sip_file" "$m"
"${TOPLEVEL}"/scripts/sipify.pl -s python/"$sip_file" -p python/"${module}"/auto_additions/"${pyfile}" "$f"
if ! diff -u "$m" python/"$sip_file" >>"$SIPIFYDIFF"; then
echo "python/$sip_file is not up to date"
fi
rm $m
rm "$m"
fi
fi
done
if [[ -s "$SIPIFYDIFF" ]]; then
if tty -s; then
# review astyle changes
colordiff <$SIPIFYDIFF | less -r
colordiff <"$SIPIFYDIFF" | less -r
else
echo "Files changed (see $ASTYLEDIFF)"
fi
exit 1
else
rm $SIPIFYDIFF
rm "$SIPIFYDIFF"
fi
if [ -s "$ASTYLEDIFF" ]; then
exit 1
@@ -9,57 +9,57 @@ r=$(mktemp -t repl.XXXX.pl)
d=$(mktemp -t apibreak.XXXX.txt)

# Rename classes
for i in $(git --no-pager grep "Qgs[a-zA-Z0-9_]*V2" $codepaths | perl -pe 's#^.*(Qgs[a-zA-Z0-9_]*)V2([a-zA-Z0-9_]*).*$#$1V2$2#' | sort -u)
for i in $(git --no-pager grep "Qgs[a-zA-Z0-9_]*V2" "$codepaths" | perl -pe 's#^.*(Qgs[a-zA-Z0-9_]*)V2([a-zA-Z0-9_]*).*$#$1V2$2#' | sort -u)
do
src=$i
dst=${src/V2/}
if git --no-pager grep -l "\<$dst\>" $codepaths; then
echo "$src vs $dst" >>$s
if git --no-pager grep -l "\<$dst\>" "$codepaths"; then
echo "$src vs $dst" >>"$s"
else
echo " REPLACE $src => $dst"
echo "s/\b$src\b/$dst/g;" >>$r
echo "s/\bsipType_$src\b/sipType_$dst/;" >>$r
echo "<tr><td>$src<td>$dst" >>$d
echo "s/\b$src\b/$dst/g;" >>"$r"
echo "s/\bsipType_$src\b/sipType_$dst/;" >>"$r"
echo "<tr><td>$src<td>$dst" >>"$d"
fi
done

for i in $(git --no-pager grep "::[a-zA-Z0-9_]*V2" $codepaths | perl -pe 's#^.*::([a-zA-Z0-9_]*)V2([a-zA-Z0-9_]*).*$#$1V2$2#' | grep -v -E "^Qgs|SslV2" | sort -u)
for i in $(git --no-pager grep "::[a-zA-Z0-9_]*V2" "$codepaths" | perl -pe 's#^.*::([a-zA-Z0-9_]*)V2([a-zA-Z0-9_]*).*$#$1V2$2#' | grep -v -E "^Qgs|SslV2" | sort -u)
do
src=$i
dst=${src/V2/}

if git --no-pager grep -l "\<$dst\>" $codepaths; then
echo "$src vs $dst" >>$s
if git --no-pager grep -l "\<$dst\>" "$codepaths"; then
echo "$src vs $dst" >>"$s"
else
echo " REPLACE $src => $dst"
echo "s/\b$src\b/$dst/g;" >>$r
echo "<tr><td>$src<td>$dst" >>$d
echo "s/\b$src\b/$dst/g;" >>"$r"
echo "<tr><td>$src<td>$dst" >>"$d"
fi
done

find $codepaths \( -name "*v2*.h" -o -name "*v2*.cpp" -o -name "*v2*.sip" \) -type f | while read f; do
find "$codepaths" \( -name "*v2*.h" -o -name "*v2*.cpp" -o -name "*v2*.sip" \) -type f | while read f; do
s=${f##*/}
d=${s/v2/}
echo "FIND $d"
if [ $(find $codepaths -name "$d" -print | wc -l) -gt 0 ]; then
echo "$f vs $b" >>$s
if [ $(find "$codepaths" -name "$d" -print | wc -l) -gt 0 ]; then
echo "$f vs $b" >>"$s"
continue
fi

git mv "$f" "${f/v2/}"

case "$s" in
*.sip)
echo "s#\b$s\b#$d#g;" >>$r
echo "s#\b$s\b#$d#g;" >>"$r"
;;

*)
echo "s#\b$s\b#$d#g;" >>$r
echo "s#\b$s\b#$d#g;" >>"$r"
;;
esac
done

echo "API breaks logged to: $d"
echo "Skipped V2 symbols: $s"
echo "Replacing from $r"
find $codepaths -type f | xargs perl -i -p $r
find "$codepaths" -type f | xargs perl -i -p "$r"
@@ -73,7 +73,7 @@ do
sort -u $FILE3 >> $FILE1
SORTING=false
fi
mv $FILE1 $file
mv $FILE1 "$file"
rm -f $FILE1 $FILE2 $FILE3
done

0 comments on commit 2104b56

Please sign in to comment.
You can’t perform that action at this time.