Skip to content

Fix the Clang-Tidy warnings flagged by Android Studio - #30

Merged
jpcottin merged 1 commit into
mainfrom
fix/clang-tidy-warnings
Aug 2, 2026
Merged

Fix the Clang-Tidy warnings flagged by Android Studio#30
jpcottin merged 1 commit into
mainfrom
fix/clang-tidy-warnings

Conversation

@jpcottin

@jpcottin jpcottin commented Aug 2, 2026

Copy link
Copy Markdown
Owner

Fixes all the Clang-Tidy warnings that Android Studio's default inspection profile reports on the native sources (app code and tests), with no behavior change:

  • Narrowing conversions (int / uint32_t → float): explicit (float) casts, matching the existing cast style.
  • Uninitialized record types: default member initializers on the small POD structs (Alien, Bullet, Bomb, Saucer, PowerUp, Particle, Explosion, Star, Pointer, DrawCmd), plus {} on the high-score fread buffers and the timespec in now_s().
  • readability-use-anyofallof: fireHeld() now uses std::any_of.
  • modernize-loop-convert: the duplicate-check loop in mergeHighScore() is now a range-based for.
  • const/static suggestions: emit() and all the draw helpers are now const (they only append to the caller's DrawCmd list), numDigits() is static.
  • audio_stub.cpp: targeted NOLINT — the stub ignores this, but the real AudioEngine::init in audio.cpp can't be static, so the suggestion is a stub-only false positive.

The words flagged as typos (frand, SINV, octo, highscores, …) are intentional identifiers and are deliberately left unchanged.

Verified with clang-tidy from NDK r29 (same checks + project-wide header filter: 0 warnings after), externalNativeBuildDebug, runNativeTests on the Fold AVD (103/103 pass), and an on-emulator smoke run — the title screen renders identically.

All 66 warnings from the default inspection profile, no behavior change:
- narrowing int/uint32_t-to-float conversions: explicit (float) casts
- uninitialized record types: default member initializers on the small
  POD structs (Alien, Bullet, Bomb, Saucer, PowerUp, Particle, Explosion,
  Star, Pointer, DrawCmd) and {} on the fread buffers / timespec
- fireHeld: loop replaced with std::any_of
- mergeHighScore: index loop replaced with a range-based for
- emit and the draw helpers made const, numDigits made static

Intentional identifiers flagged as typos (frand, SINV, octo, ...) are
left as-is on purpose.
@jpcottin
jpcottin merged commit 11c874d into main Aug 2, 2026
14 checks passed
@jpcottin
jpcottin deleted the fix/clang-tidy-warnings branch August 2, 2026 23:37
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.

1 participant