Repository navigation
[ESLint] Extract complex expressions (expression-complexity) + promote to error - #32381
Conversation
|
Too many files changed for review (115 files, 100 file limit). Bypass the limit by tagging |
❌ PR checklist incompleteThis PR cannot be merged until the following are addressed on its linked issue:
The fields live on the linked issue in the Shipping project (open the issue → right sidebar → Projects). After you set them, re-run this check (or push a commit) — issue/project changes do not re-trigger it automatically. Maintainers can bypass this check by adding the |
✅ Playwright Results — workflow succeededValidated commit ✅ 4464 passed · ❌ 0 failed · 🟡 14 flaky · ⏭️ 1 skipped · 🧰 0 lifecycle flaky PerformanceBlocking targets: ✅ met · Optimization targets: 🟡 in progress Shard-job maxima below are not the full workflow wall time; the linked run includes build, fixture, planning, and reporting. 🕒 Full workflow signal wall (to summary) 59m 1s ⏱️ Max setup 4m 37s · max shard execution 19m 26s · max shard-job elapsed before upload 23m 3s · reporting 38s 🌐 207.38 requests/attempt · 2.30 app boots/UI scenario · 27.87% common-shard skew Optimization targets still in progress:
🟡 14 flaky test(s) (passed on retry)
How to debug locally# Download playwright-test-results-<shard> artifact and unzip
npx playwright show-trace path/to/trace.zip # view trace |
0a64340 to
75843ba
Compare
…atch 1/2 Partial: 49 of 110 files with sonarjs/expression-complexity (S1067) violations refactored by extracting sub-expressions into named consts, preserving short-circuit/lazy evaluation. Committed to protect against the workspace-sync reset; remaining 61 files follow in batch 2. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
🚦 Removed from the merge queue —
|
Conflicts: - DestinationSelectItemV2.tsx: accepted main's deletion (#32078). - DestinationSelectItem.tsx: took main's react-hook-form rewrite wholesale — this branch's refactor targeted the AntD implementation main replaced — then re-applied expression extraction to its new JSX so the promoted rule holds. - AlertsUtil.tsx: accepted main's removal of getConnectionTimeoutField, getReadTimeoutField and getDestinationConfigField; no references remain. - TableV2.tsx: kept this branch's showCustomPagination/showClientPagination extraction, updated the client-pagination condition to main's serverTotal form, and added main's rest.footer block. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Code Review
|
| Compact |
|
Was this helpful? React with 👍 / 👎 | Powered by Gitar — free for open source
There was a problem hiding this comment.
🔵 Needs a closer look
A few refactors introduced/retained stale-closure risks via incomplete useMemo dependency arrays that can cause incorrect UI state until fixed.
Review details
Suppressed comments (3)
openmetadata-ui/src/main/resources/ui/src/components/common/QueryBuilderWidgetV1/QueryBuilderWidgetV1.tsx:217
showFilteredResourceCountdepends onsearchResults, but it isn't included in theuseMemodependency list. This can leave the boolean stale (e.g., whensetSearchResults(undefined)runs without changing any listed deps), causing the count preview UI to render inconsistently.
openmetadata-ui/src/main/resources/ui/src/components/Settings/Team/TeamDetails/TeamsHeaderSection/TeamsHeadingLabel.component.tsx:193teamHeadingRender'suseMemoreads values/functions (hasAccess,isCurrentTeamOwner,handleClose,onHeadingSave,t) that are not in its dependency array. If permissions/user/locale change, the memoized JSX can be stale (e.g., edit button not appearing/disappearing).
openmetadata-ui/src/main/resources/ui/src/components/Settings/Team/TeamDetails/TeamDetailsV1.tsx:967teamActionButton'suseMemoreadsisOrganization,currentTeam.isJoinable, andt, but they are not listed in the dependency array. If the selected team changes (or joinable/org flags change), the memo can render the wrong Join/Leave button state.
- Files reviewed: 115/115 changed files
- Comments generated: 0 new
- Review effort level: Lite
|
🚦 Removed from the merge queue —
|
✅ Full Playwright suite — green on
|
🚦 Removed from the merge queue —
|



Summary
Part of rule 9 of the ESLint-cleanup epic (#30977, sub-issue #30984 — the sonarjs complexity family). Takes
sonarjs/expression-complexity(SonarJS S1067, "too many conditional operators in one expression — max 3") to 0 violations and promotes itwarn→error. The remaining complexity rules in #30984 (cyclomatic-complexity,cognitive-complexity) staywarnfor follow-up PRs.Approach — real refactors, short-circuit-safe
All 141 violations across 110 files fixed by extracting sub-expressions into named
consts so no single expression has >3&&/||/?:operators. The key hazard — naively splitting a short-circuit chain can eagerly evaluate a dereference out from behind its null-guard and throw — was avoided by:a && b && c && d→const abc = a && b && c; abc && d) so evaluation order and short-circuiting are byte-for-byte identical;Boolean(...)wraps around narrowing guards;if-splits where a guard feeds later access).Two heavy JSX subtrees (
OntologyExplorer~9 operators,AlertAiDestinationItem~12) use a<>→<Fragment>boundary — identical render output — to isolate sibling conditionals where const extraction was impractical. Called out for reviewer visibility; noeslint-disableanywhere.Verification
eslint --quiet srcwith the rule at error → 0 errors tree-wide, 0expression-complexity.tscdiff vs the stacked base → 0 net-new errors in any of the 110 files (remaining diff signatures are union-member-ordering noise in unrelated files; branch has fewer total).Ratchet