FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Ruff rules SIM for simplification by cclauss · Pull Request #337 · cpplint/cpplint · GitHub

Ruff rules SIM for simplification - #337

Merged
aaronliu0130 merged 1 commit into
developfrom
ruff-rules-SIM-for-simplification
Mar 15, 2025
Merged

Ruff rules SIM for simplification#337
aaronliu0130 merged 1 commit into
developfrom
ruff-rules-SIM-for-simplification

Conversation

cclauss commented Mar 12, 2025

Copy link
Copy Markdown
Member

cclauss force-pushed the ruff-rules-SIM-for-simplification branch from f6df434 to 3cd4953 Compare March 12, 2025 21:06
Comment thread cpplint.py
Comment on lines -4764 to +4763
if keyword := re.search(
r"\b(else if|if|while|for|switch)" # These have parens
r"\s*\(.*\)\s*(?:\[\[(?:un)?likely\]\]\s*)?{\s*[^\s\\};]",
line,
):
error(
filename,
linenum,
"whitespace/newline",
5,
f"Controlled statements inside brackets of {keyword.group(1)} clause"
" should be on a separate line",
if (
keyword := re.search(
r"\b(else if|if|while|for|switch)" # These have parens
r"\s*\(.*\)\s*(?:\[\[(?:un)?likely\]\]\s*)?{\s*[^\s\\};]",
line,
)
) or (
keyword := re.search(
r"\b(else|do|try)" # These don't have parens
r"\s*(?:\[\[(?:un)?likely\]\]\s*)?{\s*[^\s\\}]",
line,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

I wonder why it put everything in brackets...

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Assignment Operator may require parentheses. Also there is a RUF rule that adds parens to clarify precedence between and, or, not.

This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
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.

2 participants


Back | FazBrowse Home | New Git URL