Skip to content

fix: resolve all remaining clang-tidy violations — threshold to 0#236

Merged
vtz merged 4 commits intomainfrom
feat/clang-tidy-batch9
Apr 18, 2026
Merged

fix: resolve all remaining clang-tidy violations — threshold to 0#236
vtz merged 4 commits intomainfrom
feat/clang-tidy-batch9

Conversation

@vtz
Copy link
Copy Markdown
Owner

@vtz vtz commented Apr 18, 2026

Summary

Eliminates all 168 remaining clang-tidy violations, bringing the quality gate threshold from 170 → 0.

Rule of Five (88 violations → 0)

  • Delete copy/move on 20+ non-copyable classes (Pimpl impls, interfaces, RAII wrappers, registries)
  • Default move on Deserializer (used by tests via move assignment)

Code fixes (8 violations → 0)

  • Convert SOMEIP_INVALID_SOCKET macro to constexpr (macro-to-enum)
  • Rename namespace E2ECRCe2ecrc (lower_case convention, readability-identifier-naming)
  • Rename static constant tableCRC32_TABLE (UPPER_CASE convention)

Targeted NOLINT suppressions (72 violations → 0)

  • fcntl() vararg calls — POSIX API, unavoidable
  • Reference data member lk_ in RAII helper — design choice
  • CRC table lookups with non-constant indices
  • Platform memory pool globals (FreeRTOS/ThreadX runtime state)
  • Platform macros for pool size configuration
  • SD option/entry static_cast downcasts — type-safe by protocol field
  • ThreadX TX_DISABLE macro — SDK API
  • Placement new for platform memory — owning-memory

Test plan

  • All 15 host tests pass locally
  • CI builds pass (Ubuntu gcc/clang, Windows, Fedora)
  • clang-tidy quality gate passes with threshold = 0
  • Pre-commit validation passes
  • FreeRTOS / ThreadX / Zephyr builds pass

Made with Cursor

Summary by CodeRabbit

  • Refactor

    • Strengthened object lifecycle constraints across multiple components to prevent unintended copying or moving
    • Renamed E2E CRC function namespace from E2ECRC to e2ecrc
  • Chores

    • Reset clang-tidy baseline for enhanced code quality checks
    • Converted socket constant from macro to constexpr for improved type safety
    • Added lint annotations to reduce static analysis noise

Rule of Five (special-member-functions):
- Delete copy/move on 20+ non-copyable classes (Pimpl impls, interfaces,
  RAII wrappers, registries)
- Default move on Deserializer (used by tests via move assignment)

Code fixes:
- Convert SOMEIP_INVALID_SOCKET macro to constexpr
- Rename namespace E2ECRC -> e2ecrc (lower_case convention)
- Rename static constant table -> CRC32_TABLE (UPPER_CASE convention)

Targeted NOLINT suppressions for unavoidable violations:
- fcntl() vararg calls (POSIX API)
- Reference data member in RAII helper (design choice)
- CRC table lookups with non-constant indices
- Platform memory pool globals (FreeRTOS/ThreadX runtime state)
- Platform macros for pool size configuration
- SD option/entry static_cast downcasts (type-safe by protocol)
- ThreadX TX_DISABLE macro (SDK API)
- Placement new for platform memory (owning-memory)

Lowers baseline threshold from 170 to 0.
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 18, 2026

📝 Walkthrough

Walkthrough

This pull request enforces stricter object ownership semantics across the codebase by explicitly deleting copy and move constructors/assignment operators in numerous classes, reduces clang-tidy baseline warnings from 170 to 0, renames the E2ECRC namespace to e2ecrc, and adds NOLINT annotations to suppress specific linter warnings throughout the implementation.

Changes

Cohort / File(s) Summary
Clang-tidy baseline and suppressions
clang-tidy-baseline.txt, include/platform/threadx/memory_internal.h, src/platform/freertos/memory.cpp, src/platform/threadx/memory.cpp, src/e2e/e2e_crc.cpp
Reduced clang-tidy baseline from 170 to 0; added NOLINTNEXTLINE annotations to suppress warnings for non-const globals, macro usage, and owning-memory guidelines across platform and e2e modules.
E2E CRC namespace refactoring
include/e2e/e2e_crc.h, src/e2e/e2e_crc.cpp, src/e2e/e2e_profiles/standard_profile.cpp, tests/shared/test_e2e_common.inc, tests/test_e2e.cpp
Renamed namespace from someip::e2e::E2ECRC to someip::e2e::e2ecrc; renamed internal CRC-32 lookup table from table to CRC32_TABLE; updated all function call sites and tests to use new namespace qualification.
Core and platform class hardening
include/core/session_manager.h, include/platform/host/host_condition_variable.h, include/platform/posix/net_impl.h, include/platform/thread.h
Added deleted move constructor/assignment operators to SessionManager and ScopedLock; added default destructor and deleted move operations to ConditionVariable; converted SOMEIP_INVALID_SOCKET from macro to typed constexpr and added NOLINT suppressions for fcntl calls.
E2E profile and protection classes
include/e2e/e2e_profile.h, include/e2e/e2e_profile_registry.h, include/e2e/e2e_protection.h
Deleted copy/move constructors and assignment operators; added protected default constructor to E2EProfile to restrict direct instantiation while preserving virtual interface; made E2EProfileRegistry and E2EProtection non-copyable and non-movable.
SD message base classes
include/sd/sd_message.h
Deleted copy/move constructors and assignment operators for SdEntry and SdOption base classes to prevent duplication or transfer of managed instances.
Serialization classes
include/serialization/serializer.h
Made Serializer fully non-copyable and non-movable by deleting all special member functions; made Deserializer non-copyable but explicitly allowed move operations via = default.
Transport interface and implementation classes
include/transport/transport.h, include/transport/udp_transport.h
Deleted copy/move constructors and assignment operators; added protected default constructors to ITransportListener and ITransport interface classes; made UdpTransport explicitly non-movable.
Event and RPC private implementation classes
src/events/event_publisher.cpp, src/events/event_subscriber.cpp, src/rpc/rpc_client.cpp, src/rpc/rpc_server.cpp
Deleted copy/move constructors and assignment operators in all private implementation classes to enforce non-transferable ownership of internal state.
SD client/server with downcast annotations
src/sd/sd_client.cpp, src/sd/sd_server.cpp
Made SdClientImpl and SdServerImpl non-copyable and non-movable; added NOLINTNEXTLINE annotations for multiple static_cast downcasts from base entry/option types to concrete derived types.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~22 minutes

Possibly related PRs

Poem

🐰 Hopping through the code with care,
Move and copy? They shan't be there!
Namespaces dance from E2ECRC to e2ecrc's grace,
NOLINT notes keep lint at bay—what a productive pace! 🚀

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 45.56% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The pull request title 'fix: resolve all remaining clang-tidy violations — threshold to 0' accurately and concisely describes the main objective: eliminating all remaining clang-tidy violations and lowering the threshold to zero.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ 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 feat/clang-tidy-batch9

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 and usage tips.

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 924b1e4728

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread include/e2e/e2e_crc.h
* - CRC32: Standard 32-bit CRC
*/
namespace someip::e2e::E2ECRC {
namespace someip::e2e::e2ecrc {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Preserve old E2ECRC namespace alias

Renaming the public namespace from someip::e2e::E2ECRC to someip::e2e::e2ecrc is a source-breaking API change for downstream users: any existing code that calls E2ECRC::calculate_crc* will stop compiling immediately after upgrading, even though this commit is framed as a clang-tidy cleanup. Please keep backward compatibility by adding an alias (for example, keeping E2ECRC as a compatibility namespace) instead of removing the old symbol path outright.

Useful? React with 👍 / 👎.

NOLINTNEXTLINE doesn't cover the variable name on the continuation
line; switch to inline NOLINT on the line with the diagnostic.
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 4

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
include/e2e/e2e_crc.h (1)

30-75: ⚠️ Potential issue | 🟠 Major

Document or mitigate the public namespace breaking change.

All in-repo call sites have been updated to use the new lowercase namespace e2ecrc::, but external consumers of this public header will fail to compile. No changelog entry, deprecation warning, or compatibility alias exists to support migration. Either add a temporary compatibility namespace alias with appropriate documentation, or add a migration notice to CHANGELOG.md if this is an intentional breaking release.

Compatibility option
 }  // namespace someip::e2e::e2ecrc
+
+namespace someip::e2e {
+// NOLINTNEXTLINE(readability-identifier-naming) - Compatibility alias for the pre-rename public namespace.
+namespace E2ECRC = e2ecrc;
+}  // namespace someip::e2e
 
 `#endif` // E2E_CRC_H
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@include/e2e/e2e_crc.h` around lines 30 - 75, The public header moved the
namespace to someip::e2e::e2ecrc which breaks external consumers; add a
temporary compatibility alias (and brief deprecation comment) that re-exports
the new namespace under the old name so external code still compiles, and add a
short migration note in CHANGELOG.md; specifically, in the header where
namespace someip::e2e::e2ecrc is declared, add a backward-compatible alias/using
for the previous namespace name (and a comment marking it deprecated) so symbols
like calculate_crc8_sae_j1850, calculate_crc16_itu_x25, calculate_crc32, and
calculate_crc remain available under the old namespace while you document the
removal timeline in CHANGELOG.md.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@include/serialization/serializer.h`:
- Around line 120-123: The Serializer class currently deletes the move
constructor and move assignment even though it only owns a std::vector<uint8_t>
and exposes move_buffer(), which prevents idiomatic moves and is asymmetric with
Deserializer; change the move operations (Serializer(Serializer&&) and
Serializer& operator=(Serializer&&)) from deleted to defaulted so the class
remains movable (i.e., use = default for the move ctor/assignment) while keeping
copy ops deleted and retaining move_buffer() behavior.

In `@src/sd/sd_client.cpp`:
- Around line 215-218: The code is performing an unnecessary downcast to
EventGroupEntry to call set_index1/set_num_opts1 (these are members of SdEntry);
remove the static_cast and NOLINT and instead set those fields on the derived
unique_ptr before it is moved into sd_message. Locate where the EventGroupEntry
unique_ptr is created (the variable passed into sd_message.get_entries() or the
point where you construct the entry prior to insertion) and call
entry->set_index1(0) and entry->set_num_opts1(1) on that unique_ptr (type
EventGroupEntry or std::unique_ptr<SdEntry>), then move it into sd_message so no
cast or lint suppression is needed.

In `@src/sd/sd_server.cpp`:
- Around line 396-399: In send_service_offer (and similarly in
send_service_offer_to_client) remove the unnecessary static_cast and NOLINT by
setting the SdEntry fields directly on the local offer_entry object (call
offer_entry->set_index1(0) and offer_entry->set_num_opts1(1)) before calling
sd_message.add_entry(std::move(offer_entry)); this eliminates the downcast to
ServiceEntry* and the need for NOLINT while preserving the same behavior.
- Around line 236-239: The code is performing an unnecessary downcast to
EventGroupEntry to call set_index1/set_num_opts1 which are defined on the
SdEntry base class; remove the static_cast<EventGroupEntry*> and the NOLINT, and
instead set_index1(...) and set_num_opts1(...) directly on the response_entry
object before it is moved into response_message (mirror the fix done in
sd_client.cpp's subscribe_eventgroup). Ensure you update the code to call
response_entry->set_index1(0) and response_entry->set_num_opts1(1) (or the
equivalent variable) prior to adding it to response_message.get_entries().

---

Outside diff comments:
In `@include/e2e/e2e_crc.h`:
- Around line 30-75: The public header moved the namespace to
someip::e2e::e2ecrc which breaks external consumers; add a temporary
compatibility alias (and brief deprecation comment) that re-exports the new
namespace under the old name so external code still compiles, and add a short
migration note in CHANGELOG.md; specifically, in the header where namespace
someip::e2e::e2ecrc is declared, add a backward-compatible alias/using for the
previous namespace name (and a comment marking it deprecated) so symbols like
calculate_crc8_sae_j1850, calculate_crc16_itu_x25, calculate_crc32, and
calculate_crc remain available under the old namespace while you document the
removal timeline in CHANGELOG.md.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 64764b37-449b-4c18-8481-74448aff3f0b

📥 Commits

Reviewing files that changed from the base of the PR and between 82f9ffd and 924b1e4.

📒 Files selected for processing (26)
  • clang-tidy-baseline.txt
  • include/core/session_manager.h
  • include/e2e/e2e_crc.h
  • include/e2e/e2e_profile.h
  • include/e2e/e2e_profile_registry.h
  • include/e2e/e2e_protection.h
  • include/platform/host/host_condition_variable.h
  • include/platform/posix/net_impl.h
  • include/platform/thread.h
  • include/platform/threadx/memory_internal.h
  • include/sd/sd_message.h
  • include/serialization/serializer.h
  • include/transport/transport.h
  • include/transport/udp_transport.h
  • src/e2e/e2e_crc.cpp
  • src/e2e/e2e_profiles/standard_profile.cpp
  • src/events/event_publisher.cpp
  • src/events/event_subscriber.cpp
  • src/platform/freertos/memory.cpp
  • src/platform/threadx/memory.cpp
  • src/rpc/rpc_client.cpp
  • src/rpc/rpc_server.cpp
  • src/sd/sd_client.cpp
  • src/sd/sd_server.cpp
  • tests/shared/test_e2e_common.inc
  • tests/test_e2e.cpp

Comment thread include/serialization/serializer.h Outdated
Comment thread src/sd/sd_client.cpp Outdated
Comment thread src/sd/sd_server.cpp Outdated
Comment thread src/sd/sd_server.cpp Outdated
vtz added 2 commits April 18, 2026 15:01
- Add backward-compatible E2ECRC namespace alias for API stability
- Default Serializer move operations instead of deleting
- Eliminate 4 unnecessary static_cast downcasts in SD client/server
  by setting index/opts before moving entry into message
- Fix NOLINT placement for multi-line pool_buffer declarations
Platform files (FreeRTOS, ThreadX) produce compilation errors in the
CI clang-tidy environment because SDK headers are unavailable. These
are not clang-tidy check violations and should not count against the
quality gate threshold.
@vtz vtz merged commit a5c83f7 into main Apr 18, 2026
43 checks passed
@vtz vtz deleted the feat/clang-tidy-batch9 branch April 18, 2026 20:48
@vtz vtz mentioned this pull request Apr 18, 2026
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