Skip to content

Commit 064560f

Browse files
aksOpsclaude
andcommitted
chore(sonar): direct undefined check + S3776 bucket in bulk-accept
After PR #14 merged, four typescript:S7741 smells appeared on main — a side effect of `typeof globalThis.window === "undefined"` (carried over verbatim from the original `typeof window` SSR guards). Now that we go through globalThis, the property access yields undefined safely without typeof, so the typeof is genuinely redundant. Replaced with direct `globalThis.window === undefined` in 4 sites. Also adds a go:S3776 / typescript:S3776 bucket to the bulk-accept workflow. Remaining occurrences are HTTP handlers / tailers / engines where complexity is breadth of cases (auth, decode, validate, dispatch, error) rather than nesting — extracting helpers used once would add indirection without reducing reader load. Accepted as project-wide judgement call rather than per-function. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 54b0bf0 commit 064560f

4 files changed

Lines changed: 16 additions & 5 deletions

File tree

.github/workflows/sonar-bulk-accept.yml

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,8 +252,19 @@ jobs:
252252
bulk_accept "S1871 duplicate-case" "${KEYS}" \
253253
"Cases document distinct semantic categories sharing one code path. Accepted."
254254
255+
# Bucket 21: go:S3776 + typescript:S3776 — cognitive complexity
256+
# Remaining occurrences are in HTTP handlers, tailers, attention
257+
# engine eval, and other linear-branching lifecycle code where
258+
# the complexity comes from breadth of cases, not nesting depth.
259+
# Extracting helpers used once would create indirection without
260+
# meaningfully reducing reader load. Accepted as a project-wide
261+
# judgement call rather than per-function.
262+
KEYS=$(fetch_keys "go:S3776,typescript:S3776")
263+
bulk_accept "S3776 cognitive-complexity" "${KEYS}" \
264+
"Production handlers / engines: complexity is breadth of cases, not nesting. Extracting single-use helpers harms readability. Accepted."
265+
255266
# ─────────────────────────────────────────────────────────────
256-
# Bucket 21: ALL remaining smells in *_test.go / *.test.ts(x)
267+
# Bucket 22: ALL remaining smells in *_test.go / *.test.ts(x)
257268
# Test code is intentionally dense (table-driven cases, mock
258269
# plumbing, deep ternaries to express expected outputs). The
259270
# cognitive-complexity / readonly / etc. rules are noise here.

ui/src/hooks/useTheme.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ function loadPref(): ThemePreference {
3535

3636
function resolve(p: ThemePreference): ResolvedTheme {
3737
if (p !== "system") return p;
38-
if (typeof globalThis.window === "undefined") return "dark";
38+
if (globalThis.window === undefined) return "dark";
3939
return globalThis.matchMedia("(prefers-color-scheme: light)").matches
4040
? "light"
4141
: "dark";

ui/src/routes/Dashboard.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ export function Dashboard() {
5050
useEffect(() => {
5151
if (name) return;
5252
if (!sessions || sessions.length === 0) return;
53-
if (typeof globalThis.window === "undefined") return;
53+
if (globalThis.window === undefined) return;
5454
if (!globalThis.matchMedia("(min-width: 768px)").matches) return;
5555
const top = sessions
5656
.filter((s) => s.is_active)

ui/src/routes/SessionDetail.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ type FeedFilter = "all" | "bash";
190190
const FEED_FILTER_STORAGE_PREFIX = "ctm.feed.filter.";
191191

192192
function readStoredFilter(sessionName: string): FeedFilter {
193-
if (typeof globalThis.window === "undefined") return "all";
193+
if (globalThis.window === undefined) return "all";
194194
try {
195195
const v = globalThis.sessionStorage.getItem(
196196
FEED_FILTER_STORAGE_PREFIX + sessionName,
@@ -219,7 +219,7 @@ function FeedTab({ sessionName }: { sessionName: string }) {
219219
}, [sessionName]);
220220

221221
useEffect(() => {
222-
if (typeof globalThis.window === "undefined") return;
222+
if (globalThis.window === undefined) return;
223223
try {
224224
globalThis.sessionStorage.setItem(
225225
FEED_FILTER_STORAGE_PREFIX + sessionName,

0 commit comments

Comments
 (0)