Skip to content

refactor(frontend): reduce cognitive complexity in components - #620

Merged
Starosdev merged 1 commit into
developfrom
fix/sonarqube-frontend
Jun 18, 2026
Merged

Starosdev merged 1 commit into
developfrom
fix/sonarqube-frontend

Conversation

@Starosdev

Copy link
Copy Markdown
Owner

Summary

Reduces SonarQube cognitive complexity (typescript:S3776) for all three flagged frontend functions. Each now sits well below the allowed limit of 15.

Function File Before After
buildAppriseUrl dashboard-settings.component.ts 24 <15
set range @treo/date-range.component.ts 22 <15
_generateSmartAttributeTableDataSource detail.component.ts 21 <15

Changes

Pure extraction of helpers; no behavior change.

  • dashboard-settings — buildCustomAppriseUrl, buildEmailAppriseUrl (the email case carried all the nesting)
  • date-range — _applyStartDate, _applyEndDate; the three independent whichDate if blocks become an if/else-if/else, inner clamping logic moved into the helpers
  • detail — _setSmartAttributeTableColumns (protocol/display-mode column selection) and _buildAttributeChartHistory (per-attribute sparkline datapoints)

Verification

  • npx eslint on the three files — clean
  • npm run build:prod — compiles
  • npm test -- --watch=false --browsers=ChromeHeadless — 153/153 pass

Notes

Continuation of SonarQube Group 5 (cognitive complexity), after #616 (smart.go), #617 (collector commands), #618 (notify), #619 (detect). Remaining clusters need InfluxDB to test locally: repository, DB migrations, and the web middleware/heartbeat functions.

Extract focused helpers from three high-complexity functions. Behavior
is unchanged; lint, production build, and the 153 unit tests all pass.

- dashboard-settings buildAppriseUrl (24): buildCustomAppriseUrl,
  buildEmailAppriseUrl
- date-range set range (22): _applyStartDate, _applyEndDate
- detail _generateSmartAttributeTableDataSource (21):
  _setSmartAttributeTableColumns, _buildAttributeChartHistory

All three functions now sit well below the cognitive complexity limit
of 15.

Resolves SonarQube typescript:S3776.
@Starosdev
Starosdev merged commit 278cd44 into develop Jun 18, 2026
15 checks passed
Starosdev pushed a commit that referenced this pull request Jun 20, 2026
## [1.65.0-beta.1](v1.64.0...v1.65.0-beta.1) (2026-06-20)

### Features

* **api:** expose and update heartbeat_enabled on notify URLs ([99bb242](99bb242))
* **heartbeat:** filter notify URLs by heartbeat_enabled ([24f359a](24f359a))
* **notify:** add heartbeat_enabled field to notify_urls ([6432a2c](6432a2c))
* **notify:** LoadHeartbeatDatabaseUrls filters by heartbeat_enabled ([51d8662](51d8662))
* **thresholds:** detect Power-On Hours 16-bit counter rollover ([#595](#595)) ([#625](#625)) ([390de8b](390de8b))
* **ui:** add contextual help links for settings docs ([#492](#492)) ([8ceb12b](8ceb12b))
* **ui:** add contextual help links pointing to docs folder ([#492](#492)) ([7b484a0](7b484a0))
* **ui:** add heartbeat toggle per notification URL ([e6bbfea](e6bbfea))
* **ui:** add navigation visibility settings for ZFS, MDADM, Btrfs, Workload ([#588](#588)) ([fca1ae3](fca1ae3))
* **ui:** group MDADM and Workload pages by host ([#579](#579)) ([3e3aa73](3e3aa73))

### Bug Fixes

* **api:** return 404 when heartbeat toggle targets non-existent notify URL ([8c375c2](8c375c2))
* **backend:** pass SmartInfo by pointer to syncDeviceSelfTests (hugeParam) ([e027c33](e027c33))
* **backend:** satisfy gocritic hugeParam and govet fieldalignment lint ([be05416](be05416))
* **db:** simplify migration func to satisfy unlambda linter ([8158a34](8158a34))
* **ui:** style learn more link in Consumer Drive Profiles hint ([#492](#492)) ([ba5b6c3](ba5b6c3))

### Refactoring

* **collector:** reduce cognitive complexity in collector commands ([#617](#617)) ([dedf386](dedf386)), closes [#616](#616)
* **collector:** reduce cognitive complexity in device detection ([#619](#619)) ([b2e5a9d](b2e5a9d))
* **database:** reduce cognitive complexity in repository ([#621](#621)) ([4990d88](4990d88))
* **database:** reduce cognitive complexity in the migration runner ([#624](#624)) ([037c82d](037c82d))
* **frontend:** reduce cognitive complexity in components ([#620](#620)) ([278cd44](278cd44))
* **measurements:** reduce cognitive complexity in smart.go ([#616](#616)) ([b82e0f5](b82e0f5))
* **models:** reduce cognitive complexity in measurement models ([#622](#622)) ([900e4c3](900e4c3))
* **notify:** reduce cognitive complexity in notification senders ([#618](#618)) ([249d836](249d836)), closes [#616](#616) [#617](#617)
* **web:** reduce cognitive complexity in middleware and monitors ([#623](#623)) ([8695dc8](8695dc8))
@Starosdev
Starosdev deleted the fix/sonarqube-frontend branch June 20, 2026 01:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant