docs: add coverage thresholds, ./gradlew coverage, and LSP warning discipline

AGENTS.md:
  - Add "./gradlew coverage" to All-in-one quick-start section
  - Add "npm run test:coverage" to Frontend commands
  - Add Coverage section: command, threshold table (70% lines, 60%
    branches, 70% functions), HTML report paths for both layers
  - Note that coverage is enforced during ./gradlew check

CODING_GUIDELINES.md:
  - Section 1 (General Principles): add "Treat warnings as mistakes"
    rule — LSP diagnostics, compiler warnings, and lint warnings are
    bugs that must be fixed before commit
  - Known false positives (Lombok, getActivePinia) must be suppressed
    explicitly at the narrowest scope with a comment explaining why
  - Uncommented suppressions are treated as errors
  - Section 7 (Testing): add Coverage subsection with thresholds table,
    command reference, report paths, and enforcement rule (PRs must
    maintain or improve coverage)
This commit is contained in:
Joakim Mörling 2026-05-15 12:16:16 +02:00
parent 7e6124ce4a
commit 3fa4f6831e
2 changed files with 50 additions and 1 deletions

View file

@ -37,7 +37,8 @@ docker compose up -d # starts postgres, backend, frontend
### All-in-one ### All-in-one
```bash ```bash
./gradlew check # frontend lint → frontend test → backend test → integration test ./gradlew check # frontend lint → frontend test → backend test → coverage verification
./gradlew coverage # backend + frontend tests with coverage reports
./gradlew up # docker compose up -d ./gradlew up # docker compose up -d
./gradlew down # docker compose down ./gradlew down # docker compose down
./gradlew reset # docker compose down -v && docker compose up -d (full DB reset) ./gradlew reset # docker compose down -v && docker compose up -d (full DB reset)
@ -52,6 +53,7 @@ npm run dev # dev server on :3000 with HMR
npm run build # production build npm run build # production build
npm run lint # ESLint npm run lint # ESLint
npm run test # vitest npm run test # vitest
npm run test:coverage # vitest with coverage (HTML at frontend/coverage/)
``` ```
### Backend (Spring Boot 4 + Java 21) ### Backend (Spring Boot 4 + Java 21)
@ -228,6 +230,26 @@ the same PR — never merge code without corresponding tests.
--- ---
## Coverage
```bash
./gradlew coverage # backend + frontend tests with coverage
```
Coverage thresholds are enforced during `./gradlew check`. PRs must maintain
or improve coverage.
| Layer | Lines | Branches | Functions |
|----------|-------|----------|-----------|
| Backend | 70% | 60% | — |
| Frontend | 70% | 60% | 70% |
HTML reports:
- Backend: `backend/build/reports/jacoco/index.html`
- Frontend: `frontend/coverage/index.html`
---
## External References ## External References
For detailed conventions, load `@CODING_GUIDELINES.md`. For detailed conventions, load `@CODING_GUIDELINES.md`.

View file

@ -15,6 +15,15 @@ Conventions and standards for the BilHej codebase. These exist to keep the proje
- **No commented-out code.** Delete it. Git history keeps it if needed. - **No commented-out code.** Delete it. Git history keeps it if needed.
- **Keep functions small.** A function should do one thing. If it's over 30 lines, it probably does too much. - **Keep functions small.** A function should do one thing. If it's over 30 lines, it probably does too much.
- **No magic numbers.** Use named constants or enums. - **No magic numbers.** Use named constants or enums.
- **Treat warnings as mistakes.** LSP diagnostics, compiler warnings, and lint
warnings are bugs. Never commit code that produces them. If a warning is a
known false positive (e.g. Lombok `@RequiredArgsConstructor` triggering
"uninitialized final field"), suppress it explicitly at the narrowest scope
with a comment explaining why:
- Java: `@SuppressWarnings("...") // Lombok generates constructor`
- TypeScript: `// @ts-expect-error — pinia getActivePinia returns null in test context`
Uncommented suppressions are indistinguishable from ignoring a real problem
and are treated as errors.
--- ---
@ -303,6 +312,24 @@ the same PR — never merge code without corresponding tests.
raw SQL in test code. Tests interact with the database the same way raw SQL in test code. Tests interact with the database the same way
production code does: through the ORM. production code does: through the ORM.
### Coverage
```bash
./gradlew coverage # backend + frontend tests with coverage
```
Coverage is enforced via `./gradlew check`. Thresholds:
| Layer | Lines | Branches | Functions |
|----------|-------|----------|-----------|
| Backend | 70% | 60% | — |
| Frontend | 70% | 60% | 70% |
- Backend: JaCoCo (`backend/build/reports/jacoco/index.html`).
- Frontend: Vitest v8 provider (`frontend/coverage/index.html`).
- PRs must maintain or improve coverage levels. If a new feature changes
coverage, update the test suite — never lower thresholds without discussion.
--- ---
## 8. Linting & Formatting ## 8. Linting & Formatting