Repository navigation
[ESLint] Clear sonarjs/no-nested-conditional + promote to error - #32348
Conversation
|
Too many files changed for review (136 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 |
There was a problem hiding this comment.
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/elsebranches across UI utilities, components, and API helpers. - Added focused co-located unit tests for refactored pure-logic utilities/hooks.
- Promoted
sonarjs/no-nested-conditionalfromwarn→errorin 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.
There was a problem hiding this comment.
🔵 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
getSelectEqualsNotEqualsPropertiesis typed asvalue: string, but the implementation (and new unit test) relies onvaluesometimes being a boolean (isBoolean(value)) and sometimes an array (Array.isArray(value)). This mismatch forces unsafe casts at call sites and also makeslistValuesinfer a too-broad shape (e.g., boolean keys) even though async list values are only meaningful for non-equality operators. Widen thevalueparameter type and constructlistValuesonly for the non-equality branch, coercing scalar keys to strings.
- Files reviewed: 136/136 changed files
- Comments generated: 0 new
- Review effort level: Lite
🚦 Removed from the merge queue —
|
🚦 Removed from the merge queue —
|
🚦 Removed from the merge queue —
|
|
Thanks — the flagged finding doesn't hold, but chasing it did surface two real misses, so the review was net useful. Details below. The
|
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]>
This comment was marked as resolved.
This comment was marked as resolved.
|



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-conditionalsub-rule to 0 violations and promotes itwarn→errorso nested ternaries can't drift back in. The remaining complexity rules in #30984 (cyclomatic-complexity,no-nested-functions,cognitive-complexity) stay atwarnfor their own follow-up PRs — this keeps the change small and reviewable, consistent with the one-rule-per-PR ratchet. (expression-complexitywas already promoted toerroronmainby #32381; this PR leaves that line untouched — it shows up as unchanged context in theeslint.config.mjsdiff.)Approach — real refactors, behavior-preserving
Every nested ternary was refactored, not suppressed: the inner ternary is lifted into an intermediate
const/let(or anif/elsechain for value selection) so the render/return logic reads top-to-bottom. Noeslint-disable, no logic change.let,lodash/compact, an explicit non-null guard in the render path, a typedif/else, anunknownbridge). See commitpreserve type narrowing after no-nested-conditional extraction.Verification
eslint --quiet 'src/**/*.{ts,tsx}'with the rule at error → 0 errors tree-wide, 0no-nested-conditionaloccurrences.tsc --noEmitdiff vsorigin/main, line/path-normalized → 0 net-new error signatures (branch has 587 total vs main 591; net direction is fewer errors, none introduced).TaskTabNewfailure was CPU-contention flake under parallel workers — passes 30/30 in isolation).utils+ theuseRouteActivationhook) — 37 cases, each exercising every arm of the refactored conditional.yarn ui-checkstyle:changed→ 0 errors.Ratchet
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.