Skip to content

Commit e2e5982

Browse files
christian-huehn-mwclaude
authored andcommitted
fix(visualization): address sonar code-smell findings
- Use `globalThis` instead of `window` (S7764) in dispatchAfterPaint. - Mark `scrollFunction` field as `readonly` (S2933) in explorerTreeLevel. - Drop redundant `as` assertion in sidebarExplorer.selectors and annotate the `.map` callback's return type so the literals stay narrow (S4325). - Remove `role="img"` on the explorer tree item icon span (S6819) — the existing `aria-hidden="true"` already hides it from assistive tech. - Replace the explorer sort control's div-with-button-role with a real `<button>` element and drop the redundant `tabindex="0"` from the dropdown `<ul>` (S6819, S6845). - Replace the rules popover's `<div role="list">` with a real `<ul>` containing `<li>` rule rows (S6819). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 1c4695a commit e2e5982

6 files changed

Lines changed: 18 additions & 16 deletions

File tree

visualization/app/codeCharta/features/sidebarExplorer/components/explorerSortControl/explorerSortControl.component.html

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
<div class="dropdown dropdown-start w-full px-2 mt-2">
2-
<div
3-
tabindex="0"
4-
role="button"
2+
<button
3+
type="button"
54
class="btn btn-ghost btn-sm w-full justify-between normal-case font-normal"
65
[title]="'Sort: ' + currentOption()"
76
>
@@ -11,8 +10,8 @@
1110
<i class="fa text-[10px]" [class.fa-arrow-up]="isAscending()" [class.fa-arrow-down]="!isAscending()"></i>
1211
</span>
1312
<i class="fa fa-chevron-down text-[10px] opacity-60"></i>
14-
</div>
15-
<ul tabindex="0" class="dropdown-content menu bg-base-100 rounded-box z-20 w-full mx-2 p-2 shadow">
13+
</button>
14+
<ul class="dropdown-content menu bg-base-100 rounded-box z-20 w-full mx-2 p-2 shadow">
1615
@for (option of sortOptions; track option) {
1716
<li>
1817
<button

visualization/app/codeCharta/features/sidebarExplorer/components/explorerTreeItemIcon/explorerTreeItemIcon.component.html

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
<span
2-
role="img"
32
[class]="iconClass()"
43
[style.color]="iconColor()"
54
aria-hidden="true"

visualization/app/codeCharta/features/sidebarExplorer/components/explorerTreeLevel/explorerTreeLevel.component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ export class ExplorerTreeLevelComponent implements OnInit {
129129
this.isScrollListenerRegistered = false
130130
}
131131

132-
private scrollFunction = () => {
132+
private readonly scrollFunction = () => {
133133
this.appStatusStore.setRightClickedNodeData(null)
134134
this.removeScrollListener()
135135
}

visualization/app/codeCharta/features/sidebarExplorer/components/rulesPopover/rulesPopover.component.html

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,12 @@
2020
@if (rules().length === 0) {
2121
<div class="text-xs opacity-60 px-2 py-3">No rules</div>
2222
} @else {
23-
<div role="list" class="flex flex-col max-h-[60vh] overflow-y-auto">
23+
<ul class="flex flex-col max-h-[60vh] overflow-y-auto m-0 p-0 list-none">
2424
@for (rule of rules(); track rule.item.path) {
25-
<cc-rule-row [item]="rule.item" [affectedCount]="rule.affectedCount" [kind]="rule.kind"></cc-rule-row>
25+
<li>
26+
<cc-rule-row [item]="rule.item" [affectedCount]="rule.affectedCount" [kind]="rule.kind"></cc-rule-row>
27+
</li>
2628
}
27-
</div>
29+
</ul>
2830
}
2931
</div>

visualization/app/codeCharta/features/sidebarExplorer/selectors/sidebarExplorer.selectors.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -91,11 +91,13 @@ const buildRulesWithCount = (blacklist: BlacklistItem[], allLeaves: CodeMapNode[
9191
}
9292

9393
return rulesWithStats
94-
.map(({ item, count }) => ({
95-
item,
96-
affectedCount: count,
97-
kind: (isPatternRule(item.path) ? "RULE" : "MANUAL") as "RULE" | "MANUAL"
98-
}))
94+
.map(
95+
({ item, count }): RuleWithCount => ({
96+
item,
97+
affectedCount: count,
98+
kind: isPatternRule(item.path) ? "RULE" : "MANUAL"
99+
})
100+
)
99101
.sort((a, b) => a.item.path.localeCompare(b.item.path))
100102
}
101103

visualization/app/codeCharta/util/dispatchAfterPaint.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ export function dispatchAfterPaint(store: Store<CcState>, action: Action | Actio
2121
// In jest tests rAF is async via setTimeout — skip the deferral so existing
2222
// dispatch-assertion tests stay synchronous. The spinner UX only matters at
2323
// runtime.
24-
if (typeof window !== "undefined" && (window as unknown as { __TEST_ENVIRONMENT__?: boolean }).__TEST_ENVIRONMENT__) {
24+
if ((globalThis as unknown as { __TEST_ENVIRONMENT__?: boolean }).__TEST_ENVIRONMENT__) {
2525
for (const a of actions) {
2626
store.dispatch(a)
2727
}

0 commit comments

Comments
 (0)