Skip to content

Commit

Permalink
Merge pull request #708 from aireilly/add-tools-vale_report.sh
Browse files Browse the repository at this point in the history
Put back Fabrice's tools/vale_report.sh script
  • Loading branch information
aireilly authored Jan 23, 2024
2 parents 167c531 + 8e5b3d4 commit 80a119c
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions tools/vale_report.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#!/bin/sh
#
# Copyright (c) 2021 Red Hat, Inc.
# This program and the accompanying materials are made
# available under the terms of the Eclipse Public License 2.0
# which is available at https://www.eclipse.org/legal/epl-2.0/
#
# SPDX-License-Identifier: EPL-2.0
#
# Loop on each git repository found on location given as argument, or current directory
find "${1:-.}" -name .git -print | sed 's@/.git@@' | sort | uniq | while read -r directory;
do
echo "Generating report on $directory"
# Provide a full list of files to report on
# Ignore files containing a space, content in German, /deprecated/ and /Internal/ directories
FILE_LIST=$(find "${directory}" -type f -name '*.adoc' -print | sed 's#^\.\/##;/ /d;/de-de\.adoc/d;/\/deprecated\//d;/\/Internal\//d;/\/internal-resources\//d'| sort | uniq)
REPORT_BASENAME=vale-report-$(basename "${directory}" | sed 's#^\.##')
# Create file list
echo "$FILE_LIST" > "${REPORT_BASENAME}-list.log"
# Count words in the corpus
# shellcheck disable=SC2002,SC2086
cat $FILE_LIST | wc -w > "${REPORT_BASENAME}-wordcount.log"
# Create Vale report
# shellcheck disable=SC2086
vale --output=JSON --no-exit $FILE_LIST > "$REPORT_BASENAME.json"
# A minimal analyze
jq .[][].Severity "$REPORT_BASENAME.json" | sort | uniq -c | sort -nr > "$REPORT_BASENAME.severity"
jq .[][].Check "$REPORT_BASENAME.json" | sort | uniq -c | sort -nr > "$REPORT_BASENAME.rules"
# Report all words generating a Spelling error
# Interesting fields:
# Filter on: "Check": "RedHat.Spelling"
# Display the values of: "Match"
RULES="$(jq .[][].Check "$REPORT_BASENAME.json" | sort | uniq | sed s/\"//g)"
for RULE in $RULES
do
jq -r ".[][] | select(.Check==\"$RULE\") | .Match" "$REPORT_BASENAME.json" | sort | uniq -c | sort -nr > "$REPORT_BASENAME-rule-$RULE.txt"
done
done

0 comments on commit 80a119c

Please sign in to comment.