-
Notifications
You must be signed in to change notification settings - Fork 59
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #708 from aireilly/add-tools-vale_report.sh
Put back Fabrice's tools/vale_report.sh script
- Loading branch information
Showing
1 changed file
with
38 additions
and
0 deletions.
There are no files selected for viewing
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
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 |