Skip to content

Commit fb8ddef

Browse files
authored
Merge pull request #67 from CoverageTracker/chore/formatting-and-typing
chore: add EditorConfig, Prettier, and ESLint across all three projects
2 parents b318024 + 9771236 commit fb8ddef

84 files changed

Lines changed: 5732 additions & 808 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.editorconfig

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
root = true
2+
3+
[*]
4+
charset = utf-8
5+
end_of_line = lf
6+
insert_final_newline = true
7+
trim_trailing_whitespace = true
8+
indent_style = space
9+
indent_size = 2
10+
11+
[*.md]
12+
trim_trailing_whitespace = false
13+
14+
[*.{json,yml,yaml}]
15+
indent_size = 2
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
node_modules/
2+
dist/
3+
coverage/
4+
package-lock.json
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"semi": true,
3+
"singleQuote": true,
4+
"trailingComma": "all",
5+
"printWidth": 100,
6+
"tabWidth": 2
7+
}

.github/actions/report/README.md

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -13,40 +13,40 @@ configured threshold is breached.
1313

1414
```yaml
1515
permissions:
16-
id-token: write # mint OIDC token for Worker auth
17-
checks: write # post Check Run on PRs
16+
id-token: write # mint OIDC token for Worker auth
17+
checks: write # post Check Run on PRs
1818

1919
steps:
2020
- uses: actions/checkout@v4
21-
- run: npm test -- --coverage # your tests write coverage/lcov.info
21+
- run: npm test -- --coverage # your tests write coverage/lcov.info
2222
- uses: CoverageTracker/coverage-tracker/.github/actions/report@v0.4.0
2323
with:
2424
worker-url: https://coverage-tracker.yourdomain.com
2525
```
2626
2727
## Inputs
2828
29-
| Input | Required | Default | Description |
30-
|---|---|---|---|
31-
| `worker-url` | **yes** | — | Base URL of your coverage-tracker Worker. |
32-
| `coverage-path` | no | *(probed)* | Path to the coverage report. When unset, the documented per-language default paths are probed in a fixed order; the first hit wins. **Missing coverage is always a hard failure** (the error lists every probed path). An explicit path always wins. |
33-
| `coverage-tool` | no | `''` | Only relevant for Cobertura, whose branch semantics vary by producer (`gocover-cobertura`, `kcov`, `covertool`, `phpunit`, `gcovr`). Naming it silences the "trusting the data" warning. Ignored for LCOV / JaCoCo / Go. |
34-
| `complexity-path` | no | *(probed)* | Radon JSON, gocyclo text, or Lizard XML. When unset, probes `radon.json` → `gocyclo.txt` → `lizard-report.xml`. |
35-
| `duplication-path` | no | *(probed)* | jscpd JSON. When unset, probes `jscpd-report/jscpd-report.json`. The Action no longer runs jscpd — run it yourself. |
36-
| `min-coverage` | no | `''` | Absolute coverage floor (%). |
37-
| `max-coverage-drop` | no | `''` | Max allowed drop (pp) from the default-branch baseline (PR checks only). |
38-
| `max-complexity` | no | `''` | Max allowed average cyclomatic complexity. |
39-
| `max-duplication` | no | `''` | Max allowed duplication (%). |
40-
| `github-token` | no | `${{ github.token }}` | Token used to post the PR Check Run. |
29+
| Input | Required | Default | Description |
30+
| ------------------- | -------- | --------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
31+
| `worker-url` | **yes** | — | Base URL of your coverage-tracker Worker. |
32+
| `coverage-path` | no | _(probed)_ | Path to the coverage report. When unset, the documented per-language default paths are probed in a fixed order; the first hit wins. **Missing coverage is always a hard failure** (the error lists every probed path). An explicit path always wins. |
33+
| `coverage-tool` | no | `''` | Only relevant for Cobertura, whose branch semantics vary by producer (`gocover-cobertura`, `kcov`, `covertool`, `phpunit`, `gcovr`). Naming it silences the "trusting the data" warning. Ignored for LCOV / JaCoCo / Go. |
34+
| `complexity-path` | no | _(probed)_ | Radon JSON, gocyclo text, or Lizard XML. When unset, probes `radon.json` → `gocyclo.txt` → `lizard-report.xml`. |
35+
| `duplication-path` | no | _(probed)_ | jscpd JSON. When unset, probes `jscpd-report/jscpd-report.json`. The Action no longer runs jscpd — run it yourself. |
36+
| `min-coverage` | no | `''` | Absolute coverage floor (%). |
37+
| `max-coverage-drop` | no | `''` | Max allowed drop (pp) from the default-branch baseline (PR checks only). |
38+
| `max-complexity` | no | `''` | Max allowed average cyclomatic complexity. |
39+
| `max-duplication` | no | `''` | Max allowed duplication (%). |
40+
| `github-token` | no | `${{ github.token }}` | Token used to post the PR Check Run. |
4141

4242
## Coverage formats (auto-detected by content)
4343

44-
| Signal | Format | Parsed as |
45-
|---|---|---|
46-
| First line `mode: set\|count\|atomic` | Go coverage profile | statement coverage |
47-
| Starts with `TN:` / `SF:` | LCOV | line + branch (if present) |
48-
| XML root `<coverage>` | Cobertura | line + branch (per quirks) |
49-
| XML root `<report>` | JaCoCo | line + branch + cyclomatic (free) |
44+
| Signal | Format | Parsed as |
45+
| ------------------------------------- | ------------------- | --------------------------------- |
46+
| First line `mode: set\|count\|atomic` | Go coverage profile | statement coverage |
47+
| Starts with `TN:` / `SF:` | LCOV | line + branch (if present) |
48+
| XML root `<coverage>` | Cobertura | line + branch (per quirks) |
49+
| XML root `<report>` | JaCoCo | line + branch + cyclomatic (free) |
5050

5151
For per-language commands and the full default-path table, see
5252
[docs/generating-coverage-reports.md](../../../docs/generating-coverage-reports.md).
@@ -58,7 +58,7 @@ configured for them**:
5858

5959
- **Coverage** is always required. If no report is found (explicit path or
6060
probe), the Action fails and lists every path it probed.
61-
- **Complexity / duplication** are skipped silently when the metric is *both*
61+
- **Complexity / duplication** are skipped silently when the metric is _both_
6262
unconfigured and absent. But if `max-complexity` / `max-duplication` is set
6363
and no matching report is found, the Action **fails** with an actionable
6464
error — a configured threshold with no data is treated as a mistake, not a

.github/actions/report/dist/index.js

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24779,7 +24779,9 @@ async function runPRCheck(workerUrl, oidcToken, metrics, owner, repo, category =
2477924779
const data = await res.json();
2478024780
baselines[m.name] = data.value;
2478124781
} catch {
24782-
warning(`Baseline fetch for "${m.name}" returned non-JSON body (HTTP ${res.status}) \u2014 skipping baseline.`);
24782+
warning(
24783+
`Baseline fetch for "${m.name}" returned non-JSON body (HTTP ${res.status}) \u2014 skipping baseline.`
24784+
);
2478324785
}
2478424786
} else if (res.status !== 404) {
2478524787
warning(`Baseline fetch for "${m.name}" returned HTTP ${res.status}.`);
@@ -24811,7 +24813,13 @@ async function runPRCheck(workerUrl, oidcToken, metrics, owner, repo, category =
2481124813
}
2481224814
const failed = reasons.length > 0;
2481324815
if (failed) anyFailed = true;
24814-
const hasThreshold = thresholdConfigured(m.name, minCoverage, maxCoverageDrop, maxComplexity, maxDuplication);
24816+
const hasThreshold = thresholdConfigured(
24817+
m.name,
24818+
minCoverage,
24819+
maxCoverageDrop,
24820+
maxComplexity,
24821+
maxDuplication
24822+
);
2481524823
results.push({
2481624824
metric: m.name,
2481724825
current: m.value,
@@ -30200,7 +30208,7 @@ function parseLizard(content) {
3020030208

3020130209
// src/complexity/detect.ts
3020230210
function detectComplexityShape(content) {
30203-
const trimmed = content.replace(/^/, "").trimStart();
30211+
const trimmed = content.replace(/^\uFEFF/, "").trimStart();
3020430212
if (trimmed.startsWith("{") || trimmed.startsWith("[")) return "radon";
3020530213
if (trimmed.startsWith("<")) return "lizard";
3020630214
return "gocyclo";
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import js from '@eslint/js';
2+
import tseslint from 'typescript-eslint';
3+
import eslintConfigPrettier from 'eslint-config-prettier';
4+
import globals from 'globals';
5+
6+
export default tseslint.config(
7+
{ ignores: ['dist/**', 'coverage/**', 'node_modules/**'] },
8+
js.configs.recommended,
9+
...tseslint.configs.recommended,
10+
{ languageOptions: { globals: { ...globals.node } } },
11+
eslintConfigPrettier,
12+
);

0 commit comments

Comments
 (0)