Skip to content

clang-tidy: the 54 deferred checks of twenty findings or fewer, 39 on and 15 off for good - #181

Merged
theAndreas merged 2 commits into
mainfrom
tidy/small-tail
Nov 14, 2026
Merged

theAndreas merged 2 commits into
mainfrom
tidy/small-tail

Conversation

@theAndreas

@theAndreas theAndreas commented Nov 14, 2026 •

Copy link
Copy Markdown
Owner

Stacked on #180, which makes main green again; merge that first and this one retargets to main.

The survey of #175 left 54 checks in the "for now" list with twenty findings or fewer, about 350 in all across the three targets, the host tests and the fuzzers. Each check is settled here: 40 are now on with what they found fixed, and 14 are off for good with a reason in .clang-tidy. All 54 leave the count list. The three bigger checks that sat between them (avoid-const-or-ref-data-members, math-missing-parentheses, redundant-member-init) stay deferred, as before.

What the checks found that was worth more than style

  • bugprone-derived-method-shadowing-base-method: OverlayDate, -Temperature and -Text each had a Task() that hid Overlay::Task(), and all three did the same thing: restart the text once it had scrolled through. That now lives in Overlay behind a fifth CRTP hook, SetText(). A call through the base can no longer skip it, and the three copies are gone.
  • clang-diagnostic-undef: MsgCmdDisplayPixelParser sized -I by WS2812_NUMBER_OF_LEDS, which nothing defines. The comment beside it admitted as much. It now reads DISPLAY_NUMBER_OF_LEDS. At 110 LEDs the type stays uint8, so behaviour does not change.
  • readability-function-cognitive-complexity: the eight functions above 15 are split into named steps, as CLAUDE.md asks.

Off for good, and why not the obvious fix

Check Reason
bugprone-throwing-static-initialization cert-err58-cpp's other name, already off
clang-diagnostic-enum-enum-conversion wx flags and the AVR vendor header's group configs are ORed enumerations by design
cppcoreguidelines-avoid-do-while the at-least-once loop is a do-while
cppcoreguidelines-pro-type-reinterpret-cast registers, the settings blob, sockets, F() strings; memcpy only hides the cast
cppcoreguidelines-pro-type-vararg snprintf is the formatting every target has
cppcoreguidelines-use-enum-class StdReturnType (CLAUDE.md's exception) and wx window ids
google-runtime-int / -float every finding is someone else's name: millis(), Print, the std stand-in
misc-non-private-member-variables-in-classes animation and overlay state is meant to be driven by the derived classes
modernize-raw-string-literal it converts half of a JSON writer, the fragments with three escapes
readability-redundant-casting redundant where int is 16 bits (AVR), needed where it is 32
readability-suspicious-call-argument name-similarity false positives on WriteBit
readability-use-anyofallof / -use-std-min-max <algorithm> is not in the AVR's std

readability-redundant-typename stays on. Two of its findings were in a non-template class and are fixed. The third was only redundant in C++20, which leads to the next section.

The ESP32 was C++20

platformio.ini said C++17 but only unflagged -std=gnu++11. The framework's cpp_flags append -std=gnu++2b -std=gnu++2a after our -std=gnu++17, and the last one wins. So the ESP32 firmware, and its clang-tidy database with it, was C++20. The AVR, the RP2350, the simulator and the tests are all C++17. Both flags are now unflagged too:

  • The firmware builds without a warning, at +8 bytes of flash.
  • The typename NOLINT is gone.
  • modernize-use-constraints is on: it finds nothing in C++17.
  • One difference that C++20 had hidden turned up: std::atomic<int> value-initialises itself only in C++20, so the web interface's client table gets {}.

Measured

  • tools/tidy.sh: no findings on avr128da48, esp32, rp2350, the host tests and the fuzzers.
  • make lint, make headers, cmake --workflow --preset default, make host-esp32 host-rp2350: pass.
  • Firmware: ci-avr (warnings as errors), plus pio run for both esp32 and rp2350, build cleanly.
  • AVR flash: 18 bytes less than clang-tidy on main again: the backends' findings of the five checks #176 turned on #180 (42 978 vs 42 996 text); data and bss unchanged.

clang-tidy's -fix was used for the mechanical checks. Where the overlapping fixes from several translation units broke an initialiser list, the code was repaired by hand. Every hunk was read.

🤖 Generated with Claude Code

… and 15 off for good

The survey of #175 left 54 checks of the "for now" list with twenty findings or fewer, some 350
across the three targets, the host tests and the fuzzers. Each is answered here, and all 54
leave the count list.

On, with what they found fixed:
- bugprone-derived-method-shadowing-base-method: OverlayDate, -Temperature and -Text each had a
  Task() that hid Overlay::Task() and did the same thing - restart the text once it had scrolled
  through. That is Overlay's now, through a fifth CRTP hook, SetText(); a call through the base
  can no longer skip it, and the three copies are gone.
- clang-diagnostic-undef: MsgCmdDisplayPixelParser sized -I by WS2812_NUMBER_OF_LEDS, which
  nothing defines, so the comment beside it admitted the type was uint8 whatever the strip. It
  reads DISPLAY_NUMBER_OF_LEDS now; at 110 LEDs the type is uint8 as before.
- readability-function-cognitive-complexity: the eight functions above 15 are split into named
  steps, the way CLAUDE.md asks - WriteOption() out of WriteCommands(), the two directions of
  AnimationSqueeze::ClearRow(), ShiftColumnTowardsCenter(), Text::SetFontIndex(), the message
  builder's FillOptionRow(), and the roll and colour-wheel tests' own helpers.
- clang-diagnostic-deprecated-copy-with-dtor: the defaulted destructors of five value types,
  which said nothing and cost them their implicit copies' standing.
- modernize-type-traits: the AVR's stand-in for <type_traits> gains the _v templates, and the
  core uses them; the stand-in's own definitions of _t and _v carry a NOLINT, being what the
  check asks for.
- readability-redundant-typename: two were in a class that is no template; the third is needed
  in C++17 and is only redundant to the ESP32's database, which reads as C++23, so it has a
  NOLINT.
- the mechanical rest by clang-tidy's own fixes, repaired by hand where the overlapping fixes
  of several translation units broke a constructor's initialiser list: isolate-declaration,
  simplify-boolean-expr, redundant-nested-if, -parentheses, -access-specifiers, loop-convert,
  use-default-member-init, prefer-member-initializer, pro-type-member-init, use-using,
  use-override, use-nullptr, implicit-bool-conversion and the like.
- NOLINT with its reason where the code is right: a self-comparison that is the test, the XPM
  icon, wx's protected virtual destructors, the one recursion of the simulator's decoder, the
  stateless second base of MsgCmdOverlayParser, the rp2350 core's global __FlashStringHelper,
  GPIO_OUT, and Itoa, whose likeness to ltoa is the C library's.
- cppcoreguidelines-avoid-non-const-global-variables with AllowInternalLinkage, so a module's
  state in an anonymous namespace is the file's own.

Off for good, each with its reason in .clang-tidy: bugprone-throwing-static-initialization
(cert-err58-cpp's other name), clang-diagnostic-enum-enum-conversion, cppcoreguidelines-avoid-
do-while, -pro-type-reinterpret-cast, -pro-type-vararg, -use-enum-class, google-runtime-int and
-float, misc-non-private-member-variables-in-classes, modernize-raw-string-literal,
-use-constraints, readability-redundant-casting, -suspicious-call-argument, -use-anyofallof and
-use-std-min-max.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Base automatically changed from tidy/fix-main to main November 14, 2026 09:16
platformio.ini said C++17 and unflagged -std=gnu++11, but the framework's cpp_flags put
-std=gnu++2b and -std=gnu++2a after the project's -std=gnu++17, and the last one wins: the ESP32
firmware was C++20, and so was its clang-tidy database, while the AVR, the RP2350, the
simulator and the tests are C++17. Both flags are unflagged now. The firmware builds without a
warning, 8 bytes of flash larger.

What C++20 had papered over: std::atomic<int> value-initialises itself there and not in C++17,
so the web interface's client table is initialised with {} now (the constructor writes every
slot anyway; cppcoreguidelines-pro-type-member-init found it).

What it had caused: the NOLINT on the typename of MsgCmdOverlayParser, redundant only to C++20,
is gone, and modernize-use-constraints, which only reported where requires exists, is on - it
finds nothing in C++17. The previous commit called the ESP32's dialect C++23; it was C++20.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@theAndreas
theAndreas merged commit d6dfc8f into main Nov 14, 2026
14 checks passed
@theAndreas
theAndreas deleted the tidy/small-tail branch November 14, 2026 09:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants