Skip to content

fix: accept U/u integer-literal suffix before << in whitespace/operators#440

Open
Noethix55555 wants to merge 3 commits into
cpplint:developfrom
Noethix55555:fix/shift-unsigned-suffix
Open

fix: accept U/u integer-literal suffix before << in whitespace/operators#440
Noethix55555 wants to merge 3 commits into
cpplint:developfrom
Noethix55555:fix/shift-unsigned-suffix

Conversation

@Noethix55555

@Noethix55555 Noethix55555 commented Jun 13, 2026

Copy link
Copy Markdown

Summary

The whitespace/operators check allows no-space shifts of suffixed integer literals (10UL<<20, 10LL<<20), but the suffix alternation omitted the standalone U/u suffix, so 10U<<20 and 10u<<20 were wrongly reported as missing spaces around <<. This adds U and u to the alternation.

Added assertions for 10U<<20 and 10u<<20 next to the existing 10LL<<20/10ULL<<20 cases.

Closes #439.

Summary by CodeRabbit

  • Bug Fixes

    • Improved operator-spacing validation for the left-shift operator to better handle numeric literal type prefixes, reducing incorrect “Missing spaces around <<” warnings.
  • Tests

    • Added new single-line lint test cases for left-shift spacing with unsigned numeric literals, covering both uppercase and lowercase U suffix casing.

The check that allows no-space shifts of suffixed integer literals (10UL<<20, 10LL<<20) omitted the standalone U/u suffix, so 10U<<20 and 10u<<20 were wrongly flagged as missing spaces around <<. Add U and u to the suffix alternation.
@coderabbitai

coderabbitai Bot commented Jun 13, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 53b0c4e2-28bd-4c66-bee1-3ea1adf14e55

📥 Commits

Reviewing files that changed from the base of the PR and between 5d8645d and 9468a2d.

📒 Files selected for processing (1)
  • cpplint.py
🚧 Files skipped from review as they are similar to previous changes (1)
  • cpplint.py

📝 Walkthrough

Walkthrough

This PR fixes a false-positive operator-spacing lint error. The << (left-shift) operator spacing check regex is updated to recognize U and u as standalone integer-literal suffixes, matching existing support for L, UL, LL, and ULL variants. Two test cases verify that 10U<<20 and 10u<<20 no longer trigger "Missing spaces around <<" warnings.

Changes

Left-shift operator spacing check

Layer / File(s) Summary
Left-shift operator suffix recognition in spacing check
cpplint.py, cpplint_unittest.py
The << spacing detection regex in CheckOperatorSpacing is updated with a case-insensitive pattern to accept U and u suffixes alongside existing suffix variants. Two test assertions confirm that unsigned-suffix integer-literal shifts like 10U<<20 and 10u<<20 are now recognized without lint errors.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes


🐰 A little regex tweak, a fuzzy delight,
To let U and u shift without a fight,
Ten-U-twenty shifts left all day,
No false alarms in the linting way!

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.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
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and accurately summarizes the main change: adding U/u suffix support to the left-shift operator whitespace check regex pattern.
Linked Issues check ✅ Passed The PR directly addresses issue #439 by adding U and u to the regex suffix alternation in CheckOperatorSpacing and includes test cases for both 10U<<20 and 10u<<20, meeting all stated coding requirements.
Out of Scope Changes check ✅ Passed All changes are scoped to fixing the false positive warning for U/u suffixed integer literals in left-shift operations; no unrelated modifications were introduced.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

@cclauss

cclauss commented Jun 13, 2026

Copy link
Copy Markdown
Member

GitHub account was created today.

aaronliu0130 and others added 2 commits June 19, 2026 21:03
the better way to do this
probably no need to worry about the `OPERATORULL<<` F+
why write and commit straight from github? yoloooo
@aaronliu0130 aaronliu0130 requested a review from cclauss June 20, 2026 01:07
@aaronliu0130

Copy link
Copy Markdown
Member

next, could we review the other PRs before they become a year old? :)

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.

whitespace/operators false positive on U/u integer-literal shift (10U<<20)

3 participants