Skip to content

fix: handle operators after brace initialization - #474

Open
walidbi200 wants to merge 1 commit into
cpplint:developfrom
walidbi200:fix/issue-373-brace-initialization
Open

walidbi200 wants to merge 1 commit into
cpplint:developfrom
walidbi200:fix/issue-373-brace-initialization

Conversation

@walidbi200

@walidbi200 walidbi200 commented Sep 22, 2026 •

Copy link
Copy Markdown

Fixes #373.

The brace-spacing check already recognizes several contexts where {} is initialization rather than a block, but it can misclassify a nested braced value when its closing brace is followed by an operator.

For example:

return std::optional{pmr_string{a} + " " + b};

This currently reports whitespace/braces on pmr_string{a}.

This change recognizes operator continuation after a braced value while preserving block-spacing diagnostics such as malformed requires(T t){ ... } and lambda bodies.

Regression coverage includes the original #373 shape, nested braced values followed by arithmetic, bitwise, comparison, shift, and logical operators, plus negative controls for block braces.

Validation:

  • full pytest: 231 passed, 96.42% coverage
  • pylint: passed
  • mypy: passed
  • pre-commit: passed
  • git diff --check: passed

@coderabbitai

coderabbitai Bot commented Sep 22, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Advanced

Run ID: 1df68c9b-bcb0-4826-8415-be44e90f093f

📥 Commits

Reviewing files that changed from the base of the PR and between 8628446 and 1583672.

📒 Files selected for processing (3)
  • CHANGELOG.rst
  • cpplint.py
  • cpplint_unittest.py

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


📝 Walkthrough

Walkthrough

The brace-spacing check now suppresses false positives for nested brace initialization followed by operators. Tests cover arithmetic, comparison, bitwise, shift, and logical operators, plus requires clause handling. The unreleased changelog records the fix.

Changes

Brace spacing false-positive fix

Layer / File(s) Summary
Update brace spacing rule
cpplint.py
CheckBracesSpacing suppresses the warning for qualifying braced values followed by operators, while retaining checks for parameterized requires clauses.
Add regression coverage and changelog
cpplint_unittest.py, CHANGELOG.rst
Tests cover nested brace initialization with 18 operators and concept requires forms. The changelog records issue #373.

Priority: ⬇️ Low

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

Change: Bug fix · Severity of issue fixed: Low

Suggested reviewers: aaronliu0130

Merge Risk: ⚪ Minimal · up to 15836

The brace-spacing rule avoids the reported false positives while preserving relevant diagnostics, and the supplied regression coverage supports merging.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 3 functions across 2 files. (1 skipped: 1… Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed The pull request meets the coding requirements in issue #373. CheckBracesSpacing now recognizes operators after nested braced initialization values and suppresses the false positive for expressions …
Out of Scope Changes check ✅ Passed The changes stay within issue #373. The implementation updates whitespace/braces, the tests add coverage for the reported initialization pattern and its controls, and the changelog records the fix. …
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: handling operators that follow brace initialization.
Full details: Docstring Coverage

Explanation

Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 3 functions across 2 files. (1 skipped: 1 unsupported.)

  • Fix all pre-merge checks with AI
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new 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.

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.

False positive for whitespace/braces with curly

1 participant