Skip to content

clang-tidy: enable cppcoreguidelines-pro-type-const-cast - #3199

Open
AdityaRanaX wants to merge 1 commit into
pgRouting:developfrom
AdityaRanaX:clang-tidy-const-cast
Open

AdityaRanaX wants to merge 1 commit into
pgRouting:developfrom
AdityaRanaX:clang-tidy-const-cast

Conversation

@AdityaRanaX

@AdityaRanaX AdityaRanaX commented Nov 27, 2026 •

Copy link
Copy Markdown

Part of #3036

Changes in this PR:

  • Enable cppcoreguidelines-pro-type-const-cast by removing it from the list of disabled checks in .clang-tidy, as mentioned in my comment on Clang tidy checks that need fixes #3036.

  • tested with clang-tidy 14 on develop 0385ea7. the check reports 4 warning and 0 after my changes

  • changes in code - char* type to const char* type in the two headers and removed the 4 const_cast.

  • All CI checks passed

@pgRouting/admins

Summary by CodeRabbit

  • Refactor
    • Made vertex and edge type labels immutable, improving type safety without changing their values or behavior.
  • Chores
    • Enabled the const-cast guideline in static analysis.

@coderabbitai

coderabbitai Bot commented Nov 27, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

Runtime type fields now use const char*. Vertex and edge tuple initialization uses string literals instead of const_cast. The clang-tidy configuration no longer excludes the const-cast check.

Changes

Runtime type fields and tuple initialization

Layer / File(s) Summary
Const type fields and tuple initialization
include/c_types/contracted_rt.h, include/c_types/contractionHierarchies_rt.h, include/cpp_common/to_postgres.hpp, src/contraction/contractGraph_driver.cpp, .clang-tidy
The runtime type fields change from char* to const char*. Vertex and edge tuple initializers use string literals instead of const_cast. The clang-tidy configuration removes the const-cast exclusion.

Estimated code review effort: 2 (Simple) | ~8 minutes

Change: Refactor

Suggested reviewers: cvvergara, aubousquet, thisisashukla

Merge Risk: Minimal · up to 3eb05

This change makes two type fields const-correct and enables a static-analysis check. It should not change runtime behavior, and no merge-blocking risk was identified.

Pre-merge checks: Passed 4

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title names the main change: enabling the clang-tidy check cppcoreguidelines-pro-type-const-cast. The changeset removes that check from the disabled list in .clang-tidy. It also changes char* to c…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title names the main change: enabling the clang-tidy check cppcoreguidelines-pro-type-const-cast. The changeset removes that check from the disabled list in .clang-tidy. It also changes char* to const char* in two headers and removes const_cast uses in two source files, which the title does not mention. Those edits are the fixes that let the check pass, so the title matches the primary change.

Finishing Touches

Generate unit tests (beta)

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

A rabbit checks each type with care,
Const strings now rest safely there.
“v” and “e” go hopping by,
No const_cast in their path to fly.
The tidy check is back in sight.

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: ASSERTIVE
  • Plan: Advanced
  • Run ID: dd22713f-48a0-43f0-b949-2677a2c9b18e
Commits

Reviewing files that changed from the base of the PR and between b00d03d and 3eb05c4.

Files selected for processing: 5

  • .clang-tidy
  • include/c_types/contracted_rt.h
  • include/c_types/contractionHierarchies_rt.h
  • include/cpp_common/to_postgres.hpp
  • src/contraction/contractGraph_driver.cpp
Files with no reviewable changes: 1

  • .clang-tidy

Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 3 remain after this review.

This branch has not been deployed

No deployments
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