From cc8251d119cc66552af23e6931ef4e9ef14946cc Mon Sep 17 00:00:00 2001 From: Olliver Schinagl Date: Tue, 14 Nov 2023 21:28:45 +0100 Subject: [PATCH] Destroyed checkunit2text (markdown) --- checkunit2text.md | 81 ----------------------------------------------- 1 file changed, 81 deletions(-) delete mode 100644 checkunit2text.md diff --git a/checkunit2text.md b/checkunit2text.md deleted file mode 100644 index 67d30dd..0000000 --- a/checkunit2text.md +++ /dev/null @@ -1,81 +0,0 @@ -Since shellcheck can only produce output in a single format, producing machine readable formats (such as `XML`), posses a problem when also wanting to get the text output. - -Producing checkstyle output we have something machine processable, but not user readable. - -If we want both outputs, without the overhead of re-processing shellcheck, `sed` can be used to somewhat reproduce the original shellcheck _tty_ format. Since checkstyle does not include column length, we can only indicate the start of the issue. Also severity colors and shellcheck summary links are lost, where the intend was to remain similar to the original output. - -Using the [xslt](#checkstyle2jtext.xslt) at the end of this article, combined with the following `sed` magic, we generate machine/human parsable output and then translate that to human readable output. This is needed because neither checkstyle, nor xslt allow us to show the content of the failure. - -``` - xmlstarlet tr 'checkstyle2log.xslt] '/path/to/checkstyle.xml' | \ - sed -n \ - -e "s|^\(.*\): ShellCheck.\(SC\d\+\) (\(.*\)) line \(\d\+\), column \(\d\+\) - \(.*\)$|echo 'In \1 line \4:'\nsed -n '\4p' \1\nprintf \"%\$((\5 - 1\))s^\\\n\"\necho '\2 (\3): \6'\necho\n|p" | \ - sh | \ - tee -a 'shellcheck.log' -``` - -Producing an incompatible output, but with ShellCheck URL's and a simple file header -``` -xmlstarlet tr "/tmp/checkstyle2text.xslt" "/path/to/file" | \ -sed 's|"|\\"|g' | \ -sed -n \ - -e "s|^\(.*\) - \([0-9]\+\) failure.*$|echo '========='\n \ - echo 'Found \2 failure(s) in \1'\n \ - echo '---------'|p" \ - -e "s|^\(.*\): \(ShellCheck\.\)\?\(\(..\)[0-9]\{4\}\) (\(.*\)) line \([0-9]\+\), column \([0-9]\+\) - \(.*\)$|echo 'In \1 line \6:'\n \ - sed -n '\6p' \1\n \ - printf \"%\$((\7 - 1\))s^ \"\n \ - printf 'https://github.com/hadolint/hadolint/wiki/' \ - echo \"\3 (\5): \8\"\n \ - echo\n|p" | \ -sh | \ -tee -a "${_file%%.checkstyle.xml}.log" -``` - -### `checkstyle2text.xslt` -``` - - - - - - - - - - - - - - - - - failure(s) - - - - - - - - - - - - - : - - ( - - ) line - - , column - - - - - - - - - - - -``` \ No newline at end of file