summaryrefslogtreecommitdiff
path: root/bin/gradle-report
diff options
context:
space:
mode:
authorClaude <noreply@anthropic.com>2026-09-21 19:18:56 +0000
committerClaude <noreply@anthropic.com>2026-09-21 19:18:56 +0000
commit95f95acdb551168f2e5a52e000ff62167be266a8 (patch)
treeeb36f1d9fab024f223a988e1815012c1a2a18e35 /bin/gradle-report
parent8f94e3caa0b1b477bacbbbd8954f2cea743a9337 (diff)
gradle-report: name UP-TO-DATE as the cause of a stale report
Found by running it: detekt exited 0 while the report predated the run, because Gradle skipped the task. 'STALE' alone leaves the reader to work out why nothing changed, so it now says which task was skipped and how to force it, with --allow-stale to accept an older report deliberately. Same shape as gradle-test, which learned this first. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018AwnALZL6bD4VBtATDVv3B
Diffstat (limited to 'bin/gradle-report')
-rwxr-xr-xbin/gradle-report19
1 files changed, 16 insertions, 3 deletions
diff --git a/bin/gradle-report b/bin/gradle-report
index c59945a..bbee2b7 100755
--- a/bin/gradle-report
+++ b/bin/gradle-report
@@ -1,5 +1,5 @@
#!/usr/bin/env bash
-# gradle-report <project-dir> <detekt|lint> -- [gradle args]
+# gradle-report <project-dir> <detekt|lint> [--allow-stale] [-- <gradle args>]
#
# Runs a static-analysis task and reports from its XML report, refusing to speak if the report
# is older than the run.
@@ -18,6 +18,8 @@ die() { echo "gradle-report: $1" >&2; exit 2; }
PROJECT_DIR=$(cd "$1" 2>/dev/null && pwd) || die "no such project directory: $1"
KIND="$2"
shift 2
+ALLOW_STALE=0
+if [ "${1:-}" = "--allow-stale" ]; then ALLOW_STALE=1; shift; fi
[ "${1:-}" = "--" ] && shift
EXTRA=("$@")
@@ -62,8 +64,15 @@ if [ ! -f "$REPORT" ]; then
exit $STATUS
fi
-if [ "$REPORT" -ot "$MARKER" ]; then
+if [ "$REPORT" -ot "$MARKER" ] && [ $ALLOW_STALE -eq 0 ]; then
echo "report : STALE — $REPORT predates this run"
+ if grep -qE "Task :app:(detekt|lintDebug) UP-TO-DATE" "$LOG"; then
+ echo "hint : Gradle treated $TASK as UP-TO-DATE, so nothing was re-analysed and the"
+ echo " report on disk describes an earlier state of the code."
+ echo " Re-run with: -- --rerun-tasks (or --allow-stale to accept it)"
+ else
+ echo "hint : the task ran but produced no new report. Re-run with: -- --rerun-tasks"
+ fi
echo "result : FAIL — refusing to report numbers that describe older code"
rm -f "$LOG"
exit 1
@@ -96,7 +105,11 @@ for r in rows:
PY
)
-echo "report : fresh"
+if [ "$REPORT" -ot "$MARKER" ]; then
+ echo "report : STALE (accepted via --allow-stale)"
+else
+ echo "report : fresh"
+fi
echo "$FINDINGS" | head -1 | sed 's/^COUNT /findings: /'
echo "$FINDINGS" | tail -n +2