Skip to content

Commit e346ffe

Browse files
fix(enrichment): restore comma-separated any annotations in unsafe-any
Drop the object-literal guard that suppressed valid `(v: any, next)` and `let a: any, b` matches; document the remaining shorthand false-positive. Co-authored-by: Cursor <cursoragent@cursor.com>
1 parent bcfb984 commit e346ffe

5 files changed

Lines changed: 7 additions & 7 deletions

File tree

apps/gittensory-ui/src/lib/rees-analyzers.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -952,7 +952,7 @@ export const REES_ANALYZERS = [
952952
reports: "File, line, and kind: annotation, cast, or assertion.",
953953
network: "Pure local analyzer. No external network call.",
954954
notes:
955-
"Structural regex only — no type-checker. String literals and full-line comments are ignored; inline `//` and `/* */` comments are stripped before matching.",
955+
"Structural regex only — no type-checker. String literals and full-line comments are ignored; inline `//` and `/* */` comments (including multi-line blocks) are stripped before matching. Object-literal shorthand values such as `{ value: any }` may false-positive when `any` is a variable name.",
956956
},
957957
},
958958
{

review-enrichment/analyzer-metadata.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1075,7 +1075,7 @@
10751075
"looksAt": "Added lines in changed non-test .ts/.tsx/.mts/.cts source files.",
10761076
"reports": "File, line, and kind: annotation, cast, or assertion.",
10771077
"network": "Pure local analyzer. No external network call.",
1078-
"notes": "Structural regex only — no type-checker. String literals and full-line comments are ignored; inline `//` and `/* */` comments are stripped before matching."
1078+
"notes": "Structural regex only — no type-checker. String literals and full-line comments are ignored; inline `//` and `/* */` comments (including multi-line blocks) are stripped before matching. Object-literal shorthand values such as `{ value: any }` may false-positive when `any` is a variable name."
10791079
}
10801080
},
10811081
{

review-enrichment/src/analyzers/registry.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -993,7 +993,7 @@ export const ANALYZER_DESCRIPTORS = [
993993
reports: "File, line, and kind: annotation, cast, or assertion.",
994994
network: "Pure local analyzer. No external network call.",
995995
notes:
996-
"Structural regex only — no type-checker. String literals and full-line comments are ignored; inline `//` and `/* */` comments are stripped before matching.",
996+
"Structural regex only — no type-checker. String literals and full-line comments are ignored; inline `//` and `/* */` comments (including multi-line blocks) are stripped before matching. Object-literal shorthand values such as `{ value: any }` may false-positive when `any` is a variable name.",
997997
},
998998
render: (findings, helpers) => {
999999
if (!findings.length) return [];

review-enrichment/src/analyzers/unsafe-any.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ const TS_EXTS = new Set(["ts", "tsx", "mts", "cts"]);
1212

1313
const CAST_RE = /\bas\s+any\b/;
1414
const ASSERTION_RE = /<\s*any\s*>/;
15-
const ANNOTATION_RE = /:\s*any\b(?!\s*[,}])/;
15+
const ANNOTATION_RE = /:\s*any\b/;
1616

1717
function isTypeScriptPath(path: string): boolean {
1818
const ext = /\.([^.]+)$/.exec(path)?.[1]?.toLowerCase();

review-enrichment/test/unsafe-any.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,9 @@ test("detectUnsafeAny: ignores block comments after real code", () => {
4949
assert.equal(detectUnsafeAny("/* @internal */ const value: any = input;"), "annotation");
5050
});
5151

52-
test("detectUnsafeAny: does not treat object-literal values as type annotations", () => {
53-
assert.equal(detectUnsafeAny("return { value: any };"), null);
54-
assert.equal(detectUnsafeAny("return { value: any, other: true };"), null);
52+
test("detectUnsafeAny: flags comma-separated parameter and declarator annotations", () => {
53+
assert.equal(detectUnsafeAny("function f(v: any, next: string) {}"), "annotation");
54+
assert.equal(detectUnsafeAny("let a: any, b: string;"), "annotation");
5555
});
5656

5757
test("scanPatchForUnsafeAny: ignores multi-line block comments spanning added lines", () => {

0 commit comments

Comments
 (0)