lib/tweezer.rb
Pass array contents as separate arguments. Open
Open
UNPARENTHESIZED_METHODS = Set[*%i(source ruby git path group platforms gem)]
- Read upRead up
- Exclude checks
This cop checks for unneeded usages of splat expansion
Example:
# bad
a = *[1, 2, 3]
a = *'a'
a = *1
begin
foo
rescue *[StandardError, ApplicationError]
bar
end
case foo
when *[1, 2, 3]
bar
else
baz
end
Example:
# good
c = [1, 2, 3]
a = *c
a, b = *c
a, *b = *c
a = *1..10
a = ['a']
begin
foo
rescue StandardError, ApplicationError
bar
end
case foo
when *[1, 2, 3]
bar
else
baz
end
%i
-literals should be delimited by [
and ]
. Open
Open
UNPARENTHESIZED_METHODS = Set[*%i(source ruby git path group platforms gem)]
- Read upRead up
- Exclude checks
This cop enforces the consistent usage of %
-literal delimiters.
Specify the 'default' key to set all preferred delimiters at once. You can continue to specify individual preferred delimiters to override the default.
Example:
# Style/PercentLiteralDelimiters:
# PreferredDelimiters:
# default: '[]'
# '%i': '()'
# good
%w[alpha beta] + %i(gamma delta)
# bad
%W(alpha #{beta})
# bad
%I(alpha beta)