Skip to content

Check coderabbit settings#3160

Open
robbycochran wants to merge 2 commits intomasterfrom
rc-check-pr
Open

Check coderabbit settings#3160
robbycochran wants to merge 2 commits intomasterfrom
rc-check-pr

Conversation

@robbycochran
Copy link
Copy Markdown
Collaborator

Description

A detailed explanation of the changes in your PR.

Feel free to remove this section if it is overkill for your PR, and the title of your PR is sufficiently descriptive.

Checklist

  • Investigated and inspected CI test results
  • Updated documentation accordingly

Automated testing

  • Added unit tests
  • Added integration tests
  • Added regression tests

If any of these don't apply, please comment below.

Testing Performed

TODO(replace-me)
Use this space to explain how you tested your PR, or, if you didn't test it, why you did not do so. (Valid reasons include "CI is sufficient" or "No testable changes")
In addition to reviewing your code, reviewers must also review your testing instructions, and make sure they are sufficient.

For more details, ref the Confluence page about this section.

robbycochran and others added 2 commits March 27, 2026 15:21
Replace manual memory management with RAII using std::unique_ptr for:
- nRadixNode members (value_, left_, right_)
- NRadixTree root_ member

This eliminates manual delete calls, simplifies copy/assignment operators,
and prevents potential memory leaks.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
@robbycochran robbycochran requested a review from a team as a code owner March 27, 2026 22:22
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Mar 27, 2026

📝 Walkthrough

Summary by CodeRabbit

  • Refactor
    • Internal improvements to data structure implementation and memory management for enhanced code quality and maintainability.

Walkthrough

Refactored NRadixTree and nRadixNode to use std::unique_ptr for memory management instead of raw pointers. Updated all pointer declarations (root_, value_, left_, right_), replaced new/delete with std::make_unique, and removed explicit destructors to rely on automatic cleanup via smart pointer semantics.

Changes

Cohort / File(s) Summary
Smart Pointer Type Declarations
collector/lib/NRadix.h
Replaced raw owning pointers with std::unique_ptr in nRadixNode (value_, left_, right_) and NRadixTree (root_). Added <memory> include. Updated constructors, copy assignment, and copy constructor to use std::make_unique for allocation and deep copying. Removed manual destructors for both classes.
Pointer Traversal and Memory Management
collector/lib/NRadix.cpp
Updated Insert, Find, getAll, GetAll, and IsAnyIPNetSubset methods to navigate pointers via .get() accessors and allocate child nodes with std::make_unique. Payload values now assigned via std::make_unique<IPNet> instead of raw new calls. All recursive tree operations updated to dereference through smart pointer accessors.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~18 minutes

🚥 Pre-merge checks | ❌ 3

❌ Failed checks (3 warnings)

Check name Status Explanation Resolution
Title check ⚠️ Warning The pull request title 'Check coderabbit settings' does not match the actual changes, which refactor raw pointers to std::unique_ptr in NRadix code. The title is misleading and unrelated to the changeset. Update the title to reflect the actual change, such as 'Refactor NRadix to use std::unique_ptr for memory management' or 'Replace raw pointers with RAII in NRadix'
Description check ⚠️ Warning The pull request description is entirely a boilerplate template with no actual content. All sections contain placeholders (TODO, checkboxes unchecked) with no explanation of the actual refactoring changes made to NRadix. Fill in the description with details about replacing raw pointers with std::unique_ptr, the rationale, and actual testing performed. Complete the checklist items and replace TODO placeholders.
Docstring Coverage ⚠️ Warning Docstring coverage is 10.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.

✏️ 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 rc-check-pr

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@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 `@collector/lib/NRadix.h`:
- Around line 56-63: The copy-assignment operator for nRadixNode causes infinite
recursion because std::swap falls back to copy assignment when no move
operations exist; declare and default the move constructor and move-assignment
operator for nRadixNode (e.g., nRadixNode(nRadixNode&&) noexcept = default; and
nRadixNode& operator=(nRadixNode&&) noexcept = default;) so std::swap will use
move semantics, or alternatively implement a noexcept member swap and call that
from operator=; update the class declaration to include these move operations
(and mark them noexcept) so the copy-and-swap implementation of operator= stops
recursing.
🪄 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: Central YAML (base), Organization UI (inherited)

Review profile: CHILL

Plan: Pro

Run ID: 8a027223-4a87-4a0a-be65-620317f28f34

📥 Commits

Reviewing files that changed from the base of the PR and between c8c0181 and b9b97ee.

📒 Files selected for processing (2)
  • collector/lib/NRadix.cpp
  • collector/lib/NRadix.h

Comment on lines 56 to 63
nRadixNode& operator=(const nRadixNode& other) {
if (this == &other) {
return *this;
}
auto* new_node = new nRadixNode(other);
auto new_node = std::make_unique<nRadixNode>(other);
std::swap(*new_node, *this);
delete new_node;
return *this;
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🔴 Critical

Infinite recursion: std::swap falls back to copy assignment without move operations.

Since nRadixNode has a user-declared copy constructor and copy assignment, the move constructor and move assignment operator are not implicitly generated. When std::swap(*new_node, *this) executes, it attempts to use move semantics but falls back to copy operations. The internal a = std::move(b) call invokes this same operator=, causing infinite recursion and stack overflow.

Add move operations to enable proper swap semantics:

🐛 Proposed fix: add defaulted move operations
   nRadixNode(const nRadixNode& other) : value_(nullptr), left_(nullptr), right_(nullptr) {
     if (other.value_) {
       value_ = std::make_unique<IPNet>(*other.value_);
     }
     if (other.left_) {
       left_ = std::make_unique<nRadixNode>(*other.left_);
     }
     if (other.right_) {
       right_ = std::make_unique<nRadixNode>(*other.right_);
     }
   }

+  nRadixNode(nRadixNode&&) = default;
+  nRadixNode& operator=(nRadixNode&&) = default;
+
   nRadixNode& operator=(const nRadixNode& other) {
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@collector/lib/NRadix.h` around lines 56 - 63, The copy-assignment operator
for nRadixNode causes infinite recursion because std::swap falls back to copy
assignment when no move operations exist; declare and default the move
constructor and move-assignment operator for nRadixNode (e.g.,
nRadixNode(nRadixNode&&) noexcept = default; and nRadixNode&
operator=(nRadixNode&&) noexcept = default;) so std::swap will use move
semantics, or alternatively implement a noexcept member swap and call that from
operator=; update the class declaration to include these move operations (and
mark them noexcept) so the copy-and-swap implementation of operator= stops
recursing.

@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Mar 27, 2026

Codecov Report

❌ Patch coverage is 75.00000% with 8 lines in your changes missing coverage. Please review.
✅ Project coverage is 27.42%. Comparing base (c8c0181) to head (b9b97ee).
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
collector/lib/NRadix.cpp 82.60% 0 Missing and 4 partials ⚠️
collector/lib/NRadix.h 55.55% 0 Missing and 4 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #3160      +/-   ##
==========================================
+ Coverage   27.38%   27.42%   +0.03%     
==========================================
  Files          95       95              
  Lines        5427     5423       -4     
  Branches     2548     2540       -8     
==========================================
+ Hits         1486     1487       +1     
  Misses       3214     3214              
+ Partials      727      722       -5     
Flag Coverage Δ
collector-unit-tests 27.42% <75.00%> (+0.03%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@github-actions
Copy link
Copy Markdown

/retest collector-on-push

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