Repository navigation
feat(lint): enforce Public Settings Pattern for fl:: global setters (layer 5) - #2716
Merged
zackees merged 2 commits intoJun 3, 2026
Conversation
Adds `PublicSettingsPatternChecker` (ci/lint_cpp/public_settings_pattern_checker.py) — layer 5 of the six-layer Public Settings Pattern enforcement plan introduced in PR #2715 / docs commit d51a8f6. What it checks: Every public free function declared at `namespace fl` root scope in `src/fl/**/*.h` whose name matches `^(set|enable|disable|use)_[a-z]` MUST have a matching `CFastLED::setX()` / `enableX()` / `disableX()` wrapper in `src/FastLED.h` that delegates to it. Carve-outs (NOT flagged): - Sub-namespaces (fl::detail::, fl::isr::, fl::colorimetric_detail::, …) - Anonymous namespaces - Class/struct member functions (per-object setters) - Function-pointer installers (set_rgb_2_rgbw_function, set_rgb_2_rgbww_function) - Per-object mutators: non-const ptr/ref to user-defined type as first param - Lines suppressed with `// nolint` or `// ok public_settings` Grandfathered allowlist (pre-rule offenders, not flagged): set_rgbw_colorimetric_profile, set_input_gamut (from #2715 description), enable_rgbw_colorimetric_lut, disable_rgbw_colorimetric_lut (#2545), set_rgbww_colorimetric_profile (#2558). Implementation notes: - Uses a per-`{` scope stack (not a simple brace counter) so that enum bodies, inline function definitions, and nested namespaces are all tracked correctly without false namespace pops. - FastLED.h is loaded once at `__init__` time for cross-file wrapper lookup. - 63 unit tests; `bash lint --cpp` passes clean on the full codebase. - Registered in the `fl` scope in run_all_checkers.py. Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
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 |
Pyright (--strict) flagged `first_param` as `list[Unknown]` since it's initialized as a bare `[]`. The list only ever holds str characters from iterating `params_raw` (a str), so the annotation is `list[str]`. Drive-by while reviewing the agent-generated PR #2716. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
This was referenced Jun 3, 2026
zackees
added a commit
that referenced
this pull request
Jun 4, 2026
…layer 5) (#2716) * feat(lint): enforce Public Settings Pattern for fl:: global setters Adds `PublicSettingsPatternChecker` (ci/lint_cpp/public_settings_pattern_checker.py) — layer 5 of the six-layer Public Settings Pattern enforcement plan introduced in PR #2715 / docs commit d51a8f6. What it checks: Every public free function declared at `namespace fl` root scope in `src/fl/**/*.h` whose name matches `^(set|enable|disable|use)_[a-z]` MUST have a matching `CFastLED::setX()` / `enableX()` / `disableX()` wrapper in `src/FastLED.h` that delegates to it. Carve-outs (NOT flagged): - Sub-namespaces (fl::detail::, fl::isr::, fl::colorimetric_detail::, …) - Anonymous namespaces - Class/struct member functions (per-object setters) - Function-pointer installers (set_rgb_2_rgbw_function, set_rgb_2_rgbww_function) - Per-object mutators: non-const ptr/ref to user-defined type as first param - Lines suppressed with `// nolint` or `// ok public_settings` Grandfathered allowlist (pre-rule offenders, not flagged): set_rgbw_colorimetric_profile, set_input_gamut (from #2715 description), enable_rgbw_colorimetric_lut, disable_rgbw_colorimetric_lut (#2545), set_rgbww_colorimetric_profile (#2558). Implementation notes: - Uses a per-`{` scope stack (not a simple brace counter) so that enum bodies, inline function definitions, and nested namespaces are all tracked correctly without false namespace pops. - FastLED.h is loaded once at `__init__` time for cross-file wrapper lookup. - 63 unit tests; `bash lint --cpp` passes clean on the full codebase. - Registered in the `fl` scope in run_all_checkers.py. Co-Authored-By: Claude Sonnet 4.6 <[email protected]> * fix(lint): annotate first_param list type in public_settings checker Pyright (--strict) flagged `first_param` as `list[Unknown]` since it's initialized as a bare `[]`. The list only ever holds str characters from iterating `params_raw` (a str), so the annotation is `list[str]`. Drive-by while reviewing the agent-generated PR #2716. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]> --------- Co-authored-by: Claude Sonnet 4.6 <[email protected]>
zackees
added a commit
that referenced
this pull request
Jun 4, 2026
* docs(cpp): enforce Public Settings Pattern for global setters Codifies the long-implicit rule that new library-wide configuration setters must be exposed on the `CFastLED` god instance (e.g. `FastLED.setX(...)`) rather than as bare `fl::set_x(...)` free functions. The free function may exist for ADL / testability, but the documented call site is the god instance. Motivated by PR #2711, which added `fl::set_input_gamut(...)` as a free function only — following the unwrapped precedent of `fl::set_rgbw_colorimetric_profile`. Neither has a `FastLED.setX()` entry point, so users don't discover them. Both are now grandfathered exceptions; new code must wrap. Changes: - `agents/docs/cpp-standards.md`: New "Public Settings Pattern" section with rules, exemplar (`setPowerModel` → `set_power_model`), and a grandfathered allowlist. - `CLAUDE.md`: One-liner pointer in the task table and Code Standards section so agents see the rule on entry. - `.coderabbit.yaml`: `path_instructions` for `src/fl/**/*.h`, `src/FastLED.h`, and `src/fl/gfx/**` telling CodeRabbit to flag bare new `fl::set_* / enable_* / disable_* / use_*` declarations without a matching `CFastLED` wrapper as HIGH severity, with the grandfathered allowlist honored. - `.claude/agents/architecture-reviewer-agent.md`: API Surface check step gains a "Public Settings Pattern enforcement" subsection. - `.claude/commands/code_review.md`: New rule block before "SIGNED INTEGER OVERFLOW", plus a counter in the violations summary. - `src/FastLED.h`: Backfills `CFastLED::setRgbwColorimetricProfile()` and `getRgbwColorimetricProfile()` — thin `inline` delegators to the existing `fl::` free functions. `setInputGamut` is intentionally left for PR #2711 to add alongside its own free function (it isn't on master yet). Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]> * docs(cpp): drop grandfathered allowlist; require wrapper for all global setters Removes the grandfathered exceptions section from the Public Settings Pattern docs. Both names that were allowlisted in the initial commit of this PR were introduced after the policy itself was being defined, so neither was historically grandfathered: - `fl::set_rgbw_colorimetric_profile` is already wrapped on `CFastLED` (`CFastLED::setRgbwColorimetricProfile`) in this PR, so it no longer needs an exception. - `fl::set_input_gamut` (#2710) is introduced in PR #2711 without a `CFastLED` wrapper. The wrapper must be added before that PR merges. Updated files: - `.coderabbit.yaml` - `agents/docs/cpp-standards.md` - `.claude/agents/architecture-reviewer-agent.md` - `.claude/commands/code_review.md` Addresses CodeRabbit review on PR #2715. Co-Authored-By: Claude Opus 4.7 <[email protected]> * feat(lint): enforce Public Settings Pattern for fl:: global setters (layer 5) (#2716) * feat(lint): enforce Public Settings Pattern for fl:: global setters Adds `PublicSettingsPatternChecker` (ci/lint_cpp/public_settings_pattern_checker.py) — layer 5 of the six-layer Public Settings Pattern enforcement plan introduced in PR #2715 / docs commit d51a8f6. What it checks: Every public free function declared at `namespace fl` root scope in `src/fl/**/*.h` whose name matches `^(set|enable|disable|use)_[a-z]` MUST have a matching `CFastLED::setX()` / `enableX()` / `disableX()` wrapper in `src/FastLED.h` that delegates to it. Carve-outs (NOT flagged): - Sub-namespaces (fl::detail::, fl::isr::, fl::colorimetric_detail::, …) - Anonymous namespaces - Class/struct member functions (per-object setters) - Function-pointer installers (set_rgb_2_rgbw_function, set_rgb_2_rgbww_function) - Per-object mutators: non-const ptr/ref to user-defined type as first param - Lines suppressed with `// nolint` or `// ok public_settings` Grandfathered allowlist (pre-rule offenders, not flagged): set_rgbw_colorimetric_profile, set_input_gamut (from #2715 description), enable_rgbw_colorimetric_lut, disable_rgbw_colorimetric_lut (#2545), set_rgbww_colorimetric_profile (#2558). Implementation notes: - Uses a per-`{` scope stack (not a simple brace counter) so that enum bodies, inline function definitions, and nested namespaces are all tracked correctly without false namespace pops. - FastLED.h is loaded once at `__init__` time for cross-file wrapper lookup. - 63 unit tests; `bash lint --cpp` passes clean on the full codebase. - Registered in the `fl` scope in run_all_checkers.py. Co-Authored-By: Claude Sonnet 4.6 <[email protected]> * fix(lint): annotate first_param list type in public_settings checker Pyright (--strict) flagged `first_param` as `list[Unknown]` since it's initialized as a bare `[]`. The list only ever holds str characters from iterating `params_raw` (a str), so the annotation is `list[str]`. Drive-by while reviewing the agent-generated PR #2716. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]> --------- Co-authored-by: Claude Sonnet 4.6 <[email protected]> * docs(cpp): align grandfathered allowlist text with checker CodeRabbit (#2715 thread on agents/docs/cpp-standards.md:262) flagged that the "No grandfathered offenders" wording contradicted the actual enforcement state: public_settings_pattern_checker.py still carries a small GRANDFATHERED_NAMES allowlist for legacy bare setters that have not yet received CFastLED wrappers (set_input_gamut, enable_rgbw_colorimetric_lut, disable_rgbw_colorimetric_lut, set_rgbww_colorimetric_profile). Reconcile the policy text in cpp-standards.md, architecture-reviewer- agent.md, and code_review.md to describe the transitional allowlist explicitly: strict for *new* code, shrinking allowlist for legacy names, entries removed as wrappers land. The behavior of the rule is unchanged; only the documentation matches reality now. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]> --------- Co-authored-by: Claude Opus 4.7 (1M context) <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
ci/lint_cpp/public_settings_pattern_checker.py— a newFileContentCheckerthat enforces the Public Settings Pattern documented inagents/docs/cpp-standards.md→ "Public Settings Pattern (Global Configuration viaCFastLED)"flscope inci/lint_cpp/run_all_checkers.pyso it runs automatically viabash lint --cppci/lint_cpp/test_public_settings_pattern_checker.py; all pass;bash lint --cppexits cleanThis is layer 5 of the six-layer enforcement plan introduced in PR #2715 (docs, CodeRabbit, architecture-reviewer-agent, /code_review skill, backfill wrappers, syntactic check ← this PR).
What it flags
Every public free function in
src/fl/**/*.hmatching^(set|enable|disable|use)_[a-z]that is declared atnamespace flroot scope and has no corresponding call-site insrc/FastLED.h(i.e. noCFastLEDwrapper method that delegates to it).Violation message example:
Suppression:
// nolintor// ok public_settingson the declaration line.Carve-outs (not flagged)
fl::detail::*,fl::isr::*, any sub-namespacefl::APInamespace { }set_rgb_2_rgbw_function,set_rgb_2_rgbww_functionGrandfathered allowlist (seeded from PR #2715 description)
These predate the rule and are NOT flagged:
set_rgbw_colorimetric_profile— wrapped in PR docs(cpp): enforce Public Settings Pattern for global setters #2715; allowlist is defence-in-depthset_input_gamut— grandfathered; wrapper plannedenable_rgbw_colorimetric_lut— added in feat(rgbw): sub-gamut white-extraction algorithm for chromaticity-accurate RGBW output #2545; wrapper planneddisable_rgbw_colorimetric_lut— added in feat(rgbw): sub-gamut white-extraction algorithm for chromaticity-accurate RGBW output #2545; wrapper plannedset_rgbww_colorimetric_profile— added in feat(rgbww): 5-channel RGB+WW (warm/cool white) support via Channels API (Phase 3 of #2545) #2558; wrapper plannedImplementation notes
The scope tracker uses a per-
{scope stack (not a simple brace depth counter). This correctly handles enum bodies, inline function definitions, and nested namespaces without false namespace pops — a bug that would occur with the naive counter approach (verified by tracingsrc/fl/gfx/rgbww.hwhereenum { kDefaultCct = 2700 }closes beforeset_rgbww_colorimetric_profileis declared).src/FastLED.his loaded once at checker__init__time; the wrapper lookup is a word-boundary regex scan that skips#includelines and pure comment lines.Test plan
bash lint --cpppasses clean on the full codebase🤖 Generated with Claude Code