File tree Expand file tree Collapse file tree 2 files changed +18
-1
lines changed
Expand file tree Collapse file tree 2 files changed +18
-1
lines changed Original file line number Diff line number Diff line change 33This is GitHub's Ruby Style Guide, inspired by [ RuboCop's guide] [ rubocop-guide ] .
44
55## Table of Contents
6+
671 . [ Layout] ( #layout )
78 1 . [ Indentation] ( #indentation )
89 2 . [ Inline] ( #inline )
@@ -763,6 +764,22 @@ if x > 10
763764end
764765```
765766
767+ * Don't use ` unless ` with a negated condition.
768+ <a name =" no-unless-negation " ></a ><sup >[[ link] ( #no-unless-negation )] </sup >
769+ * <a href =" https://docs.rubocop.org/rubocop/cops_style.html#stylenegatedunless " >RuboCop rule: Style/NegatedUnless</a >
770+
771+ ``` ruby
772+ # bad
773+ unless ! condition?
774+ do_something
775+ end
776+
777+ # good
778+ if condition?
779+ do_something
780+ end
781+ ```
782+
766783### Ternary operator
767784
768785* Avoid the ternary operator (` ?: ` ) except in cases where all expressions are extremely
Original file line number Diff line number Diff line change @@ -1370,7 +1370,7 @@ Style/NegatedIfElseCondition:
13701370 Enabled : false
13711371
13721372Style/NegatedUnless :
1373- Enabled : false
1373+ Enabled : true
13741374
13751375Style/NegatedWhile :
13761376 Enabled : false
You can’t perform that action at this time.
0 commit comments