cnescatlab/i-CodeCNES

SH.FLOW.ChECKARGUMENTS

Opened this issue · 2 comments

Expected behavior

By taking the code recommended in CNES script coding rules (RNC-CNES-Q-HB-80-516->SH.FLOW.ChECKARGUMENTS) we expect to make disappear i-code error SH.FLOW.ChECKARGUMENTS in our script

Actual behavior

a) when we take the code from (RNC-CNES-Q-HB-80-516->SH.FLOW.ChECKARGUMENTS) a new variable error occurs with i-code
b) when we correct this new variable error, the i-code error SH.FLOW.ChECKARGUMENTS is present again

Steps to reproduce behavior

SH.FLOW.ChECKARGUMENTS.PPTX

Detection version

i-code 3.0

The argument check rule performed by i-code does not work in the following cases also:
function usage(){
# display arguments information
if [ ${#} -eq 0 ]
then
printf "S2 quicklook script :\n"
printf "\t-h : S2 quicklook script help\n"
printf "\t-v : S2 quicklook script version\n"
printf "\t-p : S2 product name. required \n"
printf "\t-r : resolution (0 is full resolution). default value is ${res}\n"
printf "\t-d : quicklook destination root directory default value is ${destination_root_directory}\n"
printf "\t--sd= : quicklook destination sub directory default value is unset\n"
printf "\t--rgb : quicklook_type (rgb or irgb or comp). default value is ${quicklook_type}\n"
printf "\t--irgb : quicklook_type (rgb or irgb or comp). default value is ${quicklook_type}\n"
printf "\t--comp : quicklook_type (rgb or irgb or comp). default value is ${quicklook_type}\n"
printf "\t--help : S2 quicklook script help\n"
printf "\t--version : S2 quicklook script version\n"
fi
}

function min() {
# min function using sort
# examples :
# min -g 3 2 5 1
# min -h 25M 13G 99K 1098M
# min -M "OCT" "APR" "SEP" "FEB" "JUL"
# $1 is sort option
# other arguments are entities to compare
if [ ${#} -ge 3 ]
then
# min function using sort : see above examples and comment
printf "%s\n" "${@:2}" | sort "${1}" | head -n1
fi
}

cleanup() {
# display error information
if [ ${#} -eq 1 ]
then
exitcode=${?}
printf 'error condition hit\n' 1>&2
printf 'exit code returned: %s\n' "${exitcode}"
printf 'the command executing at the time of the error was: %s\n' "${BASH_COMMAND}"
printf 'command present on line: %d' "${BASH_LINENO[0]}"
# Some more clean up code can be added here before exiting
exit ${exitcode}
fi
}

In all these cases, the error SH.FLOW.ChECKARGUMENTS is raised by i-code whereas the arguments are actually checked

The error explained in the first comment is still present is the version 4.0 of i-code.