lib/active_mocker/mock/single_relation.rb
Use each_value
instead of each
. (https://github.com/bbatsov/ruby-style-guide#hash-each) Open
Open
[*item.class._find_associations_by_class(child_self.class.send("mocked_class"))].each do |_type, relations|
- 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 }
Add an empty line after magic comments. (https://github.com/bbatsov/ruby-style-guide#separate-magic-comments-from-code) Open
Open
module ActiveMocker
- Read upRead up
- Exclude checks
Checks for a newline after the final magic comment.
Example:
# good
# frozen_string_literal: true
# Some documentation for Person
class Person
# Some code
end
# bad
# frozen_string_literal: true
# Some documentation for Person
class Person
# Some code
end
Unused method argument - foreign_key
. (https://github.com/bbatsov/ruby-style-guide#underscore-unused-vars) Open
Open
def initialize(item, child_self:, foreign_key:)
- Read upRead up
- Exclude checks
This cop checks for unused method arguments.
Example:
# bad
def some_method(used, unused, _unused_but_allowed)
puts used
end
Example:
# good
def some_method(used, _unused, _unused_but_allowed)
puts used
end