Commit 6696fc6
authored
fix(tsextractor): detect nested-generic and lowercase-verb HTTP client calls (#154)
The optional type-argument group in the client-call patterns was `<[^>]*>`,
which cannot span a nested type argument: on `fetch<ApiResponse<Foo>>(…)` the
inner class stops at the first `>`, the following `\s*\(` meets a `>`, and RE2
has no recursion, so backtracking to the empty alternative then meets `<`. One
level of generics matched, two silently did not — including on the
openapi-fetch shape the pattern was written for. Bind the group on `(`, which a
type argument never contains.
Lowercase verb calls (`axios.get('/path')`, `http.post('/path')`) matched
nothing at all. They were excluded to avoid colliding with `map.get()` /
`cache.delete()`; `lowerVerbCall` pays for admitting them by requiring a
`/`-rooted literal argument — a condition `cleanTSPath` already enforces
downstream, so no collection lookup can reach it. A lowercase call on an
interpolated template stays deliberately unmatched.
Both gaps erased outbound calls entirely — not counted detected, external or
unresolved — so a cross-repo residual under-reported with no sign that it had.
Admitting lowercase verbs immediately required a guard: a supertest call in an
e2e suite is byte-identical in shape to production client traffic. Gate
client-route extraction on facts.IsTestPath, and teach that predicate the two
e2e conventions its .spec/.test suffixes cannot match — the hyphen means
`.e2e-spec.ts` and `.e2e.ts` carry no leading dot. Ungated, one API's own test
suite became 500+ client routes, promoted that service from isolated to
connected, and fabricated a cross-repo dependency edge out of test traffic.
Note the guard also removes pre-existing false positives: e2e HTTP calls were
already being counted as production client routes before this change.
cacheVersion v141. Golden fixture extended so the patterns are exercised at
all — TestGolden previously passed untouched against the fixed extractor.1 parent 627aba4 commit 6696fc6
8 files changed
Lines changed: 231 additions & 10 deletions
File tree
- internal
- cachecov
- engine
- testdata
- golden
- repos/py_fastapi_multirepo/acme/web/src
- extractors/tsextractor
- facts
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
169 | 169 | | |
170 | 170 | | |
171 | 171 | | |
172 | | - | |
| 172 | + | |
| 173 | + | |
173 | 174 | | |
174 | 175 | | |
175 | 176 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
767 | 767 | | |
768 | 768 | | |
769 | 769 | | |
770 | | - | |
| 770 | + | |
| 771 | + | |
| 772 | + | |
| 773 | + | |
| 774 | + | |
| 775 | + | |
| 776 | + | |
| 777 | + | |
| 778 | + | |
| 779 | + | |
| 780 | + | |
| 781 | + | |
| 782 | + | |
| 783 | + | |
| 784 | + | |
| 785 | + | |
| 786 | + | |
| 787 | + | |
| 788 | + | |
| 789 | + | |
| 790 | + | |
| 791 | + | |
| 792 | + | |
| 793 | + | |
| 794 | + | |
| 795 | + | |
| 796 | + | |
| 797 | + | |
| 798 | + | |
| 799 | + | |
| 800 | + | |
| 801 | + | |
| 802 | + | |
771 | 803 | | |
772 | 804 | | |
773 | 805 | | |
| |||
Lines changed: 4 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
8 | | - | |
| 8 | + | |
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
| 15 | + | |
15 | 16 | | |
16 | 17 | | |
17 | 18 | | |
18 | | - | |
| 19 | + | |
19 | 20 | | |
20 | 21 | | |
21 | 22 | | |
22 | 23 | | |
23 | 24 | | |
24 | 25 | | |
| 26 | + | |
Lines changed: 11 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
24 | | - | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
25 | 33 | | |
26 | 34 | | |
27 | 35 | | |
| |||
34 | 42 | | |
35 | 43 | | |
36 | 44 | | |
37 | | - | |
38 | | - | |
39 | | - | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
40 | 69 | | |
41 | 70 | | |
42 | 71 | | |
| |||
207 | 236 | | |
208 | 237 | | |
209 | 238 | | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
210 | 249 | | |
211 | 250 | | |
212 | 251 | | |
| |||
0 commit comments