Skip to content

fix: remediate remaining clang-tidy violations + Allure integration (batch 7)#232

Open
vtz wants to merge 3 commits intomainfrom
feat/clang-tidy-batch7
Open

fix: remediate remaining clang-tidy violations + Allure integration (batch 7)#232
vtz wants to merge 3 commits intomainfrom
feat/clang-tidy-batch7

Conversation

@vtz
Copy link
Copy Markdown
Owner

@vtz vtz commented Apr 15, 2026

Summary

  • Lower quality-gate baseline from 1783 to 384 (78.5% total reduction across batches 1-7)
  • Fix hicpp-use-equals-delete (6): Move deleted copy/assignment to public in session_manager.h, e2e_profile_registry.h, udp_transport.h
  • Fix hicpp-signed-bitwise (4): Use unsigned shift counts (16U) in types.h
  • Fix misc-const-correctness (~50): Add const to unmodified variables across source files
  • Fix misc-include-cleaner (13): Remove unused includes (<unordered_map>, <iostream>, someip/types.h, e2e_config.h); add NOLINT suppression for platform::Mutex/sleep_for from thread.h abstraction
  • Fix bugprone-implicit-widening-of-multiplication-result (1): Explicit cast in net_impl.h
  • Fix performance-inefficient-vector-operation (3): Add reserve() before loop push_back
  • Fix hicpp-move-const-arg (2): Remove std::move from trivially-copyable E2EHeader
  • Fix modernize-use-auto (6) and modernize-use-emplace (1)
  • Add clang-tidy to Allure reporting: New scripts/clang_tidy_to_allure.py converts clang-tidy report to JUnit XML; CI workflow updated to upload as allure-results-clang-tidy artifact

Test plan

  • Full local build passes (all targets)
  • All unit tests pass (403 tests, 4 pre-existing flaky SD socket tests excluded)
  • CI builds pass (posix, FreeRTOS, ThreadX, Zephyr, Windows)
  • Quality gate passes with new baseline (384)
  • Allure integration produces valid JUnit XML artifact

Made with Cursor

Summary by CodeRabbit

  • New Features

    • CI now generates and uploads Allure-formatted clang-tidy reports, including an optional quality-gate threshold.
  • Bug Fixes

    • Adjusted message move behavior to ensure headers are preserved for recipients.
  • Chores

    • Updated clang-tidy baseline value.
    • Widespread const-correctness, type-safety and linting tweaks.
    • Minor performance improvements (pre-allocation, emplace usage) and cleanup.

- Lower quality-gate baseline from 1783 to 384 (78.5% reduction)
- Fix hicpp-use-equals-delete: move deleted members to public in 3 headers
- Fix hicpp-signed-bitwise: use unsigned shift counts in types.h
- Fix misc-const-correctness: add const to ~50 variables across source files
- Fix misc-include-cleaner: remove unused includes, add NOLINT suppression
  for platform::Mutex/sleep_for from thread.h abstraction layer
- Fix bugprone-implicit-widening-of-multiplication-result in net_impl.h
- Fix performance-inefficient-vector-operation: add reserve() in 3 files
- Fix hicpp-move-const-arg: remove std::move from trivially-copyable types
- Fix modernize-use-auto and modernize-use-emplace in sd_message/tcp_transport
- Add clang-tidy to Allure reporting via JUnit XML conversion script
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Apr 15, 2026

📝 Walkthrough

Walkthrough

Adds CI steps to convert clang-tidy text reports into Allure-compatible JUnit XML and upload them; updates clang-tidy baseline. Also applies widespread local const-correctness, small API-declaration relocations, minor casting/bit-packing fixes, unused-include removals, vector preallocation, and small move-semantics and emplace changes across source files.

Changes

Cohort / File(s) Summary
CI workflow & report conversion
​.github/workflows/clang-tidy.yml, scripts/clang_tidy_to_allure.py, clang-tidy-baseline.txt
Added two always-run CI steps: convert build/clang-tidy-report.txt → Allure JUnit XML via scripts/clang_tidy_to_allure.py (optional --threshold from first line of baseline), and upload allure-results/ as allure-results-clang-tidy. Baseline value changed from 1783384.
Deleted-copy declarations moved
include/core/session_manager.h, include/e2e/e2e_profile_registry.h, include/transport/udp_transport.h
Moved = delete copy constructor and copy-assignment declarations from private → public for three classes; semantics unchanged.
Casting & bit-packing fixes
include/platform/posix/net_impl.h, include/someip/types.h
Made socket timeout microsecond computation use static_cast<long>(...) * 1000L; changed integer shifts to unsigned literals (16U) for MessageId/RequestId packing/unpacking.
Allure converter script
scripts/clang_tidy_to_allure.py
New CLI: parses clang-tidy text report (file/line/message/check), deduplicates warnings per check, extracts summary metrics, builds JUnit XML with per-check testsuites and a clang-tidy/quality-gate testsuite (supports threshold failure), writes clang-tidy-results.xml to output dir.
Const-correctness & small refactors — E2E / profiles
src/e2e/e2e_crc.cpp, src/e2e/e2e_profile_registry.cpp, src/e2e/e2e_profiles/standard_profile.cpp
Marked loop/local variables const, removed unused include in registry, and minor indentation/const tweaks for CRC/profile code.
Const-correctness & reserve usage — events & RPC
src/events/event_publisher.cpp, src/events/event_subscriber.cpp, src/rpc/rpc_client.cpp, src/rpc/rpc_server.cpp
Marked multiple local variables const, added reserve() before pushing results, and added NOLINTBEGIN/END include-cleaner suppressions.
SD & transport minor edits
src/sd/sd_client.cpp, src/sd/sd_message.cpp, src/sd/sd_server.cpp, src/transport/tcp_transport.cpp, src/transport/udp_transport.cpp
Adjusted local constness/auto const spelling, removed unused includes, changed push({})emplace(...), reserved vector capacity in getters, and made receive result variables const.
Message move semantics
src/someip/message.cpp
Move constructor/operator now copy e2e_header_ instead of moving it; moved-from invalidation still applied.

Sequence Diagram(s)

sequenceDiagram
    participant CI as GitHub Actions (clang-tidy job)
    participant Report as clang-tidy report (`build/clang-tidy-report.txt`)
    participant Script as scripts/clang_tidy_to_allure.py
    participant Artifacts as GitHub Actions artifact storage (allure-results-clang-tidy)

    CI->>Report: run clang-tidy and upload raw report
    CI->>Script: run converter (reads Report, optional threshold from baseline)
    Script->>Script: parse warnings, group by check, build JUnit XML
    Script->>CI: write `allure-results/clang-tidy-results.xml`
    CI->>Artifacts: upload `allure-results/` as `allure-results-clang-tidy`
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Poem

🐰 With tidy hops I scan each line and mend,
I cast and const, and tidy includes I send,
Reports now bloom as Allure files so bright,
Baseline trimmed, CI uploads through the night,
Hoppy commits — linted, tidy, and light!

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 42.55% 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
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The PR title accurately summarizes the main objective: remediating clang-tidy violations and integrating Allure reporting, matching the extensive changes across the codebase.

✏️ 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-batch7

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

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@scripts/clang_tidy_to_allure.py`:
- Line 93: The testcase name f-string currently omits "threshold=0" due to
truthiness check; change the conditional to explicitly check threshold is not
None so threshold=0 is preserved—update the line building
name=f"violations={total}" + (f" threshold={threshold}" if threshold is not None
else "") (referencing the variables threshold and total used when constructing
the testcase name).
- Line 27: The file is opening the clang-tidy report with locale-dependent
decoding; update the open(report_path) call to use an explicit encoding (e.g.,
encoding="utf-8") so the file is read deterministically (optionally add
errors="replace" or errors="surrogateescape" if you want to tolerate invalid
bytes). Locate the open(report_path) usage in the script (the with
open(report_path) as f: line) and modify it to explicitly pass the encoding
parameter to ensure consistent decoding across CI runners.
- Line 17: Remove the unused import statement "import sys" from the top of the
module (the stray import sys line) so the file no longer references sys; simply
delete that import line to satisfy pre-commit/flake checks and keep the module
tidy.
- Around line 29-31: The current re.match that assigns m can miscapture
bracketed text inside the diagnostic message; update the regex used in the
re.match call so it anchors to the start and end of the line and explicitly
captures the final check token in square brackets (e.g., change the pattern to
require the trailing `[...]` at the end and use a character-class like `[^\]]+`
for that capture, while allowing the message capture to span internal brackets),
so the match reliably extracts filename, line, message, and the final check name
when called as m = re.match(..., line.strip()).

In `@src/events/event_subscriber.cpp`:
- Around line 182-183: The stored callback key and the lookup key are
inconsistent: callbacks are saved with make_field_key(service_id, instance_id,
event_id) but later looked up with make_field_key(service_id, 0, event_id), so
non-zero instance_id entries are never found. Fix by making key generation
consistent—either change the store to use make_field_key(service_id, 0,
event_id) when inserting into field_requests_ or change the lookup to use the
actual instance_id (make_field_key(service_id, instance_id, event_id)); update
the code paths that call or search field_requests_ (references to
field_requests_, make_field_key, service_id, instance_id, event_id) so both
insertion and lookup use the same key scheme.
🪄 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: dcc19d2f-80c6-4b55-b1c4-b8503334c352

📥 Commits

Reviewing files that changed from the base of the PR and between 6e71a26 and a23b6dd.

📒 Files selected for processing (21)
  • .github/workflows/clang-tidy.yml
  • clang-tidy-baseline.txt
  • include/core/session_manager.h
  • include/e2e/e2e_profile_registry.h
  • include/platform/posix/net_impl.h
  • include/someip/types.h
  • include/transport/udp_transport.h
  • scripts/clang_tidy_to_allure.py
  • src/e2e/e2e_crc.cpp
  • src/e2e/e2e_profile_registry.cpp
  • src/e2e/e2e_profiles/standard_profile.cpp
  • src/events/event_publisher.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/sd/sd_server.cpp
  • src/someip/message.cpp
  • src/transport/tcp_transport.cpp
  • src/transport/udp_transport.cpp
💤 Files with no reviewable changes (1)
  • src/e2e/e2e_profile_registry.cpp

Comment thread scripts/clang_tidy_to_allure.py Outdated
Comment thread scripts/clang_tidy_to_allure.py Outdated
Comment thread scripts/clang_tidy_to_allure.py Outdated
Comment on lines +29 to +31
m = re.match(
r"(.+?):(\d+):\d+: warning: (.+?) \[(.+?)\]", line.strip()
)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

Harden warning regex to parse the trailing check token reliably.

Lines 29-31 can misparse messages that contain bracketed content inside the diagnostic text. Anchor to full line and capture the final [check] token.

Suggested fix
-            m = re.match(
-                r"(.+?):(\d+):\d+: warning: (.+?) \[(.+?)\]", line.strip()
-            )
+            m = re.match(
+                r"^(.*):(\d+):\d+: warning: (.*) \[([^\]]+)\]$",
+                line.rstrip("\n"),
+            )
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
m = re.match(
r"(.+?):(\d+):\d+: warning: (.+?) \[(.+?)\]", line.strip()
)
m = re.match(
r"^(.*):(\d+):\d+: warning: (.*) \[([^\]]+)\]$",
line.rstrip("\n"),
)
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@scripts/clang_tidy_to_allure.py` around lines 29 - 31, The current re.match
that assigns m can miscapture bracketed text inside the diagnostic message;
update the regex used in the re.match call so it anchors to the start and end of
the line and explicitly captures the final check token in square brackets (e.g.,
change the pattern to require the trailing `[...]` at the end and use a
character-class like `[^\]]+` for that capture, while allowing the message
capture to span internal brackets), so the match reliably extracts filename,
line, message, and the final check name when called as m = re.match(...,
line.strip()).

Comment thread scripts/clang_tidy_to_allure.py Outdated
Comment on lines +182 to 183
const std::string key = make_field_key(service_id, instance_id, event_id);
field_requests_[key] = std::move(callback);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

Field-response callback key is inconsistent with lookup key.

At Line 183 the callback is stored with make_field_key(service_id, instance_id, event_id), but lookup uses make_field_key(service_id, 0, event_id) (Line 303). For non-zero instance_id, callbacks won’t be found.

💡 Proposed fix
-        const std::string key = make_field_key(service_id, instance_id, event_id);
+        // Response matching currently does not carry instance_id; keep keying consistent.
+        const std::string key = make_field_key(service_id, 0, event_id);
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
const std::string key = make_field_key(service_id, instance_id, event_id);
field_requests_[key] = std::move(callback);
// Response matching currently does not carry instance_id; keep keying consistent.
const std::string key = make_field_key(service_id, 0, event_id);
field_requests_[key] = std::move(callback);
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/events/event_subscriber.cpp` around lines 182 - 183, The stored callback
key and the lookup key are inconsistent: callbacks are saved with
make_field_key(service_id, instance_id, event_id) but later looked up with
make_field_key(service_id, 0, event_id), so non-zero instance_id entries are
never found. Fix by making key generation consistent—either change the store to
use make_field_key(service_id, 0, event_id) when inserting into field_requests_
or change the lookup to use the actual instance_id (make_field_key(service_id,
instance_id, event_id)); update the code paths that call or search
field_requests_ (references to field_requests_, make_field_key, service_id,
instance_id, event_id) so both insertion and lookup use the same key scheme.

vtz added 2 commits April 15, 2026 16:44
Remove unused import sys, collapse multi-line calls per ruff formatter.
Use explicit UTF-8 encoding with error replacement for report parsing.
Fix threshold=0 truthiness bug by checking `is not None`.
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.

♻️ Duplicate comments (1)
scripts/clang_tidy_to_allure.py (1)

28-28: ⚠️ Potential issue | 🟠 Major

Harden warning parsing to capture the trailing clang-tidy check token correctly.

Line 28 can misparse diagnostics that contain bracketed text in the message body, causing incorrect check attribution.

Proposed fix
-            m = re.match(r"(.+?):(\d+):\d+: warning: (.+?) \[(.+?)\]", line.strip())
+            m = re.match(
+                r"^(.*):(\d+):\d+: warning: (.*) \[([^\]]+)\]$",
+                line.rstrip("\n"),
+            )

Run this to verify the current pattern vs the anchored pattern behavior:

#!/bin/bash
python - <<'PY'
import re

current = re.compile(r"(.+?):(\d+):\d+: warning: (.+?) \[(.+?)\]")
fixed = re.compile(r"^(.*):(\d+):\d+: warning: (.*) \[([^\]]+)\]$")

samples = [
    "src/a.cpp:10:3: warning: simple message [modernize-use-auto]",
    "src/b.cpp:20:7: warning: has [internal] brackets [readability-identifier-naming]",
]

for s in samples:
    c = current.match(s.strip())
    f = fixed.match(s.rstrip("\n"))
    print("LINE:", s)
    print(" current:", (c.group(3), c.group(4)) if c else None)
    print(" fixed  :", (f.group(3), f.group(4)) if f else None)
    print()
PY
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@scripts/clang_tidy_to_allure.py` at line 28, The current inline regex at the
m = re.match(...) call can mis-capture bracketed text inside the message body;
replace it with an anchored, bracket-safe pattern so the trailing clang-tidy
check token is always captured correctly (use a pattern equivalent to
^(.*):(\d+):\d+: warning: (.*) \[([^\]]+)\]$) and update the match usage in
scripts/clang_tidy_to_allure.py (the m = re.match(...) location) to use that
pattern (optionally precompile with re.compile for clarity).
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Duplicate comments:
In `@scripts/clang_tidy_to_allure.py`:
- Line 28: The current inline regex at the m = re.match(...) call can
mis-capture bracketed text inside the message body; replace it with an anchored,
bracket-safe pattern so the trailing clang-tidy check token is always captured
correctly (use a pattern equivalent to ^(.*):(\d+):\d+: warning: (.*)
\[([^\]]+)\]$) and update the match usage in scripts/clang_tidy_to_allure.py
(the m = re.match(...) location) to use that pattern (optionally precompile with
re.compile for clarity).

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: eeb9f225-bee1-427b-8e2b-ef6b6b3c95c8

📥 Commits

Reviewing files that changed from the base of the PR and between a23b6dd and a92e4b5.

📒 Files selected for processing (1)
  • scripts/clang_tidy_to_allure.py

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