Skip to content

Tech-debt: deduplicate _parsePossibleChannels shared between usp_wifi_data_service and usp_wifi_settings_service #1038

Description

@AustinChangLinksys

Summary

_parsePossibleChannels — which parses a TR-181 PossibleChannels string into a sorted list of channel numbers — is duplicated verbatim in two service files. Any future fix (e.g. sentinel filtering, range-parsing hardening) must be applied in both places; missing one causes silent divergence between the two services.

Locations

  • lib/page/wifi_settings/services/usp_wifi_data_service.dart (_parsePossibleChannels, ~line 424)
  • lib/page/wifi_settings/services/usp_wifi_settings_service.dart (identical top-level function, ~line 622)

Impact

Suggested fix

Extract to a single shared utility (e.g. lib/core/utils/wifi_channel_utils.dart, parsePossibleChannels(String raw) -> List<int>) and import from both services. Move the associated unit tests to cover the shared function once.

★ The shared utility MUST carry the hardened logic (sentinel "0" filtering, bounds.length != 2 guard, range-notation coverage), taking the usp_wifi_data_service copy as the correct baseline — NOT the un-hardened usp_wifi_settings_service copy. Extracting from the wrong baseline would spread the gap rather than close it. This subsumes the "C-1" finding raised in PR #1027 review (Round 3), which was downgraded there and folded into this issue.

Notes

Related functional fixes (band normalization for DFS annotation, "0" sentinel filtering, range-notation test coverage) were handled directly in #1023 / PR #1027 for the usp_wifi_data_service path. This issue tracks the deduplication tech-debt AND re-convergence of the two now-diverged copies (hardening the settings-service path in the process), deferred from #1027 to avoid scope-creep.

Metadata

Metadata

Assignees

Labels

2.xLabeled for 2.x versionconfidence:lowInsufficient evidence; body-only speculation (not posted)feature:wifiWiFi configuration and management

Type

Fields

No fields configured for Task.

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions