Skip to content

Instantly share code, notes, and snippets.

@alexec
Created August 19, 2018 15:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alexec/3fa7c24bd37f6fab502a9f3d5ebab2e7 to your computer and use it in GitHub Desktop.
Save alexec/3fa7c24bd37f6fab502a9f3d5ebab2e7 to your computer and use it in GitHub Desktop.
#!/bin/sh
set -Eeuo pipefail
get_xml_attribute() {
set -Eeuo pipefail
name=$1
while read line ; do
echo $line | sed "s/.*$name=\"\([^\"]*\)\".*/\1/"
done
}
find_checkstyle_reports() {
set -Eeuo pipefail
find . -type f -name checkstyle-result.xml
}
get_checkstyle_report() {
set -Eeuo pipefail
path=/dev/null
find_checkstyle_reports | while read report ; do
cat $report | while read line ; do
path=$(echo $line | grep 'file name' | get_xml_attribute name | cut -c $(echo $(pwd)/ | wc -c | tr -d ' ')- || echo $path)
line_no=$(echo $line | grep 'error' | get_xml_attribute line || true)
message=$(echo $line | grep 'error' | get_xml_attribute message || true)
name=$(basename "$path")
[ "$message" != "" ] && echo $name:$line_no:$message
done
done
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment