Repository navigation
[ESLint] Flatten sonarjs/no-nested-functions + promote to error - #32364
Conversation
❌ 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 ✅ 1616 passed · ❌ 0 failed · 🟡 3 flaky · ⏭️ 0 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) 48m 23s ⏱️ Max setup 4m 29s · max shard execution 18m 22s · max shard-job elapsed before upload 21m 42s · reporting 8s 🌐 225.37 requests/attempt · 2.30 app boots/UI scenario · 29.49% common-shard skew Optimization targets still in progress:
🟡 3 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 |
Resolve all 75 sonarjs/no-nested-functions (S2004) violations across 40 files by hoisting the innermost deeply-nested callback to a shallower named scope — module-scope pure helpers where no closure is needed, component/hook-scope useCallback handlers, or extracted render helpers — preserving closures (via scope or explicit params), async ordering, and error semantics exactly. No eslint-disable, no behaviour change. Auth paths (AuthProvider token-refresh 401 driver, OidcAuthenticator logout) hoist drainPendingRequests/startTokenRefresh out of the response interceptor; startTokenRefresh receives the re-init callback as a parameter to avoid a use-before-define cycle. 73 auth tests pass. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
All sonarjs/no-nested-functions violations are refactored to zero, so ratchet the rule warn -> error: eslint --quiet over src reports 0 errors tree-wide. Also carries the organize-imports fix on NodeUtils.test.ts (from the stacked no-nested-conditional base) so the lint_src git-status gate stays clean. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
…ityFormTab These two files overlap #32348 and hit large 3-way conflicts when this branch was rebased off #32348 onto main (41 commits of drift). Resolved by taking main's version and re-applying the no-nested-functions extraction against current code (matchesFilterEntry / renderRowCells / ContractPolicyCard), preserving behavior. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
There was a problem hiding this comment.
🟡 Changes recommended
The refactor introduces/retains concrete correctness risks (notably inconsistent antd Form.List key/index usage in ContractSecurityFormTab and a potentially hanging service-worker activation wait helper) that should be fixed before promoting the rule to error.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Review details
Suppressed comments (3)
openmetadata-ui/src/main/resources/ui/src/components/DataContract/ContractSecurityFormTab/ContractSecurityFormTab.tsx:92
- ContractPolicyCard mixes Form.List field identifiers: editingKey is sometimes treated as an index (policyField.name) and sometimes as a unique key (policyField.key). This also indexes policiesFormData by policyField.key. In antd Form.List, key and name can diverge after insert/remove, which can result in the wrong card expanding and the wrong policy title rendering.
{editingKey === policyField.key ? null : (
<div className="security-form-item-title-container">
<div className="d-flex items-center gap-6">
<div className="d-flex flex-column">
<Typography.Text className="consumer-form-item-title">
openmetadata-ui/src/main/resources/ui/src/components/DataContract/ContractSecurityFormTab/ContractSecurityFormTab.tsx:115
- Policy deletion is currently wired through policyField.key, but handleDeletePolicy treats its argument as an array index (filters by idx !== key). If Form.List keys diverge from indexes, deleting can remove the wrong policy. Pass policyField.name (the index) instead.
onClick={() => {
onDeletePolicy(policyField.key);
}}
openmetadata-ui/src/main/resources/ui/src/components/DataContract/ContractSecurity/ContractSecurityCard.component.tsx:31
- renderRowFilterValues returns an array of elements without a key prop. This triggers React's "each child in a list should have a unique key" warning and can cause inefficient reconciliation.
const renderRowFilterValues = (filter: RowFilter) =>
filter.values?.map((item, index) => (
<span className="row-filter-value">{`${item}${
filter.values?.length === index + 1 ? '' : ','
}`}</span>
- Files reviewed: 41/41 changed files
- Comments generated: 3
- Review effort level: Lite
|
| Count | Rule |
|---|---|
| 86 | react-hooks/exhaustive-deps |
| 37 | sonarjs/cyclomatic-complexity |
| 13 | sonarjs/cognitive-complexity |
| 13 | sonarjs/no-nested-conditional |
| 7 | openmetadata-imports/no-api-calls-in-iteration |
| 5 | openmetadata-imports/no-lower-layer-page-imports |
| 4 | openmetadata-imports/no-internal-barrel-imports |
| 2 | openmetadata-imports/no-circular-imports |
| 1 | openmetadata-imports/review-sequential-api-calls |
All findings
| Location | Rule | Message | |
|---|---|---|---|
| 🟡 | src/components/Auth/AppAuthenticators/OidcAuthenticator.tsx:30:1 |
openmetadata-imports/no-lower-layer-page-imports |
Pages are route-level composition modules. Move the shared implementation/type to a lower layer instead of importing a page from here. |
| 🟡 | src/components/Auth/AuthProviders/AuthProvider.tsx:80:1 |
openmetadata-imports/no-internal-barrel-imports |
Import the internal module directly instead of its index barrel so unrelated siblings do not enter the bundle graph. |
| 🟡 | src/components/Auth/AuthProviders/AuthProvider.tsx:309:9 |
react-hooks/exhaustive-deps |
The 'onLoginHandler' function makes the dependencies of useMemo Hook (at line 992) change on every render. Move it inside the useMemo callback. Alternatively, w |
| 🟡 | src/components/Auth/AuthProviders/AuthProvider.tsx:394:6 |
react-hooks/exhaustive-deps |
React Hook useCallback has missing dependencies: 'navigate', 'setApplicationLoading', 'setCurrentUser', and 'setIsAuthenticated'. Either include them or remove |
| 🟡 | src/components/Auth/AuthProviders/AuthProvider.tsx:419:9 |
react-hooks/exhaustive-deps |
The 'resetUserDetails' function makes the dependencies of useMemo Hook (at line 992) change on every render. To fix this, wrap the definition of 'resetUserDetai |
| 🟡 | src/components/Auth/AuthProviders/AuthProvider.tsx:520:45 |
sonarjs/cyclomatic-complexity |
{"message":"Function has a complexity of 12 which is greater than 10 authorized.","cost":2,"secondaryLocations":[{"line":520,"column":44,"endLine":520,"endColum |
| 🟡 | src/components/Auth/AuthProviders/AuthProvider.tsx:582:6 |
react-hooks/exhaustive-deps |
React Hook useEffect has missing dependencies: 'getLoggedInUserDetails' and 'startTokenExpiryTimer'. Either include them or remove the dependency array. |
| 🟡 | src/components/Auth/AuthProviders/AuthProvider.tsx:592:9 |
react-hooks/exhaustive-deps |
The 'handleFailedLogin' function makes the dependencies of useMemo Hook (at line 992) change on every render. Move it inside the useMemo callback. Alternatively |
| 🟡 | src/components/Auth/AuthProviders/AuthProvider.tsx:650:5 |
react-hooks/exhaustive-deps |
React Hook useCallback has missing dependencies: 'authConfig?.provider', 'handledVerifiedUser', 'navigate', 'resetUserDetails', and 'startTokenExpiryTimer'. Eit |
| 🟡 | src/components/Auth/AuthProviders/AuthProvider.tsx:706:11 |
openmetadata-imports/no-api-calls-in-iteration |
Avoid issuing one API request per item. Fetch at the data owner, use a bulk endpoint, or use useQueries with an intentional concurrency policy. |
| 🟡 | src/components/Auth/AuthProviders/AuthProvider.tsx:754:9 |
react-hooks/exhaustive-deps |
The 'initializeAxiosInterceptors' function makes the dependencies of useMemo Hook (at line 992) change on every render. To fix this, wrap the definition of 'ini |
| 🟡 | src/components/Auth/AuthProviders/AuthProvider.tsx:888:30 |
sonarjs/cyclomatic-complexity |
{"message":"Function has a complexity of 17 which is greater than 10 authorized.","cost":7,"secondaryLocations":[{"line":888,"column":29,"endLine":888,"endColum |
| 🟡 | src/components/Auth/AuthProviders/AuthProvider.tsx:981:6 |
react-hooks/exhaustive-deps |
React Hook useEffect has missing dependencies: 'cleanup', 'fetchAuthConfig', 'initializeAxiosInterceptors', and 'startTokenExpiryTimer'. Either include them or |
| 🟡 | src/components/BlockEditor/hooks/useCustomEditor.ts:154:6 |
react-hooks/exhaustive-deps |
React Hook useEffect was passed a dependency list that is not an array literal. This means we can't statically verify whether you've passed the correct dependen |
| 🟡 | src/components/BlockEditor/hooks/useCustomEditor.ts:154:6 |
react-hooks/exhaustive-deps |
React Hook useEffect has missing dependencies: 'forceUpdate' and 'options'. Either include them or remove the dependency array. |
| 🟡 | src/components/ContextCenter/CreateMemoryModal/CreateMemoryModal.component.tsx:255:4 |
sonarjs/cyclomatic-complexity |
{"message":"Function has a complexity of 36 which is greater than 10 authorized.","cost":26,"secondaryLocations":[{"line":255,"column":3,"endLine":255,"endColum |
| 🟡 | src/components/ContextCenter/CreateMemoryModal/CreateMemoryModal.component.tsx:331:16 |
sonarjs/cyclomatic-complexity |
{"message":"Function has a complexity of 11 which is greater than 10 authorized.","cost":1,"secondaryLocations":[{"line":331,"column":15,"endLine":331,"endColum |
| 🟡 | src/components/ContextCenter/CreateMemoryModal/CreateMemoryModal.component.tsx:428:57 |
sonarjs/cognitive-complexity |
Refactor this function to reduce its Cognitive Complexity from 19 to the 15 allowed. |
| 🟡 | src/components/ContextCenter/CreateMemoryModal/CreateMemoryModal.component.tsx:428:57 |
sonarjs/cyclomatic-complexity |
{"message":"Function has a complexity of 18 which is greater than 10 authorized.","cost":8,"secondaryLocations":[{"line":428,"column":56,"endLine":428,"endColum |
| 🟡 | src/components/DataContract/ContractSecurity/ContractSecurityCard.component.tsx:120:6 |
react-hooks/exhaustive-deps |
React Hook useMemo has missing dependencies: 't' and 'tableColumnNameMap'. Either include them or remove the dependency array. |
| 🟡 | src/components/DataContract/ContractSecurityFormTab/ContractSecurityFormTab.tsx:302:11 |
sonarjs/no-nested-conditional |
Extract this nested ternary operation into an independent statement. |
| 🟡 | src/components/DataContract/ContractSecurityFormTab/ContractSecurityFormTab.tsx:425:5 |
react-hooks/exhaustive-deps |
React Hook useCallback has missing dependencies: 'dataClassificationFormItem', 'form', and 'onChange'. Either include them or remove the dependency array. If 'o |
| 🟡 | src/components/DataContract/ContractSecurityFormTab/ContractSecurityFormTab.tsx:460:6 |
react-hooks/exhaustive-deps |
React Hook useEffect has a missing dependency: 'form'. Either include it or remove the dependency array. |
| 🟡 | src/components/DataQuality/AddDataQualityTest/components/ParameterForm.tsx:337:5 |
sonarjs/cyclomatic-complexity |
{"message":"Function has a complexity of 19 which is greater than 10 authorized.","cost":9,"secondaryLocations":[{"line":337,"column":4,"endLine":337,"endColumn |
| 🟡 | src/components/Entity/EntityExportModalProvider/EntityExportModalProvider.component.tsx:38:1 |
openmetadata-imports/no-circular-imports |
This runtime import participates in a circular dependency. Extract the shared type/constant/utility or invert the dependency. |
| 🟡 | src/components/Entity/EntityExportModalProvider/EntityExportModalProvider.component.tsx:288:53 |
sonarjs/cyclomatic-complexity |
{"message":"Function has a complexity of 11 which is greater than 10 authorized.","cost":1,"secondaryLocations":[{"line":288,"column":52,"endLine":288,"endColum |
| 🟡 | src/components/Entity/EntityExportModalProvider/EntityExportModalProvider.component.tsx:472:22 |
sonarjs/cognitive-complexity |
Refactor this function to reduce its Cognitive Complexity from 17 to the 15 allowed. |
| 🟡 | src/components/Entity/EntityExportModalProvider/EntityExportModalProvider.component.tsx:472:22 |
sonarjs/cyclomatic-complexity |
{"message":"Function has a complexity of 12 which is greater than 10 authorized.","cost":2,"secondaryLocations":[{"line":472,"column":21,"endLine":472,"endColum |
| 🟡 | src/components/Entity/EntityExportModalProvider/EntityExportModalProvider.component.tsx:540:6 |
sonarjs/cognitive-complexity |
Refactor this function to reduce its Cognitive Complexity from 21 to the 15 allowed. |
| 🟡 | src/components/Entity/EntityExportModalProvider/EntityExportModalProvider.component.tsx:540:6 |
sonarjs/cyclomatic-complexity |
{"message":"Function has a complexity of 17 which is greater than 10 authorized.","cost":7,"secondaryLocations":[{"line":540,"column":5,"endLine":540,"endColumn |
| 🟡 | src/components/Entity/EntityExportModalProvider/EntityExportModalProvider.component.tsx:714:6 |
react-hooks/exhaustive-deps |
React Hook useEffect has a missing dependency: 'handleExport'. Either include it or remove the dependency array. |
| 🟡 | src/components/Entity/EntityExportModalProvider/EntityExportModalProvider.component.tsx:721:27 |
react-hooks/exhaustive-deps |
The ref value 'exportGenerationRef.current' will likely have changed by the time this effect cleanup function runs. If this ref points to a node rendered by Rea |
| 🟡 | src/components/Entity/EntityExportModalProvider/EntityExportModalProvider.component.tsx:726:36 |
react-hooks/exhaustive-deps |
The ref value 'pendingCSVExportResponsesRef.current' will likely have changed by the time this effect cleanup function runs. If this ref points to a node render |
| 🟡 | src/components/KnowledgeCenter/KnowledgePageListComponent/KnowledgePageListComponent.tsx:100:5 |
sonarjs/cyclomatic-complexity |
{"message":"Function has a complexity of 14 which is greater than 10 authorized.","cost":4,"secondaryLocations":[{"line":100,"column":4,"endLine":100,"endColumn |
| 🟡 | src/components/KnowledgeCenter/KnowledgePageListComponent/KnowledgePageListComponent.tsx:341:8 |
react-hooks/exhaustive-deps |
React Hook useEffect has a missing dependency: 'fetchKnowledgePages'. Either include it or remove the dependency array. |
| 🟡 | src/components/KnowledgeCenter/KnowledgePageListComponent/KnowledgePageListComponent.tsx:363:8 |
react-hooks/exhaustive-deps |
React Hook useEffect has missing dependencies: 'fetchKnowledgePages' and 'pageOffset'. Either include them or remove the dependency array. |
| 🟡 | src/components/KnowledgeCenter/KnowledgePageListComponent/KnowledgePageListComponent.tsx:423:7 |
react-hooks/exhaustive-deps |
React Hook useMemo has a missing dependency: 'addQuickLinkKnowledgePage'. Either include it or remove the dependency array. |
| 🟡 | src/components/KnowledgeCenter/KnowledgePageListComponent/KnowledgePageListComponent.tsx:432:8 |
react-hooks/exhaustive-deps |
React Hook useEffect has missing dependencies: 'onPageChange' and 't'. Either include them or remove the dependency array. If 'onPageChange' changes too often, |
| 🟡 | src/components/MyData/Widgets/KPIWidget/KPIWidget.component.tsx:138:9 |
react-hooks/exhaustive-deps |
The 'handleTitleClick' function makes the dependencies of useMemo Hook (at line 450) change on every render. Move it inside the useMemo callback. Alternatively, |
| 🟡 | src/components/MyData/Widgets/KPIWidget/KPIWidget.component.tsx:170:9 |
openmetadata-imports/no-api-calls-in-iteration |
Avoid issuing one API request per item. Fetch at the data owner, use a bulk endpoint, or use useQueries with an intentional concurrency policy. |
| 🟡 | src/components/MyData/Widgets/KPIWidget/KPIWidget.component.tsx:408:6 |
react-hooks/exhaustive-deps |
React Hook useMemo has a missing dependency: 'customTooltipStyles'. Either include it or remove the dependency array. |
| 🟡 | src/components/MyData/Widgets/KPIWidget/KPIWidget.component.tsx:434:6 |
react-hooks/exhaustive-deps |
React Hook useEffect has missing dependencies: 'fetchKpiLatestResults' and 'fetchKpiResults'. Either include them or remove the dependency array. |
| 🟡 | src/components/OntologyExplorer/OntologyAuthoringInspector.tsx:144:37 |
sonarjs/cyclomatic-complexity |
{"message":"Function has a complexity of 16 which is greater than 10 authorized.","cost":6,"secondaryLocations":[{"line":144,"column":36,"endLine":144,"endColum |
| 🟡 | src/components/OntologyExplorer/OntologyAuthoringInspector.tsx:250:9 |
react-hooks/exhaustive-deps |
The 'conceptMappings' logical expression could make the dependencies of useCallback Hook (at line 323) change on every render. To fix this, wrap the initializat |
| 🟡 | src/components/OntologyExplorer/OntologyStructurePanel.tsx:284:33 |
sonarjs/cyclomatic-complexity |
{"message":"Function has a complexity of 12 which is greater than 10 authorized.","cost":2,"secondaryLocations":[{"line":284,"column":32,"endLine":284,"endColum |
| 🟡 | src/components/OntologyExplorer/OntologyStructurePanel.tsx:312:6 |
react-hooks/exhaustive-deps |
React Hook useEffect has a missing dependency: 'selectedGlossary'. Either include it or remove the dependency array. |
| 🟡 | src/components/OntologyExplorer/hooks/useGraphData.ts:141:17 |
sonarjs/cognitive-complexity |
Refactor this function to reduce its Cognitive Complexity from 81 to the 15 allowed. |
| 🟡 | src/components/OntologyExplorer/hooks/useGraphData.ts:141:17 |
sonarjs/cyclomatic-complexity |
{"message":"Function has a complexity of 28 which is greater than 10 authorized.","cost":18,"secondaryLocations":[{"line":141,"column":16,"endLine":141,"endColu |
| 🟡 | src/components/OntologyExplorer/hooks/useGraphData.ts:324:32 |
sonarjs/cognitive-complexity |
Refactor this function to reduce its Cognitive Complexity from 25 to the 15 allowed. |
| 🟡 | src/components/OntologyExplorer/hooks/useGraphData.ts:324:32 |
sonarjs/cyclomatic-complexity |
{"message":"Function has a complexity of 23 which is greater than 10 authorized.","cost":13,"secondaryLocations":[{"line":324,"column":31,"endLine":324,"endColu |
… and 118 more. Run make ui-checkstyle-changed locally for the full list.
Fix locally (fast - only checks files changed in this branch):
make ui-checkstyle-changed…stFieldData
The Antd deprecation guard fails a PR that introduces an antd specifier not
already imported by the file. The no-nested-functions extraction added
`import type { FormListFieldData } from 'antd'`, which counts as new antd
debt. Derive the same type from the already-imported `Form.List` instead.
Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
There was a problem hiding this comment.
🔵 Needs a closer look
It introduces at least one concrete behavior bug (antd Form.List editing state compares editingKey against name instead of key) and a real potential hang in service worker activation waiting that should be fixed before merging.
Review details
Suppressed comments (6)
Previously missed (2) — in code that hasn't changed since the last review.
openmetadata-ui/src/main/resources/ui/src/components/discovery/personal-space/Profile/components/DomainsRow.tsx:18
Keyis used only as a type here; prefer a type-only import (import type { Key } ...) to avoid emitting a runtime import and to match the codebase’s common pattern.
openmetadata-ui/src/main/resources/ui/src/components/discovery/personal-space/Profile/components/PersonaRow.tsx:18Keyfromreact-aria-componentsis used only as a type in this file; importing it as a value adds an unnecessary runtime import and is inconsistent with the surrounding codebase (most files useimport type { Key } ...). Switch to a type-only import.
openmetadata-ui/src/main/resources/ui/src/components/DataContract/ContractSecurityFormTab/ContractSecurityFormTab.tsx:92
editingKeyis set withpolicyField.key(see the edit button), but the card’s active/expanded checks compare againstpolicyField.name. In antdForm.List,nameis the current index and can diverge fromkeyafter deletions/reorders, so the card can fail to enter the editing state. UsepolicyField.keyconsistently foreditingKeycomparisons.
className: classNames(
'contract-consumer-security-card expandable-card',
{
'expanded-active-card': editingKey === policyField.name,
}
),
openmetadata-ui/src/main/resources/ui/src/components/DataContract/ContractSecurityFormTab/ContractSecurityFormTab.tsx:133
- Same
editingKeymismatch here:defaultExpandedand the conditional render usepolicyField.name(index), buteditingKeystorespolicyField.key. After list mutations this can desync and render the wrong branch. CompareeditingKeytopolicyField.keyhere as well.
dataTestId={`contract-policy-card-${policyField.key}`}
defaultExpanded={editingKey === policyField.name}>
{editingKey === policyField.name ? (
<Row className="security-form-item-content" key={policyField.key}>
openmetadata-ui/src/main/resources/ui/src/utils/SwMessenger.ts:28
waitForWorkerActivationcan hang if the worker is already inactivated(or transitions toactivatedbetween the callsite and listener registration), because it only resolves on a futurestatechangeevent and never performs an immediate state check. Make the helper idempotent by running the check immediately after registering the listener (and remove the listener once it resolves) so you can’t miss the activation transition.
openmetadata-ui/src/main/resources/ui/src/components/DataContract/ContractSecurity/ContractSecurityCard.component.tsx:32renderRowFilterValuesreturns an array of<span>elements without akey, which triggers React list-key warnings and can cause unstable reconciliation. Add a stablekeyfor each rendered value.
filter.values?.map((item, index) => (
<span className="row-filter-value">{`${item}${
filter.values?.length === index + 1 ? '' : ','
}`}</span>
));
- Files reviewed: 41/41 changed files
- Comments generated: 0 new
- Review effort level: Lite
…nt-no-nested-functions # Conflicts: # openmetadata-ui/src/main/resources/ui/src/components/OntologyExplorer/hooks/useGraphData.ts # openmetadata-ui/src/main/resources/ui/src/components/common/Table/TableV2.tsx
Re: the two
|
| symbol | merge-base | branch head | main |
|---|---|---|---|
buildExpandedDetailRow |
0 | 0 | 2 |
getRowIds |
0 | 0 | 2 |
rowIds |
0 | 0 | 3 |
controlledCurrent |
0 | 0 | 2 |
And both flagged sites are byte-identical on clean main (83c7612):
actualIndexvs controlled page —TableV2.tsx:851-853onmain:const actualIndex = clientPagination ? (internalCurrentPage - 1) * clientPagination.pageSize + idx : idx;
- detail-row id collision —
TableV2.tsx:278-279onmain:id={`${flatRow.rowKey}-expanded`} key={`${flatRow.rowKey}-expanded`}
This PR's only change to that region was lifting the cell-rendering callback into renderRowCells for sonarjs/no-nested-functions, and re-applying that extraction on top of main's rewrite when resolving the merge.
That said, both findings look correct — they describe live bugs in main today, not false positives. The actualIndex one in particular: currentPage resolves to controlledCurrent ?? internalCurrentPage and pagedDataSource slices with currentPage, while flatRows still indexes from internalCurrentPage. Any call site driving pagination.current without a total gets mismatched indices on page ≥ 2, which then flow into getRowKey, onRow, and column render.
They should be fixed in main on their own PR rather than inside a 40-file lint cleanup that claims to be behaviour-preserving.
|
Confirmed — checked Agreed on both counts: these are pre-existing bugs on Given they predate this PR and this diff doesn't touch that logic, no action here — worth splitting into a dedicated |
🚦 Removed from the merge queue —
|
🚦 Removed from the merge queue —
|
…nt-no-nested-functions
Code Review ✅ Approved 2 resolved / 2 findingsFlattens the ✅ 2 resolved✅ Bug: flatRows actualIndex ignores controlled current page
✅ Edge Case: Expanded detail row id can collide on duplicate rowKeys
OptionsDisplay: compact → Showing less information. Comment with these commands to change the behavior for this request:
Was this helpful? React with 👍 / 👎 | Powered by Gitar — free for open source |
|



Summary
Part of rule 9 of the ESLint-cleanup epic (#30977, sub-issue #30984 — the sonarjs complexity family). Takes the
sonarjs/no-nested-functionssub-rule (SonarJS S2004, "don't nest functions more than 4 levels deep") to 0 violations and promotes itwarn→error. The remaining complexity rules in #30984 (cyclomatic-complexity,expression-complexity,cognitive-complexity) staywarnfor their own follow-up PRs.Approach — real refactors, behavior-preserving
All 75 violations across 40 files fixed by hoisting the innermost deeply-nested callback to a shallower named scope — never a suppression:
*VersionUtilsdiff formatters,TableV2filter predicates),useCallbackhandlers (Profile*Rows,NodeFormSidebar,ColumnGrid),TableV2.renderRowCells,ContractPolicyCard,ParameterArrayField).Closures are preserved via scope or explicit parameters; async ordering and error semantics are unchanged.
Auth paths handled with extra care (
AuthProvider401 token-refresh driver,OidcAuthenticatorlogout):drainPendingRequestsandstartTokenRefreshare hoisted out of the response interceptor, andstartTokenRefreshreceives the interceptor re-init as a parameter to avoid ano-use-before-definecycle between the two mutually-recursive component functions. The.then/.catchchains are not converted toasync/await— microtask ordering is preserved byte-for-byte.Verification
eslint --quiet srcwith the rule at error → 0 errors tree-wide, 0no-nested-functions.tscdiff vs the stacked base → 0 net-new errors in any of the 40 changed files (the only diff signatures are union-member-ordering noise in unrelated files; branch has fewer total).TokenServiceUtil71 tests pass.yarn ui-checkstyle:changed→ 0 errors.Ratchet