Skip to content

chore(lint): drive pre-existing bash lint violations to zero - #3496

Merged
zackees merged 1 commit into
masterfrom
chore/lint-cleanup-preexisting
Jul 1, 2026
Merged

zackees merged 1 commit into
masterfrom
chore/lint-cleanup-preexisting

Conversation

@zackees

@zackees zackees commented Jul 1, 2026 •

Copy link
Copy Markdown
Member

Summary

bash lint --cpp is now clean on master. Prior state: 16 pre-existing violations across 8 checkers (LPC drivers, RMT4 memory manager, AutoResearch example, UnityBuild structure) — all unrelated to #3481 but blocking any hard-fail promotion of new lint rules.

Follow-up to #3495 (SingletonElisionChecker land).

What's fixed

Suppressions with // ok <checker> annotations:

  • BareAllocation: free() member func in rmt_memory_manager_4.h; private-impl new in rmt_rx_channel_4.cpp.hpp
  • PlatformIncludes: intentional deep-include in AutoResearchPwmDmaClockless.h
  • ReinterpretCast: 3× LPC DMA descriptor raw-address casts in spi_arm_lpc_dma.h

Real fixes:

  • IsHeaderInclude: added #include "platforms/arm/is_arm.h" to channel_drivers_lpc.impl.hpp
  • SpanFromPointer: fl::span<const u8>(x.data(), x.size()) → fl::span<const u8>(x) in lpc_sct_dma_runtime.h

Structural fixes:

  • Test moved — tests/fl/channels/lpc_sct_dma_engine.cpp → tests/platforms/arm/lpc/drivers/sct_dma/channel_engine_lpc_sct_dma.cpp (mirrors the source layout).
  • Unity 1-level rule — new src/platforms/arm/lpc/drivers/_build.cpp.hpp hop.
  • Unity section comments — added // begin current directory includes / // begin sub directory includes to platforms/arm/lpc/_build.cpp.hpp.

New UnityBuildChecker escape hatches (each requires a non-empty reason):

  • UNITY_BUILD_EXCLUDE(<reason>) — in a .cpp.hpp file's first 15 lines, marks it as intentionally NOT part of the unity build. Applied to i2s_peripheral_esp32dev_esp.cpp.hpp (Stage-4 impl whose driver/gpio.h symbols collide with the restored classic driver → ADC: CONFLICT! boot loop).
  • UNITY_BUILD_ORDER(<reason>) — in a _build.cpp.hpp, suppresses alphabetical-order check when compile-order dependency forces non-alphabetical include. Applied to platforms/arm/lpc/drivers/sct_dma/_build.cpp.hpp (engine instantiates runtime class as member — runtime must precede engine).

Test plan

  • bash lint --cpp — ✅ All C++ linting checks passed
  • bash test --cpp — 344/344 pass
  • CI green

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features

    • Improved build support for platform-specific unity headers, including more flexible include handling and clearer build ordering.
  • Bug Fixes

    • Added safeguards to skip unity-build checks for intentionally excluded files.
    • Fixed include wiring and platform detection in ARM/LPC components to support more reliable builds.
  • Documentation

    • Clarified several inline comments around build order, exclusion rules, and DMA/RMT implementation details.

`bash lint --cpp` is now clean on master. Prior state was 16 pre-existing
violations across 8 checkers (LPC drivers, RMT4 memory manager, AutoResearch
example, UnityBuild structure) — all unrelated to the singleton-elision work
that landed in #3495 but blocking any hard-fail promotion of that checker.

## Fixes by category

### Suppressions (single-line intent statements)
- `rmt_memory_manager_4.h` L168: `bool free(...)` is a member function, not
  C free() — annotated `// ok bare allocation`.
- `rmt_rx_channel_4.cpp.hpp` L605: `new RmtRxChannelImpl(pin)` is inside a
  `shared_ptr<>` factory for a PRIVATE impl type; `make_shared` would need
  to expose it. Annotated `// ok bare allocation`.
- `AutoResearchPwmDmaClockless.h` L58: deep-include of the concrete engine
  header is intentional for the driver-specific validation harness.
  Annotated `// ok platform headers`.
- `spi_arm_lpc_dma.h` L437/438/444: LPC DMA descriptor construction needs
  raw addresses. Three `// ok reinterpret cast` annotations.

### Real fixes
- `channel_drivers_lpc.impl.hpp`: add missing `#include "platforms/arm/is_arm.h"`
  (the file uses `FL_IS_ARM_LPC_845` which requires the ARM detection header).
- `lpc_sct_dma_runtime.h` L137: `fl::span<const u8>(x.data(), x.size())` →
  `fl::span<const u8>(x)` per SpanFromPointerChecker.

### Structural fixes
- **Test relocation**: `tests/fl/channels/lpc_sct_dma_engine.cpp` →
  `tests/platforms/arm/lpc/drivers/sct_dma/channel_engine_lpc_sct_dma.cpp`.
  The test exercises a platform-specific engine, not a `fl/channels/`
  source file, so the mirror-source-directory convention places it under
  `tests/platforms/arm/lpc/drivers/sct_dma/`.
- **Unity build 1-level rule**: introduced `src/platforms/arm/lpc/drivers/_build.cpp.hpp`
  as the intermediate hop so the parent `platforms/arm/lpc/_build.cpp.hpp`
  only reaches one level deep (per UnityBuildChecker convention).
- **Unity section comments**: added `// begin current directory includes`
  and `// begin sub directory includes` markers to `platforms/arm/lpc/_build.cpp.hpp`
  in the required positions (immediately before their include blocks).

### New checker opt-outs (with mandatory reason strings)
The two structural issues below have legitimate technical rationales that
predate the linter. Rather than restructure driver code as part of a lint
cleanup, added minimal file-level opt-outs to UnityBuildChecker:

1. **`UNITY_BUILD_EXCLUDE(<reason>)`** — declared in a `.cpp.hpp` file's
   first 15 lines. Marks the file as intentionally NOT part of the unity
   build. Applied to `i2s_peripheral_esp32dev_esp.cpp.hpp` whose Stage-4
   `driver/gpio.h` symbol set collides with the restored classic driver
   as `ADC: CONFLICT!` at boot. Design rationale is documented in the
   `_build.cpp.hpp` header comment; the marker points reviewers to it.

2. **`UNITY_BUILD_ORDER(<reason>)`** — declared in a `_build.cpp.hpp` file.
   Suppresses the alphabetical-order check for cases where compile-order
   dependency forces non-alphabetical include. Applied to
   `platforms/arm/lpc/drivers/sct_dma/_build.cpp.hpp` where
   `lpc_sct_dma_runtime.cpp.hpp` must precede `channel_engine_lpc_sct_dma.cpp.hpp`
   because the engine instantiates `LpcSctDmaTransmitter` (from runtime)
   as a data member.

Both markers require a non-empty reason argument so the rationale is
visible at every review site.

## Verification

- `bash lint --cpp`: ✅ All C++ linting checks passed
- `bash test --cpp`: 344/344 pass

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
@zackees
zackees merged commit 0e42532 into master Jul 1, 2026
8 of 10 checks passed
@coderabbitai

coderabbitai Bot commented Jul 1, 2026 •

Copy link
Copy Markdown

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: ddae7883-15be-4573-98c1-6e782fe733c7

📥 Commits

Reviewing files that changed from the base of the PR and between 80167aa and f1216e6.

📒 Files selected for processing (12)
  • ci/lint_cpp_rs/src/checkers/unity_build.rs
  • examples/AutoResearch/AutoResearchPwmDmaClockless.h
  • src/platforms/arm/lpc/_build.cpp.hpp
  • src/platforms/arm/lpc/channel_drivers_lpc.impl.hpp
  • src/platforms/arm/lpc/drivers/_build.cpp.hpp
  • src/platforms/arm/lpc/drivers/sct_dma/_build.cpp.hpp
  • src/platforms/arm/lpc/drivers/sct_dma/lpc_sct_dma_runtime.h
  • src/platforms/arm/lpc/spi_arm_lpc_dma.h
  • src/platforms/esp/32/drivers/i2s/i2s_peripheral_esp32dev_esp.cpp.hpp
  • src/platforms/esp/32/drivers/rmt/rmt_4/rmt_memory_manager_4.h
  • src/platforms/esp/32/drivers/rmt_rx/rmt_rx_4/rmt_rx_channel_4.cpp.hpp
  • tests/platforms/arm/lpc/drivers/sct_dma/channel_engine_lpc_sct_dma.cpp

📝 Walkthrough

Walkthrough

This PR adds UNITY_BUILD_EXCLUDE and UNITY_BUILD_ORDER suppression logic to the unity build checker, restructures LPC platform unity-build headers by introducing a new drivers subdirectory header, adds an is_arm.h include, and makes minor comment/formatting-only changes across several ESP32 and LPC driver files.

Changes

Unity Build Checker Opt-outs

Layer / File(s) Summary
Exclude/order marker suppression
ci/lint_cpp_rs/src/checkers/unity_build.rs
Adds detection of UNITY_BUILD_EXCLUDE in the first 15 lines to suppress missing-include violations for single-file and whole-project completeness checks, and detection of UNITY_BUILD_ORDER to skip alphabetical include ordering validation.

LPC Unity Build Restructuring and Platform Header Updates

Layer / File(s) Summary
LPC unity-build header restructuring
src/platforms/arm/lpc/_build.cpp.hpp, src/platforms/arm/lpc/drivers/_build.cpp.hpp, src/platforms/arm/lpc/drivers/sct_dma/_build.cpp.hpp
Reorganizes includes into current/sub-directory sections and adds a new intermediate drivers unity-build header that routes to the sct_dma unity header, with clarified include-ordering comments.
LPC driver supporting changes
src/platforms/arm/lpc/channel_drivers_lpc.impl.hpp, src/platforms/arm/lpc/drivers/sct_dma/lpc_sct_dma_runtime.h, src/platforms/arm/lpc/spi_arm_lpc_dma.h, examples/AutoResearch/AutoResearchPwmDmaClockless.h
Adds an is_arm.h include, simplifies a span construction, adds clarifying comments around reinterpret_cast expressions and an include, without changing logic.
ESP32 driver comment updates
src/platforms/esp/32/drivers/i2s/i2s_peripheral_esp32dev_esp.cpp.hpp, src/platforms/esp/32/drivers/rmt/rmt_4/rmt_memory_manager_4.h, src/platforms/esp/32/drivers/rmt_rx/rmt_rx_4/rmt_rx_channel_4.cpp.hpp
Adds a UNITY_BUILD_EXCLUDE rationale comment, reformats a method declaration, and clarifies a factory return statement, with no behavior changes.

Estimated code review effort: 2 (Simple) | ~12 minutes

Possibly related PRs

  • FastLED/FastLED#3243: Related to the same unity build alphabetical ordering validation logic changed in this PR.
  • FastLED/FastLED#3478: Touches the same ESP32 i2s stage-4 unity-build exclusion setup and i2s_peripheral_esp32dev_esp.cpp.hpp file.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch chore/lint-cleanup-preexisting

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@fastled-project-sync fastled-project-sync Bot moved this to Triage in FastLED Tracker Jul 1, 2026
@fastled-project-sync fastled-project-sync Bot moved this from Triage to Done in FastLED Tracker Jul 1, 2026
@zackees
zackees deleted the chore/lint-cleanup-preexisting branch August 21, 2026 19:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

1 participant