HDDS-2157. checkstyle: print filenames relative to project root (#1485)

This commit is contained in:
Doroszlai, Attila 2019-09-20 23:05:35 +02:00 committed by Anu Engineer
parent 3f223bebfa
commit 53637301d1
1 changed files with 11 additions and 1 deletions

View File

@ -16,6 +16,7 @@
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
cd "$DIR/../../.." || exit 1
BASE_DIR="$(pwd -P)"
REPORT_DIR=${OUTPUT_DIR:-"$DIR/../../../target/checkstyle"}
mkdir -p "$REPORT_DIR"
REPORT_FILE="$REPORT_DIR/summary.txt"
@ -23,7 +24,16 @@ REPORT_FILE="$REPORT_DIR/summary.txt"
mvn -B -fn checkstyle:check -f pom.ozone.xml
#Print out the exact violations with parsing XML results with sed
find "." -name checkstyle-errors.xml -print0 | xargs -0 sed '$!N; /<file.*\n<\/file/d;P;D' | sed '/<\/.*/d;/<checkstyle.*/d;s/<error.*line="\([[:digit:]]*\)".*message="\([^"]\+\).*/ \1: \2/;s/<file name="\([^"]*\)".*/\1/;/<\?xml.*>/d' | tee "$REPORT_FILE"
find "." -name checkstyle-errors.xml -print0 \
| xargs -0 sed '$!N; /<file.*\n<\/file/d;P;D' \
| sed \
-e '/<\?xml.*>/d' \
-e '/<checkstyle.*/d' \
-e '/<\/.*/d' \
-e 's/<file name="\([^"]*\)".*/\1/' \
-e 's/<error.*line="\([[:digit:]]*\)".*message="\([^"]*\)".*/ \1: \2/' \
-e "s!^${BASE_DIR}/!!" \
| tee "$REPORT_FILE"
## generate counter
wc -l "$REPORT_DIR/summary.txt" | awk '{print $1}'> "$REPORT_DIR/failures"