Skip to content

[ESLint] Clear sonarjs/no-nested-conditional + promote to error - #32348

Merged
ShaileshParmar11 merged 1 commit into
mainfrom
ShaileshParmar11/eslint-no-nested-conditional
Sep 6, 2026
Merged

ShaileshParmar11 merged 1 commit into
mainfrom
ShaileshParmar11/eslint-no-nested-conditional

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). This PR takes the sonarjs/no-nested-conditional sub-rule to 0 violations and promotes it warn → error so nested ternaries can't drift back in. The remaining complexity rules in #30984 (cyclomatic-complexity, no-nested-functions, cognitive-complexity) stay at warn for their own follow-up PRs — this keeps the change small and reviewable, consistent with the one-rule-per-PR ratchet. (expression-complexity was already promoted to error on main by #32381; this PR leaves that line untouched — it shows up as unchanged context in the eslint.config.mjs diff.)

Approach — real refactors, behavior-preserving

Every nested ternary was refactored, not suppressed: the inner ternary is lifted into an intermediate const/let (or an if/else chain for value selection) so the render/return logic reads top-to-bottom. No eslint-disable, no logic change.

  • ~194 violations across 122 files → 0.
  • Extraction can drop TypeScript control-flow narrowing; five files needed the type restored without reintroducing a nested ternary (typed let, lodash/compact, an explicit non-null guard in the render path, a typed if/else, an unknown bridge). See commit preserve type narrowing after no-nested-conditional extraction.

Verification

  • ESLint: eslint --quiet 'src/**/*.{ts,tsx}' with the rule at error → 0 errors tree-wide, 0 no-nested-conditional occurrences.
  • Types — no regressions: full tsc --noEmit diff vs origin/main, line/path-normalized → 0 net-new error signatures (branch has 587 total vs main 591; net direction is fewer errors, none introduced).
  • Existing behavior: the 86 co-located test suites covering the changed files pass (1111 tests green; the lone TaskTabNew failure was CPU-contention flake under parallel workers — passes 30/30 in isolation).
  • New coverage: added focused co-located unit tests for the 10 pure-logic files whose refactor touched exported branch logic and that had no co-located test (9 utils + the useRouteActivation hook) — 37 cases, each exercising every arm of the refactored conditional.
  • yarn ui-checkstyle:changed → 0 errors.

Ratchet

- 'sonarjs/no-nested-conditional': 'warn', // 16
+ 'sonarjs/no-nested-conditional': 'error',

Per the epic's merge-time lesson, a full-lint over the whole tree (not just changed files) was run right before promotion to confirm zero violations anywhere.


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

Copilot AI lite review requested due to automatic review settings September 1, 2026 10:07
@greptile-apps

greptile-apps Bot commented Sep 1, 2026 •

Copy link
Copy Markdown
Contributor

Too many files changed for review (136 files, 100 file limit).

Bypass the limit by tagging @greptile-apps to review.

@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.

@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

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.

Pull request overview

This PR completes the OpenMetadata UI cleanup for sonarjs/no-nested-conditional by refactoring nested ternaries across the frontend codebase and then promoting the rule from warn to error in eslint.config.mjs to prevent regressions.

Changes:

  • Refactored nested ternaries into intermediate variables and if/else branches across UI utilities, components, and API helpers.
  • Added focused co-located unit tests for refactored pure-logic utilities/hooks.
  • Promoted sonarjs/no-nested-conditional from warn → error in the UI ESLint config.

Reviewed changes

Copilot reviewed 137 out of 137 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
openmetadata-ui/src/main/resources/ui/src/utils/TaskPayloadUtils.ts Remove nested ternary (suggestedValue)
openmetadata-ui/src/main/resources/ui/src/utils/TaskPayloadUtils.test.ts New tests for suggestedValue branches
openmetadata-ui/src/main/resources/ui/src/utils/RecentActivityUtils.ts Refactor comparator conditionals
openmetadata-ui/src/main/resources/ui/src/utils/RecentActivityUtils.test.ts New tests for comparator branches
openmetadata-ui/src/main/resources/ui/src/utils/QueryBuilderPureUtils.ts Refactor valueType/listValues selection
openmetadata-ui/src/main/resources/ui/src/utils/QueryBuilderPureUtils.test.ts New tests for valueType/listValues branches
openmetadata-ui/src/main/resources/ui/src/utils/QueryBuilderElasticsearchFormatUtils.js Refactor extensionValue conditional
openmetadata-ui/src/main/resources/ui/src/utils/NodeUtils.ts Refactor scheduleType selection
openmetadata-ui/src/main/resources/ui/src/utils/NodeUtils.test.ts New tests for scheduleType branches
openmetadata-ui/src/main/resources/ui/src/utils/ExplorePureUtils.ts Refactor must-array normalization
openmetadata-ui/src/main/resources/ui/src/utils/EntitySummaryPanelUtilsV1.tsx Refactor matched children selection
openmetadata-ui/src/main/resources/ui/src/utils/EntityLineageNodeUtils.ts Refactor lineage node type selection
openmetadata-ui/src/main/resources/ui/src/utils/EntityDisplayPureUtils.tsx Refactor badge class selection
openmetadata-ui/src/main/resources/ui/src/utils/EntityDisplayPureUtils.test.tsx New tests for badge class branches
openmetadata-ui/src/main/resources/ui/src/utils/DataQuality/DataQualityPureUtils.ts Refactor description selection
openmetadata-ui/src/main/resources/ui/src/utils/DataQuality/DataQualityPureUtils.test.ts New tests for description patch branches
openmetadata-ui/src/main/resources/ui/src/utils/CSV/CSVPureUtils.ts Refactor columnWidth fallback logic
openmetadata-ui/src/main/resources/ui/src/utils/CSV/CSVPureUtils.test.ts New tests for columnWidth branches
openmetadata-ui/src/main/resources/ui/src/utils/ContextCenterPureUtils.ts Refactor href derivation
openmetadata-ui/src/main/resources/ui/src/utils/ContextCenterPureUtils.test.ts New tests for href/tag/title mapping
openmetadata-ui/src/main/resources/ui/src/rest/suggestionsAPI.ts Refactor tag label newValue selection
openmetadata-ui/src/main/resources/ui/src/rest/searchAPI.ts Refactor hit mapping + apiQuery building
openmetadata-ui/src/main/resources/ui/src/pages/WorkflowDefinitions/WorkflowBuilder/WorkflowBuilder.tsx Refactor isNodeDragEnabled selection
openmetadata-ui/src/main/resources/ui/src/pages/TasksPage/shared/Assignees.tsx Refactor options normalization
openmetadata-ui/src/main/resources/ui/src/pages/TagPage/TagPage.tsx Refactor dqFilterKey selection
openmetadata-ui/src/main/resources/ui/src/pages/TableDetailsPageV1/TableConstraints/TableConstraints.tsx Refactor headerExtra render selection
openmetadata-ui/src/main/resources/ui/src/pages/ObservabilityAlertsPage/components/ObservabilityAlertsTable.tsx Refactor empty/error placeholder selection
openmetadata-ui/src/main/resources/ui/src/pages/LearningResourcesPage/LearningResourceForm.component.tsx Extract normalizeToArray helper
openmetadata-ui/src/main/resources/ui/src/pages/IncidentManager/IncidentManagerDetailPage/IncidentManagerDetailPage.tsx Refactor breadcrumb selection
openmetadata-ui/src/main/resources/ui/src/context/LineageProvider/LineageProvider.tsx Refactor must-array normalization
openmetadata-ui/src/main/resources/ui/src/components/WorkflowDefinitions/WorkflowBuilder/WorkflowCanvas.tsx Refactor dim opacity selection
openmetadata-ui/src/main/resources/ui/src/components/WorkflowDefinitions/WorkflowBuilder/forms/CronExpressionBuilder.tsx Refactor displayHour selection
openmetadata-ui/src/main/resources/ui/src/components/WorkflowDefinitions/WorkflowBuilder/forms/ConditionBuilder/ConditionBuilder.tsx Refactor items source selection
openmetadata-ui/src/main/resources/ui/src/components/Visualisations/Chart/CardinalityDistributionChart.component.tsx Refactor tick/cell fill selection
openmetadata-ui/src/main/resources/ui/src/components/SparqlQueryConsole/SparqlQueryConsole.component.tsx Refactor error + render branches
openmetadata-ui/src/main/resources/ui/src/components/SettingsSso/SsoTestLogin/SsoTestLoginModal.tsx Refactor description selection
openmetadata-ui/src/main/resources/ui/src/components/SettingsSso/SSOConfigurationForm/SsoConfigurationFormArrayFieldTemplate.tsx Refactor scope conversion conditional
openmetadata-ui/src/main/resources/ui/src/components/Settings/Users/UsersProfile/UserPermissions/UserPermissions.component.tsx Refactor policy color selection
openmetadata-ui/src/main/resources/ui/src/components/Settings/Users/CreateUser/CreateUser.component.tsx Refactor authMechanismConfig building
openmetadata-ui/src/main/resources/ui/src/components/Settings/Users/AccessTokenCard/AccessTokenCard.component.tsx Refactor return branches
openmetadata-ui/src/main/resources/ui/src/components/Settings/Persona/PersonaAIContext/ContextRuleEditor/ContextRuleEditor.component.tsx Refactor translation key selection
openmetadata-ui/src/main/resources/ui/src/components/Settings/Bot/BotListV1/BotListV1.component.tsx Refactor tooltip title selection
openmetadata-ui/src/main/resources/ui/src/components/Settings/Bot/BotDetails/AuthMechanism.tsx Refactor expiry text selection
openmetadata-ui/src/main/resources/ui/src/components/SearchSettings/EntitySeachSettings/EntitySearchSettings.tsx Refactor stage mapping + label suffix
openmetadata-ui/src/main/resources/ui/src/components/platform/ai-shell/context/useRouteActivation.ts Refactor activation reason selection
openmetadata-ui/src/main/resources/ui/src/components/platform/ai-shell/context/useRouteActivation.test.tsx New tests for activation reasons
openmetadata-ui/src/main/resources/ui/src/components/OntologyExplorer/utils/graphStyles.ts Refactor label style selections
openmetadata-ui/src/main/resources/ui/src/components/OntologyExplorer/RelationshipTypePicker.component.tsx Extract list render helper
openmetadata-ui/src/main/resources/ui/src/components/OntologyExplorer/OntologyVisualQueryBuilder.tsx Refactor axios error message selection
openmetadata-ui/src/main/resources/ui/src/components/OntologyExplorer/OntologyStudioQueryConsole.tsx Refactor error + modal title selection
openmetadata-ui/src/main/resources/ui/src/components/OntologyExplorer/OntologyQueryResults.tsx Refactor result view branching
openmetadata-ui/src/main/resources/ui/src/components/OntologyExplorer/OntologyNodeRelationsContent.tsx Refactor edit/add mapping branches
openmetadata-ui/src/main/resources/ui/src/components/OntologyExplorer/OntologyLibraryDetail.tsx Extract nonInstallPanel conditional
openmetadata-ui/src/main/resources/ui/src/components/OntologyExplorer/OntologyLibraryCatalogue.tsx Extract pack action button conditional
openmetadata-ui/src/main/resources/ui/src/components/OntologyExplorer/OntologyLibrary.tsx Extract libraryBody conditional
openmetadata-ui/src/main/resources/ui/src/components/OntologyExplorer/OntologyImportExportModal.tsx Extract preview/shacl status conditionals
openmetadata-ui/src/main/resources/ui/src/components/OntologyExplorer/OntologyConceptRealization.component.tsx Refactor canAuthor branches
openmetadata-ui/src/main/resources/ui/src/components/OntologyExplorer/hooks/useOntologyGraphDerived.ts Refactor exportableGlossaryId selection
openmetadata-ui/src/main/resources/ui/src/components/OntologyExplorer/hooks/useOntologyGraph.ts Refactor badgeText selection
openmetadata-ui/src/main/resources/ui/src/components/OntologyExplorer/hooks/useOntologyExplorer.ts Refactor requestedGlossaryIds selection
openmetadata-ui/src/main/resources/ui/src/components/OntologyExplorer/hooks/useGraphData.ts Refactor sizing/pos/label selection
openmetadata-ui/src/main/resources/ui/src/components/observability/common/FilterChip/FilterChip.tsx Refactor displayText selection
openmetadata-ui/src/main/resources/ui/src/components/observability/Alerts/ObservabilityAlertsAiTable.component.tsx Refactor empty/error placeholder selection
openmetadata-ui/src/main/resources/ui/src/components/observability/Alerts/AlertAiNotificationTemplateUtils.ts Refactor template key/data selection
openmetadata-ui/src/main/resources/ui/src/components/observability/Alerts/AlertAiFormFieldsPureUtils.ts Refactor getStringArrayValue + reuse
openmetadata-ui/src/main/resources/ui/src/components/observability/Alerts/AlertAiFormFields.component.test.tsx Refactor test i18n mock conditional
openmetadata-ui/src/main/resources/ui/src/components/observability/Alerts/AlertAiDestinationConfigFields.component.tsx Extract optionsContent conditional
openmetadata-ui/src/main/resources/ui/src/components/MyData/Widgets/KPIWidget/KPILegend/KPILegend.tsx Extract centerContent conditional
openmetadata-ui/src/main/resources/ui/src/components/MyData/Widgets/DomainsWidget/DomainsWidget.tsx Extract domainsContent conditional
openmetadata-ui/src/main/resources/ui/src/components/MyData/Widgets/DataProductsWidget/DataProductsWidget.component.tsx Extract widgetContent conditional
openmetadata-ui/src/main/resources/ui/src/components/MyData/Persona/PersonaSelectableList/PersonaSelectableList.component.test.tsx Refactor mock search conditional
openmetadata-ui/src/main/resources/ui/src/components/Learning/ResourcePlayer/ResourcePlayerModal.component.tsx Extract durationUnitLabel conditional
openmetadata-ui/src/main/resources/ui/src/components/Learning/LearningDrawer/LearningDrawer.component.tsx Extract drawerContent conditional
openmetadata-ui/src/main/resources/ui/src/components/KnowledgeGraph3D/rdfGraphAdapter.ts Refactor conceptId selection
openmetadata-ui/src/main/resources/ui/src/components/KnowledgeGraph3D/KnowledgeGraph3DEdgePanel.tsx Extract relationshipTypeLabel conditional
openmetadata-ui/src/main/resources/ui/src/components/KnowledgeGraph3D/KnowledgeGraph3D.tsx Refactor tooltip/levelKey selection
openmetadata-ui/src/main/resources/ui/src/components/Glossary/GlossaryUpdateConfirmationModal/GlossaryUpdateConfirmationModal.tsx Refactor progress selection
openmetadata-ui/src/main/resources/ui/src/components/Glossary/GlossaryTerms/tabs/RelatedTerms.tsx Extract diff class selection
openmetadata-ui/src/main/resources/ui/src/components/Glossary/GlossaryTerms/tabs/GlossaryTermReferences.tsx Refactor render conditionals
openmetadata-ui/src/main/resources/ui/src/components/Glossary/AddGlossary/AddGlossary.component.tsx Normalize selectedDomain list safely
openmetadata-ui/src/main/resources/ui/src/components/Explore/QuickFilterDropdown.tsx Extract optionListContent conditional
openmetadata-ui/src/main/resources/ui/src/components/Explore/EntitySummaryPanel/CommonEntitySummaryInfo/CommonEntitySummaryInfo.tsx Extract valueContent conditional
openmetadata-ui/src/main/resources/ui/src/components/Entity/Task/TaskTab/TaskTabNew.component.tsx Refactor actionable/newValue selection
openmetadata-ui/src/main/resources/ui/src/components/Entity/EntityExportModalProvider/EntityExportModal.component.tsx Extract alertVariant conditional
openmetadata-ui/src/main/resources/ui/src/components/Domain/AddDomainForm/AddDomainFormExtensionFields.tsx Extract numeric/enum helpers
openmetadata-ui/src/main/resources/ui/src/components/Domain/AddDomainForm/AddDomainForm.component.tsx Refactor entityTypeApiName selection
openmetadata-ui/src/main/resources/ui/src/components/discovery/personal-space/Profile/ProfilePage.tsx Refactor updatedKeyData selection
openmetadata-ui/src/main/resources/ui/src/components/discovery/personal-space/Profile/components/InlineEditCard.tsx Refactor rightPadding selection
openmetadata-ui/src/main/resources/ui/src/components/discovery/personal-space/InboxPage/tabs/TasksTab.tsx Refactor visibility + detail panel content
openmetadata-ui/src/main/resources/ui/src/components/discovery/personal-space/InboxPage/tabs/ActivityTab.tsx Extract empty placeholder + content
openmetadata-ui/src/main/resources/ui/src/components/discovery/personal-space/InboxPage/components/TaskDetailPanel.tsx Extract aboutPath/title/button conditionals
openmetadata-ui/src/main/resources/ui/src/components/discovery/personal-space/InboxPage/components/ActivityFeedItem.tsx Refactor actionLabel selection
openmetadata-ui/src/main/resources/ui/src/components/discovery/personal-space/InboxPage/components/ActivityDetailDrawer.tsx Refactor actionLabel selection
openmetadata-ui/src/main/resources/ui/src/components/discovery/personal-space/InboxIconButton/InboxIconButton.tsx Refactor badgeLabel selection
openmetadata-ui/src/main/resources/ui/src/components/discovery/explore/ExploreHeader/ExploreSearchCard.tsx Refactor quickFilter selection
openmetadata-ui/src/main/resources/ui/src/components/DataQuality/TestSuite/TestSuitePipelineTab/TestSuitePipelineTab.component.tsx Refactor cell render branches
openmetadata-ui/src/main/resources/ui/src/components/DataProducts/DataProductDomainWidget/DataProductDomainWidget.tsx Refactor selectedDomain normalization
openmetadata-ui/src/main/resources/ui/src/components/DataContract/ContractSecurityFormTab/ContractSecurityFormTab.tsx Extract rowFilterContent conditional
openmetadata-ui/src/main/resources/ui/src/components/Database/RetentionPeriod/RetentionPeriod.component.tsx Extract duration unit formatter
openmetadata-ui/src/main/resources/ui/src/components/Database/Profiler/TableProfiler/ProfilerSettingsModal/ProfilerSettingsModal.tsx Refactor profileSample selection
openmetadata-ui/src/main/resources/ui/src/components/DataAssets/DomainLabelV2/DomainLabelV2.tsx Refactor domainsPayload normalization
openmetadata-ui/src/main/resources/ui/src/components/DataAssets/DomainLabelV2/DomainLabelV2.test.tsx Refactor test i18n mock conditional
openmetadata-ui/src/main/resources/ui/src/components/ContextCenter/DocumentsView/DocumentsView.component.tsx Extract emptyStateContent conditional
openmetadata-ui/src/main/resources/ui/src/components/ContextCenter/ContextSimplePillarCard/ContextSimplePillarCard.component.tsx Extract pillarBody conditional
openmetadata-ui/src/main/resources/ui/src/components/common/UserTeamSelectableList/UserTeamSelectableList.component.tsx Refactor activeOwners normalization
openmetadata-ui/src/main/resources/ui/src/components/common/TierWidget/TierWidget.tsx Refactor headerExtra selection
openmetadata-ui/src/main/resources/ui/src/components/common/TableDataCardV2/TableDataCardV2.tsx Refactor tierName selection
openmetadata-ui/src/main/resources/ui/src/components/common/Table/TableV2Utils.ts Refactor rawValue selection
openmetadata-ui/src/main/resources/ui/src/components/common/Table/TableV2Utils.test.ts New tests for rawValue branches
openmetadata-ui/src/main/resources/ui/src/components/common/LogViewerModal/useLogStream.ts Refactor cursor URL building
openmetadata-ui/src/main/resources/ui/src/components/common/LogViewerModal/LogViewerModal.component.tsx Extract logBodyContent conditional
openmetadata-ui/src/main/resources/ui/src/components/common/HeaderShell/HeaderShell.component.tsx Extract footer padding conditional
openmetadata-ui/src/main/resources/ui/src/components/common/FormBuilderV1/widgets/coreWidgetUtils.ts Refactor label selection
openmetadata-ui/src/main/resources/ui/src/components/common/FilterButton/FilterButton.tsx Refactor trigger label + option rendering
openmetadata-ui/src/main/resources/ui/src/components/common/EntityImport/CsvJobsTray/CsvJobsTray.component.tsx Extract nonRunningIcon conditional
openmetadata-ui/src/main/resources/ui/src/components/common/EntityDetailHeader/EntityDetailHeader.component.tsx Extract iconElement conditional
openmetadata-ui/src/main/resources/ui/src/components/common/EntityDescription/EntityAttachmentProvider/EntityAttachmentProvider.tsx Refactor error handling branches
openmetadata-ui/src/main/resources/ui/src/components/common/DomainsSection/DomainsSection.tsx Refactor domainsToSave normalization
openmetadata-ui/src/main/resources/ui/src/components/common/DomainLabel/DomainLabel.component.tsx Refactor domains normalization
openmetadata-ui/src/main/resources/ui/src/components/common/CertificationWidget/CertificationWidget.tsx Refactor headerExtra selection
openmetadata-ui/src/main/resources/ui/src/components/common/atoms/navigation/usePageHeader.tsx Extract iconLeading conditional
openmetadata-ui/src/main/resources/ui/src/components/common/atoms/drawer/AiFormModal.tsx Extract modalWidth conditional
openmetadata-ui/src/main/resources/ui/src/components/Certification/Certification.component.tsx Extract iconContent conditional
openmetadata-ui/src/main/resources/ui/src/components/BulkEditEntity/BulkEditEntity.component.tsx Extract state flags/conditional rendering
openmetadata-ui/src/main/resources/ui/src/components/Alerts/DestinationFormItemV2/TeamAndUserSelectItemV2/TeamAndUserSelectItemV2.tsx Extract renderOptionList conditional
openmetadata-ui/src/main/resources/ui/src/components/ActivityFeed/TaskFeedCard/TaskFeedCardFromTask.component.tsx Extract rowGutter conditional
openmetadata-ui/src/main/resources/ui/src/components/ActivityFeed/ActivityFeedCardV2/FeedCardBody/OwnerFeed/ActivityOwnersFeed.tsx Refactor parsed owners normalization
openmetadata-ui/src/main/resources/ui/eslint.config.mjs Promote rule to error (ratchet)

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@ShaileshParmar11 ShaileshParmar11 added the skip-pr-checks Bypass PR metadata validation check label 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.94% (92782/132642) 54.72% (57372/104839) 55.89% (17436/31195)

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

getSelectEqualsNotEqualsProperties’s value typing is inconsistent with its boolean/array-handling logic, leading to unsafe casts and should be corrected before merging.

Review details

Suppressed comments (1)

Previously missed (1) — in code that hasn't changed since the last review.

openmetadata-ui/src/main/resources/ui/src/utils/QueryBuilderPureUtils.ts:95

  • getSelectEqualsNotEqualsProperties is typed as value: string, but the implementation (and new unit test) relies on value sometimes being a boolean (isBoolean(value)) and sometimes an array (Array.isArray(value)). This mismatch forces unsafe casts at call sites and also makes listValues infer a too-broad shape (e.g., boolean keys) even though async list values are only meaningful for non-equality operators. Widen the value parameter type and construct listValues only for the non-equality branch, coercing scalar keys to strings.
  • Files reviewed: 136/136 changed files
  • Comments generated: 0 new
  • Review effort level: Lite

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.

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-04T03:05:50Z)

Blocked the queue: ui-checkstyle

@github-actions

github-actions Bot commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

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

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

@github-actions

github-actions Bot commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

🚦 Removed from the merge queue — merge_conflict (2026-09-05T05:45:28Z)

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.

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

Thanks — the flagged finding doesn't hold, but chasing it did surface two real misses, so the review was net useful. Details below.

The expression-complexity promotion isn't in this PR

This branch's complete diff to eslint.config.mjs is a single line:

       'sonarjs/expression-complexity': 'error',          ← unchanged context
-      'sonarjs/no-nested-conditional': 'warn', // 16
+      // Promoted to error: all nested-ternary violations refactored to
+      // intermediate variables / if-else; backlog is zero and this ratchets it.
+      'sonarjs/no-nested-conditional': 'error',

sonarjs/expression-complexity: 'error' was already on main, promoted by #32381, and the "141 over-complex expressions" comment is that PR's text. The cited range (347-350) spans those unchanged context lines. The one-rule-per-PR scope is intact — applying the suggested fix would revert #32381 and show up as a regression.

The backlog question, answered with numbers

Fair question regardless of who promoted the rule, since ui-checkstyle only lints changed files — a green main doesn't prove a rule's backlog is zero. Ran ESLint across all of src/**/*.{ts,tsx,js,jsx} at error level:

sonarjs/expression-complexity : 0
sonarjs/no-nested-conditional : 0

Both confirmed zero tree-wide, so the promotion is safe.

What the scan actually caught

The first run of that scan returned no-nested-conditional: 2 — two nested ternaries the original sweep missed, in files outside this PR's changed set:

  • TeamAndUserSelectItem.tsx:221 — three-branch JSX ternary chain
  • TableV2.parity.test.tsx:47 — nested ternary in getTextAlign (under __tests__/, likely skipped by the sweep's glob)

Because neither file was in the changed set, CI would have passed and merged 'error' alongside a "backlog is zero" comment that wasn't true — leaving a trap for the next PR to touch either file. Both are now fixed and the numbers above are post-fix.

Also folded in four pre-existing expression-complexity violations in QueryBuilderElasticsearchFormatUtils.js. Those are dormant on main for the same changed-files-only reason, but this branch has to touch that file to fix a nested ternary, which pulls them into lint scope and would fail the job. 22/22 existing tests pass on that file.

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.

Extracts every nested ternary in the UI into intermediate variables or
if/else statements, taking the sonarjs/no-nested-conditional backlog to zero,
then ratchets the rule from warn to error in eslint.config.mjs. Type narrowing
is preserved at each extraction site rather than relying on the ternary's
implicit narrowing. Adds unit tests covering the refactored pure logic.

Also clears four sonarjs/expression-complexity violations in
QueryBuilderElasticsearchFormatUtils.js by replacing long || chains with
module-level list constants. Those violations pre-exist on main but lie
dormant there, because ui-checkstyle only lints changed files and nothing on
main touches that file. This branch has to touch it, and expression-complexity
is now error, so they would otherwise fail the job.

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.

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

@gitar-bot

This comment was marked as resolved.

@sonarqubecloud

sonarqubecloud Bot commented Sep 6, 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