Skip to content

Conversation

@Kushagra0811
Copy link

@Kushagra0811 Kushagra0811 commented Jan 12, 2026

Description
This PR enables the cppcoreguidelines-virtual-class-destructor check in .clang-tidy and fixes the warnings currently present in the codebase.

Changes

  • Modified .clang-tidy to enable the check.
  • Added virtual ~ClassName() = default; to the following classes:
    • Pgr_bdAstar in include/bdAstar/bdAstar.hpp
    • Pgr_bdDijkstra in include/bdDijkstra/bdDijkstra.hpp
    • Pgr_bidirectional in include/cpp_common/bidirectional.hpp
    • Pgr_kruskal in include/spanningTree/kruskal.hpp
    • Pgr_mst in include/spanningTree/mst.hpp
    • Pgr_prim in include/spanningTree/prim.hpp

Verification
Built locally with clang-tidy enabled using:
CXX=clang++ CC=clang cmake -DUSE_CLANG_TIDY=ON ..
Result: Build completed successfully with no warnings generated for this check.

Summary by CodeRabbit

  • Chores
    • Updated internal code quality configurations and standards compliance across the codebase.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 12, 2026

Walkthrough

The PR removes the cppcoreguidelines-virtual-class-destructor check from .clang-tidy configuration and adds or modifies destructors across six base classes (Pgr_bdAstar, Pgr_bdDijkstra, Pgr_bidirectional, Pgr_kruskal, Pgr_mst, Pgr_prim) to be virtual, enabling proper polymorphic cleanup when deleting through base class pointers.

Changes

Cohort / File(s) Summary
Configuration Update
.clang-tidy
Removed cppcoreguidelines-virtual-class-destructor check while retaining cppcoreguidelines-use-default-member-init; no other semantic changes to configuration
Virtual Destructors - Pathfinding Algorithms
include/bdAstar/bdAstar.hpp, include/bdDijkstra/bdDijkstra.hpp, include/cpp_common/bidirectional.hpp
Made destructors virtual in Pgr_bdAstar, Pgr_bdDijkstra, and Pgr_bidirectional classes; signature changed from ~ClassName() = default; to virtual ~ClassName() = default;
Virtual Destructors - Spanning Tree Algorithms
include/spanningTree/kruskal.hpp, include/spanningTree/mst.hpp, include/spanningTree/prim.hpp
Added public virtual destructors to Pgr_kruskal, Pgr_mst, and Pgr_prim classes with virtual ~ClassName() = default;

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

Suggested labels

Enhancement, C/C++

Suggested reviewers

  • cvvergara
  • robe2

Poem

🐰 Virtual destructors bloom with care,
Base classes cleaned with flair,
No more warnings from the linter's sight,
Polymorphic cleanup done just right!

🚥 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 describes the main change: enabling a clang-tidy check and fixing related violations by adding virtual destructors to multiple classes.

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

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

📜 Recent review details

Configuration used: Repository UI

Review profile: ASSERTIVE

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 9d9c911 and eaee113.

📒 Files selected for processing (7)
  • .clang-tidy
  • include/bdAstar/bdAstar.hpp
  • include/bdDijkstra/bdDijkstra.hpp
  • include/cpp_common/bidirectional.hpp
  • include/spanningTree/kruskal.hpp
  • include/spanningTree/mst.hpp
  • include/spanningTree/prim.hpp
🧰 Additional context used
🧠 Learnings (3)
📚 Learning: 2026-01-06T20:27:43.082Z
Learnt from: cvvergara
Repo: pgRouting/pgrouting PR: 3026
File: src/ordering/sloanOrdering.cpp:46-89
Timestamp: 2026-01-06T20:27:43.082Z
Learning: In pgRouting, the team plans to eventually stop using the base graph class wrappers. Direct Boost Graph Library calls (e.g., `boost::num_vertices(graph.graph)`) are acceptable and preferred over wrapper methods (e.g., `graph.num_vertices()`) as this future-proofs the code against the planned removal of the base class.

Applied to files:

  • include/spanningTree/mst.hpp
  • include/spanningTree/prim.hpp
📚 Learning: 2025-12-30T19:45:24.426Z
Learnt from: cvvergara
Repo: pgRouting/pgrouting PR: 3004
File: .clang-tidy:9-11
Timestamp: 2025-12-30T19:45:24.426Z
Learning: In .clang-tidy files (and similar list-based configuration files), the last entry in a list should not have a trailing comma, following project convention. Enforce that lists do not end with a comma to improve diffs and consistency across configuration files.

Applied to files:

  • .clang-tidy
📚 Learning: 2025-12-30T19:45:40.183Z
Learnt from: cvvergara
Repo: pgRouting/pgrouting PR: 3004
File: .clang-tidy:11-11
Timestamp: 2025-12-30T19:45:40.183Z
Learning: In any .clang-tidy configuration files, ensure that the last element of a list does not have a trailing comma, to follow the repository's coding convention. This applies to all pgRouting/.clang-tidy files across the codebase.

Applied to files:

  • .clang-tidy
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Codacy Static Code Analysis
🔇 Additional comments (7)
include/spanningTree/mst.hpp (1)

53-55: LGTM!

Adding a public virtual destructor to Pgr_mst is the correct fix. Since this class has a pure virtual function (generate_mst) and serves as a base for Pgr_kruskal and Pgr_prim, a virtual destructor ensures proper polymorphic destruction when deleting derived objects through a base class pointer.

.clang-tidy (1)

29-29: LGTM!

Removing the -cppcoreguidelines-virtual-class-destructor exclusion (which was previously in this list) correctly enables the check. The formatting follows the project convention with no trailing comma on the last entry.

include/spanningTree/prim.hpp (1)

54-54: LGTM!

Adding the explicit virtual destructor maintains consistency with the base class and satisfies the clang-tidy check. While Pgr_prim inherits a virtual destructor from Pgr_mst, explicitly marking it as virtual improves clarity.

include/bdAstar/bdAstar.hpp (1)

81-81: LGTM!

The explicit virtual destructor is consistent with the changes to the base class Pgr_bidirectional and the pattern applied across this PR.

include/spanningTree/kruskal.hpp (1)

45-45: LGTM!

Adding the explicit virtual destructor maintains consistency with the base class Pgr_mst and satisfies the clang-tidy check.

include/cpp_common/bidirectional.hpp (1)

81-81: LGTM!

Adding virtual to the destructor is correct and necessary. Pgr_bidirectional has pure virtual functions (explore_forward, explore_backward), so it must have a virtual destructor to ensure proper polymorphic destruction when derived objects are deleted through base class pointers.

include/bdDijkstra/bdDijkstra.hpp (1)

80-80: LGTM!

The explicit virtual keyword is technically redundant since the base class Pgr_bidirectional<G> already has a virtual destructor (making this one implicitly virtual), but it's acceptable for clarity and consistency with other classes in this PR.


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.

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