Method linguistic_filter
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
def linguistic_filter(json, locale, lines, name, field, type)
Avoid parameter lists longer than 5 parameters. [6/5] Open
def linguistic_filter(json, locale, lines, name, field, type)
- Read upRead up
- Exclude checks
Checks for methods with too many parameters.
The maximum number of parameters is configurable. Keyword arguments can optionally be excluded from the total count, as they add less complexity than positional or optional parameters.
Any number of arguments for initialize
method inside a block of
Struct.new
and Data.define
like this is always allowed:
Struct.new(:one, :two, :three, :four, :five, keyword_init: true) do
def initialize(one:, two:, three:, four:, five:)
end
end
This is because checking the number of arguments of the initialize
method
does not make sense.
NOTE: Explicit block argument &block
is not counted to prevent
erroneous change that is avoided by making block argument implicit.
Example: Max: 3
# good
def foo(a, b, c = 1)
end
Example: Max: 2
# bad
def foo(a, b, c = 1)
end
Example: CountKeywordArgs: true (default)
# counts keyword args towards the maximum
# bad (assuming Max is 3)
def foo(a, b, c, d: 1)
end
# good (assuming Max is 3)
def foo(a, b, c: 1)
end
Example: CountKeywordArgs: false
# don't count keyword args towards the maximum
# good (assuming Max is 3)
def foo(a, b, c, d: 1)
end
This cop also checks for the maximum number of optional parameters.
This can be configured using the MaxOptionalParameters
config option.
Example: MaxOptionalParameters: 3 (default)
# good
def foo(a = 1, b = 2, c = 3)
end
Example: MaxOptionalParameters: 2
# bad
def foo(a = 1, b = 2, c = 3)
end
Use %w
or %W
for an array of words. Open
json.char_filter ["html_strip", "quotes"]
- Read upRead up
- Exclude checks
Checks for array literals made up of word-like strings, that are not using the %w() syntax.
Alternatively, it can check for uses of the %w() syntax, in projects which do not want to include that syntax.
NOTE: When using the percent
style, %w() arrays containing a space
will be registered as offenses.
Configuration option: MinSize
If set, arrays with fewer elements than this value will not trigger the
cop. For example, a MinSize
of 3
will not enforce a style on an
array of 2 or fewer elements.
Example: EnforcedStyle: percent (default)
# good
%w[foo bar baz]
# bad
['foo', 'bar', 'baz']
# bad (contains spaces)
%w[foo\ bar baz\ quux]
# bad
[
['one', 'One'],
['two', 'Two']
]
# good
[
%w[one One],
%w[two Two]
]
# good (2d array containing spaces)
[
['one', 'One'],
['two', 'Two'],
['forty two', 'Forty Two']
]
Example: EnforcedStyle: brackets
# good
['foo', 'bar', 'baz']
# bad
%w[foo bar baz]
# good (contains spaces)
['foo bar', 'baz quux']
# good
[
['one', 'One'],
['two', 'Two']
]
# bad
[
%w[one One],
%w[two Two]
]
Use parentheses for method calls with arguments. Open
json.set! "#{locale}_stem_filter" do
- Read upRead up
- Exclude checks
Enforces the presence (default) or absence of parentheses in method calls containing parameters.
In the default style (require_parentheses), macro methods are allowed.
Additional methods can be added to the AllowedMethods
or AllowedPatterns
list. These options are
valid only in the default style. Macros can be included by
either setting IgnoreMacros
to false or adding specific macros to
the IncludedMacros
list.
Precedence of options is all follows:
AllowedMethods
AllowedPatterns
IncludedMacros
eg. If a method is listed in both
IncludedMacros
and AllowedMethods
, then the latter takes
precedence (that is, the method is allowed).
In the alternative style (omit_parentheses), there are three additional options.
AllowParenthesesInChaining
isfalse
by default. Setting it totrue
allows the presence of parentheses in the last call during method chaining.AllowParenthesesInMultilineCall
isfalse
by default. Setting it totrue
allows the presence of parentheses in multi-line method calls.AllowParenthesesInCamelCaseMethod
isfalse
by default. This allows the presence of parentheses when calling a method whose name begins with a capital letter and which has no arguments. Setting it totrue
allows the presence of parentheses in such a method call even with arguments.
NOTE: Parentheses are still allowed in cases where omitting them results in ambiguous or syntactically incorrect code. For example, parentheses are required around a method with arguments when inside an endless method definition introduced in Ruby 3.0. Parentheses are also allowed when forwarding arguments with the triple-dot syntax introduced in Ruby 2.7 as omitting them starts an endless range. And Ruby 3.1's hash omission syntax has a case that requires parentheses because of the following issue: https://bugs.ruby-lang.org/issues/18396.
Example: EnforcedStyle: require_parentheses (default)
# bad
array.delete e
# good
array.delete(e)
# good
# Operators don't need parens
foo == bar
# good
# Setter methods don't need parens
foo.bar = baz
# okay with `puts` listed in `AllowedMethods`
puts 'test'
# okay with `^assert` listed in `AllowedPatterns`
assert_equal 'test', x
Example: EnforcedStyle: omit_parentheses
# bad
array.delete(e)
# good
array.delete e
# bad
foo.enforce(strict: true)
# good
foo.enforce strict: true
# good
# Allows parens for calls that won't produce valid Ruby or be ambiguous.
model.validate strict(true)
# good
# Allows parens for calls that won't produce valid Ruby or be ambiguous.
yield path, File.basename(path)
# good
# Operators methods calls with parens
array&.[](index)
# good
# Operators methods without parens, if you prefer
array.[] index
# good
# Operators methods calls with parens
array&.[](index)
# good
# Operators methods without parens, if you prefer
array.[] index
Example: IgnoreMacros: true (default)
# good
class Foo
bar :baz
end
Example: IgnoreMacros: false
# bad
class Foo
bar :baz
end
Example: AllowParenthesesInMultilineCall: false (default)
# bad
foo.enforce(
strict: true
)
# good
foo.enforce \
strict: true
Example: AllowParenthesesInMultilineCall: true
# good
foo.enforce(
strict: true
)
# good
foo.enforce \
strict: true
Example: AllowParenthesesInChaining: false (default)
# bad
foo().bar(1)
# good
foo().bar 1
Example: AllowParenthesesInChaining: true
# good
foo().bar(1)
# good
foo().bar 1
Example: AllowParenthesesInCamelCaseMethod: false (default)
# bad
Array(1)
# good
Array 1
Example: AllowParenthesesInCamelCaseMethod: true
# good
Array(1)
# good
Array 1
Example: AllowParenthesesInStringInterpolation: false (default)
# bad
"#{t('this.is.bad')}"
# good
"#{t 'this.is.better'}"
Example: AllowParenthesesInStringInterpolation: true
# good
"#{t('this.is.good')}"
# good
"#{t 'this.is.also.good'}"
Avoid multi-line chains of blocks. Open
end.each do |locale, file|
- Read upRead up
- Exclude checks
Checks for chaining of a block after another block that spans multiple lines.
Example:
# bad
Thread.list.select do |t|
t.alive?
end.map do |t|
t.object_id
end
# good
alive_threads = Thread.list.select do |t|
t.alive?
end
alive_threads.map do |t|
t.object_id
end
Prefer single-quoted strings when you don't need string interpolation or special symbols. Open
json.match_mapping_type "string"
- Read upRead up
- Exclude checks
Checks if uses of quotes match the configured preference.
Example: EnforcedStyle: single_quotes (default)
# bad
"No special symbols"
"No string interpolation"
"Just text"
# good
'No special symbols'
'No string interpolation'
'Just text'
"Wait! What's #{this}!"
Example: EnforcedStyle: double_quotes
# bad
'Just some text'
'No special chars or interpolation'
# good
"Just some text"
"No special chars or interpolation"
"Every string in #{project} uses double_quotes"
Prefer single-quoted strings when you don't need string interpolation or special symbols. Open
[locale, Rails.root.join("config", "locales", "analysis", "#{locale}_#{type}.txt")]
- Read upRead up
- Exclude checks
Checks if uses of quotes match the configured preference.
Example: EnforcedStyle: single_quotes (default)
# bad
"No special symbols"
"No string interpolation"
"Just text"
# good
'No special symbols'
'No string interpolation'
'Just text'
"Wait! What's #{this}!"
Example: EnforcedStyle: double_quotes
# bad
'Just some text'
'No special chars or interpolation'
# good
"Just some text"
"No special chars or interpolation"
"Every string in #{project} uses double_quotes"
Use parentheses for method calls with arguments. Open
json.type type
- Read upRead up
- Exclude checks
Enforces the presence (default) or absence of parentheses in method calls containing parameters.
In the default style (require_parentheses), macro methods are allowed.
Additional methods can be added to the AllowedMethods
or AllowedPatterns
list. These options are
valid only in the default style. Macros can be included by
either setting IgnoreMacros
to false or adding specific macros to
the IncludedMacros
list.
Precedence of options is all follows:
AllowedMethods
AllowedPatterns
IncludedMacros
eg. If a method is listed in both
IncludedMacros
and AllowedMethods
, then the latter takes
precedence (that is, the method is allowed).
In the alternative style (omit_parentheses), there are three additional options.
AllowParenthesesInChaining
isfalse
by default. Setting it totrue
allows the presence of parentheses in the last call during method chaining.AllowParenthesesInMultilineCall
isfalse
by default. Setting it totrue
allows the presence of parentheses in multi-line method calls.AllowParenthesesInCamelCaseMethod
isfalse
by default. This allows the presence of parentheses when calling a method whose name begins with a capital letter and which has no arguments. Setting it totrue
allows the presence of parentheses in such a method call even with arguments.
NOTE: Parentheses are still allowed in cases where omitting them results in ambiguous or syntactically incorrect code. For example, parentheses are required around a method with arguments when inside an endless method definition introduced in Ruby 3.0. Parentheses are also allowed when forwarding arguments with the triple-dot syntax introduced in Ruby 2.7 as omitting them starts an endless range. And Ruby 3.1's hash omission syntax has a case that requires parentheses because of the following issue: https://bugs.ruby-lang.org/issues/18396.
Example: EnforcedStyle: require_parentheses (default)
# bad
array.delete e
# good
array.delete(e)
# good
# Operators don't need parens
foo == bar
# good
# Setter methods don't need parens
foo.bar = baz
# okay with `puts` listed in `AllowedMethods`
puts 'test'
# okay with `^assert` listed in `AllowedPatterns`
assert_equal 'test', x
Example: EnforcedStyle: omit_parentheses
# bad
array.delete(e)
# good
array.delete e
# bad
foo.enforce(strict: true)
# good
foo.enforce strict: true
# good
# Allows parens for calls that won't produce valid Ruby or be ambiguous.
model.validate strict(true)
# good
# Allows parens for calls that won't produce valid Ruby or be ambiguous.
yield path, File.basename(path)
# good
# Operators methods calls with parens
array&.[](index)
# good
# Operators methods without parens, if you prefer
array.[] index
# good
# Operators methods calls with parens
array&.[](index)
# good
# Operators methods without parens, if you prefer
array.[] index
Example: IgnoreMacros: true (default)
# good
class Foo
bar :baz
end
Example: IgnoreMacros: false
# bad
class Foo
bar :baz
end
Example: AllowParenthesesInMultilineCall: false (default)
# bad
foo.enforce(
strict: true
)
# good
foo.enforce \
strict: true
Example: AllowParenthesesInMultilineCall: true
# good
foo.enforce(
strict: true
)
# good
foo.enforce \
strict: true
Example: AllowParenthesesInChaining: false (default)
# bad
foo().bar(1)
# good
foo().bar 1
Example: AllowParenthesesInChaining: true
# good
foo().bar(1)
# good
foo().bar 1
Example: AllowParenthesesInCamelCaseMethod: false (default)
# bad
Array(1)
# good
Array 1
Example: AllowParenthesesInCamelCaseMethod: true
# good
Array(1)
# good
Array 1
Example: AllowParenthesesInStringInterpolation: false (default)
# bad
"#{t('this.is.bad')}"
# good
"#{t 'this.is.better'}"
Example: AllowParenthesesInStringInterpolation: true
# good
"#{t('this.is.good')}"
# good
"#{t 'this.is.also.good'}"
Prefer single-quoted strings when you don't need string interpolation or special symbols. Open
json.tokenizer "icu_tokenizer"
- Read upRead up
- Exclude checks
Checks if uses of quotes match the configured preference.
Example: EnforcedStyle: single_quotes (default)
# bad
"No special symbols"
"No string interpolation"
"Just text"
# good
'No special symbols'
'No string interpolation'
'Just text'
"Wait! What's #{this}!"
Example: EnforcedStyle: double_quotes
# bad
'Just some text'
'No special chars or interpolation'
# good
"Just some text"
"No special chars or interpolation"
"Every string in #{project} uses double_quotes"
Prefer single-quoted strings when you don't need string interpolation or special symbols. Open
File.readlines(file).map(&:chomp).reject { |line| line.starts_with?("#") }
- Read upRead up
- Exclude checks
Checks if uses of quotes match the configured preference.
Example: EnforcedStyle: single_quotes (default)
# bad
"No special symbols"
"No string interpolation"
"Just text"
# good
'No special symbols'
'No string interpolation'
'Just text'
"Wait! What's #{this}!"
Example: EnforcedStyle: double_quotes
# bad
'Just some text'
'No special chars or interpolation'
# good
"Just some text"
"No special chars or interpolation"
"Every string in #{project} uses double_quotes"
Use parentheses for method calls with arguments. Open
json.type "date"
- Read upRead up
- Exclude checks
Enforces the presence (default) or absence of parentheses in method calls containing parameters.
In the default style (require_parentheses), macro methods are allowed.
Additional methods can be added to the AllowedMethods
or AllowedPatterns
list. These options are
valid only in the default style. Macros can be included by
either setting IgnoreMacros
to false or adding specific macros to
the IncludedMacros
list.
Precedence of options is all follows:
AllowedMethods
AllowedPatterns
IncludedMacros
eg. If a method is listed in both
IncludedMacros
and AllowedMethods
, then the latter takes
precedence (that is, the method is allowed).
In the alternative style (omit_parentheses), there are three additional options.
AllowParenthesesInChaining
isfalse
by default. Setting it totrue
allows the presence of parentheses in the last call during method chaining.AllowParenthesesInMultilineCall
isfalse
by default. Setting it totrue
allows the presence of parentheses in multi-line method calls.AllowParenthesesInCamelCaseMethod
isfalse
by default. This allows the presence of parentheses when calling a method whose name begins with a capital letter and which has no arguments. Setting it totrue
allows the presence of parentheses in such a method call even with arguments.
NOTE: Parentheses are still allowed in cases where omitting them results in ambiguous or syntactically incorrect code. For example, parentheses are required around a method with arguments when inside an endless method definition introduced in Ruby 3.0. Parentheses are also allowed when forwarding arguments with the triple-dot syntax introduced in Ruby 2.7 as omitting them starts an endless range. And Ruby 3.1's hash omission syntax has a case that requires parentheses because of the following issue: https://bugs.ruby-lang.org/issues/18396.
Example: EnforcedStyle: require_parentheses (default)
# bad
array.delete e
# good
array.delete(e)
# good
# Operators don't need parens
foo == bar
# good
# Setter methods don't need parens
foo.bar = baz
# okay with `puts` listed in `AllowedMethods`
puts 'test'
# okay with `^assert` listed in `AllowedPatterns`
assert_equal 'test', x
Example: EnforcedStyle: omit_parentheses
# bad
array.delete(e)
# good
array.delete e
# bad
foo.enforce(strict: true)
# good
foo.enforce strict: true
# good
# Allows parens for calls that won't produce valid Ruby or be ambiguous.
model.validate strict(true)
# good
# Allows parens for calls that won't produce valid Ruby or be ambiguous.
yield path, File.basename(path)
# good
# Operators methods calls with parens
array&.[](index)
# good
# Operators methods without parens, if you prefer
array.[] index
# good
# Operators methods calls with parens
array&.[](index)
# good
# Operators methods without parens, if you prefer
array.[] index
Example: IgnoreMacros: true (default)
# good
class Foo
bar :baz
end
Example: IgnoreMacros: false
# bad
class Foo
bar :baz
end
Example: AllowParenthesesInMultilineCall: false (default)
# bad
foo.enforce(
strict: true
)
# good
foo.enforce \
strict: true
Example: AllowParenthesesInMultilineCall: true
# good
foo.enforce(
strict: true
)
# good
foo.enforce \
strict: true
Example: AllowParenthesesInChaining: false (default)
# bad
foo().bar(1)
# good
foo().bar 1
Example: AllowParenthesesInChaining: true
# good
foo().bar(1)
# good
foo().bar 1
Example: AllowParenthesesInCamelCaseMethod: false (default)
# bad
Array(1)
# good
Array 1
Example: AllowParenthesesInCamelCaseMethod: true
# good
Array(1)
# good
Array 1
Example: AllowParenthesesInStringInterpolation: false (default)
# bad
"#{t('this.is.bad')}"
# good
"#{t 'this.is.better'}"
Example: AllowParenthesesInStringInterpolation: true
# good
"#{t('this.is.good')}"
# good
"#{t 'this.is.also.good'}"
Use parentheses for method calls with arguments. Open
json.match "*"
- Read upRead up
- Exclude checks
Enforces the presence (default) or absence of parentheses in method calls containing parameters.
In the default style (require_parentheses), macro methods are allowed.
Additional methods can be added to the AllowedMethods
or AllowedPatterns
list. These options are
valid only in the default style. Macros can be included by
either setting IgnoreMacros
to false or adding specific macros to
the IncludedMacros
list.
Precedence of options is all follows:
AllowedMethods
AllowedPatterns
IncludedMacros
eg. If a method is listed in both
IncludedMacros
and AllowedMethods
, then the latter takes
precedence (that is, the method is allowed).
In the alternative style (omit_parentheses), there are three additional options.
AllowParenthesesInChaining
isfalse
by default. Setting it totrue
allows the presence of parentheses in the last call during method chaining.AllowParenthesesInMultilineCall
isfalse
by default. Setting it totrue
allows the presence of parentheses in multi-line method calls.AllowParenthesesInCamelCaseMethod
isfalse
by default. This allows the presence of parentheses when calling a method whose name begins with a capital letter and which has no arguments. Setting it totrue
allows the presence of parentheses in such a method call even with arguments.
NOTE: Parentheses are still allowed in cases where omitting them results in ambiguous or syntactically incorrect code. For example, parentheses are required around a method with arguments when inside an endless method definition introduced in Ruby 3.0. Parentheses are also allowed when forwarding arguments with the triple-dot syntax introduced in Ruby 2.7 as omitting them starts an endless range. And Ruby 3.1's hash omission syntax has a case that requires parentheses because of the following issue: https://bugs.ruby-lang.org/issues/18396.
Example: EnforcedStyle: require_parentheses (default)
# bad
array.delete e
# good
array.delete(e)
# good
# Operators don't need parens
foo == bar
# good
# Setter methods don't need parens
foo.bar = baz
# okay with `puts` listed in `AllowedMethods`
puts 'test'
# okay with `^assert` listed in `AllowedPatterns`
assert_equal 'test', x
Example: EnforcedStyle: omit_parentheses
# bad
array.delete(e)
# good
array.delete e
# bad
foo.enforce(strict: true)
# good
foo.enforce strict: true
# good
# Allows parens for calls that won't produce valid Ruby or be ambiguous.
model.validate strict(true)
# good
# Allows parens for calls that won't produce valid Ruby or be ambiguous.
yield path, File.basename(path)
# good
# Operators methods calls with parens
array&.[](index)
# good
# Operators methods without parens, if you prefer
array.[] index
# good
# Operators methods calls with parens
array&.[](index)
# good
# Operators methods without parens, if you prefer
array.[] index
Example: IgnoreMacros: true (default)
# good
class Foo
bar :baz
end
Example: IgnoreMacros: false
# bad
class Foo
bar :baz
end
Example: AllowParenthesesInMultilineCall: false (default)
# bad
foo.enforce(
strict: true
)
# good
foo.enforce \
strict: true
Example: AllowParenthesesInMultilineCall: true
# good
foo.enforce(
strict: true
)
# good
foo.enforce \
strict: true
Example: AllowParenthesesInChaining: false (default)
# bad
foo().bar(1)
# good
foo().bar 1
Example: AllowParenthesesInChaining: true
# good
foo().bar(1)
# good
foo().bar 1
Example: AllowParenthesesInCamelCaseMethod: false (default)
# bad
Array(1)
# good
Array 1
Example: AllowParenthesesInCamelCaseMethod: true
# good
Array(1)
# good
Array 1
Example: AllowParenthesesInStringInterpolation: false (default)
# bad
"#{t('this.is.bad')}"
# good
"#{t 'this.is.better'}"
Example: AllowParenthesesInStringInterpolation: true
# good
"#{t('this.is.good')}"
# good
"#{t 'this.is.also.good'}"
Prefer single-quoted strings when you don't need string interpolation or special symbols. Open
json.char_filter ["html_strip", "quotes"]
- Read upRead up
- Exclude checks
Checks if uses of quotes match the configured preference.
Example: EnforcedStyle: single_quotes (default)
# bad
"No special symbols"
"No string interpolation"
"Just text"
# good
'No special symbols'
'No string interpolation'
'Just text'
"Wait! What's #{this}!"
Example: EnforcedStyle: double_quotes
# bad
'Just some text'
'No special chars or interpolation'
# good
"Just some text"
"No special chars or interpolation"
"Every string in #{project} uses double_quotes"
Use parentheses for method calls with arguments. Open
json.type type
- Read upRead up
- Exclude checks
Enforces the presence (default) or absence of parentheses in method calls containing parameters.
In the default style (require_parentheses), macro methods are allowed.
Additional methods can be added to the AllowedMethods
or AllowedPatterns
list. These options are
valid only in the default style. Macros can be included by
either setting IgnoreMacros
to false or adding specific macros to
the IncludedMacros
list.
Precedence of options is all follows:
AllowedMethods
AllowedPatterns
IncludedMacros
eg. If a method is listed in both
IncludedMacros
and AllowedMethods
, then the latter takes
precedence (that is, the method is allowed).
In the alternative style (omit_parentheses), there are three additional options.
AllowParenthesesInChaining
isfalse
by default. Setting it totrue
allows the presence of parentheses in the last call during method chaining.AllowParenthesesInMultilineCall
isfalse
by default. Setting it totrue
allows the presence of parentheses in multi-line method calls.AllowParenthesesInCamelCaseMethod
isfalse
by default. This allows the presence of parentheses when calling a method whose name begins with a capital letter and which has no arguments. Setting it totrue
allows the presence of parentheses in such a method call even with arguments.
NOTE: Parentheses are still allowed in cases where omitting them results in ambiguous or syntactically incorrect code. For example, parentheses are required around a method with arguments when inside an endless method definition introduced in Ruby 3.0. Parentheses are also allowed when forwarding arguments with the triple-dot syntax introduced in Ruby 2.7 as omitting them starts an endless range. And Ruby 3.1's hash omission syntax has a case that requires parentheses because of the following issue: https://bugs.ruby-lang.org/issues/18396.
Example: EnforcedStyle: require_parentheses (default)
# bad
array.delete e
# good
array.delete(e)
# good
# Operators don't need parens
foo == bar
# good
# Setter methods don't need parens
foo.bar = baz
# okay with `puts` listed in `AllowedMethods`
puts 'test'
# okay with `^assert` listed in `AllowedPatterns`
assert_equal 'test', x
Example: EnforcedStyle: omit_parentheses
# bad
array.delete(e)
# good
array.delete e
# bad
foo.enforce(strict: true)
# good
foo.enforce strict: true
# good
# Allows parens for calls that won't produce valid Ruby or be ambiguous.
model.validate strict(true)
# good
# Allows parens for calls that won't produce valid Ruby or be ambiguous.
yield path, File.basename(path)
# good
# Operators methods calls with parens
array&.[](index)
# good
# Operators methods without parens, if you prefer
array.[] index
# good
# Operators methods calls with parens
array&.[](index)
# good
# Operators methods without parens, if you prefer
array.[] index
Example: IgnoreMacros: true (default)
# good
class Foo
bar :baz
end
Example: IgnoreMacros: false
# bad
class Foo
bar :baz
end
Example: AllowParenthesesInMultilineCall: false (default)
# bad
foo.enforce(
strict: true
)
# good
foo.enforce \
strict: true
Example: AllowParenthesesInMultilineCall: true
# good
foo.enforce(
strict: true
)
# good
foo.enforce \
strict: true
Example: AllowParenthesesInChaining: false (default)
# bad
foo().bar(1)
# good
foo().bar 1
Example: AllowParenthesesInChaining: true
# good
foo().bar(1)
# good
foo().bar 1
Example: AllowParenthesesInCamelCaseMethod: false (default)
# bad
Array(1)
# good
Array 1
Example: AllowParenthesesInCamelCaseMethod: true
# good
Array(1)
# good
Array 1
Example: AllowParenthesesInStringInterpolation: false (default)
# bad
"#{t('this.is.bad')}"
# good
"#{t 'this.is.better'}"
Example: AllowParenthesesInStringInterpolation: true
# good
"#{t('this.is.good')}"
# good
"#{t 'this.is.also.good'}"
Use parentheses for method calls with arguments. Open
json.char_filter ["html_strip", "quotes"]
- Read upRead up
- Exclude checks
Enforces the presence (default) or absence of parentheses in method calls containing parameters.
In the default style (require_parentheses), macro methods are allowed.
Additional methods can be added to the AllowedMethods
or AllowedPatterns
list. These options are
valid only in the default style. Macros can be included by
either setting IgnoreMacros
to false or adding specific macros to
the IncludedMacros
list.
Precedence of options is all follows:
AllowedMethods
AllowedPatterns
IncludedMacros
eg. If a method is listed in both
IncludedMacros
and AllowedMethods
, then the latter takes
precedence (that is, the method is allowed).
In the alternative style (omit_parentheses), there are three additional options.
AllowParenthesesInChaining
isfalse
by default. Setting it totrue
allows the presence of parentheses in the last call during method chaining.AllowParenthesesInMultilineCall
isfalse
by default. Setting it totrue
allows the presence of parentheses in multi-line method calls.AllowParenthesesInCamelCaseMethod
isfalse
by default. This allows the presence of parentheses when calling a method whose name begins with a capital letter and which has no arguments. Setting it totrue
allows the presence of parentheses in such a method call even with arguments.
NOTE: Parentheses are still allowed in cases where omitting them results in ambiguous or syntactically incorrect code. For example, parentheses are required around a method with arguments when inside an endless method definition introduced in Ruby 3.0. Parentheses are also allowed when forwarding arguments with the triple-dot syntax introduced in Ruby 2.7 as omitting them starts an endless range. And Ruby 3.1's hash omission syntax has a case that requires parentheses because of the following issue: https://bugs.ruby-lang.org/issues/18396.
Example: EnforcedStyle: require_parentheses (default)
# bad
array.delete e
# good
array.delete(e)
# good
# Operators don't need parens
foo == bar
# good
# Setter methods don't need parens
foo.bar = baz
# okay with `puts` listed in `AllowedMethods`
puts 'test'
# okay with `^assert` listed in `AllowedPatterns`
assert_equal 'test', x
Example: EnforcedStyle: omit_parentheses
# bad
array.delete(e)
# good
array.delete e
# bad
foo.enforce(strict: true)
# good
foo.enforce strict: true
# good
# Allows parens for calls that won't produce valid Ruby or be ambiguous.
model.validate strict(true)
# good
# Allows parens for calls that won't produce valid Ruby or be ambiguous.
yield path, File.basename(path)
# good
# Operators methods calls with parens
array&.[](index)
# good
# Operators methods without parens, if you prefer
array.[] index
# good
# Operators methods calls with parens
array&.[](index)
# good
# Operators methods without parens, if you prefer
array.[] index
Example: IgnoreMacros: true (default)
# good
class Foo
bar :baz
end
Example: IgnoreMacros: false
# bad
class Foo
bar :baz
end
Example: AllowParenthesesInMultilineCall: false (default)
# bad
foo.enforce(
strict: true
)
# good
foo.enforce \
strict: true
Example: AllowParenthesesInMultilineCall: true
# good
foo.enforce(
strict: true
)
# good
foo.enforce \
strict: true
Example: AllowParenthesesInChaining: false (default)
# bad
foo().bar(1)
# good
foo().bar 1
Example: AllowParenthesesInChaining: true
# good
foo().bar(1)
# good
foo().bar 1
Example: AllowParenthesesInCamelCaseMethod: false (default)
# bad
Array(1)
# good
Array 1
Example: AllowParenthesesInCamelCaseMethod: true
# good
Array(1)
# good
Array 1
Example: AllowParenthesesInStringInterpolation: false (default)
# bad
"#{t('this.is.bad')}"
# good
"#{t 'this.is.better'}"
Example: AllowParenthesesInStringInterpolation: true
# good
"#{t('this.is.good')}"
# good
"#{t 'this.is.also.good'}"
Prefer single-quoted strings when you don't need string interpolation or special symbols. Open
json.char_filter ["html_strip", "quotes"]
- Read upRead up
- Exclude checks
Checks if uses of quotes match the configured preference.
Example: EnforcedStyle: single_quotes (default)
# bad
"No special symbols"
"No string interpolation"
"Just text"
# good
'No special symbols'
'No string interpolation'
'Just text'
"Wait! What's #{this}!"
Example: EnforcedStyle: double_quotes
# bad
'Just some text'
'No special chars or interpolation'
# good
"Just some text"
"No special chars or interpolation"
"Every string in #{project} uses double_quotes"
Prefer single-quoted strings when you don't need string interpolation or special symbols. Open
json.type "keyword"
- Read upRead up
- Exclude checks
Checks if uses of quotes match the configured preference.
Example: EnforcedStyle: single_quotes (default)
# bad
"No special symbols"
"No string interpolation"
"Just text"
# good
'No special symbols'
'No string interpolation'
'Just text'
"Wait! What's #{this}!"
Example: EnforcedStyle: double_quotes
# bad
'Just some text'
'No special chars or interpolation'
# good
"Just some text"
"No special chars or interpolation"
"Every string in #{project} uses double_quotes"
Prefer single-quoted strings when you don't need string interpolation or special symbols. Open
json.type "stemmer"
- Read upRead up
- Exclude checks
Checks if uses of quotes match the configured preference.
Example: EnforcedStyle: single_quotes (default)
# bad
"No special symbols"
"No string interpolation"
"Just text"
# good
'No special symbols'
'No string interpolation'
'Just text'
"Wait! What's #{this}!"
Example: EnforcedStyle: double_quotes
# bad
'Just some text'
'No special chars or interpolation'
# good
"Just some text"
"No special chars or interpolation"
"Every string in #{project} uses double_quotes"
Use parentheses for method calls with arguments. Open
json.set! "#{locale}_#{name}" do
- Read upRead up
- Exclude checks
Enforces the presence (default) or absence of parentheses in method calls containing parameters.
In the default style (require_parentheses), macro methods are allowed.
Additional methods can be added to the AllowedMethods
or AllowedPatterns
list. These options are
valid only in the default style. Macros can be included by
either setting IgnoreMacros
to false or adding specific macros to
the IncludedMacros
list.
Precedence of options is all follows:
AllowedMethods
AllowedPatterns
IncludedMacros
eg. If a method is listed in both
IncludedMacros
and AllowedMethods
, then the latter takes
precedence (that is, the method is allowed).
In the alternative style (omit_parentheses), there are three additional options.
AllowParenthesesInChaining
isfalse
by default. Setting it totrue
allows the presence of parentheses in the last call during method chaining.AllowParenthesesInMultilineCall
isfalse
by default. Setting it totrue
allows the presence of parentheses in multi-line method calls.AllowParenthesesInCamelCaseMethod
isfalse
by default. This allows the presence of parentheses when calling a method whose name begins with a capital letter and which has no arguments. Setting it totrue
allows the presence of parentheses in such a method call even with arguments.
NOTE: Parentheses are still allowed in cases where omitting them results in ambiguous or syntactically incorrect code. For example, parentheses are required around a method with arguments when inside an endless method definition introduced in Ruby 3.0. Parentheses are also allowed when forwarding arguments with the triple-dot syntax introduced in Ruby 2.7 as omitting them starts an endless range. And Ruby 3.1's hash omission syntax has a case that requires parentheses because of the following issue: https://bugs.ruby-lang.org/issues/18396.
Example: EnforcedStyle: require_parentheses (default)
# bad
array.delete e
# good
array.delete(e)
# good
# Operators don't need parens
foo == bar
# good
# Setter methods don't need parens
foo.bar = baz
# okay with `puts` listed in `AllowedMethods`
puts 'test'
# okay with `^assert` listed in `AllowedPatterns`
assert_equal 'test', x
Example: EnforcedStyle: omit_parentheses
# bad
array.delete(e)
# good
array.delete e
# bad
foo.enforce(strict: true)
# good
foo.enforce strict: true
# good
# Allows parens for calls that won't produce valid Ruby or be ambiguous.
model.validate strict(true)
# good
# Allows parens for calls that won't produce valid Ruby or be ambiguous.
yield path, File.basename(path)
# good
# Operators methods calls with parens
array&.[](index)
# good
# Operators methods without parens, if you prefer
array.[] index
# good
# Operators methods calls with parens
array&.[](index)
# good
# Operators methods without parens, if you prefer
array.[] index
Example: IgnoreMacros: true (default)
# good
class Foo
bar :baz
end
Example: IgnoreMacros: false
# bad
class Foo
bar :baz
end
Example: AllowParenthesesInMultilineCall: false (default)
# bad
foo.enforce(
strict: true
)
# good
foo.enforce \
strict: true
Example: AllowParenthesesInMultilineCall: true
# good
foo.enforce(
strict: true
)
# good
foo.enforce \
strict: true
Example: AllowParenthesesInChaining: false (default)
# bad
foo().bar(1)
# good
foo().bar 1
Example: AllowParenthesesInChaining: true
# good
foo().bar(1)
# good
foo().bar 1
Example: AllowParenthesesInCamelCaseMethod: false (default)
# bad
Array(1)
# good
Array 1
Example: AllowParenthesesInCamelCaseMethod: true
# good
Array(1)
# good
Array 1
Example: AllowParenthesesInStringInterpolation: false (default)
# bad
"#{t('this.is.bad')}"
# good
"#{t 'this.is.better'}"
Example: AllowParenthesesInStringInterpolation: true
# good
"#{t('this.is.good')}"
# good
"#{t 'this.is.also.good'}"
Prefer single-quoted strings when you don't need string interpolation or special symbols. Open
json.type "date"
- Read upRead up
- Exclude checks
Checks if uses of quotes match the configured preference.
Example: EnforcedStyle: single_quotes (default)
# bad
"No special symbols"
"No string interpolation"
"Just text"
# good
'No special symbols'
'No string interpolation'
'Just text'
"Wait! What's #{this}!"
Example: EnforcedStyle: double_quotes
# bad
'Just some text'
'No special chars or interpolation'
# good
"Just some text"
"No special chars or interpolation"
"Every string in #{project} uses double_quotes"
Prefer single-quoted strings when you don't need string interpolation or special symbols. Open
json.match "*"
- Read upRead up
- Exclude checks
Checks if uses of quotes match the configured preference.
Example: EnforcedStyle: single_quotes (default)
# bad
"No special symbols"
"No string interpolation"
"Just text"
# good
'No special symbols'
'No string interpolation'
'Just text'
"Wait! What's #{this}!"
Example: EnforcedStyle: double_quotes
# bad
'Just some text'
'No special chars or interpolation'
# good
"Just some text"
"No special chars or interpolation"
"Every string in #{project} uses double_quotes"
Missing frozen string literal comment. Open
module Templatable
- Read upRead up
- Exclude checks
Helps you transition from mutable string literals
to frozen string literals.
It will add the # frozen_string_literal: true
magic comment to the top
of files to enable frozen string literals. Frozen string literals may be
default in future Ruby. The comment will be added below a shebang and
encoding comment. The frozen string literal comment is only valid in Ruby 2.3+.
Note that the cop will accept files where the comment exists but is set
to false
instead of true
.
To require a blank line after this comment, please see
Layout/EmptyLineAfterMagicComment
cop.
Safety:
This cop's autocorrection is unsafe since any strings mutations will
change from being accepted to raising FrozenError
, as all strings
will become frozen by default, and will need to be manually refactored.
Example: EnforcedStyle: always (default)
# The `always` style will always add the frozen string literal comment
# to a file, regardless of the Ruby version or if `freeze` or `<<` are
# called on a string literal.
# bad
module Bar
# ...
end
# good
# frozen_string_literal: true
module Bar
# ...
end
# good
# frozen_string_literal: false
module Bar
# ...
end
Example: EnforcedStyle: never
# The `never` will enforce that the frozen string literal comment does
# not exist in a file.
# bad
# frozen_string_literal: true
module Baz
# ...
end
# good
module Baz
# ...
end
Example: EnforcedStyle: always_true
# The `always_true` style enforces that the frozen string literal
# comment is set to `true`. This is a stricter option than `always`
# and forces projects to use frozen string literals.
# bad
# frozen_string_literal: false
module Baz
# ...
end
# bad
module Baz
# ...
end
# good
# frozen_string_literal: true
module Bar
# ...
end
Use parentheses for method calls with arguments. Open
File.exist? locale_file_array.last
- Read upRead up
- Exclude checks
Enforces the presence (default) or absence of parentheses in method calls containing parameters.
In the default style (require_parentheses), macro methods are allowed.
Additional methods can be added to the AllowedMethods
or AllowedPatterns
list. These options are
valid only in the default style. Macros can be included by
either setting IgnoreMacros
to false or adding specific macros to
the IncludedMacros
list.
Precedence of options is all follows:
AllowedMethods
AllowedPatterns
IncludedMacros
eg. If a method is listed in both
IncludedMacros
and AllowedMethods
, then the latter takes
precedence (that is, the method is allowed).
In the alternative style (omit_parentheses), there are three additional options.
AllowParenthesesInChaining
isfalse
by default. Setting it totrue
allows the presence of parentheses in the last call during method chaining.AllowParenthesesInMultilineCall
isfalse
by default. Setting it totrue
allows the presence of parentheses in multi-line method calls.AllowParenthesesInCamelCaseMethod
isfalse
by default. This allows the presence of parentheses when calling a method whose name begins with a capital letter and which has no arguments. Setting it totrue
allows the presence of parentheses in such a method call even with arguments.
NOTE: Parentheses are still allowed in cases where omitting them results in ambiguous or syntactically incorrect code. For example, parentheses are required around a method with arguments when inside an endless method definition introduced in Ruby 3.0. Parentheses are also allowed when forwarding arguments with the triple-dot syntax introduced in Ruby 2.7 as omitting them starts an endless range. And Ruby 3.1's hash omission syntax has a case that requires parentheses because of the following issue: https://bugs.ruby-lang.org/issues/18396.
Example: EnforcedStyle: require_parentheses (default)
# bad
array.delete e
# good
array.delete(e)
# good
# Operators don't need parens
foo == bar
# good
# Setter methods don't need parens
foo.bar = baz
# okay with `puts` listed in `AllowedMethods`
puts 'test'
# okay with `^assert` listed in `AllowedPatterns`
assert_equal 'test', x
Example: EnforcedStyle: omit_parentheses
# bad
array.delete(e)
# good
array.delete e
# bad
foo.enforce(strict: true)
# good
foo.enforce strict: true
# good
# Allows parens for calls that won't produce valid Ruby or be ambiguous.
model.validate strict(true)
# good
# Allows parens for calls that won't produce valid Ruby or be ambiguous.
yield path, File.basename(path)
# good
# Operators methods calls with parens
array&.[](index)
# good
# Operators methods without parens, if you prefer
array.[] index
# good
# Operators methods calls with parens
array&.[](index)
# good
# Operators methods without parens, if you prefer
array.[] index
Example: IgnoreMacros: true (default)
# good
class Foo
bar :baz
end
Example: IgnoreMacros: false
# bad
class Foo
bar :baz
end
Example: AllowParenthesesInMultilineCall: false (default)
# bad
foo.enforce(
strict: true
)
# good
foo.enforce \
strict: true
Example: AllowParenthesesInMultilineCall: true
# good
foo.enforce(
strict: true
)
# good
foo.enforce \
strict: true
Example: AllowParenthesesInChaining: false (default)
# bad
foo().bar(1)
# good
foo().bar 1
Example: AllowParenthesesInChaining: true
# good
foo().bar(1)
# good
foo().bar 1
Example: AllowParenthesesInCamelCaseMethod: false (default)
# bad
Array(1)
# good
Array 1
Example: AllowParenthesesInCamelCaseMethod: true
# good
Array(1)
# good
Array 1
Example: AllowParenthesesInStringInterpolation: false (default)
# bad
"#{t('this.is.bad')}"
# good
"#{t 'this.is.better'}"
Example: AllowParenthesesInStringInterpolation: true
# good
"#{t('this.is.good')}"
# good
"#{t 'this.is.also.good'}"
Use parentheses for method calls with arguments. Open
json.type "custom"
- Read upRead up
- Exclude checks
Enforces the presence (default) or absence of parentheses in method calls containing parameters.
In the default style (require_parentheses), macro methods are allowed.
Additional methods can be added to the AllowedMethods
or AllowedPatterns
list. These options are
valid only in the default style. Macros can be included by
either setting IgnoreMacros
to false or adding specific macros to
the IncludedMacros
list.
Precedence of options is all follows:
AllowedMethods
AllowedPatterns
IncludedMacros
eg. If a method is listed in both
IncludedMacros
and AllowedMethods
, then the latter takes
precedence (that is, the method is allowed).
In the alternative style (omit_parentheses), there are three additional options.
AllowParenthesesInChaining
isfalse
by default. Setting it totrue
allows the presence of parentheses in the last call during method chaining.AllowParenthesesInMultilineCall
isfalse
by default. Setting it totrue
allows the presence of parentheses in multi-line method calls.AllowParenthesesInCamelCaseMethod
isfalse
by default. This allows the presence of parentheses when calling a method whose name begins with a capital letter and which has no arguments. Setting it totrue
allows the presence of parentheses in such a method call even with arguments.
NOTE: Parentheses are still allowed in cases where omitting them results in ambiguous or syntactically incorrect code. For example, parentheses are required around a method with arguments when inside an endless method definition introduced in Ruby 3.0. Parentheses are also allowed when forwarding arguments with the triple-dot syntax introduced in Ruby 2.7 as omitting them starts an endless range. And Ruby 3.1's hash omission syntax has a case that requires parentheses because of the following issue: https://bugs.ruby-lang.org/issues/18396.
Example: EnforcedStyle: require_parentheses (default)
# bad
array.delete e
# good
array.delete(e)
# good
# Operators don't need parens
foo == bar
# good
# Setter methods don't need parens
foo.bar = baz
# okay with `puts` listed in `AllowedMethods`
puts 'test'
# okay with `^assert` listed in `AllowedPatterns`
assert_equal 'test', x
Example: EnforcedStyle: omit_parentheses
# bad
array.delete(e)
# good
array.delete e
# bad
foo.enforce(strict: true)
# good
foo.enforce strict: true
# good
# Allows parens for calls that won't produce valid Ruby or be ambiguous.
model.validate strict(true)
# good
# Allows parens for calls that won't produce valid Ruby or be ambiguous.
yield path, File.basename(path)
# good
# Operators methods calls with parens
array&.[](index)
# good
# Operators methods without parens, if you prefer
array.[] index
# good
# Operators methods calls with parens
array&.[](index)
# good
# Operators methods without parens, if you prefer
array.[] index
Example: IgnoreMacros: true (default)
# good
class Foo
bar :baz
end
Example: IgnoreMacros: false
# bad
class Foo
bar :baz
end
Example: AllowParenthesesInMultilineCall: false (default)
# bad
foo.enforce(
strict: true
)
# good
foo.enforce \
strict: true
Example: AllowParenthesesInMultilineCall: true
# good
foo.enforce(
strict: true
)
# good
foo.enforce \
strict: true
Example: AllowParenthesesInChaining: false (default)
# bad
foo().bar(1)
# good
foo().bar 1
Example: AllowParenthesesInChaining: true
# good
foo().bar(1)
# good
foo().bar 1
Example: AllowParenthesesInCamelCaseMethod: false (default)
# bad
Array(1)
# good
Array 1
Example: AllowParenthesesInCamelCaseMethod: true
# good
Array(1)
# good
Array 1
Example: AllowParenthesesInStringInterpolation: false (default)
# bad
"#{t('this.is.bad')}"
# good
"#{t 'this.is.better'}"
Example: AllowParenthesesInStringInterpolation: true
# good
"#{t('this.is.good')}"
# good
"#{t 'this.is.also.good'}"
Prefer single-quoted strings when you don't need string interpolation or special symbols. Open
[locale, Rails.root.join("config", "locales", "analysis", "#{locale}_#{type}.txt")]
- Read upRead up
- Exclude checks
Checks if uses of quotes match the configured preference.
Example: EnforcedStyle: single_quotes (default)
# bad
"No special symbols"
"No string interpolation"
"Just text"
# good
'No special symbols'
'No string interpolation'
'Just text'
"Wait! What's #{this}!"
Example: EnforcedStyle: double_quotes
# bad
'Just some text'
'No special chars or interpolation'
# good
"Just some text"
"No special chars or interpolation"
"Every string in #{project} uses double_quotes"
Prefer single-quoted strings when you don't need string interpolation or special symbols. Open
stemmer_name = degree == "standard" ? '' : "#{degree}_"
- Read upRead up
- Exclude checks
Checks if uses of quotes match the configured preference.
Example: EnforcedStyle: single_quotes (default)
# bad
"No special symbols"
"No string interpolation"
"Just text"
# good
'No special symbols'
'No string interpolation'
'Just text'
"Wait! What's #{this}!"
Example: EnforcedStyle: double_quotes
# bad
'Just some text'
'No special chars or interpolation'
# good
"Just some text"
"No special chars or interpolation"
"Every string in #{project} uses double_quotes"
Prefer single-quoted strings when you don't need string interpolation or special symbols. Open
json.type "custom"
- Read upRead up
- Exclude checks
Checks if uses of quotes match the configured preference.
Example: EnforcedStyle: single_quotes (default)
# bad
"No special symbols"
"No string interpolation"
"Just text"
# good
'No special symbols'
'No string interpolation'
'Just text'
"Wait! What's #{this}!"
Example: EnforcedStyle: double_quotes
# bad
'Just some text'
'No special chars or interpolation'
# good
"Just some text"
"No special chars or interpolation"
"Every string in #{project} uses double_quotes"
Use parentheses for method calls with arguments. Open
json.tokenizer "icu_tokenizer"
- Read upRead up
- Exclude checks
Enforces the presence (default) or absence of parentheses in method calls containing parameters.
In the default style (require_parentheses), macro methods are allowed.
Additional methods can be added to the AllowedMethods
or AllowedPatterns
list. These options are
valid only in the default style. Macros can be included by
either setting IgnoreMacros
to false or adding specific macros to
the IncludedMacros
list.
Precedence of options is all follows:
AllowedMethods
AllowedPatterns
IncludedMacros
eg. If a method is listed in both
IncludedMacros
and AllowedMethods
, then the latter takes
precedence (that is, the method is allowed).
In the alternative style (omit_parentheses), there are three additional options.
AllowParenthesesInChaining
isfalse
by default. Setting it totrue
allows the presence of parentheses in the last call during method chaining.AllowParenthesesInMultilineCall
isfalse
by default. Setting it totrue
allows the presence of parentheses in multi-line method calls.AllowParenthesesInCamelCaseMethod
isfalse
by default. This allows the presence of parentheses when calling a method whose name begins with a capital letter and which has no arguments. Setting it totrue
allows the presence of parentheses in such a method call even with arguments.
NOTE: Parentheses are still allowed in cases where omitting them results in ambiguous or syntactically incorrect code. For example, parentheses are required around a method with arguments when inside an endless method definition introduced in Ruby 3.0. Parentheses are also allowed when forwarding arguments with the triple-dot syntax introduced in Ruby 2.7 as omitting them starts an endless range. And Ruby 3.1's hash omission syntax has a case that requires parentheses because of the following issue: https://bugs.ruby-lang.org/issues/18396.
Example: EnforcedStyle: require_parentheses (default)
# bad
array.delete e
# good
array.delete(e)
# good
# Operators don't need parens
foo == bar
# good
# Setter methods don't need parens
foo.bar = baz
# okay with `puts` listed in `AllowedMethods`
puts 'test'
# okay with `^assert` listed in `AllowedPatterns`
assert_equal 'test', x
Example: EnforcedStyle: omit_parentheses
# bad
array.delete(e)
# good
array.delete e
# bad
foo.enforce(strict: true)
# good
foo.enforce strict: true
# good
# Allows parens for calls that won't produce valid Ruby or be ambiguous.
model.validate strict(true)
# good
# Allows parens for calls that won't produce valid Ruby or be ambiguous.
yield path, File.basename(path)
# good
# Operators methods calls with parens
array&.[](index)
# good
# Operators methods without parens, if you prefer
array.[] index
# good
# Operators methods calls with parens
array&.[](index)
# good
# Operators methods without parens, if you prefer
array.[] index
Example: IgnoreMacros: true (default)
# good
class Foo
bar :baz
end
Example: IgnoreMacros: false
# bad
class Foo
bar :baz
end
Example: AllowParenthesesInMultilineCall: false (default)
# bad
foo.enforce(
strict: true
)
# good
foo.enforce \
strict: true
Example: AllowParenthesesInMultilineCall: true
# good
foo.enforce(
strict: true
)
# good
foo.enforce \
strict: true
Example: AllowParenthesesInChaining: false (default)
# bad
foo().bar(1)
# good
foo().bar 1
Example: AllowParenthesesInChaining: true
# good
foo().bar(1)
# good
foo().bar 1
Example: AllowParenthesesInCamelCaseMethod: false (default)
# bad
Array(1)
# good
Array 1
Example: AllowParenthesesInCamelCaseMethod: true
# good
Array(1)
# good
Array 1
Example: AllowParenthesesInStringInterpolation: false (default)
# bad
"#{t('this.is.bad')}"
# good
"#{t 'this.is.better'}"
Example: AllowParenthesesInStringInterpolation: true
# good
"#{t('this.is.good')}"
# good
"#{t 'this.is.also.good'}"
Use parentheses for method calls with arguments. Open
json.set! field do
- Read upRead up
- Exclude checks
Enforces the presence (default) or absence of parentheses in method calls containing parameters.
In the default style (require_parentheses), macro methods are allowed.
Additional methods can be added to the AllowedMethods
or AllowedPatterns
list. These options are
valid only in the default style. Macros can be included by
either setting IgnoreMacros
to false or adding specific macros to
the IncludedMacros
list.
Precedence of options is all follows:
AllowedMethods
AllowedPatterns
IncludedMacros
eg. If a method is listed in both
IncludedMacros
and AllowedMethods
, then the latter takes
precedence (that is, the method is allowed).
In the alternative style (omit_parentheses), there are three additional options.
AllowParenthesesInChaining
isfalse
by default. Setting it totrue
allows the presence of parentheses in the last call during method chaining.AllowParenthesesInMultilineCall
isfalse
by default. Setting it totrue
allows the presence of parentheses in multi-line method calls.AllowParenthesesInCamelCaseMethod
isfalse
by default. This allows the presence of parentheses when calling a method whose name begins with a capital letter and which has no arguments. Setting it totrue
allows the presence of parentheses in such a method call even with arguments.
NOTE: Parentheses are still allowed in cases where omitting them results in ambiguous or syntactically incorrect code. For example, parentheses are required around a method with arguments when inside an endless method definition introduced in Ruby 3.0. Parentheses are also allowed when forwarding arguments with the triple-dot syntax introduced in Ruby 2.7 as omitting them starts an endless range. And Ruby 3.1's hash omission syntax has a case that requires parentheses because of the following issue: https://bugs.ruby-lang.org/issues/18396.
Example: EnforcedStyle: require_parentheses (default)
# bad
array.delete e
# good
array.delete(e)
# good
# Operators don't need parens
foo == bar
# good
# Setter methods don't need parens
foo.bar = baz
# okay with `puts` listed in `AllowedMethods`
puts 'test'
# okay with `^assert` listed in `AllowedPatterns`
assert_equal 'test', x
Example: EnforcedStyle: omit_parentheses
# bad
array.delete(e)
# good
array.delete e
# bad
foo.enforce(strict: true)
# good
foo.enforce strict: true
# good
# Allows parens for calls that won't produce valid Ruby or be ambiguous.
model.validate strict(true)
# good
# Allows parens for calls that won't produce valid Ruby or be ambiguous.
yield path, File.basename(path)
# good
# Operators methods calls with parens
array&.[](index)
# good
# Operators methods without parens, if you prefer
array.[] index
# good
# Operators methods calls with parens
array&.[](index)
# good
# Operators methods without parens, if you prefer
array.[] index
Example: IgnoreMacros: true (default)
# good
class Foo
bar :baz
end
Example: IgnoreMacros: false
# bad
class Foo
bar :baz
end
Example: AllowParenthesesInMultilineCall: false (default)
# bad
foo.enforce(
strict: true
)
# good
foo.enforce \
strict: true
Example: AllowParenthesesInMultilineCall: true
# good
foo.enforce(
strict: true
)
# good
foo.enforce \
strict: true
Example: AllowParenthesesInChaining: false (default)
# bad
foo().bar(1)
# good
foo().bar 1
Example: AllowParenthesesInChaining: true
# good
foo().bar(1)
# good
foo().bar 1
Example: AllowParenthesesInCamelCaseMethod: false (default)
# bad
Array(1)
# good
Array 1
Example: AllowParenthesesInCamelCaseMethod: true
# good
Array(1)
# good
Array 1
Example: AllowParenthesesInStringInterpolation: false (default)
# bad
"#{t('this.is.bad')}"
# good
"#{t 'this.is.better'}"
Example: AllowParenthesesInStringInterpolation: true
# good
"#{t('this.is.good')}"
# good
"#{t 'this.is.also.good'}"
Use parentheses for method calls with arguments. Open
json.set! field do
- Read upRead up
- Exclude checks
Enforces the presence (default) or absence of parentheses in method calls containing parameters.
In the default style (require_parentheses), macro methods are allowed.
Additional methods can be added to the AllowedMethods
or AllowedPatterns
list. These options are
valid only in the default style. Macros can be included by
either setting IgnoreMacros
to false or adding specific macros to
the IncludedMacros
list.
Precedence of options is all follows:
AllowedMethods
AllowedPatterns
IncludedMacros
eg. If a method is listed in both
IncludedMacros
and AllowedMethods
, then the latter takes
precedence (that is, the method is allowed).
In the alternative style (omit_parentheses), there are three additional options.
AllowParenthesesInChaining
isfalse
by default. Setting it totrue
allows the presence of parentheses in the last call during method chaining.AllowParenthesesInMultilineCall
isfalse
by default. Setting it totrue
allows the presence of parentheses in multi-line method calls.AllowParenthesesInCamelCaseMethod
isfalse
by default. This allows the presence of parentheses when calling a method whose name begins with a capital letter and which has no arguments. Setting it totrue
allows the presence of parentheses in such a method call even with arguments.
NOTE: Parentheses are still allowed in cases where omitting them results in ambiguous or syntactically incorrect code. For example, parentheses are required around a method with arguments when inside an endless method definition introduced in Ruby 3.0. Parentheses are also allowed when forwarding arguments with the triple-dot syntax introduced in Ruby 2.7 as omitting them starts an endless range. And Ruby 3.1's hash omission syntax has a case that requires parentheses because of the following issue: https://bugs.ruby-lang.org/issues/18396.
Example: EnforcedStyle: require_parentheses (default)
# bad
array.delete e
# good
array.delete(e)
# good
# Operators don't need parens
foo == bar
# good
# Setter methods don't need parens
foo.bar = baz
# okay with `puts` listed in `AllowedMethods`
puts 'test'
# okay with `^assert` listed in `AllowedPatterns`
assert_equal 'test', x
Example: EnforcedStyle: omit_parentheses
# bad
array.delete(e)
# good
array.delete e
# bad
foo.enforce(strict: true)
# good
foo.enforce strict: true
# good
# Allows parens for calls that won't produce valid Ruby or be ambiguous.
model.validate strict(true)
# good
# Allows parens for calls that won't produce valid Ruby or be ambiguous.
yield path, File.basename(path)
# good
# Operators methods calls with parens
array&.[](index)
# good
# Operators methods without parens, if you prefer
array.[] index
# good
# Operators methods calls with parens
array&.[](index)
# good
# Operators methods without parens, if you prefer
array.[] index
Example: IgnoreMacros: true (default)
# good
class Foo
bar :baz
end
Example: IgnoreMacros: false
# bad
class Foo
bar :baz
end
Example: AllowParenthesesInMultilineCall: false (default)
# bad
foo.enforce(
strict: true
)
# good
foo.enforce \
strict: true
Example: AllowParenthesesInMultilineCall: true
# good
foo.enforce(
strict: true
)
# good
foo.enforce \
strict: true
Example: AllowParenthesesInChaining: false (default)
# bad
foo().bar(1)
# good
foo().bar 1
Example: AllowParenthesesInChaining: true
# good
foo().bar(1)
# good
foo().bar 1
Example: AllowParenthesesInCamelCaseMethod: false (default)
# bad
Array(1)
# good
Array 1
Example: AllowParenthesesInCamelCaseMethod: true
# good
Array(1)
# good
Array 1
Example: AllowParenthesesInStringInterpolation: false (default)
# bad
"#{t('this.is.bad')}"
# good
"#{t 'this.is.better'}"
Example: AllowParenthesesInStringInterpolation: true
# good
"#{t('this.is.good')}"
# good
"#{t 'this.is.also.good'}"
Use parentheses for method calls with arguments. Open
json.type "keyword"
- Read upRead up
- Exclude checks
Enforces the presence (default) or absence of parentheses in method calls containing parameters.
In the default style (require_parentheses), macro methods are allowed.
Additional methods can be added to the AllowedMethods
or AllowedPatterns
list. These options are
valid only in the default style. Macros can be included by
either setting IgnoreMacros
to false or adding specific macros to
the IncludedMacros
list.
Precedence of options is all follows:
AllowedMethods
AllowedPatterns
IncludedMacros
eg. If a method is listed in both
IncludedMacros
and AllowedMethods
, then the latter takes
precedence (that is, the method is allowed).
In the alternative style (omit_parentheses), there are three additional options.
AllowParenthesesInChaining
isfalse
by default. Setting it totrue
allows the presence of parentheses in the last call during method chaining.AllowParenthesesInMultilineCall
isfalse
by default. Setting it totrue
allows the presence of parentheses in multi-line method calls.AllowParenthesesInCamelCaseMethod
isfalse
by default. This allows the presence of parentheses when calling a method whose name begins with a capital letter and which has no arguments. Setting it totrue
allows the presence of parentheses in such a method call even with arguments.
NOTE: Parentheses are still allowed in cases where omitting them results in ambiguous or syntactically incorrect code. For example, parentheses are required around a method with arguments when inside an endless method definition introduced in Ruby 3.0. Parentheses are also allowed when forwarding arguments with the triple-dot syntax introduced in Ruby 2.7 as omitting them starts an endless range. And Ruby 3.1's hash omission syntax has a case that requires parentheses because of the following issue: https://bugs.ruby-lang.org/issues/18396.
Example: EnforcedStyle: require_parentheses (default)
# bad
array.delete e
# good
array.delete(e)
# good
# Operators don't need parens
foo == bar
# good
# Setter methods don't need parens
foo.bar = baz
# okay with `puts` listed in `AllowedMethods`
puts 'test'
# okay with `^assert` listed in `AllowedPatterns`
assert_equal 'test', x
Example: EnforcedStyle: omit_parentheses
# bad
array.delete(e)
# good
array.delete e
# bad
foo.enforce(strict: true)
# good
foo.enforce strict: true
# good
# Allows parens for calls that won't produce valid Ruby or be ambiguous.
model.validate strict(true)
# good
# Allows parens for calls that won't produce valid Ruby or be ambiguous.
yield path, File.basename(path)
# good
# Operators methods calls with parens
array&.[](index)
# good
# Operators methods without parens, if you prefer
array.[] index
# good
# Operators methods calls with parens
array&.[](index)
# good
# Operators methods without parens, if you prefer
array.[] index
Example: IgnoreMacros: true (default)
# good
class Foo
bar :baz
end
Example: IgnoreMacros: false
# bad
class Foo
bar :baz
end
Example: AllowParenthesesInMultilineCall: false (default)
# bad
foo.enforce(
strict: true
)
# good
foo.enforce \
strict: true
Example: AllowParenthesesInMultilineCall: true
# good
foo.enforce(
strict: true
)
# good
foo.enforce \
strict: true
Example: AllowParenthesesInChaining: false (default)
# bad
foo().bar(1)
# good
foo().bar 1
Example: AllowParenthesesInChaining: true
# good
foo().bar(1)
# good
foo().bar 1
Example: AllowParenthesesInCamelCaseMethod: false (default)
# bad
Array(1)
# good
Array 1
Example: AllowParenthesesInCamelCaseMethod: true
# good
Array(1)
# good
Array 1
Example: AllowParenthesesInStringInterpolation: false (default)
# bad
"#{t('this.is.bad')}"
# good
"#{t 'this.is.better'}"
Example: AllowParenthesesInStringInterpolation: true
# good
"#{t('this.is.good')}"
# good
"#{t 'this.is.also.good'}"
Use parentheses for method calls with arguments. Open
json.index true
- Read upRead up
- Exclude checks
Enforces the presence (default) or absence of parentheses in method calls containing parameters.
In the default style (require_parentheses), macro methods are allowed.
Additional methods can be added to the AllowedMethods
or AllowedPatterns
list. These options are
valid only in the default style. Macros can be included by
either setting IgnoreMacros
to false or adding specific macros to
the IncludedMacros
list.
Precedence of options is all follows:
AllowedMethods
AllowedPatterns
IncludedMacros
eg. If a method is listed in both
IncludedMacros
and AllowedMethods
, then the latter takes
precedence (that is, the method is allowed).
In the alternative style (omit_parentheses), there are three additional options.
AllowParenthesesInChaining
isfalse
by default. Setting it totrue
allows the presence of parentheses in the last call during method chaining.AllowParenthesesInMultilineCall
isfalse
by default. Setting it totrue
allows the presence of parentheses in multi-line method calls.AllowParenthesesInCamelCaseMethod
isfalse
by default. This allows the presence of parentheses when calling a method whose name begins with a capital letter and which has no arguments. Setting it totrue
allows the presence of parentheses in such a method call even with arguments.
NOTE: Parentheses are still allowed in cases where omitting them results in ambiguous or syntactically incorrect code. For example, parentheses are required around a method with arguments when inside an endless method definition introduced in Ruby 3.0. Parentheses are also allowed when forwarding arguments with the triple-dot syntax introduced in Ruby 2.7 as omitting them starts an endless range. And Ruby 3.1's hash omission syntax has a case that requires parentheses because of the following issue: https://bugs.ruby-lang.org/issues/18396.
Example: EnforcedStyle: require_parentheses (default)
# bad
array.delete e
# good
array.delete(e)
# good
# Operators don't need parens
foo == bar
# good
# Setter methods don't need parens
foo.bar = baz
# okay with `puts` listed in `AllowedMethods`
puts 'test'
# okay with `^assert` listed in `AllowedPatterns`
assert_equal 'test', x
Example: EnforcedStyle: omit_parentheses
# bad
array.delete(e)
# good
array.delete e
# bad
foo.enforce(strict: true)
# good
foo.enforce strict: true
# good
# Allows parens for calls that won't produce valid Ruby or be ambiguous.
model.validate strict(true)
# good
# Allows parens for calls that won't produce valid Ruby or be ambiguous.
yield path, File.basename(path)
# good
# Operators methods calls with parens
array&.[](index)
# good
# Operators methods without parens, if you prefer
array.[] index
# good
# Operators methods calls with parens
array&.[](index)
# good
# Operators methods without parens, if you prefer
array.[] index
Example: IgnoreMacros: true (default)
# good
class Foo
bar :baz
end
Example: IgnoreMacros: false
# bad
class Foo
bar :baz
end
Example: AllowParenthesesInMultilineCall: false (default)
# bad
foo.enforce(
strict: true
)
# good
foo.enforce \
strict: true
Example: AllowParenthesesInMultilineCall: true
# good
foo.enforce(
strict: true
)
# good
foo.enforce \
strict: true
Example: AllowParenthesesInChaining: false (default)
# bad
foo().bar(1)
# good
foo().bar 1
Example: AllowParenthesesInChaining: true
# good
foo().bar(1)
# good
foo().bar 1
Example: AllowParenthesesInCamelCaseMethod: false (default)
# bad
Array(1)
# good
Array 1
Example: AllowParenthesesInCamelCaseMethod: true
# good
Array(1)
# good
Array 1
Example: AllowParenthesesInStringInterpolation: false (default)
# bad
"#{t('this.is.bad')}"
# good
"#{t 'this.is.better'}"
Example: AllowParenthesesInStringInterpolation: true
# good
"#{t('this.is.good')}"
# good
"#{t 'this.is.also.good'}"
Use parentheses for method calls with arguments. Open
json.match_mapping_type "string"
- Read upRead up
- Exclude checks
Enforces the presence (default) or absence of parentheses in method calls containing parameters.
In the default style (require_parentheses), macro methods are allowed.
Additional methods can be added to the AllowedMethods
or AllowedPatterns
list. These options are
valid only in the default style. Macros can be included by
either setting IgnoreMacros
to false or adding specific macros to
the IncludedMacros
list.
Precedence of options is all follows:
AllowedMethods
AllowedPatterns
IncludedMacros
eg. If a method is listed in both
IncludedMacros
and AllowedMethods
, then the latter takes
precedence (that is, the method is allowed).
In the alternative style (omit_parentheses), there are three additional options.
AllowParenthesesInChaining
isfalse
by default. Setting it totrue
allows the presence of parentheses in the last call during method chaining.AllowParenthesesInMultilineCall
isfalse
by default. Setting it totrue
allows the presence of parentheses in multi-line method calls.AllowParenthesesInCamelCaseMethod
isfalse
by default. This allows the presence of parentheses when calling a method whose name begins with a capital letter and which has no arguments. Setting it totrue
allows the presence of parentheses in such a method call even with arguments.
NOTE: Parentheses are still allowed in cases where omitting them results in ambiguous or syntactically incorrect code. For example, parentheses are required around a method with arguments when inside an endless method definition introduced in Ruby 3.0. Parentheses are also allowed when forwarding arguments with the triple-dot syntax introduced in Ruby 2.7 as omitting them starts an endless range. And Ruby 3.1's hash omission syntax has a case that requires parentheses because of the following issue: https://bugs.ruby-lang.org/issues/18396.
Example: EnforcedStyle: require_parentheses (default)
# bad
array.delete e
# good
array.delete(e)
# good
# Operators don't need parens
foo == bar
# good
# Setter methods don't need parens
foo.bar = baz
# okay with `puts` listed in `AllowedMethods`
puts 'test'
# okay with `^assert` listed in `AllowedPatterns`
assert_equal 'test', x
Example: EnforcedStyle: omit_parentheses
# bad
array.delete(e)
# good
array.delete e
# bad
foo.enforce(strict: true)
# good
foo.enforce strict: true
# good
# Allows parens for calls that won't produce valid Ruby or be ambiguous.
model.validate strict(true)
# good
# Allows parens for calls that won't produce valid Ruby or be ambiguous.
yield path, File.basename(path)
# good
# Operators methods calls with parens
array&.[](index)
# good
# Operators methods without parens, if you prefer
array.[] index
# good
# Operators methods calls with parens
array&.[](index)
# good
# Operators methods without parens, if you prefer
array.[] index
Example: IgnoreMacros: true (default)
# good
class Foo
bar :baz
end
Example: IgnoreMacros: false
# bad
class Foo
bar :baz
end
Example: AllowParenthesesInMultilineCall: false (default)
# bad
foo.enforce(
strict: true
)
# good
foo.enforce \
strict: true
Example: AllowParenthesesInMultilineCall: true
# good
foo.enforce(
strict: true
)
# good
foo.enforce \
strict: true
Example: AllowParenthesesInChaining: false (default)
# bad
foo().bar(1)
# good
foo().bar 1
Example: AllowParenthesesInChaining: true
# good
foo().bar(1)
# good
foo().bar 1
Example: AllowParenthesesInCamelCaseMethod: false (default)
# bad
Array(1)
# good
Array 1
Example: AllowParenthesesInCamelCaseMethod: true
# good
Array(1)
# good
Array 1
Example: AllowParenthesesInStringInterpolation: false (default)
# bad
"#{t('this.is.bad')}"
# good
"#{t 'this.is.better'}"
Example: AllowParenthesesInStringInterpolation: true
# good
"#{t('this.is.good')}"
# good
"#{t 'this.is.also.good'}"
Extra empty line detected at module body end. Open
end
- Read upRead up
- Exclude checks
Checks if empty lines around the bodies of modules match the configuration.
Example: EnforcedStyle: noemptylines (default)
# good
module Foo
def bar
# ...
end
end
Example: EnforcedStyle: empty_lines
# good
module Foo
def bar
# ...
end
end
Example: EnforcedStyle: emptylinesexcept_namespace
# good
module Foo
module Bar
# ...
end
end
Example: EnforcedStyle: emptylinesspecial
# good
module Foo
def bar; end
end
Use parentheses for method calls with arguments. Open
json.index true
- Read upRead up
- Exclude checks
Enforces the presence (default) or absence of parentheses in method calls containing parameters.
In the default style (require_parentheses), macro methods are allowed.
Additional methods can be added to the AllowedMethods
or AllowedPatterns
list. These options are
valid only in the default style. Macros can be included by
either setting IgnoreMacros
to false or adding specific macros to
the IncludedMacros
list.
Precedence of options is all follows:
AllowedMethods
AllowedPatterns
IncludedMacros
eg. If a method is listed in both
IncludedMacros
and AllowedMethods
, then the latter takes
precedence (that is, the method is allowed).
In the alternative style (omit_parentheses), there are three additional options.
AllowParenthesesInChaining
isfalse
by default. Setting it totrue
allows the presence of parentheses in the last call during method chaining.AllowParenthesesInMultilineCall
isfalse
by default. Setting it totrue
allows the presence of parentheses in multi-line method calls.AllowParenthesesInCamelCaseMethod
isfalse
by default. This allows the presence of parentheses when calling a method whose name begins with a capital letter and which has no arguments. Setting it totrue
allows the presence of parentheses in such a method call even with arguments.
NOTE: Parentheses are still allowed in cases where omitting them results in ambiguous or syntactically incorrect code. For example, parentheses are required around a method with arguments when inside an endless method definition introduced in Ruby 3.0. Parentheses are also allowed when forwarding arguments with the triple-dot syntax introduced in Ruby 2.7 as omitting them starts an endless range. And Ruby 3.1's hash omission syntax has a case that requires parentheses because of the following issue: https://bugs.ruby-lang.org/issues/18396.
Example: EnforcedStyle: require_parentheses (default)
# bad
array.delete e
# good
array.delete(e)
# good
# Operators don't need parens
foo == bar
# good
# Setter methods don't need parens
foo.bar = baz
# okay with `puts` listed in `AllowedMethods`
puts 'test'
# okay with `^assert` listed in `AllowedPatterns`
assert_equal 'test', x
Example: EnforcedStyle: omit_parentheses
# bad
array.delete(e)
# good
array.delete e
# bad
foo.enforce(strict: true)
# good
foo.enforce strict: true
# good
# Allows parens for calls that won't produce valid Ruby or be ambiguous.
model.validate strict(true)
# good
# Allows parens for calls that won't produce valid Ruby or be ambiguous.
yield path, File.basename(path)
# good
# Operators methods calls with parens
array&.[](index)
# good
# Operators methods without parens, if you prefer
array.[] index
# good
# Operators methods calls with parens
array&.[](index)
# good
# Operators methods without parens, if you prefer
array.[] index
Example: IgnoreMacros: true (default)
# good
class Foo
bar :baz
end
Example: IgnoreMacros: false
# bad
class Foo
bar :baz
end
Example: AllowParenthesesInMultilineCall: false (default)
# bad
foo.enforce(
strict: true
)
# good
foo.enforce \
strict: true
Example: AllowParenthesesInMultilineCall: true
# good
foo.enforce(
strict: true
)
# good
foo.enforce \
strict: true
Example: AllowParenthesesInChaining: false (default)
# bad
foo().bar(1)
# good
foo().bar 1
Example: AllowParenthesesInChaining: true
# good
foo().bar(1)
# good
foo().bar 1
Example: AllowParenthesesInCamelCaseMethod: false (default)
# bad
Array(1)
# good
Array 1
Example: AllowParenthesesInCamelCaseMethod: true
# good
Array(1)
# good
Array 1
Example: AllowParenthesesInStringInterpolation: false (default)
# bad
"#{t('this.is.bad')}"
# good
"#{t 'this.is.better'}"
Example: AllowParenthesesInStringInterpolation: true
# good
"#{t('this.is.good')}"
# good
"#{t 'this.is.also.good'}"
Use parentheses for method calls with arguments. Open
json.set! field, lines
- Read upRead up
- Exclude checks
Enforces the presence (default) or absence of parentheses in method calls containing parameters.
In the default style (require_parentheses), macro methods are allowed.
Additional methods can be added to the AllowedMethods
or AllowedPatterns
list. These options are
valid only in the default style. Macros can be included by
either setting IgnoreMacros
to false or adding specific macros to
the IncludedMacros
list.
Precedence of options is all follows:
AllowedMethods
AllowedPatterns
IncludedMacros
eg. If a method is listed in both
IncludedMacros
and AllowedMethods
, then the latter takes
precedence (that is, the method is allowed).
In the alternative style (omit_parentheses), there are three additional options.
AllowParenthesesInChaining
isfalse
by default. Setting it totrue
allows the presence of parentheses in the last call during method chaining.AllowParenthesesInMultilineCall
isfalse
by default. Setting it totrue
allows the presence of parentheses in multi-line method calls.AllowParenthesesInCamelCaseMethod
isfalse
by default. This allows the presence of parentheses when calling a method whose name begins with a capital letter and which has no arguments. Setting it totrue
allows the presence of parentheses in such a method call even with arguments.
NOTE: Parentheses are still allowed in cases where omitting them results in ambiguous or syntactically incorrect code. For example, parentheses are required around a method with arguments when inside an endless method definition introduced in Ruby 3.0. Parentheses are also allowed when forwarding arguments with the triple-dot syntax introduced in Ruby 2.7 as omitting them starts an endless range. And Ruby 3.1's hash omission syntax has a case that requires parentheses because of the following issue: https://bugs.ruby-lang.org/issues/18396.
Example: EnforcedStyle: require_parentheses (default)
# bad
array.delete e
# good
array.delete(e)
# good
# Operators don't need parens
foo == bar
# good
# Setter methods don't need parens
foo.bar = baz
# okay with `puts` listed in `AllowedMethods`
puts 'test'
# okay with `^assert` listed in `AllowedPatterns`
assert_equal 'test', x
Example: EnforcedStyle: omit_parentheses
# bad
array.delete(e)
# good
array.delete e
# bad
foo.enforce(strict: true)
# good
foo.enforce strict: true
# good
# Allows parens for calls that won't produce valid Ruby or be ambiguous.
model.validate strict(true)
# good
# Allows parens for calls that won't produce valid Ruby or be ambiguous.
yield path, File.basename(path)
# good
# Operators methods calls with parens
array&.[](index)
# good
# Operators methods without parens, if you prefer
array.[] index
# good
# Operators methods calls with parens
array&.[](index)
# good
# Operators methods without parens, if you prefer
array.[] index
Example: IgnoreMacros: true (default)
# good
class Foo
bar :baz
end
Example: IgnoreMacros: false
# bad
class Foo
bar :baz
end
Example: AllowParenthesesInMultilineCall: false (default)
# bad
foo.enforce(
strict: true
)
# good
foo.enforce \
strict: true
Example: AllowParenthesesInMultilineCall: true
# good
foo.enforce(
strict: true
)
# good
foo.enforce \
strict: true
Example: AllowParenthesesInChaining: false (default)
# bad
foo().bar(1)
# good
foo().bar 1
Example: AllowParenthesesInChaining: true
# good
foo().bar(1)
# good
foo().bar 1
Example: AllowParenthesesInCamelCaseMethod: false (default)
# bad
Array(1)
# good
Array 1
Example: AllowParenthesesInCamelCaseMethod: true
# good
Array(1)
# good
Array 1
Example: AllowParenthesesInStringInterpolation: false (default)
# bad
"#{t('this.is.bad')}"
# good
"#{t 'this.is.better'}"
Example: AllowParenthesesInStringInterpolation: true
# good
"#{t('this.is.good')}"
# good
"#{t 'this.is.also.good'}"
Use parentheses for method calls with arguments. Open
json.type "stemmer"
- Read upRead up
- Exclude checks
Enforces the presence (default) or absence of parentheses in method calls containing parameters.
In the default style (require_parentheses), macro methods are allowed.
Additional methods can be added to the AllowedMethods
or AllowedPatterns
list. These options are
valid only in the default style. Macros can be included by
either setting IgnoreMacros
to false or adding specific macros to
the IncludedMacros
list.
Precedence of options is all follows:
AllowedMethods
AllowedPatterns
IncludedMacros
eg. If a method is listed in both
IncludedMacros
and AllowedMethods
, then the latter takes
precedence (that is, the method is allowed).
In the alternative style (omit_parentheses), there are three additional options.
AllowParenthesesInChaining
isfalse
by default. Setting it totrue
allows the presence of parentheses in the last call during method chaining.AllowParenthesesInMultilineCall
isfalse
by default. Setting it totrue
allows the presence of parentheses in multi-line method calls.AllowParenthesesInCamelCaseMethod
isfalse
by default. This allows the presence of parentheses when calling a method whose name begins with a capital letter and which has no arguments. Setting it totrue
allows the presence of parentheses in such a method call even with arguments.
NOTE: Parentheses are still allowed in cases where omitting them results in ambiguous or syntactically incorrect code. For example, parentheses are required around a method with arguments when inside an endless method definition introduced in Ruby 3.0. Parentheses are also allowed when forwarding arguments with the triple-dot syntax introduced in Ruby 2.7 as omitting them starts an endless range. And Ruby 3.1's hash omission syntax has a case that requires parentheses because of the following issue: https://bugs.ruby-lang.org/issues/18396.
Example: EnforcedStyle: require_parentheses (default)
# bad
array.delete e
# good
array.delete(e)
# good
# Operators don't need parens
foo == bar
# good
# Setter methods don't need parens
foo.bar = baz
# okay with `puts` listed in `AllowedMethods`
puts 'test'
# okay with `^assert` listed in `AllowedPatterns`
assert_equal 'test', x
Example: EnforcedStyle: omit_parentheses
# bad
array.delete(e)
# good
array.delete e
# bad
foo.enforce(strict: true)
# good
foo.enforce strict: true
# good
# Allows parens for calls that won't produce valid Ruby or be ambiguous.
model.validate strict(true)
# good
# Allows parens for calls that won't produce valid Ruby or be ambiguous.
yield path, File.basename(path)
# good
# Operators methods calls with parens
array&.[](index)
# good
# Operators methods without parens, if you prefer
array.[] index
# good
# Operators methods calls with parens
array&.[](index)
# good
# Operators methods without parens, if you prefer
array.[] index
Example: IgnoreMacros: true (default)
# good
class Foo
bar :baz
end
Example: IgnoreMacros: false
# bad
class Foo
bar :baz
end
Example: AllowParenthesesInMultilineCall: false (default)
# bad
foo.enforce(
strict: true
)
# good
foo.enforce \
strict: true
Example: AllowParenthesesInMultilineCall: true
# good
foo.enforce(
strict: true
)
# good
foo.enforce \
strict: true
Example: AllowParenthesesInChaining: false (default)
# bad
foo().bar(1)
# good
foo().bar 1
Example: AllowParenthesesInChaining: true
# good
foo().bar(1)
# good
foo().bar 1
Example: AllowParenthesesInCamelCaseMethod: false (default)
# bad
Array(1)
# good
Array 1
Example: AllowParenthesesInCamelCaseMethod: true
# good
Array(1)
# good
Array 1
Example: AllowParenthesesInStringInterpolation: false (default)
# bad
"#{t('this.is.bad')}"
# good
"#{t 'this.is.better'}"
Example: AllowParenthesesInStringInterpolation: true
# good
"#{t('this.is.good')}"
# good
"#{t 'this.is.also.good'}"
Use parentheses for method calls with arguments. Open
json.name "#{stemmer_name}#{language}"
- Read upRead up
- Exclude checks
Enforces the presence (default) or absence of parentheses in method calls containing parameters.
In the default style (require_parentheses), macro methods are allowed.
Additional methods can be added to the AllowedMethods
or AllowedPatterns
list. These options are
valid only in the default style. Macros can be included by
either setting IgnoreMacros
to false or adding specific macros to
the IncludedMacros
list.
Precedence of options is all follows:
AllowedMethods
AllowedPatterns
IncludedMacros
eg. If a method is listed in both
IncludedMacros
and AllowedMethods
, then the latter takes
precedence (that is, the method is allowed).
In the alternative style (omit_parentheses), there are three additional options.
AllowParenthesesInChaining
isfalse
by default. Setting it totrue
allows the presence of parentheses in the last call during method chaining.AllowParenthesesInMultilineCall
isfalse
by default. Setting it totrue
allows the presence of parentheses in multi-line method calls.AllowParenthesesInCamelCaseMethod
isfalse
by default. This allows the presence of parentheses when calling a method whose name begins with a capital letter and which has no arguments. Setting it totrue
allows the presence of parentheses in such a method call even with arguments.
NOTE: Parentheses are still allowed in cases where omitting them results in ambiguous or syntactically incorrect code. For example, parentheses are required around a method with arguments when inside an endless method definition introduced in Ruby 3.0. Parentheses are also allowed when forwarding arguments with the triple-dot syntax introduced in Ruby 2.7 as omitting them starts an endless range. And Ruby 3.1's hash omission syntax has a case that requires parentheses because of the following issue: https://bugs.ruby-lang.org/issues/18396.
Example: EnforcedStyle: require_parentheses (default)
# bad
array.delete e
# good
array.delete(e)
# good
# Operators don't need parens
foo == bar
# good
# Setter methods don't need parens
foo.bar = baz
# okay with `puts` listed in `AllowedMethods`
puts 'test'
# okay with `^assert` listed in `AllowedPatterns`
assert_equal 'test', x
Example: EnforcedStyle: omit_parentheses
# bad
array.delete(e)
# good
array.delete e
# bad
foo.enforce(strict: true)
# good
foo.enforce strict: true
# good
# Allows parens for calls that won't produce valid Ruby or be ambiguous.
model.validate strict(true)
# good
# Allows parens for calls that won't produce valid Ruby or be ambiguous.
yield path, File.basename(path)
# good
# Operators methods calls with parens
array&.[](index)
# good
# Operators methods without parens, if you prefer
array.[] index
# good
# Operators methods calls with parens
array&.[](index)
# good
# Operators methods without parens, if you prefer
array.[] index
Example: IgnoreMacros: true (default)
# good
class Foo
bar :baz
end
Example: IgnoreMacros: false
# bad
class Foo
bar :baz
end
Example: AllowParenthesesInMultilineCall: false (default)
# bad
foo.enforce(
strict: true
)
# good
foo.enforce \
strict: true
Example: AllowParenthesesInMultilineCall: true
# good
foo.enforce(
strict: true
)
# good
foo.enforce \
strict: true
Example: AllowParenthesesInChaining: false (default)
# bad
foo().bar(1)
# good
foo().bar 1
Example: AllowParenthesesInChaining: true
# good
foo().bar(1)
# good
foo().bar 1
Example: AllowParenthesesInCamelCaseMethod: false (default)
# bad
Array(1)
# good
Array 1
Example: AllowParenthesesInCamelCaseMethod: true
# good
Array(1)
# good
Array 1
Example: AllowParenthesesInStringInterpolation: false (default)
# bad
"#{t('this.is.bad')}"
# good
"#{t 'this.is.better'}"
Example: AllowParenthesesInStringInterpolation: true
# good
"#{t('this.is.good')}"
# good
"#{t 'this.is.also.good'}"
Use parentheses for method calls with arguments. Open
json.set! "#{locale}_analyzer" do
- Read upRead up
- Exclude checks
Enforces the presence (default) or absence of parentheses in method calls containing parameters.
In the default style (require_parentheses), macro methods are allowed.
Additional methods can be added to the AllowedMethods
or AllowedPatterns
list. These options are
valid only in the default style. Macros can be included by
either setting IgnoreMacros
to false or adding specific macros to
the IncludedMacros
list.
Precedence of options is all follows:
AllowedMethods
AllowedPatterns
IncludedMacros
eg. If a method is listed in both
IncludedMacros
and AllowedMethods
, then the latter takes
precedence (that is, the method is allowed).
In the alternative style (omit_parentheses), there are three additional options.
AllowParenthesesInChaining
isfalse
by default. Setting it totrue
allows the presence of parentheses in the last call during method chaining.AllowParenthesesInMultilineCall
isfalse
by default. Setting it totrue
allows the presence of parentheses in multi-line method calls.AllowParenthesesInCamelCaseMethod
isfalse
by default. This allows the presence of parentheses when calling a method whose name begins with a capital letter and which has no arguments. Setting it totrue
allows the presence of parentheses in such a method call even with arguments.
NOTE: Parentheses are still allowed in cases where omitting them results in ambiguous or syntactically incorrect code. For example, parentheses are required around a method with arguments when inside an endless method definition introduced in Ruby 3.0. Parentheses are also allowed when forwarding arguments with the triple-dot syntax introduced in Ruby 2.7 as omitting them starts an endless range. And Ruby 3.1's hash omission syntax has a case that requires parentheses because of the following issue: https://bugs.ruby-lang.org/issues/18396.
Example: EnforcedStyle: require_parentheses (default)
# bad
array.delete e
# good
array.delete(e)
# good
# Operators don't need parens
foo == bar
# good
# Setter methods don't need parens
foo.bar = baz
# okay with `puts` listed in `AllowedMethods`
puts 'test'
# okay with `^assert` listed in `AllowedPatterns`
assert_equal 'test', x
Example: EnforcedStyle: omit_parentheses
# bad
array.delete(e)
# good
array.delete e
# bad
foo.enforce(strict: true)
# good
foo.enforce strict: true
# good
# Allows parens for calls that won't produce valid Ruby or be ambiguous.
model.validate strict(true)
# good
# Allows parens for calls that won't produce valid Ruby or be ambiguous.
yield path, File.basename(path)
# good
# Operators methods calls with parens
array&.[](index)
# good
# Operators methods without parens, if you prefer
array.[] index
# good
# Operators methods calls with parens
array&.[](index)
# good
# Operators methods without parens, if you prefer
array.[] index
Example: IgnoreMacros: true (default)
# good
class Foo
bar :baz
end
Example: IgnoreMacros: false
# bad
class Foo
bar :baz
end
Example: AllowParenthesesInMultilineCall: false (default)
# bad
foo.enforce(
strict: true
)
# good
foo.enforce \
strict: true
Example: AllowParenthesesInMultilineCall: true
# good
foo.enforce(
strict: true
)
# good
foo.enforce \
strict: true
Example: AllowParenthesesInChaining: false (default)
# bad
foo().bar(1)
# good
foo().bar 1
Example: AllowParenthesesInChaining: true
# good
foo().bar(1)
# good
foo().bar 1
Example: AllowParenthesesInCamelCaseMethod: false (default)
# bad
Array(1)
# good
Array 1
Example: AllowParenthesesInCamelCaseMethod: true
# good
Array(1)
# good
Array 1
Example: AllowParenthesesInStringInterpolation: false (default)
# bad
"#{t('this.is.bad')}"
# good
"#{t 'this.is.better'}"
Example: AllowParenthesesInStringInterpolation: true
# good
"#{t('this.is.good')}"
# good
"#{t 'this.is.also.good'}"
Avoid multi-line chains of blocks. Open
end.select do |locale_file_array|
- Read upRead up
- Exclude checks
Checks for chaining of a block after another block that spans multiple lines.
Example:
# bad
Thread.list.select do |t|
t.alive?
end.map do |t|
t.object_id
end
# good
alive_threads = Thread.list.select do |t|
t.alive?
end
alive_threads.map do |t|
t.object_id
end
Prefer single-quoted strings when you don't need string interpolation or special symbols. Open
[locale, Rails.root.join("config", "locales", "analysis", "#{locale}_#{type}.txt")]
- Read upRead up
- Exclude checks
Checks if uses of quotes match the configured preference.
Example: EnforcedStyle: single_quotes (default)
# bad
"No special symbols"
"No string interpolation"
"Just text"
# good
'No special symbols'
'No string interpolation'
'Just text'
"Wait! What's #{this}!"
Example: EnforcedStyle: double_quotes
# bad
'Just some text'
'No special chars or interpolation'
# good
"Just some text"
"No special chars or interpolation"
"Every string in #{project} uses double_quotes"
Use parentheses for method calls with arguments. Open
json.filter filter_array(locale)
- Read upRead up
- Exclude checks
Enforces the presence (default) or absence of parentheses in method calls containing parameters.
In the default style (require_parentheses), macro methods are allowed.
Additional methods can be added to the AllowedMethods
or AllowedPatterns
list. These options are
valid only in the default style. Macros can be included by
either setting IgnoreMacros
to false or adding specific macros to
the IncludedMacros
list.
Precedence of options is all follows:
AllowedMethods
AllowedPatterns
IncludedMacros
eg. If a method is listed in both
IncludedMacros
and AllowedMethods
, then the latter takes
precedence (that is, the method is allowed).
In the alternative style (omit_parentheses), there are three additional options.
AllowParenthesesInChaining
isfalse
by default. Setting it totrue
allows the presence of parentheses in the last call during method chaining.AllowParenthesesInMultilineCall
isfalse
by default. Setting it totrue
allows the presence of parentheses in multi-line method calls.AllowParenthesesInCamelCaseMethod
isfalse
by default. This allows the presence of parentheses when calling a method whose name begins with a capital letter and which has no arguments. Setting it totrue
allows the presence of parentheses in such a method call even with arguments.
NOTE: Parentheses are still allowed in cases where omitting them results in ambiguous or syntactically incorrect code. For example, parentheses are required around a method with arguments when inside an endless method definition introduced in Ruby 3.0. Parentheses are also allowed when forwarding arguments with the triple-dot syntax introduced in Ruby 2.7 as omitting them starts an endless range. And Ruby 3.1's hash omission syntax has a case that requires parentheses because of the following issue: https://bugs.ruby-lang.org/issues/18396.
Example: EnforcedStyle: require_parentheses (default)
# bad
array.delete e
# good
array.delete(e)
# good
# Operators don't need parens
foo == bar
# good
# Setter methods don't need parens
foo.bar = baz
# okay with `puts` listed in `AllowedMethods`
puts 'test'
# okay with `^assert` listed in `AllowedPatterns`
assert_equal 'test', x
Example: EnforcedStyle: omit_parentheses
# bad
array.delete(e)
# good
array.delete e
# bad
foo.enforce(strict: true)
# good
foo.enforce strict: true
# good
# Allows parens for calls that won't produce valid Ruby or be ambiguous.
model.validate strict(true)
# good
# Allows parens for calls that won't produce valid Ruby or be ambiguous.
yield path, File.basename(path)
# good
# Operators methods calls with parens
array&.[](index)
# good
# Operators methods without parens, if you prefer
array.[] index
# good
# Operators methods calls with parens
array&.[](index)
# good
# Operators methods without parens, if you prefer
array.[] index
Example: IgnoreMacros: true (default)
# good
class Foo
bar :baz
end
Example: IgnoreMacros: false
# bad
class Foo
bar :baz
end
Example: AllowParenthesesInMultilineCall: false (default)
# bad
foo.enforce(
strict: true
)
# good
foo.enforce \
strict: true
Example: AllowParenthesesInMultilineCall: true
# good
foo.enforce(
strict: true
)
# good
foo.enforce \
strict: true
Example: AllowParenthesesInChaining: false (default)
# bad
foo().bar(1)
# good
foo().bar 1
Example: AllowParenthesesInChaining: true
# good
foo().bar(1)
# good
foo().bar 1
Example: AllowParenthesesInCamelCaseMethod: false (default)
# bad
Array(1)
# good
Array 1
Example: AllowParenthesesInCamelCaseMethod: true
# good
Array(1)
# good
Array 1
Example: AllowParenthesesInStringInterpolation: false (default)
# bad
"#{t('this.is.bad')}"
# good
"#{t 'this.is.better'}"
Example: AllowParenthesesInStringInterpolation: true
# good
"#{t('this.is.good')}"
# good
"#{t 'this.is.also.good'}"