Skip to content

Commit b536200

Browse files
ydakukabbatsov
authored andcommitted
Merge duplicated rules
1 parent 3bea60a commit b536200

File tree

1 file changed

+6
-30
lines changed

1 file changed

+6
-30
lines changed

README.adoc

Lines changed: 6 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -814,14 +814,18 @@ user.set(name: 'John', age: 45, permissions: { read: true })
814814

815815
=== DSL Method Calls [[no-dsl-decorating]]
816816

817-
Omit both the outer braces and parentheses for methods that are part of an internal DSL.
817+
Omit both the outer braces and parentheses for methods that are part of an internal DSL (e.g., Rake, Rails, RSpec).
818818

819819
[source,ruby]
820820
----
821821
class Person < ActiveRecord::Base
822822
# bad
823-
validates(:name, { presence: true, length: { within: 1..10 } })
823+
attr_reader(:name, :age)
824+
# good
825+
attr_reader :name, :age
824826
827+
# bad
828+
validates(:name, { presence: true, length: { within: 1..10 } })
825829
# good
826830
validates :name, presence: true, length: { within: 1..10 }
827831
end
@@ -3009,18 +3013,6 @@ fork
30093013
'test'.upcase
30103014
----
30113015

3012-
==== Methods That are Part of an Internal DSL [[method-invocation-parens-internal-dsl]][[method-call-parens-internal-dsl]]
3013-
3014-
Always omit parentheses for methods that are part of an internal DSL (e.g., Rake, Rails, RSpec):
3015-
3016-
[source,ruby]
3017-
----
3018-
# bad
3019-
validates(:name, presence: true)
3020-
# good
3021-
validates :name, presence: true
3022-
----
3023-
30243016
==== Methods That Have "keyword" Status in Ruby [[method-invocation-parens-keyword]][[method-call-parens-keyword]]
30253017

30263018
Always omit parentheses for methods that have "keyword" status in Ruby.
@@ -3029,22 +3021,6 @@ NOTE: Unfortunately, it's not exactly clear _which_ methods have "keyword" statu
30293021
There is agreement that declarative methods have "keyword" status.
30303022
However, there's less agreement on which non-declarative methods, if any, have "keyword" status.
30313023

3032-
===== Declarative Methods That Have "keyword" Status in Ruby [[method-invocation-parens-declarative-keyword]][[method-call-parens-declarative-keyword]]
3033-
3034-
Always omit parentheses for declarative methods (a.k.a. DSL methods or macro methods) that have "keyword" status in Ruby (e.g., various `Module` instance methods):
3035-
3036-
[source,ruby]
3037-
----
3038-
class Person
3039-
# bad
3040-
attr_reader(:name, :age)
3041-
# good
3042-
attr_reader :name, :age
3043-
3044-
# body omitted
3045-
end
3046-
----
3047-
30483024
===== Non-Declarative Methods That Have "keyword" Status in Ruby [[method-invocation-parens-non-declarative-keyword]][[method-call-parens-non-declarative-keyword]]
30493025

30503026
For non-declarative methods with "keyword" status (e.g., various `Kernel` instance methods), two styles are considered acceptable.

0 commit comments

Comments
 (0)