Skip to content

clang-tidy: check and fix cppcoreguidelines-avoid-c-arrays#3080

Merged
cvvergara merged 1 commit into
pgRouting:developfrom
ranjodhsingh1729:clang-tidy-avoid-c-arrays
Mar 1, 2026
Merged

clang-tidy: check and fix cppcoreguidelines-avoid-c-arrays#3080
cvvergara merged 1 commit into
pgRouting:developfrom
ranjodhsingh1729:clang-tidy-avoid-c-arrays

Conversation

@ranjodhsingh1729
Copy link
Copy Markdown
Contributor

@ranjodhsingh1729 ranjodhsingh1729 commented Feb 24, 2026

This PR adds cppcoreguidelines-avoid-c-arrays in .clang-tidy.

Enabling this check resulted in a single warning where the c array was replaced with std::array.

Summary by CodeRabbit

  • Refactor

    • Modernized internal error/diagnostic handling to improve robustness and maintainability.
  • Chores

    • Updated static analysis configuration to streamline development tooling.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Feb 24, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info

Configuration used: Repository UI

Review profile: ASSERTIVE

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between b6e97a4 and 1bec453.

📒 Files selected for processing (2)
  • .clang-tidy
  • src/common/assert.cpp
💤 Files with no reviewable changes (1)
  • .clang-tidy

Walkthrough

This change removes the cppcoreguidelines-avoid-c-arrays check from the clang-tidy configuration and replaces a raw C-style array with std::array<void*, 16> in src/common/assert.cpp, using trace.data() for backtrace calls while preserving existing behavior.

Changes

Cohort / File(s) Summary
clang-tidy Configuration
.clang-tidy
Removed the cppcoreguidelines-avoid-c-arrays check from the Checks list.
C++ Standard Library Modernization
src/common/assert.cpp
Replaced raw C-style trace[16] with std::array<void*, 16>; added <array> and updated calls to use trace.data() for backtrace()/backtrace_symbols().

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

Suggested labels

Enhancement

Suggested reviewers

  • robe2

Poem

🐇 I bounded my hops in tidy array,

No naked pointers led astray,
std::array keeps the traceback neat,
Clean checks removed, the code’s complete.

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% 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 title accurately reflects the main changes: enabling the cppcoreguidelines-avoid-c-arrays check in clang-tidy and fixing the resulting violation by replacing a C-style array with std::array.

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

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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 `@src/common/assert.cpp`:
- Around line 38-49: The get_backtrace() function currently passes a hardcoded
literal 16 to backtrace(), which defeats the std::array usage; change the call
to use trace.size() (or static_cast<int>(trace.size()) if needed) so
backtrace(trace.data(), /*size*/ ) uses the array's capacity, and ensure any
related uses (e.g., backtrace_symbols(trace.data(), trace_size)) remain
consistent with trace_size derived from that call; update identifiers in
get_backtrace() (trace, trace_size, backtrace call) accordingly.

ℹ️ Review info

Configuration used: Repository UI

Review profile: ASSERTIVE

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 4912a28 and b6e97a4.

📒 Files selected for processing (2)
  • .clang-tidy
  • src/common/assert.cpp
💤 Files with no reviewable changes (1)
  • .clang-tidy

Comment thread src/common/assert.cpp
@ranjodhsingh1729 ranjodhsingh1729 force-pushed the clang-tidy-avoid-c-arrays branch from b6e97a4 to 1bec453 Compare February 24, 2026 19:03
Copy link
Copy Markdown
Member

@cvvergara cvvergara left a comment

Choose a reason for hiding this comment

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

Looks fine, I am approving pending the actions I just triggered

@cvvergara cvvergara merged commit 8a6a13a into pgRouting:develop Mar 1, 2026
60 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants