You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
refactor: extract MQTT_RETAINED_STATE_OPTIONS + named regex constants
Two small DRY wins flagged by /simplify but skipped earlier:
1. The literal { retain: true, qos: 0 } appeared at 16 callsites across
haDiscovery.js, haBridgeDiagnostics.js, staleDeviceDetector.js,
mqttCommandRouter.js, and cgateWebBridge.js. Replace with a frozen
MQTT_RETAINED_STATE_OPTIONS constant in src/constants.js. The frozen
object prevents accidental mutation of a now-shared reference.
2. Two regexes in commandResponseProcessor.js — the C-Gate timestamp
prefix and the network-path extractor — were inline. Move them to
named module-scope constants (CGATE_TIMESTAMP_PREFIX,
CGATE_NETWORK_PATH) so the intent is visible at the callsite and
the patterns can be referenced by future code without copy-paste.
Also drops a now-redundant local `opts` alias in staleDeviceDetector
that just aliased the literal.
No behaviour change. Full suite 1199/1199 passing, lint clean.
0 commit comments