2
0
forked from Wavyzz/dolibarr

Qual: Ignore most shellcheck annotations, fix some (#27452)

# Qual: Ignore most shellcheck annotations, fix some

Most shellcheck annotations are ignored - this is to make sure that ci
can work for existing scripts.

Some fixes were applied.

pre-commit script was beautyfied by temporarily suppressing the IFS= expression on 2 lines.
This commit is contained in:
MDW
2024-01-12 21:03:08 +01:00
committed by GitHub
parent 96383a10a5
commit c885c6917e
32 changed files with 91 additions and 44 deletions

View File

@@ -2,6 +2,8 @@
# Debian install package run: config, preinst, prerm, postinst, postrm # Debian install package run: config, preinst, prerm, postinst, postrm
# #
# shellcheck disable=1091,2034
set -e set -e

View File

@@ -1,6 +1,8 @@
#!/bin/sh #!/bin/sh
# postinst script for dolibarr # postinst script for dolibarr
# shellcheck disable=1091,2086,2154
set -e set -e
# summary of how this script can be called: # summary of how this script can be called:

View File

@@ -3,6 +3,8 @@
# #
# see: dh_installdeb(1) # see: dh_installdeb(1)
# shellcheck disable=1091,2006,2034,2086,2089,2090
#set -e #set -e
set +e set +e

View File

@@ -1,5 +1,7 @@
#!/bin/sh #!/bin/sh
# shellcheck disable=2034,2086,2103,2164
tmpdir=$(mktemp -d) tmpdir=$(mktemp -d)

View File

@@ -2,8 +2,8 @@
# Script used by the Dockerfile. # Script used by the Dockerfile.
# See README.md to know how to create a Dolibarr env with docker # See README.md to know how to create a Dolibarr env with docker
usermod -u ${HOST_USER_ID} www-data usermod -u "${HOST_USER_ID}" www-data
groupmod -g ${HOST_USER_ID} www-data groupmod -g "${HOST_USER_ID}" www-data
chgrp -hR www-data /var/www/html chgrp -hR www-data /var/www/html
chmod g+rwx /var/www/html/conf chmod g+rwx /var/www/html/conf
@@ -15,8 +15,8 @@ fi
echo "[docker-run] => Set Permission to www-data for /var/documents" echo "[docker-run] => Set Permission to www-data for /var/documents"
chown -R www-data:www-data /var/documents chown -R www-data:www-data /var/documents
echo "[docker-run] => update ${PHP_INI_DIR}/conf.d/dolibarr-php.ini" echo "[docker-run] => update '${PHP_INI_DIR}/conf.d/dolibarr-php.ini'"
cat <<EOF > ${PHP_INI_DIR}/conf.d/dolibarr-php.ini cat <<EOF > "${PHP_INI_DIR}/conf.d/dolibarr-php.ini"
date.timezone = ${PHP_INI_DATE_TIMEZONE:-UTC} date.timezone = ${PHP_INI_DATE_TIMEZONE:-UTC}
memory_limit = ${PHP_INI_MEMORY_LIMIT:-256M} memory_limit = ${PHP_INI_MEMORY_LIMIT:-256M}
EOF EOF

View File

@@ -10,6 +10,8 @@
# with explanation on its goal, for inclusion in main branch. # with explanation on its goal, for inclusion in main branch.
#---------------------------------------------------------------------------- #----------------------------------------------------------------------------
# shellcheck disable=2086,2291
echo ----- Building patch file mypatch.patch ----- echo ----- Building patch file mypatch.patch -----
if [ -z "$1" ] || [ -z "$2" ]; if [ -z "$1" ] || [ -z "$2" ];
then then

View File

@@ -12,6 +12,8 @@
# Usage: initdemo.sh confirm # Usage: initdemo.sh confirm
# usage: initdemo.sh confirm mysqldump_dolibarr_x.x.x.sql database port login pass # usage: initdemo.sh confirm mysqldump_dolibarr_x.x.x.sql database port login pass
#------------------------------------------------------ #------------------------------------------------------
# shellcheck disable=2006,2034,2046,2064,2068,2086,2155,2166,2186,2172,2268
# shellcheck disable=2012,2016,2115
export mydir=`echo "$0" | sed -e 's/initdemo.sh//'`; export mydir=`echo "$0" | sed -e 's/initdemo.sh//'`;

View File

@@ -8,6 +8,8 @@
# Usage: initdemopassword.sh confirm # Usage: initdemopassword.sh confirm
# usage: initdemopassword.sh confirm base port login pass # usage: initdemopassword.sh confirm base port login pass
#------------------------------------------------------ #------------------------------------------------------
# shellcheck disable=2006,2034,2046,2064,2068,2086,2155,2166,2186,2172,2268
# shellcheck disable=2012,2016,2154
export mydir=`echo "$0" | sed -e 's/initdemopassword.sh//'`; export mydir=`echo "$0" | sed -e 's/initdemopassword.sh//'`;

View File

@@ -9,7 +9,7 @@
# WARNING: This script erase setup of instance, # WARNING: This script erase setup of instance,
# but not the database # but not the database
#------------------------------------------------------ #------------------------------------------------------
# shellcheck disable=2006,2034,2046,2064,2068,2086,2155,2166,2186,2172,2268
export mydir=`echo "$0" | sed -e 's/removedemo.sh//'`; export mydir=`echo "$0" | sed -e 's/removedemo.sh//'`;
if [ "x$mydir" = "x" ] if [ "x$mydir" = "x" ]

View File

@@ -9,7 +9,7 @@
# Usage: savedemo.sh # Usage: savedemo.sh
# usage: savedemo.sh mysqldump_dolibarr_x.x.x.sql database port login pass # usage: savedemo.sh mysqldump_dolibarr_x.x.x.sql database port login pass
#------------------------------------------------------ #------------------------------------------------------
# shellcheck disable=2012,2006,2034,2046,2064,2086,2155,2166,2186,2172,2268
export mydir=`echo "$0" | sed -e 's/savedemo.sh//'`; export mydir=`echo "$0" | sed -e 's/savedemo.sh//'`;
if [ "x$mydir" = "x" ] if [ "x$mydir" = "x" ]

View File

@@ -6,12 +6,12 @@
# When running git commit, it first execute this file checking only modified files, so it is faster than running on all files # When running git commit, it first execute this file checking only modified files, so it is faster than running on all files
# To run the fix manually: cd ~/git/dolibarr; phpcbf -s -p -d memory_limit=-1 --extensions=php --colors --tab-width=4 --standard=dev/setup/codesniffer/ruleset.xml --encoding=utf-8 --runtime-set ignore_warnings_on_exit true "fileordir" # To run the fix manually: cd ~/git/dolibarr; phpcbf -s -p -d memory_limit=-1 --extensions=php --colors --tab-width=4 --standard=dev/setup/codesniffer/ruleset.xml --encoding=utf-8 --runtime-set ignore_warnings_on_exit true "fileordir"
PROJECT=`php -r "echo dirname(dirname(dirname(realpath('$0'))));"` PROJECT=$(php -r "echo dirname(dirname(dirname(realpath('$0'))));")
STAGED_FILES_CMD=`git diff --cached --name-only --diff-filter=ACMR HEAD | grep -v '/includes/'| grep \\\\.php` STAGED_FILES_CMD=$(git diff --cached --name-only --diff-filter=ACMR HEAD | grep -v '/includes/'| grep \\\\.php)
DIRPHPCS="" DIRPHPCS=""
AUTOFIX=1 AUTOFIX=1
echo "Running precommit hook in .git/hooks/pre-commit" 1>&2; echo "Running precommit hook in .git/hooks/pre-commit" 1>&2
# Determine if a file list is passed # Determine if a file list is passed
if [ "$#" -eq 1 ] if [ "$#" -eq 1 ]
@@ -28,16 +28,17 @@ echo "Checking PHP Lint with php -l ..."
for FILE in $SFILES for FILE in $SFILES
do do
php -l -d display_errors=0 $PROJECT/$FILE php -l -d display_errors=0 "$PROJECT/$FILE"
result1=$? result1=$?
if [ "x$result1" != "x0" ] if [ "x$result1" != "x0" ]
then then
echo "Fix the error before commit." 1>&2; echo "Fix the error before commit." 1>&2
exit 1 exit 1
fi fi
FILES="$FILES $PROJECT/$FILE" # shellcheck disable=2089
FILES="$FILES '$PROJECT/$FILE'"
done done
@@ -46,7 +47,8 @@ then
echo "Running PHPCS Code Sniffer..." echo "Running PHPCS Code Sniffer..."
# Check Dolibarr standard # Check Dolibarr standard
${DIRPHPCS}phpcs -s -p -d memory_limit=-1 --parallel=2 --extensions=php --colors --tab-width=4 --standard=dev/setup/codesniffer/ruleset.xml --encoding=utf-8 --runtime-set ignore_warnings_on_exit true $FILES # shellcheck disable=2086,2090
"${DIRPHPCS}phpcs" -s -p -d memory_limit=-1 --parallel=2 --extensions=php --colors --tab-width=4 --standard=dev/setup/codesniffer/ruleset.xml --encoding=utf-8 --runtime-set ignore_warnings_on_exit true $FILES
# Check a common standard # Check a common standard
#${DIRPHPCS}phpcs -s -p -d memory_limit=-1 --parallel=2 --extensions=php --colors --tab-width=4 --standard=PSR2 --encoding=utf-8 --runtime-set ignore_warnings_on_exit true $FILES #${DIRPHPCS}phpcs -s -p -d memory_limit=-1 --parallel=2 --extensions=php --colors --tab-width=4 --standard=PSR2 --encoding=utf-8 --runtime-set ignore_warnings_on_exit true $FILES
@@ -58,11 +60,12 @@ then
# Fix standard errors # Fix standard errors
if [ "x$AUTOFIX" != "x0" ] if [ "x$AUTOFIX" != "x0" ]
then then
${DIRPHPCS}phpcbf -s -p -d memory_limit=-1 --extensions=php --colors --tab-width=4 --standard=dev/setup/codesniffer/ruleset.xml --encoding=utf-8 --runtime-set ignore_warnings_on_exit true $FILES # shellcheck disable=2086,2090
"${DIRPHPCS}phpcbf" -s -p -d memory_limit=-1 --extensions=php --colors --tab-width=4 --standard=dev/setup/codesniffer/ruleset.xml --encoding=utf-8 --runtime-set ignore_warnings_on_exit true $FILES
#${DIRPHPCS}phpcbf -s -p -d memory_limit=-1 --extensions=php --colors --tab-width=4 --standard=htdocs/custom/codesniffer/ruleset.xml --encoding=utf-8 --runtime-set ignore_warnings_on_exit true $FILES #${DIRPHPCS}phpcbf -s -p -d memory_limit=-1 --extensions=php --colors --tab-width=4 --standard=htdocs/custom/codesniffer/ruleset.xml --encoding=utf-8 --runtime-set ignore_warnings_on_exit true $FILES
echo "Found some errors in syntax rules. An automatic fix has been applied. Check it before commit." 1>&2; echo "Found some errors in syntax rules. An automatic fix has been applied. Check it before commit." 1>&2
exit 1 exit 1
else else
echo "Found some errors in syntax rules. Fix the error(s) before commit." 1>&2; echo "Found some errors in syntax rules. Fix the error(s) before commit." 1>&2;

View File

@@ -6,6 +6,8 @@
# #
# Raphaël Doursenaud - rdoursenaud@gpcsolutions.fr # Raphaël Doursenaud - rdoursenaud@gpcsolutions.fr
# shellcheck disable=2006,2027,2044,2045,2046,2086,2155,2166,2268
# Syntax # Syntax
if [ "x$1" != "xlist" -a "x$1" != "xfix" ] if [ "x$1" != "xlist" -a "x$1" != "xfix" ]
then then

View File

@@ -6,6 +6,7 @@
#------------------------------------------------------ #------------------------------------------------------
# Usage: fixdosfiles.sh [list|fix] # Usage: fixdosfiles.sh [list|fix]
#------------------------------------------------------ #------------------------------------------------------
# shellcheck disable=2006,2166,2268
# Syntax # Syntax
if [ "x$1" != "xlist" -a "x$1" != "xfix" ] if [ "x$1" != "xlist" -a "x$1" != "xfix" ]

View File

@@ -3,6 +3,7 @@
# #
# Copyright (C) 2014 Raphaël Doursenaud - rdoursenaud@gpcsolutions.fr # Copyright (C) 2014 Raphaël Doursenaud - rdoursenaud@gpcsolutions.fr
# shellcheck disable=2006,2035,2044,2061,2166,2268
# Syntax # Syntax
if [ "x$1" != "xlist" -a "x$1" != "xfix" ] if [ "x$1" != "xlist" -a "x$1" != "xfix" ]

View File

@@ -6,6 +6,8 @@
# #
# Raphaël Doursenaud - rdoursenaud@gpcsolutions.fr # Raphaël Doursenaud - rdoursenaud@gpcsolutions.fr
# shellcheck disable=2006,2035,2044,2046,2061,2166,2268
# Syntax # Syntax
if [ "x$1" != "xlist" -a "x$1" != "xfix" ] if [ "x$1" != "xlist" -a "x$1" != "xfix" ]
then then

View File

@@ -2,6 +2,7 @@
# #
# Example of script to fix code writing of permissions # Example of script to fix code writing of permissions
# #
# shellcheck disable=2013,2016,2086
for f in $(grep -l -e 'user->rights' -R); do for f in $(grep -l -e 'user->rights' -R); do
sed -i -r 's/!empty\(\$user->rights->([_a-z0-9]+)->([_a-z0-9]+)->([_a-z0-9]+)\) *\? *\$user->rights->\1->\2->\3 *: *0;/$user->hasRight("\1", "\2", "\3");/' $f sed -i -r 's/!empty\(\$user->rights->([_a-z0-9]+)->([_a-z0-9]+)->([_a-z0-9]+)\) *\? *\$user->rights->\1->\2->\3 *: *0;/$user->hasRight("\1", "\2", "\3");/' $f

View File

@@ -6,6 +6,7 @@
#------------------------------------------------------ #------------------------------------------------------
# Usage: fixnotabfiles.sh [list|fix] # Usage: fixnotabfiles.sh [list|fix]
#------------------------------------------------------ #------------------------------------------------------
# shellcheck disable=2166,2268
# Syntax # Syntax
if [ "x$1" != "xlist" -a "x$1" != "xfix" ] if [ "x$1" != "xlist" -a "x$1" != "xfix" ]

View File

@@ -7,6 +7,8 @@
# Usage: fixperms.sh (list|fix) # Usage: fixperms.sh (list|fix)
#------------------------------------------------------ #------------------------------------------------------
# shellcheck disable=2166,2268
# Syntax # Syntax
if [ "x$1" != "xlist" -a "x$1" != "xfix" ] if [ "x$1" != "xlist" -a "x$1" != "xfix" ]
then then

View File

@@ -1,5 +1,7 @@
#!/bin/bash #!/bin/bash
# shellcheck disable=2002,2004,2028,2034,2053,2068,2086,2116,2143,2207
## Need "rpl" package ## Need "rpl" package
RPL_INSTALLED=$(dpkg -s rpl) RPL_INSTALLED=$(dpkg -s rpl)
if [[ -z ${RPL_INSTALLED} ]]; then if [[ -z ${RPL_INSTALLED} ]]; then

View File

@@ -8,6 +8,7 @@
#------------------------------------------------------ #------------------------------------------------------
# Usage: fixutf8bomfiles.sh [list|fix] # Usage: fixutf8bomfiles.sh [list|fix]
#------------------------------------------------------ #------------------------------------------------------
# shellcheck disable=2006,2028,2086,2089,2090,2166,2268
# Syntax # Syntax
if [ "x$1" != "xlist" -a "x$1" != "xfix" ] if [ "x$1" != "xlist" -a "x$1" != "xfix" ]

View File

@@ -3,6 +3,7 @@
# Count number of different contributors and number of commits for a given year. # Count number of different contributors and number of commits for a given year.
# Can be used for statistics (for example to generate the inforgraphy of the year) # Can be used for statistics (for example to generate the inforgraphy of the year)
# #
# shellcheck disable=2027,2086,2268
if [ "x$1" = "x" ]; then if [ "x$1" = "x" ]; then
echo "Usage: $0 YEARSTART [YEAREND]" echo "Usage: $0 YEARSTART [YEAREND]"

View File

@@ -2,6 +2,7 @@
# #
# Count number of commits per user and per versions (using date for version detection) # Count number of commits per user and per versions (using date for version detection)
# #
# shellcheck disable=1113,2002,2006,2086,2164,2219
Releases=("3.9" "4.0" "5.0" "6.0" "7.0" "8.0" "9.0" "10.0" "11.0" "12.0" "13.0" "14.0" "15.0" "16.0" "17.0" "18.0" "develop") Releases=("3.9" "4.0" "5.0" "6.0" "7.0" "8.0" "9.0" "10.0" "11.0" "12.0" "13.0" "14.0" "15.0" "16.0" "17.0" "18.0" "develop")
let "counter = 0" let "counter = 0"

View File

@@ -3,6 +3,8 @@
# Count number of lines modified per user for a given branch # Count number of lines modified per user for a given branch
# #
# shellcheck disable=2002,2086,2268
if [ "x$2" = "x" ]; then if [ "x$2" = "x" ]; then
echo "Usage: $0 origin/branchstart|tagnamestart|START origin/branchend|tagnameend|HEAD" echo "Usage: $0 origin/branchstart|tagnamestart|START origin/branchend|tagnameend|HEAD"
exit exit

View File

@@ -2,6 +2,8 @@
# Based of: https://gist.github.com/jaymzcd/342399 and https://github.com/buren/flag-sprite-maker # Based of: https://gist.github.com/jaymzcd/342399 and https://github.com/buren/flag-sprite-maker
# shellcheck disable=2006,2086,2129,2219,2231
# uses imagemagick to stich together all images in a folder and # uses imagemagick to stich together all images in a folder and
# then writes a css file with the correct offsets along with a # then writes a css file with the correct offsets along with a
# test html page for verification that its all good # test html page for verification that its all good

View File

@@ -2,6 +2,8 @@
# Borrowed from https://gist.github.com/lgiraudel/6065155 # Borrowed from https://gist.github.com/lgiraudel/6065155
# Inplace mode added by Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr> # Inplace mode added by Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr>
# shellcheck disable=2003,2006,2034,2046,2086,2166,2268
PROGNAME=${0##*/} PROGNAME=${0##*/}
INPUT='' INPUT=''
QUIET='0' QUIET='0'

View File

@@ -35,7 +35,7 @@ MINPHPVERSION="7.0"
echo "***** run-php-cs-fixer.sh *****" echo "***** run-php-cs-fixer.sh *****"
if [ "x$1" = "x" ]; then if [ "$1" = "" ]; then
echo "Syntax: run-php-cs-fixer.sh check|fix [path_from_root_project]" echo "Syntax: run-php-cs-fixer.sh check|fix [path_from_root_project]"
exit 1; exit 1;
fi fi
@@ -60,7 +60,7 @@ PHP_CS_FIXER="${COMPOSER_VENDOR_DIR}/bin/php-cs-fixer"
if [ ! -r "${PHP_CS_FIXER}" ] ; then if [ ! -r "${PHP_CS_FIXER}" ] ; then
[[ ! -e "${COMPOSER_VENDOR_DIR}" ]] && ${COMPOSER_CMD} install [[ ! -e "${COMPOSER_VENDOR_DIR}" ]] && ${COMPOSER_CMD} install
[[ -e "${COMPOSER_VENDOR_DIR}" ]] && ${COMPOSER_CMD} update [[ -e "${COMPOSER_VENDOR_DIR}" ]] && ${COMPOSER_CMD} update
php${MINPHPVERSION} ${COMPOSER_CMD} require --dev friendsofphp/php-cs-fixer "php${MINPHPVERSION}" "${COMPOSER_CMD}" require --dev friendsofphp/php-cs-fixer
echo echo
fi fi

View File

@@ -4,6 +4,7 @@
# be able to make size fixed screenshots using # be able to make size fixed screenshots using
# ALT+Print screen. # ALT+Print screen.
#---------------------------------------------------- #----------------------------------------------------
# shellcheck disable=2086,2166,2268
# Syntax # Syntax
if [ "x$1" = "x" ] if [ "x$1" = "x" ]

View File

@@ -7,6 +7,8 @@
# Usage: txpull.sh (all|xx_XX) [-r dolibarr.file] [-f] # Usage: txpull.sh (all|xx_XX) [-r dolibarr.file] [-f]
#------------------------------------------------------ #------------------------------------------------------
# shellcheck disable=2006,2044,2086,2164,2268
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
cd $DIR/../.. cd $DIR/../..

View File

@@ -7,6 +7,8 @@
# Usage: txpush.sh (source|xx_XX) [-r dolibarr.file] [-f] # Usage: txpush.sh (source|xx_XX) [-r dolibarr.file] [-f]
#------------------------------------------------------ #------------------------------------------------------
# shellcheck disable=2006,2044,2086,2155,2164,2268
export project='dolibarr' export project='dolibarr'
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"

View File

@@ -6,5 +6,5 @@
# More information on https://wiki.dolibarr.org/index.php/Module_ClickToDial_En # More information on https://wiki.dolibarr.org/index.php/Module_ClickToDial_En
#--------------------------------------------------------- #---------------------------------------------------------
ekiga -c $1 & ekiga -c "$1" &

View File

@@ -8,6 +8,8 @@
# More information on https://wiki.dolibarr.org/index.php/Module_ClickToDial_En # More information on https://wiki.dolibarr.org/index.php/Module_ClickToDial_En
#--------------------------------------------------------- #---------------------------------------------------------
# shellcheck disable=2006,2086
# Note: Adding handler into gconf-tools seems to do nothing # Note: Adding handler into gconf-tools seems to do nothing
# gconftool-2 -t string -s /desktop/gnome/url-handlers/sip/command "linphone-3 -c %s" # gconftool-2 -t string -s /desktop/gnome/url-handlers/sip/command "linphone-3 -c %s"
# gconftool-2 -s /desktop/gnome/url-handlers/sip/needs_terminal false -t bool # gconftool-2 -s /desktop/gnome/url-handlers/sip/needs_terminal false -t bool

View File

@@ -18,6 +18,8 @@
# If you got this error: javaldx failed! Warning: failed to read path from javaldx with no return to prompt when running soffice --headless -env:UserInstallation=file:"/tmp" --convert-to pdf --outdir xxx ./yyy.odt, # If you got this error: javaldx failed! Warning: failed to read path from javaldx with no return to prompt when running soffice --headless -env:UserInstallation=file:"/tmp" --convert-to pdf --outdir xxx ./yyy.odt,
# check that directory defined into env:UserInstallation parameters exists and is writeable. # check that directory defined into env:UserInstallation parameters exists and is writeable.
# shellcheck disable=2046,2086,2268
if [ "x$1" == "x" ] if [ "x$1" == "x" ]
then then