Encapsulate hue.cpp's own runtime state as static, not global - #5777
Encapsulate hue.cpp's own runtime state as static, not global#5777netmindz wants to merge 1 commit into
Conversation
11 WLED_GLOBAL variables (hueXLast, hueYLast, hueHueLast, hueCtLast, hueSatLast, hueBriLast, hueLastRequestSent, hueAuthRequired, hueReceived, hueNewKey, hueClient) turned out to be referenced only in hue.cpp - nowhere else in wled00/ or usermods/ touches them. They were global purely because everything in wled.h lives in one big extern block regardless of who actually uses it. Converted all 11 to file-local `static` in hue.cpp. hueStoreAllowed, which was declared on the same line as hueNewKey, stays global since set.cpp also writes it. No behavior change - purely a storage-class change, same types and initial values as before. Verified: esp32dev builds and links cleanly via `pio run -e esp32dev` (1,320,323 bytes flash, no warnings from the changed files). Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01UtCyBD91vAYWvBzaMyQSHd
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (2)
Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review. WalkthroughHue synchronization state moved from public declarations in ChangesHue state encapsulation
Priority: ⬇️ Low Estimated code review effort: 2 (Simple) | ~10 minutes Change: Refactor Merge Risk: ⚪ Minimal · up to Hue synchronization state is now private to its implementation file without an identified behavioral or build impact. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches 💡 1⚔️ Resolve merge conflicts 💡
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
@copilot resolve the merge conflicts in this pull request |
Summary
11
WLED_GLOBALvariables declared inwled.hturned out to be referenced only inhue.cpp— nowhere else inwled00/orusermods/touches them:hueXLast,hueYLast,hueHueLast,hueCtLast,hueSatLast,hueBriLast,hueLastRequestSent,hueAuthRequired,hueReceived,hueNewKey,hueClient. They were global purely because everything inwled.hlives in one bigexternblock regardless of who actually uses it.Converted all 11 to file-local
staticinhue.cpp, with the same types and initial values as before.hueStoreAllowed, which was declared on the same source line ashueNewKey, stays global sinceset.cppalso writes it — verified by grep before splitting that declaration.No behavior change — purely a storage-class change, nothing else touched.
This is a small, mechanical first step from a broader pass identifying which of WLED's ~270
WLED_GLOBALdeclarations are actually only used in one file (this is the largest single-file cluster).Test plan
esp32dev: builds and links cleanly viapio run -e esp32dev— 1,320,323 bytes flash, no warnings from either changed file.wled00/,usermods/) that none of the 11 converted variables are referenced outsidehue.cpp.🤖 Generated with Claude Code
Summary by CodeRabbit