Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Style/ParenthesesAroundCondition-20220919233912 #785

Merged
merged 4 commits into from
Sep 28, 2022

Conversation

github-actions[bot]
Copy link
Contributor

Rubocop challenge!

Style/ParenthesesAroundCondition

Safe autocorrect: Yes
✅ The autocorrect a cop does is safe (equivalent) by design.

Description

Overview

Checks for the presence of superfluous parentheses around the
condition of if/unless/while/until.

AllowSafeAssignment option for safe assignment.
By safe assignment we mean putting parentheses around
an assignment to indicate "I know I'm using an assignment
as a condition. It's not a mistake."

Examples

# bad
x += 1 while (x < 10)
foo unless (bar || baz)

if (x > 10)
elsif (x < 3)
end

# good
x += 1 while x < 10
foo unless bar || baz

if x > 10
elsif x < 3
end

AllowSafeAssignment: true (default)

# good
foo unless (bar = baz)

AllowSafeAssignment: false

# bad
foo unless (bar = baz)

AllowInMultilineConditions: false (default)

# bad
if (x > 10 &&
   y > 10)
end

# good
 if x > 10 &&
    y > 10
 end

AllowInMultilineConditions: true

# good
if (x > 10 &&
   y > 10)
end

Auto generated by rubocop_challenger

@mathieujobin mathieujobin merged commit 431857f into master Sep 28, 2022
@mathieujobin mathieujobin deleted the rubocop-challenge/20220919233912 branch September 28, 2022 09:27
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.

1 participant