diff --git a/wdl-lint/tests/lints/shellcheck-error/source.errors b/wdl-lint/tests/lints/shellcheck-error/source.errors new file mode 100644 index 000000000..8da8ac0d3 --- /dev/null +++ b/wdl-lint/tests/lints/shellcheck-error/source.errors @@ -0,0 +1,48 @@ +note[CommandSectionShellCheck]: `shellcheck` reported the following diagnostic + ┌─ tests/lints/shellcheck-error/source.wdl:18:10 + │ +18 │ if [ -f "$broken"] + │ ^ SC1073[error]: Couldn't parse this test expression. Fix to allow more checks. + │ + = fix: address the diagnostics as recommended in the message + +note[CommandSectionShellCheck]: `shellcheck` reported the following diagnostic + ┌─ tests/lints/shellcheck-error/source.wdl:18:15 + │ +18 │ if [ -f "$broken"] + │ ^ SC1019[error]: Expected this to be an argument to the unary condition. + │ + = fix: address the diagnostics as recommended in the message + +note[CommandSectionShellCheck]: `shellcheck` reported the following diagnostic + ┌─ tests/lints/shellcheck-error/source.wdl:18:25 + │ +18 │ if [ -f "$broken"] + │ ^ SC1020[error]: You need a space before the ]. + │ + = fix: address the diagnostics as recommended in the message + +note[CommandSectionShellCheck]: `shellcheck` reported the following diagnostic + ┌─ tests/lints/shellcheck-error/source.wdl:37:10 + │ +37 │ if [ -f "$broken"] + │ ^ SC1073[error]: Couldn't parse this test expression. Fix to allow more checks. + │ + = fix: address the diagnostics as recommended in the message + +note[CommandSectionShellCheck]: `shellcheck` reported the following diagnostic + ┌─ tests/lints/shellcheck-error/source.wdl:37:15 + │ +37 │ if [ -f "$broken"] + │ ^ SC1019[error]: Expected this to be an argument to the unary condition. + │ + = fix: address the diagnostics as recommended in the message + +note[CommandSectionShellCheck]: `shellcheck` reported the following diagnostic + ┌─ tests/lints/shellcheck-error/source.wdl:37:25 + │ +37 │ if [ -f "$broken"] + │ ^ SC1020[error]: You need a space before the ]. + │ + = fix: address the diagnostics as recommended in the message + diff --git a/wdl-lint/tests/lints/shellcheck-error/source.wdl b/wdl-lint/tests/lints/shellcheck-error/source.wdl new file mode 100644 index 000000000..63525fff4 --- /dev/null +++ b/wdl-lint/tests/lints/shellcheck-error/source.wdl @@ -0,0 +1,43 @@ +#@ except: DescriptionMissing, RuntimeSectionKeys, MatchingParameterMeta, NoCurlyCommands + +## This is a test of having shellcheck error lints + +version 1.1 + +task test1 { + meta {} + + parameter_meta {} + + input { + Int placeholder + } + + command <<< + somecommand.py [[ -f $broken_test]] + if [ -f "$broken"] + >>> + + output {} + + runtime {} +} + +task test2 { + meta {} + + parameter_meta {} + + input { + Int placeholder + } + + command { + somecommand.py [[ -f $broken_test]] + if [ -f "$broken"] + } + + output {} + + runtime {} +} diff --git a/wdl-lint/tests/lints/shellcheck-ok/source.errors b/wdl-lint/tests/lints/shellcheck-ok/source.errors new file mode 100644 index 000000000..e69de29bb diff --git a/wdl-lint/tests/lints/shellcheck-ok/source.wdl b/wdl-lint/tests/lints/shellcheck-ok/source.wdl new file mode 100644 index 000000000..0f6191b04 --- /dev/null +++ b/wdl-lint/tests/lints/shellcheck-ok/source.wdl @@ -0,0 +1,54 @@ +#@ except: DescriptionMissing, RuntimeSectionKeys, MatchingParameterMeta, NoCurlyCommands + +## This is a test of having no shellcheck lints + +version 1.1 + +task test1 { + meta {} + + parameter_meta {} + + input { + Boolean i_quote_my_shellvars + Int placeholder + } + + command <<< + set -eo pipefail + + echo "$placeholder" + + if [[ "$i_quote_my_shellvars" ]]; then + echo "shellcheck will be happy" + fi + >>> + + output {} + + runtime {} +} + +task test2 { + meta {} + + parameter_meta {} + + input { + Int placeholder + } + + command { + set -eo pipefail + + echo "$placeholder" + + if [[ "$I_quote_my_shellvars" ]]; then + echo "all is well" + fi + } + + output {} + + runtime {} +} diff --git a/wdl-lint/tests/lints/shellcheck-style/source.errors b/wdl-lint/tests/lints/shellcheck-style/source.errors new file mode 100644 index 000000000..87b6b6ac1 --- /dev/null +++ b/wdl-lint/tests/lints/shellcheck-style/source.errors @@ -0,0 +1,32 @@ +note[CommandSectionShellCheck]: `shellcheck` reported the following diagnostic + ┌─ tests/lints/shellcheck-style/source.wdl:17:7 + │ +17 │ [[ ]] + │ ^^^ SC2212[style]: Use 'false' instead of empty [/[[ conditionals. + │ + = fix: address the diagnostics as recommended in the message + +note[CommandSectionShellCheck]: `shellcheck` reported the following diagnostic + ┌─ tests/lints/shellcheck-style/source.wdl:18:9 + │ +18 │ [ true ] + │ ^^^^ SC2160[style]: Instead of '[ true ]', just use 'true'. + │ + = fix: address the diagnostics as recommended in the message + +note[CommandSectionShellCheck]: `shellcheck` reported the following diagnostic + ┌─ tests/lints/shellcheck-style/source.wdl:36:7 + │ +36 │ [[ ]] + │ ^^^ SC2212[style]: Use 'false' instead of empty [/[[ conditionals. + │ + = fix: address the diagnostics as recommended in the message + +note[CommandSectionShellCheck]: `shellcheck` reported the following diagnostic + ┌─ tests/lints/shellcheck-style/source.wdl:37:9 + │ +37 │ [ true ] + │ ^^^^ SC2160[style]: Instead of '[ true ]', just use 'true'. + │ + = fix: address the diagnostics as recommended in the message + diff --git a/wdl-lint/tests/lints/shellcheck-style/source.wdl b/wdl-lint/tests/lints/shellcheck-style/source.wdl new file mode 100644 index 000000000..4d3795289 --- /dev/null +++ b/wdl-lint/tests/lints/shellcheck-style/source.wdl @@ -0,0 +1,43 @@ +#@ except: DescriptionMissing, RuntimeSectionKeys, MatchingParameterMeta, NoCurlyCommands + +## This is a test of having shellcheck style lints + +version 1.1 + +task test1 { + meta {} + + parameter_meta {} + + input { + Int placeholder + } + + command <<< + [[ ]] + [ true ] + >>> + + output {} + + runtime {} +} + +task test2 { + meta {} + + parameter_meta {} + + input { + Int placeholder + } + + command { + [[ ]] + [ true ] + } + + output {} + + runtime {} +} diff --git a/wdl-lint/tests/lints/shellcheck-warn/source.errors b/wdl-lint/tests/lints/shellcheck-warn/source.errors new file mode 100644 index 000000000..489f94715 --- /dev/null +++ b/wdl-lint/tests/lints/shellcheck-warn/source.errors @@ -0,0 +1,176 @@ +note[CommandSectionShellCheck]: `shellcheck` reported the following diagnostic + ┌─ tests/lints/shellcheck-warn/source.wdl:17:22 + │ +17 │ somecommand.py $line17 ~{placeholder} + │ ^^^^^^^ SC2086[info]: Double quote to prevent globbing and word splitting. + │ + = fix: address the diagnostics as recommended in the message + +note[CommandSectionShellCheck]: `shellcheck` reported the following diagnostic + ┌─ tests/lints/shellcheck-warn/source.wdl:17:22 + │ +17 │ somecommand.py $line17 ~{placeholder} + │ ^^^^^^^ SC2154[warning]: line17 is referenced but not assigned. + │ + = fix: address the diagnostics as recommended in the message + +note[CommandSectionShellCheck]: `shellcheck` reported the following diagnostic + ┌─ tests/lints/shellcheck-warn/source.wdl:18:37 + │ +18 │ somecommand.py ~{placeholder} $line18 + │ ^^^^^^^ SC2086[info]: Double quote to prevent globbing and word splitting. + │ + = fix: address the diagnostics as recommended in the message + +note[CommandSectionShellCheck]: `shellcheck` reported the following diagnostic + ┌─ tests/lints/shellcheck-warn/source.wdl:18:37 + │ +18 │ somecommand.py ~{placeholder} $line18 + │ ^^^^^^^ SC2154[warning]: line18 is referenced but not assigned. + │ + = fix: address the diagnostics as recommended in the message + +note[CommandSectionShellCheck]: `shellcheck` reported the following diagnostic + ┌─ tests/lints/shellcheck-warn/source.wdl:19:36 + │ +19 │ somecommand.py ~{placeholder}$line19 + │ ^^^^^^^ SC2086[info]: Double quote to prevent globbing and word splitting. + │ + = fix: address the diagnostics as recommended in the message + +note[CommandSectionShellCheck]: `shellcheck` reported the following diagnostic + ┌─ tests/lints/shellcheck-warn/source.wdl:19:36 + │ +19 │ somecommand.py ~{placeholder}$line19 + │ ^^^^^^^ SC2154[warning]: line19 is referenced but not assigned. + │ + = fix: address the diagnostics as recommended in the message + +note[CommandSectionShellCheck]: `shellcheck` reported the following diagnostic + ┌─ tests/lints/shellcheck-warn/source.wdl:30:22 + │ +30 │ somecommand.py $line30~{placeholder} + │ ^^^^^^^ SC2086[info]: Double quote to prevent globbing and word splitting. + │ + = fix: address the diagnostics as recommended in the message + +note[CommandSectionShellCheck]: `shellcheck` reported the following diagnostic + ┌─ tests/lints/shellcheck-warn/source.wdl:30:22 + │ +30 │ somecommand.py $line30~{placeholder} + │ ^^^^^^^ SC2154[warning]: line30 is referenced but not assigned. + │ + = fix: address the diagnostics as recommended in the message + +note[CommandSectionShellCheck]: `shellcheck` reported the following diagnostic + ┌─ tests/lints/shellcheck-warn/source.wdl:31:27 + │ +31 │ somecommand.py [ -f $line31 ] ~{placeholder} + │ ^^^^^^^ SC2086[info]: Double quote to prevent globbing and word splitting. + │ + = fix: address the diagnostics as recommended in the message + +note[CommandSectionShellCheck]: `shellcheck` reported the following diagnostic + ┌─ tests/lints/shellcheck-warn/source.wdl:31:27 + │ +31 │ somecommand.py [ -f $line31 ] ~{placeholder} + │ ^^^^^^^ SC2154[warning]: line31 is referenced but not assigned. + │ + = fix: address the diagnostics as recommended in the message + +note[CommandSectionShellCheck]: `shellcheck` reported the following diagnostic + ┌─ tests/lints/shellcheck-warn/source.wdl:49:22 + │ +49 │ somecommand.py $line49 ~{placeholder} + │ ^^^^^^^ SC2086[info]: Double quote to prevent globbing and word splitting. + │ + = fix: address the diagnostics as recommended in the message + +note[CommandSectionShellCheck]: `shellcheck` reported the following diagnostic + ┌─ tests/lints/shellcheck-warn/source.wdl:49:22 + │ +49 │ somecommand.py $line49 ~{placeholder} + │ ^^^^^^^ SC2154[warning]: line49 is referenced but not assigned. + │ + = fix: address the diagnostics as recommended in the message + +note[CommandSectionShellCheck]: `shellcheck` reported the following diagnostic + ┌─ tests/lints/shellcheck-warn/source.wdl:50:37 + │ +50 │ somecommand.py ~{placeholder} $line50 + │ ^^^^^^^ SC2086[info]: Double quote to prevent globbing and word splitting. + │ + = fix: address the diagnostics as recommended in the message + +note[CommandSectionShellCheck]: `shellcheck` reported the following diagnostic + ┌─ tests/lints/shellcheck-warn/source.wdl:50:37 + │ +50 │ somecommand.py ~{placeholder} $line50 + │ ^^^^^^^ SC2154[warning]: line50 is referenced but not assigned. + │ + = fix: address the diagnostics as recommended in the message + +note[CommandSectionShellCheck]: `shellcheck` reported the following diagnostic + ┌─ tests/lints/shellcheck-warn/source.wdl:51:36 + │ +51 │ somecommand.py ~{placeholder}$line51 + │ ^^^^^^^ SC2086[info]: Double quote to prevent globbing and word splitting. + │ + = fix: address the diagnostics as recommended in the message + +note[CommandSectionShellCheck]: `shellcheck` reported the following diagnostic + ┌─ tests/lints/shellcheck-warn/source.wdl:51:36 + │ +51 │ somecommand.py ~{placeholder}$line51 + │ ^^^^^^^ SC2154[warning]: line51 is referenced but not assigned. + │ + = fix: address the diagnostics as recommended in the message + +note[CommandSectionShellCheck]: `shellcheck` reported the following diagnostic + ┌─ tests/lints/shellcheck-warn/source.wdl:52:22 + │ +52 │ somecommand.py $line52~{placeholder} + │ ^^^^^^^ SC2086[info]: Double quote to prevent globbing and word splitting. + │ + = fix: address the diagnostics as recommended in the message + +note[CommandSectionShellCheck]: `shellcheck` reported the following diagnostic + ┌─ tests/lints/shellcheck-warn/source.wdl:52:22 + │ +52 │ somecommand.py $line52~{placeholder} + │ ^^^^^^^ SC2154[warning]: line52 is referenced but not assigned. + │ + = fix: address the diagnostics as recommended in the message + +note[CommandSectionShellCheck]: `shellcheck` reported the following diagnostic + ┌─ tests/lints/shellcheck-warn/source.wdl:53:27 + │ +53 │ somecommand.py [ -f $bad_test ] ~{placeholder} + │ ^^^^^^^^^ SC2086[info]: Double quote to prevent globbing and word splitting. + │ + = fix: address the diagnostics as recommended in the message + +note[CommandSectionShellCheck]: `shellcheck` reported the following diagnostic + ┌─ tests/lints/shellcheck-warn/source.wdl:53:27 + │ +53 │ somecommand.py [ -f $bad_test ] ~{placeholder} + │ ^^^^^^^^^ SC2154[warning]: bad_test is referenced but not assigned. + │ + = fix: address the diagnostics as recommended in the message + +note[CommandSectionShellCheck]: `shellcheck` reported the following diagnostic + ┌─ tests/lints/shellcheck-warn/source.wdl:54:27 + │ +54 │ somecommand.py [ -f $trailing_space ] ~{placeholder} + │ ^^^^^^^^^^^^^^^ SC2086[info]: Double quote to prevent globbing and word splitting. + │ + = fix: address the diagnostics as recommended in the message + +note[CommandSectionShellCheck]: `shellcheck` reported the following diagnostic + ┌─ tests/lints/shellcheck-warn/source.wdl:54:27 + │ +54 │ somecommand.py [ -f $trailing_space ] ~{placeholder} + │ ^^^^^^^^^^^^^^^ SC2154[warning]: trailing_space is referenced but not assigned. + │ + = fix: address the diagnostics as recommended in the message + diff --git a/wdl-lint/tests/lints/shellcheck-warn/source.wdl b/wdl-lint/tests/lints/shellcheck-warn/source.wdl new file mode 100644 index 000000000..bc863b26d --- /dev/null +++ b/wdl-lint/tests/lints/shellcheck-warn/source.wdl @@ -0,0 +1,60 @@ +#@ except: DescriptionMissing, RuntimeSectionKeys, MatchingParameterMeta, NoCurlyCommands + +## This is a test of having shellcheck warnings + +version 1.1 + +task test1 { + meta {} + + parameter_meta {} + + input { + Int placeholder + } + + command <<< + somecommand.py $line17 ~{placeholder} + somecommand.py ~{placeholder} $line18 + somecommand.py ~{placeholder}$line19 + + + + + + + + + + + somecommand.py $line30~{placeholder} + somecommand.py [ -f $line31 ] ~{placeholder} + >>> + + output {} + + runtime {} +} + +task test2 { + meta {} + + parameter_meta {} + + input { + Int placeholder + } + + command <<< + somecommand.py $line49 ~{placeholder} + somecommand.py ~{placeholder} $line50 + somecommand.py ~{placeholder}$line51 + somecommand.py $line52~{placeholder} + somecommand.py [ -f $bad_test ] ~{placeholder} + somecommand.py [ -f $trailing_space ] ~{placeholder} + >>> + + output {} + + runtime {} +}