Scores every -api module against the mechanical checks of the API quality rules, compares runs, and publishes the
weekly report.
Refer to API Quality Rules and Scores on Asana for more information and full list of checks.
| File | What it does | Run by |
|---|---|---|
score.sh + Scorer.java |
Scores the checked-out code | Manual or every workflow |
compare.py |
Diffs two scorer runs by declaration: new, resolved and moved findings, score changes, and whether it regressed | Every workflow except the scorecard |
asana_sync.py |
Posts the weekly report to Asana, and one Triage task listing all of the week's new findings | Weekly workflow |
asana_task.py |
Creates the one Asana task of a run, or updates it on a re-run | Compare workflow |
rules.json |
Each rule's name, why it matters and how to fix it: the single source for the texts in reports, PR comments and Asana tasks | compare.py, asana_sync.py |
scripts/api-quality/score.shWrites five files to scripts/api-quality/output/ (gitignored), named with today's date. Needs Java 21. The Kotlin
compiler jars come from your Gradle cache, or are downloaded once from Maven Central into ~/.cache/api-quality-scorer.
| # | Argument | Default | Meaning |
|---|---|---|---|
| 1 | Output folder | scripts/api-quality/output |
Where the files go |
| 2 | Date | Today | Used in the file names |
| 3 | Previous scores CSV | None | Adds a "Score changes" section to the scorecard |
Set REPO_ROOT to score a different checkout, e.g. REPO_ROOT=/tmp/old scripts/api-quality/score.sh /tmp/old-score.
python3 scripts/api-quality/compare.py --before /tmp/old-score --after scripts/api-quality/output --mode weekly --out-md /tmp/report.md--mode pr renders the PR comment instead. Both runs must come from the same Scorer.java.
| File | Contents |
|---|---|
api-quality-scorecard-<date>.md |
Summary and per-module scores |
api-quality-scores-<date>.csv |
One row per module, with its KDoc counts and failing rules |
api-quality-findings-<date>.csv |
One row per finding |
api-quality-declarations-<date>.csv |
Every counted public declaration, to audit M3 and M4 |
api-quality-constructors-<date>.csv |
Every constructor of a public class, any visibility; not counted, only lets compare.py tell a constructor still exists |
The posting scripts read every Asana ID from these repository variables (Settings → Secrets and variables → Actions →
Variables), which the workflows pass in as environment variables of the same names. For a local run, export them.
| Variable | Asana ID of |
|---|---|
GH_API_QUALITY_PROJECT_ID |
The project |
GH_API_QUALITY_TRIAGE_SECTION_ID |
Its Triage section: weekly regressions tasks and compare regression tasks |
GH_API_QUALITY_WEEKLY_REPORTS_SECTION_ID |
Its Weekly Reports section: weekly report tasks |
GH_API_QUALITY_GITHUB_RUN_FIELD_KEY_ID |
The "GitHub run" text field, which lets a re-run find and update its own task |
GH_API_QUALITY_STATUS_FIELD_KEY_ID |
The "API quality status" single-select field |
GH_API_QUALITY_STATUS_FIELD_NEEDS_EXPLANATION_VALUE_ID |
Its "Needs explanation" option: the weekly report counts open tasks still at it after 14 days |
GH_API_QUALITY_RULES_URL |
Optional: the "API quality rules and scores" task, linked at the end of PR comments, reports and regressions tasks |
Scheduled weekly runs post once GH_API_QUALITY_PROJECT_ID is set. A run that posts with any variable missing fails and
names the missing ones. Posting uses the existing ASANA_ACCESS_TOKEN secret.
- Source: the
.ktfiles of every non-test source set of a module:src/mainand any flavor folder such assrc/play. - Public: no
private,internalorprotectedmodifier, inside a public parent.overridemembers are left out, because the contract and KDoc belong to the declaration they override. - Declaration: each public type (top-level or nested, including type aliases; not companion objects or enum entries),
top-level function or property, and member function or property. Primary-constructor
val/varparameters count as properties. The declaration count weights the fleet score. - Sealed cases: a class or object declared inside its
sealedparent and extending it (Result.Success) needs no KDoc, like an enum entry: it counts as a declaration but not for M3. Its own members still count for M4. A subtype declared outside its parent isn't recognised, since there's no symbol resolution. - M3 covers types and top-level functions. M4 covers member functions and properties, and top-level properties. Each
fails on any declaration in its group without KDoc. A property is also documented when its class KDoc describes it with an
@property/@paramtag or a[name]link. KDoc coverage, the share of declarations with KDoc, is reported next to the scores to show progress while a module still fails the checks. - Constructors: a
val/varparameter is a property, public even behind a private constructor. Other parameters of a public constructor are checked by M2, M6 and M7 asType.constructor(...); enum and sealed class constructors aren't. - M1: a type name ending in
Repository,Dao,Entity,ViewModelorImpl, or starting withRealfollowed by an uppercase letter (RealFoo, notRealm). - M2:
Toggleanywhere in a signature or supertype, including type arguments such asList<Toggle>. A qualified name such asToggle.Statedoesn't count. - M5: a function whose declared return type is exactly
Intent?,Fragment?,View?orBundle?. - M6:
Any,PairorTripleanywhere in a signature, including type arguments, exceptequals(other: Any?)andreadResolve(). - M7: a public
varwhose setter is also public, or a writable type anywhere in a signature:Mutable*, the Java mutable collections (ArrayList,HashMap,HashSet,LinkedHashMap,LinkedHashSet,LinkedList,ConcurrentHashMap,CopyOnWriteArrayList), theAtomic*types, and the coroutinesChannelandSendChannel. The last two only count when the file imports them fromkotlinx.coroutines.channelsor writes their full name, since this repo also has its ownChannelclass. Arrays aren't checked: they're the usual type for binary data.
Files are parsed with the Kotlin compiler's own parser, so the same code always gives the same score. There is no symbol resolution: types are matched by simple name, and a declaration whose type is inferred isn't checked by M2, M5, M6 or M7.
Changing any definition changes scores across the fleet, so it follows the re-baseline procedure.
pip install -r scripts/api-quality/requirements.txt
cd scripts/api-quality && python3 -m pytesttest_scorer.py runs the scorer on small Kotlin fixtures, so it needs Java 21; it's skipped without it.

