Skip to content

Commit 550a666

Browse files
authored
Refactor linting logic in docs-quality workflow
1 parent 0eb37ab commit 550a666

1 file changed

Lines changed: 4 additions & 6 deletions

File tree

.github/workflows/docs-quality.yml

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -56,13 +56,11 @@ jobs:
5656
while IFS= read -r -d '' file; do
5757
total=$((total+1))
5858
echo "::group::$file"
59-
json_out="$(harper-cli lint $ONLY_ARG --format json "$file" 2>/dev/null)"
60-
lint_count=$(printf '%s' "$json_out" | python3 -c "import json,sys;d=json.load(sys.stdin);print(sum(len(f.get('lints',[])) for f in d))" 2>/dev/null)
61-
if [ "${lint_count:-0}" -gt 0 ]; then
62-
bad=$((bad+1))
63-
printf '%s' "$json_out" | python3 -c "import json,sys;d=json.load(sys.stdin);[print(l.get('rule','?'), file=sys.stderr) or print('['+l.get('rule','?')+'] '+l.get('message','')+((' -> should be: '+str(l.get('suggestions')[0])) if l.get('suggestions') else '')) for f in d for l in f.get('lints',[])]" 2>>"$rules_seen"
64-
else
59+
if json_out="$(harper-cli lint $ONLY_ARG --format json "$file" 2>/dev/null)"; then
6560
echo "no issues"
61+
else
62+
bad=$((bad+1))
63+
printf '%s' "$json_out" | python3 -c "import json,sys;d=json.load(sys.stdin);[print(l.get('rule','?'), file=sys.stderr) or print('['+l.get('rule','?')+'] '+l.get('message','')+((' -> should be: '+str(l.get('suggestions')[0])) if l.get('suggestions') else '')) for f in d for l in f.get('lints',[])]" 2>>"$rules_seen" || true
6664
fi
6765
echo "::endgroup::"
6866
done < <(

0 commit comments

Comments
 (0)