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 3
3
This is GitHub's Ruby Style Guide, inspired by [ RuboCop's guide] [ rubocop-guide ] .
4
4
5
5
## Table of Contents
6
+
6
7
1 . [ Layout] ( #layout )
7
8
1 . [ Indentation] ( #indentation )
8
9
2 . [ Inline] ( #inline )
@@ -763,6 +764,22 @@ if x > 10
763
764
end
764
765
```
765
766
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
+
766
783
### Ternary operator
767
784
768
785
* 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:
1370
1370
Enabled : false
1371
1371
1372
1372
Style/NegatedUnless :
1373
- Enabled : false
1373
+ Enabled : true
1374
1374
1375
1375
Style/NegatedWhile :
1376
1376
Enabled : false
You can’t perform that action at this time.
0 commit comments