Skip to content

Declare defaulted move ops noexcept (SonarQube BLOCKER cpp:S5018)#1227

Open
rgsl888prabhu wants to merge 2 commits into
mainfrom
fix/sonar-blocker-noexcept-moves
Open

Declare defaulted move ops noexcept (SonarQube BLOCKER cpp:S5018)#1227
rgsl888prabhu wants to merge 2 commits into
mainfrom
fix/sonar-blocker-noexcept-moves

Conversation

@rgsl888prabhu
Copy link
Copy Markdown
Collaborator

@rgsl888prabhu rgsl888prabhu commented May 15, 2026

SonarQube rule cpp:S5018 flags = defaulted move constructors and move-assignment operators that arent declared noexcept. This PR adds noexcept to the seven flagged sites on main, clearing 7 of 8 BLOCKER findings.

All affected classes already move trivially-noexcept members (std::vector, std::unique_ptr, rmm::device_uvector, raw pointers, scalars), so the specifier compiles cleanly. None of these four types are currently stored by value in an STL container (mip_node_t is always behind unique_ptr or raw pointer; the other three dont appear in containers), so on the current code this is a runtime no-op — it just satisfies the lint rule.

Add noexcept to seven `= default` move ctor / move assign declarations
flagged by SonarQube rule cpp:S5018. All affected classes already move
trivially-noexcept members, so the specifier is a no-op at runtime and
just satisfies the rule.

Affected types:
- optimization_problem_t          (move ctor + move assign)
- pdlp_warm_start_data_t          (move assign)
- deterministic_diving_worker_t   (move ctor + move assign)
- mip_node_t                      (move ctor + move assign)

Clears 7 of 8 BLOCKER findings on `main`.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@rgsl888prabhu rgsl888prabhu requested a review from a team as a code owner May 15, 2026 15:53
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 15, 2026

Review Change Stack

📝 Walkthrough

Walkthrough

This PR standardizes move special member declarations by adding explicit noexcept to move constructors and move assignment operators in four types while keeping them defaulted.

Changes

Move Special Members Exception Specification

Layer / File(s) Summary
Add noexcept to move special members
cpp/include/cuopt/linear_programming/optimization_problem.hpp, cpp/include/cuopt/linear_programming/pdlp/pdlp_warm_start_data.hpp, cpp/src/branch_and_bound/deterministic_workers.hpp, cpp/src/branch_and_bound/mip_node.hpp
Move constructors and move assignment operators in optimization_problem_t, pdlp_warm_start_data_t, deterministic_diving_worker_t, and mip_node_t are updated from defaulted-but-not-noexcept to explicitly noexcept = default.

🎯 1 (Trivial) | ⏱️ ~3 minutes

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
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.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarizes the main change: adding noexcept to defaulted move operations to resolve SonarQube blocker cpp:S5018 across multiple files.
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.
Description check ✅ Passed The pull request description is clearly related to the changeset, explaining the specific SonarQube rule being addressed and the rationale for adding noexcept to defaulted move operations.

✏️ 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 fix/sonar-blocker-noexcept-moves

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

clang-format adjusts column alignment of the surrounding deleted-copy
declarations to match the new noexcept move declarations. Whitespace
only.
@rgsl888prabhu rgsl888prabhu self-assigned this May 15, 2026
@rgsl888prabhu rgsl888prabhu added non-breaking Introduces a non-breaking change improvement Improves an existing functionality labels May 15, 2026
@rgsl888prabhu rgsl888prabhu requested review from chris-maes and rg20 and removed request for aliceb-nv and yuwenchen95 May 15, 2026 16:24
@mlubin
Copy link
Copy Markdown
Contributor

mlubin commented May 15, 2026

so the specifier is a no-op at runtime — it just lets the rule pass and, where it matters, lets STL containers use move-not-copy when these types are stored

Sorry which one is it? Does it change the behavior of STL containers when these types or stored or is it a no-op?

@rgsl888prabhu
Copy link
Copy Markdown
Collaborator Author

Sorry, that was contradictory wording on my part. Quick clarification:

In general, noexcept on a move ctor IS observable: std::vector (and friends) reallocate via std::move_if_noexcept, so adding noexcept lets reallocations move elements instead of copy them. So it's not strictly a runtime no-op — but only when the type is stored by value in such a container.

For these four types specifically, I checked the codebase:

  • optimization_problem_t, pdlp_warm_start_data_t, deterministic_diving_worker_t — never stored by value in any STL container.
  • mip_node_t — only ever held as std::unique_ptr<mip_node_t> or raw mip_node_t* in containers (std::vector, std::deque, std::list); the pointer types' moves are noexcept regardless of mip_node_t's declaration.

So in practice on the current code, the change really is a runtime no-op; it only satisfies the lint rule and would start mattering if a future change put one of these in a container by value. I've also dropped the misleading paragraph from the PR description.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

improvement Improves an existing functionality non-breaking Introduces a non-breaking change

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants