Skip to content

Commit fb87dff

Browse files
committed
refactor(sonar): clear another broad low-risk runtime batch
- simplify checkout-board, cricket-surface, shell-layout, runtime, and theme helper paths with local helpers and optional chaining - keep observer, render, route, overlay, and startup behavior unchanged while removing small sonar smells - validate with lint, full test suite, and final Sonar scan on xConfig (69 -> 51 open issues)
1 parent bf01fda commit fb87dff

14 files changed

Lines changed: 93 additions & 48 deletions

File tree

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ direkt zu einer versionierten Release-Sektion.
2121

2222
### Fixed
2323

24+
- Nutzerwirkung: Keine beabsichtigte sichtbare Verhaltensänderung; eine breitere Low-Risk-Sonar-Welle hält Checkout-Board, Cricket-Surface, Theme-/Runtime-Helfer und xConfig-Randpfade auf denselben fachlichen Verträgen, drückt kleine Guard-, Logger- und Auswahlzweige intern aber direkter aus.
25+
Technik: `checkout-board-targets`, `turn-surface-adapter`, `cricket-surface/*`, `cricket-highlighter/style`, `dart-marker-emphasis`, `theme-utils`, `bootstrap-runtime`, `checkout-score-pulse`, `layout-utils` und `render-controller` bereinigen nur lokale `S3358`- und `S6582`-Treffer durch kleine Helper und Optional-Chaining-Guards, ohne Observer-, Render-, Overlay-, Route- oder Runtime-Semantik umzubauen; die bestehenden Runtime-, Cricket-, Checkout- und Shell-Regressionen bleiben dabei der fachliche Schutz gegen Drift.
26+
2427
- Nutzerwirkung: Keine beabsichtigte sichtbare Verhaltensänderung; TV-Board-Zoom und die Browser-Asset-Auflösung bleiben fachlich unverändert, drücken interne Übergabe- und Reexport-Pfade in dieser Sonar-Welle aber direkter aus.
2528
Technik: `tv-board-zoom/applyZoom(...)` bündelt die drei internen Knotenparameter jetzt in ein kleines Objekt statt über eine 8-Parameter-Signatur, alle direkten Layout-Regressionen wurden auf dieselbe interne Form umgestellt, und `feature-assets.browser` exportiert die zwei Asset-Bindings nun direkt per `export ... from` ohne zusätzlichen Alias-Zwischenschritt; Zoom-Transform-, Host-Overflow- und Asset-Konsumentenpfade bleiben dabei unverändert der fachliche Vertrag.
2629

src/features/checkout-board-targets/index.js

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,16 @@ function createDebugState(featureDebug) {
4747
};
4848
}
4949

50+
function resolveFeatureDebugLogger(featureDebug, level) {
51+
if (level === "warn" && typeof featureDebug?.warn === "function") {
52+
return featureDebug.warn.bind(featureDebug);
53+
}
54+
if (typeof featureDebug?.log === "function") {
55+
return featureDebug.log.bind(featureDebug);
56+
}
57+
return null;
58+
}
59+
5060
function emitDebugEvent(debugState, level, signature, summary, payload) {
5161
if (!debugState?.featureDebug?.enabled || !signature) {
5262
return;
@@ -58,12 +68,7 @@ function emitDebugEvent(debugState, level, signature, summary, payload) {
5868
}
5969
debugState[signatureKey] = signature;
6070

61-
const logger =
62-
level === "warn" && typeof debugState.featureDebug.warn === "function"
63-
? debugState.featureDebug.warn.bind(debugState.featureDebug)
64-
: typeof debugState.featureDebug.log === "function"
65-
? debugState.featureDebug.log.bind(debugState.featureDebug)
66-
: null;
71+
const logger = resolveFeatureDebugLogger(debugState.featureDebug, level);
6772
if (!logger) {
6873
return;
6974
}

src/features/checkout-board-targets/logic.js

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,16 @@ function segmentAngles(value) {
7676
};
7777
}
7878

79+
function resolveFamilyEffectProfile(effectProfiles, family, baseEffectProfile) {
80+
if (family === "outer") {
81+
return effectProfiles.outer || baseEffectProfile;
82+
}
83+
if (family === "bull") {
84+
return effectProfiles.bull || baseEffectProfile;
85+
}
86+
return baseEffectProfile;
87+
}
88+
7989
function createWedge(ownerDocument, radius, innerRatio, outerRatio, startDeg, endDeg, edgePaddingPx) {
8090
const path = ownerDocument.createElementNS(SVG_NS, "path");
8191
const innerRadius = Math.max(0, radius * innerRatio);
@@ -249,12 +259,7 @@ function resolveTargetStyleProfile(target, radius, visualConfig, renderContext =
249259
const family = resolveTargetFamily(target);
250260
const effectProfiles = visualConfig.effectProfiles?.[visualConfig.effect] || {};
251261
const baseEffectProfile = effectProfiles.base || {};
252-
const familyEffectProfile =
253-
family === "outer"
254-
? effectProfiles.outer || baseEffectProfile
255-
: family === "bull"
256-
? effectProfiles.bull || baseEffectProfile
257-
: baseEffectProfile;
262+
const familyEffectProfile = resolveFamilyEffectProfile(effectProfiles, family, baseEffectProfile);
258263
const priorityProfile =
259264
renderContext.priorityProfile ||
260265
resolvePriorityProfile(
@@ -381,7 +386,7 @@ function applyTargetMetadata(shapeNode, target, styleProfile) {
381386
}
382387

383388
function applyShapeStyle(shapeNode, visualConfig, styleProfile) {
384-
if (!shapeNode || !shapeNode.classList || !shapeNode.style) {
389+
if (!shapeNode?.classList || !shapeNode.style) {
385390
return;
386391
}
387392

@@ -444,7 +449,7 @@ function applyShapeStyle(shapeNode, visualConfig, styleProfile) {
444449
);
445450
if (
446451
visualConfig.renderShapeStroke === false ||
447-
(shapeNode.dataset && shapeNode.dataset.noStroke === "true")
452+
shapeNode.dataset?.noStroke === "true"
448453
) {
449454
shapeNode.style.setProperty("stroke", "none");
450455
shapeNode.style.setProperty("stroke-width", "0");
@@ -463,7 +468,7 @@ function cloneShapeAsOutline(shapeNode, ownerDocument) {
463468
}
464469

465470
function applyOutlineStyle(outlineNode, visualConfig, styleProfile) {
466-
if (!outlineNode || !outlineNode.classList || !outlineNode.style) {
471+
if (!outlineNode?.classList || !outlineNode.style) {
467472
return;
468473
}
469474

@@ -502,7 +507,7 @@ function applyOutlineStyle(outlineNode, visualConfig, styleProfile) {
502507

503508
function buildTargetShapes(ownerDocument, radius, target, visualConfig) {
504509
const shapes = [];
505-
if (!ownerDocument || !target || !target.ring) {
510+
if (!ownerDocument || !target?.ring) {
506511
return shapes;
507512
}
508513

@@ -604,7 +609,7 @@ export function renderCheckoutTargets(options = {}) {
604609
const checkoutTargets = Array.isArray(options.checkoutTargets) ? options.checkoutTargets : [];
605610
const visualConfig = options.visualConfig;
606611

607-
if (!board || !board.group || !board.radius || !visualConfig) {
612+
if (!board?.group || !board?.radius || !visualConfig) {
608613
return;
609614
}
610615

src/features/checkout-score-pulse/logic.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,7 @@ export function applyHighlightState(nodes, options = {}) {
320320
const effectClassList = getEffectClassList();
321321

322322
nodes.forEach((node) => {
323-
if (!node || !node.classList) {
323+
if (!node?.classList) {
324324
return;
325325
}
326326

src/features/cricket-highlighter/style.js

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -67,15 +67,21 @@ const INTENSITY_PRESETS = Object.freeze({
6767
},
6868
});
6969

70+
function resolveIrrelevantBoardDimStyle(featureConfig) {
71+
const rawDimStyle = String(featureConfig.irrelevantBoardDimStyle || "").trim().toLowerCase();
72+
if (IRRELEVANT_DIM_STYLES.has(rawDimStyle)) {
73+
return rawDimStyle;
74+
}
75+
if (featureConfig.dimIrrelevantBoardTargets === false) {
76+
return "off";
77+
}
78+
return "smoke";
79+
}
80+
7081
export function resolveCricketVisualConfig(featureConfig = {}) {
7182
const themeKey = String(featureConfig.colorTheme || "").trim().toLowerCase();
7283
const intensityKey = String(featureConfig.intensity || "").trim().toLowerCase();
73-
const rawDimStyle = String(featureConfig.irrelevantBoardDimStyle || "").trim().toLowerCase();
74-
const irrelevantBoardDimStyle = IRRELEVANT_DIM_STYLES.has(rawDimStyle)
75-
? rawDimStyle
76-
: featureConfig.dimIrrelevantBoardTargets === false
77-
? "off"
78-
: "smoke";
84+
const irrelevantBoardDimStyle = resolveIrrelevantBoardDimStyle(featureConfig);
7985
const theme = THEME_PRESETS[themeKey] || THEME_PRESETS.standard;
8086
const intensity = INTENSITY_PRESETS[intensityKey] || INTENSITY_PRESETS.normal;
8187
const showOpenObjectives =

src/features/cricket-surface/grid-discovery.js

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,13 @@ export function filterAtomicLabelNodes(labelEntries, diagnostics = null) {
118118
return resolved;
119119
}
120120

121+
function normalizeTargetSet(targetSet) {
122+
if (targetSet instanceof Set) {
123+
return targetSet;
124+
}
125+
return new Set(Array.isArray(targetSet) ? targetSet : []);
126+
}
127+
121128
export function collectLabelNodes(
122129
rootNode,
123130
cricketRules,
@@ -129,10 +136,7 @@ export function collectLabelNodes(
129136
const selectorList = Array.isArray(selectors) ? selectors : [];
130137
const fallbackSelector = String(options.fallbackSelector || "").trim();
131138
const skipNode = typeof options.skipNode === "function" ? options.skipNode : () => false;
132-
const normalizedTargetSet =
133-
targetSet instanceof Set
134-
? targetSet
135-
: new Set(Array.isArray(targetSet) ? targetSet : []);
139+
const normalizedTargetSet = normalizeTargetSet(targetSet);
136140
const seen = new Set();
137141
const labels = [];
138142
const pushLabelNode = (node) => {

src/features/cricket-surface/label-layout.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ export function resolveLabelCell(options = {}) {
194194
fallback = cursor;
195195
if (!isInsideTurnPreview(cursor)) {
196196
const parent = cursor.parentElement || null;
197-
const hasSiblings = Boolean(parent && parent.children && parent.children.length > 1);
197+
const hasSiblings = Boolean(parent?.children && parent.children.length > 1);
198198
if (hasSiblings) {
199199
const hasCellPeer = hasPeerLikeSibling(cursor);
200200
if (!hasCellPeer && !hasExplicitMarkHints(cursor)) {

src/features/cricket-surface/label-utils.js

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,17 +23,22 @@ export function normalizeCricketLabelNode(cricketRules, node) {
2323
return normalizeCricketLabelValue(cricketRules, textContent);
2424
}
2525

26+
function resolveClassListTokens(node) {
27+
if (typeof node.classList?.toArray === "function") {
28+
return node.classList.toArray();
29+
}
30+
if (Array.isArray(node.classList)) {
31+
return node.classList;
32+
}
33+
return null;
34+
}
35+
2636
export function getClassTokens(node) {
2737
if (!node || typeof node !== "object") {
2838
return [];
2939
}
3040

31-
const listTokens =
32-
typeof node.classList?.toArray === "function"
33-
? node.classList.toArray()
34-
: Array.isArray(node.classList)
35-
? node.classList
36-
: null;
41+
const listTokens = resolveClassListTokens(node);
3742
if (Array.isArray(listTokens) && listTokens.length > 0) {
3843
return listTokens.filter(Boolean).map((entry) => String(entry).trim()).filter(Boolean);
3944
}

src/features/dart-marker-emphasis/logic.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ function restoreSnapshot(marker, snapshot) {
4343
}
4444

4545
function isHiddenByDartOverlay(marker) {
46-
if (!marker || !marker.dataset) {
46+
if (!marker?.dataset) {
4747
return false;
4848
}
4949
return Object.hasOwn(marker.dataset, HIDDEN_MARKER_DATASET_KEY);

src/features/shared/turn-surface-adapter.js

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,16 @@ export function collectTurnThrowRows(documentRef) {
7979
});
8080
}
8181

82+
function resolveRowSource(turnContainer, throwRows) {
83+
if (turnContainer) {
84+
return "turn-container";
85+
}
86+
if (throwRows.length > 0) {
87+
return "document-fallback";
88+
}
89+
return "none";
90+
}
91+
8292
export function getTurnSurfaceSnapshot(documentRef, options = {}) {
8393
const turnContainer = findTurnContainer(documentRef);
8494
const throwRows = collectTurnThrowRows(documentRef);
@@ -91,7 +101,7 @@ export function getTurnSurfaceSnapshot(documentRef, options = {}) {
91101
turnContainer,
92102
throwRows,
93103
turnPointsToken,
94-
rowSource: turnContainer ? "turn-container" : throwRows.length > 0 ? "document-fallback" : "none",
104+
rowSource: resolveRowSource(turnContainer, throwRows),
95105
};
96106
}
97107

0 commit comments

Comments
 (0)