Pattern: Inconsistent lambda literal syntax
Issue: -
This rule (by default) checks for uses of the lambda literal syntax for single line lambdas, and the method call syntax for multi-line lambdas. It is configurable to enforce one of the styles for both single line and multi-line lambdas as well.
# EnforcedStyle: line_count_dependent (default)
# bad
f = lambda { |x| x }
f = ->(x) do
x
end
# good
f = ->(x) { x }
f = lambda do |x|
x
end
# EnforcedStyle: lambda
# bad
f = ->(x) { x }
f = ->(x) do
x
end
# good
f = lambda { |x| x }
f = lambda do |x|
x
end
# EnforcedStyle: literal
# bad
f = lambda { |x| x }
f = lambda do |x|
x
end
# good
f = ->(x) { x }
f = ->(x) do
x
end
Attribute | Value |
---|---|
EnforcedStyle | line_count_dependent |
SupportedStyles | line_count_dependent, lambda, literal |