ruby-style-guide icon indicating copy to clipboard operation
ruby-style-guide copied to clipboard

A community-driven Ruby coding style guide

Results 75 ruby-style-guide issues
Sort by recently updated
recently updated
newest added

The style guide currently says > Use the new lambda literal syntax for single line body blocks. Use the lambda method for multi-line blocks. [link] > > ``` rb >...

Existing Rule

I can't find answer to this. What is considered better style: Solution 1(Close parentheses on new line): ``` def initialize(arg1, arg2, arg3 = Whatever.new, arg4 = Whatever2.new(arg2_1, arg2_2, arg2_3 )...

Weird things can happen when you declare a variable within a conditional that you intend to use outside of it. Example: ``` if false x = 1 end puts x...

New Rule
Approved

Referring to this: https://github.com/bbatsov/ruby-style-guide#while-as-a-modifier I would argue that the single line version of the syntax is a rare example of ruby being surprising and inconsistent. We all regularly use something...

Existing Rule
Approved

Personally, I think it should be possible to know if a method is expected to return `== 1` or `>= 1` results. I was the opinion that it is part...

New Rule

The following statement: `Favor the use of exceptions from the standard library over introducing new exception classes.` reads as if you should try not to introduce new exception classes where...

Existing Rule
Approved

`|` and `||` both work for boolean arithmetic, e.g. in ``` some_flag = false some_array.each do |element| some_flag ||= do_something(element) end ``` `||=` could be interchanged with `|=`. Similarly with...

New Rule
Approved

Greetings, I would like to hear some community standpoint regarding this matter. ``` ruby class User < ActiveRecord::Base ROLES = %w(admin moderator contributor) end # > User::ROLES # => ["admin",...

New Rule
Approved

Being a non-native English speaker I sometimes have difficulties reading the style guide, especially when it comes to a rule is partially overriding another. It is clear to me that,...

Existing Rule
Approved

[It says](https://github.com/bbatsov/ruby-style-guide#no-nested-ternary): > Use one expression per branch in a ternary operator. This also means that ternary operators must not be nested. So apparently you're counting subexpressions and thus these...

Existing Rule
Approved