Skip to content

fix: remediate clang-tidy violations batch 8 — lower threshold to 175#234

Merged
vtz merged 2 commits intomainfrom
feat/clang-tidy-batch8
Apr 18, 2026
Merged

fix: remediate clang-tidy violations batch 8 — lower threshold to 175#234
vtz merged 2 commits intomainfrom
feat/clang-tidy-batch8

Conversation

@vtz
Copy link
Copy Markdown
Owner

@vtz vtz commented Apr 18, 2026

Summary

  • misc-const-correctness (59 violations): Add const to 20+ variables across 14 files (headers like message.h and net_impl.h are counted multiple times across translation units)
  • bugprone-unchecked-optional-access (1): Guard DeserializationResult::get_value()/move_value() with has_value() check
  • readability-implicit-bool-conversion (1): Explicit != 0U comparison in CRC bitmask check
  • misc-include-cleaner (1): Add missing e2e/e2e_profile.h include for E2EProfilePtr
  • cppcoreguidelines-avoid-do-while (2): Convert EINTR retry do-while loops to equivalent while loops in UDP transport

Threshold lowered from 384 → 175 (estimated ~64 violations eliminated).

Test plan

  • All 15 host tests pass locally
  • CI builds pass (Ubuntu gcc, Ubuntu clang, Windows)
  • clang-tidy quality gate passes with new threshold
  • Pre-commit validation passes

Made with Cursor

Summary by CodeRabbit

Release Notes

  • Bug Fixes

    • Enhanced error handling in the serialization layer to improve robustness when processing invalid data.
    • Refined network transport retry logic for improved reliability and consistency.
  • Chores

    • Improved static analysis compliance and code quality standards throughout the codebase.

This release focuses on internal code quality improvements and robustness enhancements without introducing new user-facing features.

- misc-const-correctness: add const to 20+ variables across 14 files
  (headers counted multiple times across TUs)
- bugprone-unchecked-optional-access: guard optional access in serializer
- readability-implicit-bool-conversion: explicit != 0U in CRC check
- misc-include-cleaner: add missing e2e_profile.h include
- cppcoreguidelines-avoid-do-while: convert EINTR retry loops to while

Lowers baseline threshold from 384 to 175.
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 18, 2026

📝 Walkthrough

Walkthrough

This PR applies const-correctness improvements across 15 files, making local variables immutable where appropriate. Additionally, UDP transport retry logic is refactored from do-while to conditional while patterns, and DeserializationResult now explicitly aborts when accessing unset values. The clang-tidy baseline metric decreases from 384 to 175.

Changes

Cohort / File(s) Summary
Clang-tidy Baseline
clang-tidy-baseline.txt
Updated baseline metric from 384 to 175, reflecting accumulated code quality improvements.
Platform Network
include/platform/posix/net_impl.h
Changed local fcntl result variable from int to const int in someip_set_nonblocking and someip_set_blocking functions.
Serialization Core
include/serialization/serializer.h, src/serialization/serializer.cpp
Updated DeserializationResult::get_value() and move_value() to explicitly check value presence and call std::abort() when unset; added #include <cstdlib>; tightened const-qualification of local variables.
Message Handling
include/someip/message.h, src/someip/message.cpp
Changed e2e_size and related length variables to const in get_total_size(), deserialize(), has_valid_header(), and update_length() functions.
E2E Profile
src/e2e/e2e_crc.cpp, src/e2e/e2e_profile_registry.cpp
Updated CRC32 table generation condition to explicit non-zero comparison; added missing include for e2e/e2e_profile.h.
Events & RPC
src/events/event_subscriber.cpp, src/rpc/rpc_client.cpp, src/rpc/rpc_server.cpp
Applied const-qualification to subscription keys, response message variable, and scope-guard objects without changing control flow or synchronization logic.
Service Discovery
src/sd/sd_client.cpp, src/sd/sd_message.cpp
Tightened const-qualification for service lookup variables and network byte-order conversion temporary without altering serialization or subscription logic.
Transport Layer
src/transport/tcp_transport.cpp, src/transport/udp_transport.cpp, src/tp/tp_reassembler.cpp
Applied const-qualification to socket descriptors, byte counts, and loop variables; refactored UDP transport retry logic from do-while to initial-call-plus-while pattern for EINTR handling in send_data() and receive_data().

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Possibly related PRs

Poem

🐰 Whiskers twitch with const delight,
Variables now locked down tight,
Const by const, we clean the code,
No mutations on this road!

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 55.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 title clearly and specifically summarizes the main change: remediating clang-tidy violations and lowering the threshold from 384 to 175.
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-batch8

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
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: 1

🤖 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 80-95: The change from throwing std::bad_optional_access to
calling std::abort() in get_value() and move_value() is a breaking API change
for external consumers; revert to the previous exception behavior (throw
std::bad_optional_access when value_ is empty) or, if abort-like behavior is
desired only in debug builds, replace the unconditional std::abort() with a
debug-only assertion (e.g., assert(value_.has_value())) and throw
std::bad_optional_access in release builds; update the public API
contract/comments on get_value() and move_value() to document the chosen
behavior so downstream users know whether they must handle exceptions or if the
call is fatal.
🪄 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: e66d89cd-97a4-4ee5-8dd8-e4f585978ee2

📥 Commits

Reviewing files that changed from the base of the PR and between d0e3a50 and 2f05a57.

📒 Files selected for processing (16)
  • clang-tidy-baseline.txt
  • include/platform/posix/net_impl.h
  • include/serialization/serializer.h
  • include/someip/message.h
  • src/e2e/e2e_crc.cpp
  • src/e2e/e2e_profile_registry.cpp
  • src/events/event_subscriber.cpp
  • src/rpc/rpc_client.cpp
  • src/rpc/rpc_server.cpp
  • src/sd/sd_client.cpp
  • src/sd/sd_message.cpp
  • src/serialization/serializer.cpp
  • src/someip/message.cpp
  • src/tp/tp_reassembler.cpp
  • src/transport/tcp_transport.cpp
  • src/transport/udp_transport.cpp

Comment thread include/serialization/serializer.h
@vtz vtz merged commit 82f9ffd into main Apr 18, 2026
43 checks passed
@vtz vtz deleted the feat/clang-tidy-batch8 branch April 18, 2026 13:45
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