Skip to content

Conversation

@github-actions
Copy link
Contributor

@github-actions github-actions bot commented Jul 5, 2022

Rubocop challenge!

Style/IfUnlessModifier

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

Description

Overview

Checks for if and unless statements that would fit on one line if
written as modifier if/unless. The cop also checks for modifier
if/unless lines that exceed the maximum line length.

The maximum line length is configured in the Layout/LineLength
cop. The tab size is configured in the IndentationWidth of the
Layout/IndentationStyle cop.

Examples

# bad
if condition
  do_stuff(bar)
end

unless qux.empty?
  Foo.do_something
end

do_something_with_a_long_name(arg) if long_condition_that_prevents_code_fit_on_single_line

# good
do_stuff(bar) if condition
Foo.do_something unless qux.empty?

if long_condition_that_prevents_code_fit_on_single_line
  do_something_with_a_long_name(arg)
end

if short_condition # a long comment that makes it too long if it were just a single line
  do_something
end

Auto generated by rubocop_challenger

@mathieujobin mathieujobin merged commit cf2ed0a into master Jul 5, 2022
@mathieujobin mathieujobin deleted the rubocop-challenge/20220705233422 branch July 5, 2022 23:37
smshuja pushed a commit to TheTalentEnterprise/webhook_system that referenced this pull request Jan 25, 2024
* 🚓 regenerate rubocop todo

* 🚓 Style/IfUnlessModifier

* 🚓 regenerate rubocop todo

Co-authored-by: Rubocop Challenger <rubocop@payrollhero.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Development

Successfully merging this pull request may close these issues.

2 participants