STYLEGUIDE.md in rubocop-github-0.16.0 vs STYLEGUIDE.md in rubocop-github-0.16.1
- old
+ new
@@ -1,10 +1,10 @@
# Ruby Style Guide
* Use soft-tabs with a two space indent.
-* Keep each line of code to a readable length. Unless you have a reason to, keep lines to fewer than 100 characters.
+* Keep each line of code to a readable length. Unless you have a reason to, keep lines to a maximum of 118 characters. Why 118? That's the width at which the pull request diff UI needs horizontal scrolling (making pull requests harder to review).
* Never leave trailing whitespace.
* End each file with a [newline](https://github.com/bbatsov/ruby-style-guide#newline-eof).
@@ -29,31 +29,47 @@
``` ruby
!array.include?(element)
```
-* Indent `when` as deep as `case`.
+* Indent `when` with the start of the `case` expression.
``` ruby
+# bad
+message = case
+ when song.name == "Misty"
+ "Not again!"
+ when song.duration > 120
+ "Too long!"
+ when Time.now.hour > 21
+ "It's too late"
+ else
+ song.to_s
+ end
+
+# good
+message = case
+when song.name == "Misty"
+ "Not again!"
+when song.duration > 120
+ "Too long!"
+when Time.now.hour > 21
+ "It's too late"
+else
+ song.to_s
+end
+
+# good
case
when song.name == "Misty"
puts "Not again!"
when song.duration > 120
puts "Too long!"
when Time.now.hour > 21
puts "It's too late"
else
song.play
end
-
-kind = case year
- when 1850..1889 then "Blues"
- when 1890..1909 then "Ragtime"
- when 1910..1929 then "New Orleans Jazz"
- when 1930..1939 then "Swing"
- when 1940..1950 then "Bebop"
- else "Jazz"
- end
```
* Use empty lines between `def`s and to break up a method into logical
paragraphs.