Showing 6 of 6 total issues
Use each_key
instead of keys.each
. Open
Open
defaults.keys.each do |key|
- Read upRead up
- Exclude checks
This cop checks for uses of each_key
and each_value
Hash methods.
Note: If you have an array of two-element arrays, you can put parentheses around the block arguments to indicate that you're not working with a hash, and suppress RuboCop offenses.
Example:
# bad
hash.keys.each { |k| p k }
hash.values.each { |v| p v }
hash.each { |k, _v| p k }
hash.each { |_k, v| p v }
# good
hash.each_key { |k| p k }
hash.each_value { |v| p v }
Parenthesize the param `proc {
defaults = Redis::Client::DEFAULTS.dup Open
Open
set :redis, proc {
defaults = Redis::Client::DEFAULTS.dup
defaults.keys.each do |key|
# Fill in defaults if needed
- Read upRead up
- Exclude checks
This cop checks for ambiguous block association with method when param passed without parentheses.
Example:
# bad
some_method a { |val| puts val }
Example:
# good
# With parentheses, there's no ambiguity.
some_method(a) { |val| puts val }
# good
# Operator methods require no disambiguation
foo == bar { |b| b.baz }
# good
# Lambda arguments require no disambiguation
foo = ->(bar) { bar.baz }
Script file rubocop.rake doesn't have execute permission. Open
Open
#!/usr/bin/env rake
- Exclude checks
Script file rspec.rake doesn't have execute permission. Open
Open
#!/usr/bin/env rake
- Exclude checks
Script file bundler.rake doesn't have execute permission. Open
Open
#!/usr/bin/env rake
- Exclude checks
Parenthesize the param proc {
Redis.new settings.redis
}
to make sure that the block will be associated with the proc
method call. Open
Open
set :redis_client, proc {
Redis.new settings.redis
}
- Read upRead up
- Exclude checks
This cop checks for ambiguous block association with method when param passed without parentheses.
Example:
# bad
some_method a { |val| puts val }
Example:
# good
# With parentheses, there's no ambiguity.
some_method(a) { |val| puts val }
# good
# Operator methods require no disambiguation
foo == bar { |b| b.baz }
# good
# Lambda arguments require no disambiguation
foo = ->(bar) { bar.baz }