Skip to content

[ESLint] Flatten sonarjs/no-nested-functions + promote to error - #32364

Merged
ShaileshParmar11 merged 9 commits into
mainfrom
ShaileshParmar11/eslint-no-nested-functions
Sep 5, 2026
Merged

ShaileshParmar11 merged 9 commits into
mainfrom
ShaileshParmar11/eslint-no-nested-functions

Conversation

@ShaileshParmar11

@ShaileshParmar11 ShaileshParmar11 commented Sep 1, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Part of rule 9 of the ESLint-cleanup epic (#30977, sub-issue #30984 — the sonarjs complexity family). Takes the sonarjs/no-nested-functions sub-rule (SonarJS S2004, "don't nest functions more than 4 levels deep") to 0 violations and promotes it warn → error. The remaining complexity rules in #30984 (cyclomatic-complexity, expression-complexity, cognitive-complexity) stay warn for their own follow-up PRs.

Stacked on #32348 (no-nested-conditional). Base is that PR's branch so this diff shows only the 40 no-nested-functions files; GitHub will retarget this to main automatically once #32348 merges.

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:

  • module-scope pure helpers where no closure is needed (e.g. the *VersionUtils diff formatters, TableV2 filter predicates),
  • component/hook-scope useCallback handlers (Profile *Rows, NodeFormSidebar, ColumnGrid),
  • extracted render helpers / sub-components (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 (AuthProvider 401 token-refresh driver, OidcAuthenticator logout): drainPendingRequests and startTokenRefresh are hoisted out of the response interceptor, and startTokenRefresh receives the interceptor re-init as a parameter to avoid a no-use-before-define cycle between the two mutually-recursive component functions. The .then/.catch chains are not converted to async/await — microtask ordering is preserved byte-for-byte.

Verification

  • ESLint: eslint --quiet src with the rule at error → 0 errors tree-wide, 0 no-nested-functions.
  • Types: full tsc diff 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).
  • Tests: the 22 co-located suites for the changed files pass (350 tests); auth specifically → 8 suites / 73 tests + TokenServiceUtil 71 tests pass.
  • yarn ui-checkstyle:changed → 0 errors.

Ratchet

- 'sonarjs/no-nested-functions': 'warn', // 18
+ 'sonarjs/no-nested-functions': 'error',

Tracker: this PR does not close #30984 — it clears only the no-nested-functions sub-rule of the complexity family, leaving #30984 open for the remaining rules. The PR-metadata gate is intentionally bypassed via the skip-pr-checks label for this reason.

@github-actions

github-actions Bot commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

❌ PR checklist incomplete

This PR cannot be merged until the following are addressed on its linked issue:

  • No GitHub issue is linked. Link an issue in the Development section of the PR (or add Fixes #12345 to the description). For a same-org cross-repo issue, add Fixes open-metadata/<repo>#123 to the description.

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 skip-pr-checks label.

@ShaileshParmar11 ShaileshParmar11 added the skip-pr-checks Bypass PR metadata validation check label Sep 1, 2026
@github-actions github-actions Bot added safe to test Add this label to run secure Github workflows on PRs UI UI specific issues labels Sep 1, 2026
@github-actions

github-actions Bot commented Sep 1, 2026 •

Copy link
Copy Markdown
Contributor

Jest test Coverage

UI tests summary

Lines Statements Branches Functions
Coverage: 69%
69.86% (92228/132018) 54.55% (57238/104924) 55.81% (17396/31168)

@github-actions

github-actions Bot commented Sep 1, 2026 •

Copy link
Copy Markdown
Contributor

✅ Playwright Results — workflow succeeded

Validated commit 4cf3f021d06c1e2246e21756db79418ec2859ca8 in Playwright run 33945618665, attempt 1.

✅ 1616 passed · ❌ 0 failed · 🟡 3 flaky · ⏭️ 0 skipped · 🧰 0 lifecycle flaky

Performance

Blocking 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:

  • Common shard skew was 29.49% (convergence target: at most 15%).
  • Browser traffic was 225.37 requests per attempt (convergence target: fewer than 200).
  • Application boot ratio was 2.3 per UI scenario (4312 boots / 1873 scenarios; convergence target: at most 1).
Shard Passed Failed Flaky Skipped Lifecycle failed Lifecycle flaky
✅ Shard chromium-01 134 0 0 0 0 0
🟡 Shard chromium-02 148 0 1 0 0 0
🟡 Shard chromium-03 169 0 1 0 0 0
✅ Shard chromium-04 138 0 0 0 0 0
✅ Shard chromium-05 135 0 0 0 0 0
✅ Shard chromium-06 154 0 0 0 0 0
✅ Shard chromium-07 155 0 0 0 0 0
✅ Shard chromium-08 162 0 0 0 0 0
🟡 Shard chromium-09 145 0 1 0 0 0
✅ Shard data-asset-rules-01 65 0 0 0 0 0
✅ Shard domain-isolation-01 16 0 0 0 0 0
✅ Shard global-state-01 34 0 0 0 0 0
✅ Shard import-export-01 52 0 0 0 0 0
✅ Shard ingestion-01 30 0 0 0 0 0
✅ Shard ingestion-02 34 0 0 0 0 0
✅ Shard reindex-01 5 0 0 0 0 0
✅ Shard search-01 11 0 0 0 0 0
✅ Shard search-rbac-01 29 0 0 0 0 0
🟡 3 flaky test(s) (passed on retry)
  • Features/DataQuality/TestLibrary.spec.ts › should handle supported services field correctly (shard chromium-02, 1 retry)
  • Features/ContextCenterMemories.spec.ts › adding a linked asset in edit mode shows entity badge on the row (shard chromium-03, 1 retry)
  • Pages/Entity.spec.ts › Update description (shard chromium-09, 1 retry)

📦 Download artifacts

How to debug locally
# Download playwright-test-results-<shard> artifact and unzip
npx playwright show-trace path/to/trace.zip    # view trace

ShaileshParmar11 and others added 3 commits September 2, 2026 10:29
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]>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 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

@github-actions

github-actions Bot commented Sep 2, 2026 •

Copy link
Copy Markdown
Contributor

⚠️ UI Checkstyle passed — lint findings in changed files

🔍 ESLint findings in this PR's files — 0 error(s), 168 warning(s)

Errors block the build. Warnings do not yet — they are rules whose backlog is still
being worked down, listed so this PR does not add to it. See docs/ui-code-quality-gate.md.

0 error(s), 168 warning(s) across 25 changed file(s).

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]>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 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

  • Key is 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:18
  • Key from react-aria-components is 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 use import type { Key } ...). Switch to a type-only import.

openmetadata-ui/src/main/resources/ui/src/components/DataContract/ContractSecurityFormTab/ContractSecurityFormTab.tsx:92

  • editingKey is set with policyField.key (see the edit button), but the card’s active/expanded checks compare against policyField.name. In antd Form.List, name is the current index and can diverge from key after deletions/reorders, so the card can fail to enter the editing state. Use policyField.key consistently for editingKey comparisons.
        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 editingKey mismatch here: defaultExpanded and the conditional render use policyField.name (index), but editingKey stores policyField.key. After list mutations this can desync and render the wrong branch. Compare editingKey to policyField.key here 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

  • waitForWorkerActivation can hang if the worker is already in activated (or transitions to activated between the callsite and listener registration), because it only resolves on a future statechange event 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:32
  • renderRowFilterValues returns an array of <span> elements without a key, which triggers React list-key warnings and can cause unstable reconciliation. Add a stable key for 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

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@ShaileshParmar11

Copy link
Copy Markdown
Contributor Author

Re: the two TableV2 findings — both are pre-existing main code, not changes from this PR

@gitar-bot reviewed the merge result rather than this branch, so both findings point at code that arrived from main, not from this refactor.

Neither symbol the findings rest on exists at the head that was reviewed (f607feeb) or at the merge-base (649ce8b):

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):

  • actualIndex vs controlled page — TableV2.tsx:851-853 on main:
    const actualIndex = clientPagination
      ? (internalCurrentPage - 1) * clientPagination.pageSize + idx
      : idx;
  • detail-row id collision — TableV2.tsx:278-279 on main:
    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.

@gitar-bot

gitar-bot Bot commented Sep 3, 2026

Copy link
Copy Markdown

Confirmed — checked TableV2.tsx at the merge-base (83c7612), the reviewed head, and current main. Both snippets match byte-for-byte with what's in the table above, and this PR's own diff only touches that region to hoist the render callback into renderRowCells; it doesn't introduce actualIndex, internalCurrentPage, controlledCurrent, or the expanded-row id/key collision.

Agreed on both counts: these are pre-existing bugs on main, not introduced here, and they're real — currentPage resolves to controlledCurrent ?? internalCurrentPage while the actualIndex calc still keys off internalCurrentPage alone, so any caller driving pagination.current externally without clientPagination (or without a matching total) gets index drift on page ≥ 2 that flows into getRowKey, onRow, and cell render. The expanded-row id/key using only rowKey will also collide if the same key legitimately repeats across pages/sections.

Given they predate this PR and this diff doesn't touch that logic, no action here — worth splitting into a dedicated main fix as you suggested.

karanh37
karanh37 previously approved these changes Sep 3, 2026
@github-actions

github-actions Bot commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

🚦 Removed from the merge queue — manual (2026-09-04T05:09:43Z)

The entry left the queue before it was built, so no checks ran against it.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@github-actions

github-actions Bot commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

🚦 Removed from the merge queue — merge_conflict (2026-09-05T03:16:55Z)

The entry left the queue before it was built, so no checks ran against it.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@gitar-bot

gitar-bot Bot commented Sep 5, 2026

Copy link
Copy Markdown
Code Review ✅ Approved 2 resolved / 2 findings

Flattens the sonarjs/no-nested-functions rule across 40 files by hoisting 75 deeply-nested callbacks to module or component scope as named helpers and useCallback handlers, preserving closures and async semantics. Promotes the rule from warn to error with zero violations tree-wide and no type regressions. All 22 co-located test suites pass.

✅ 2 resolved
✅ Bug: flatRows actualIndex ignores controlled current page

📄 openmetadata-ui/src/main/resources/ui/src/components/common/Table/TableV2.tsx:716-717 📄 openmetadata-ui/src/main/resources/ui/src/components/common/Table/TableV2.tsx:780-783 📄 openmetadata-ui/src/main/resources/ui/src/components/common/Table/TableV2.tsx:887-901
pagedDataSource now slices with currentPage (which prefers clientPagination.controlledCurrent from pagination.current), but flatRows still computes actualIndex from internalCurrentPage. When a call site drives pagination via a controlled pagination.current without a larger total (so serverTotal is undefined and slicing still happens), the two diverge: the rows shown are for the controlled page while actualIndex is computed for the internal page. actualIndex feeds getRowKey(record, actualIndex) (index fallback), onRow(record, actualIndex), and column render(value, record, index), so those receive wrong indices/keys on any page other than the first. Compute actualIndex from the same currentPage used by pagedDataSource.

✅ Edge Case: Expanded detail row id can collide on duplicate rowKeys

📄 openmetadata-ui/src/main/resources/ui/src/components/common/Table/TableV2.tsx:264-278 📄 openmetadata-ui/src/main/resources/ui/src/components/common/Table/TableV2.tsx:940-948
Row ids are disambiguated via getRowIds/disambiguate, but buildExpandedDetailRow builds its React Aria id/key as ${flatRow.rowKey}-expanded from the raw (possibly duplicated) rowKey, not the disambiguated id. When two rows share a rowKey and both are expanded with expandedRowRender, both detail rows get the same id and React Aria silently drops one — the exact silent-row-drop the disambiguation elsewhere exists to prevent. Derive the detail row id from the disambiguated row id (e.g. rowIds[flatIndex]) instead of rowKey.

Options

Display: compact → Showing less information.

Comment with these commands to change the behavior for this request:

Compact
gitar display:verbose         

Was this helpful? React with 👍 / 👎 | Powered by Gitar — free for open source

@sonarqubecloud

sonarqubecloud Bot commented Sep 5, 2026

Copy link
Copy Markdown

This branch was previously deployed

1 inactive deployment
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

safe to test Add this label to run secure Github workflows on PRs skip-pr-checks Bypass PR metadata validation check UI UI specific issues

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[ESLint 9/10] sonarjs complexity

3 participants