Created
August 19, 2018 15:21
-
-
Save alexec/3fa7c24bd37f6fab502a9f3d5ebab2e7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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