mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-28 01:53:25 +00:00
Fix Rails::NegateInclude issues
- cop class: RuboCop::Cop::Rails::NegateInclude - replaced !array.include?(2) by array.exclude?(2)
This commit is contained in:
@@ -668,16 +668,6 @@ Rails/LexicallyScopedActionFilter:
|
||||
- 'app/controllers/spree/admin/zones_controller.rb'
|
||||
- 'app/controllers/spree/users_controller.rb'
|
||||
|
||||
# Offense count: 5
|
||||
# This cop supports unsafe autocorrection (--autocorrect-all).
|
||||
Rails/NegateInclude:
|
||||
Exclude:
|
||||
- 'app/controllers/admin/resource_controller.rb'
|
||||
- 'app/models/calculator/weight.rb'
|
||||
- 'app/models/product_import/spreadsheet_entry.rb'
|
||||
- 'lib/spree/localized_number.rb'
|
||||
- 'spec/support/matchers/table_matchers.rb'
|
||||
|
||||
# Offense count: 32
|
||||
# This cop supports unsafe autocorrection (--autocorrect-all).
|
||||
Rails/Pluck:
|
||||
|
||||
@@ -229,7 +229,7 @@ module Admin
|
||||
end
|
||||
|
||||
def member_action?
|
||||
!collection_actions.include? action
|
||||
collection_actions.exclude? action
|
||||
end
|
||||
|
||||
def new_actions
|
||||
|
||||
@@ -10,7 +10,7 @@ module Calculator
|
||||
end
|
||||
|
||||
def set_preference(name, value)
|
||||
if name == :unit_from_list && !["kg", "lb"].include?(value)
|
||||
if name == :unit_from_list && ["kg", "lb"].exclude?(value)
|
||||
calculable.errors.add(:preferred_unit_from_list, I18n.t(:calculator_preferred_unit_error))
|
||||
else
|
||||
__send__ self.class.preference_setter_method(name), value
|
||||
|
||||
@@ -94,7 +94,7 @@ module ProductImport
|
||||
units = UnitConverter.new(attrs)
|
||||
|
||||
units.converted_attributes.each do |attr, value|
|
||||
if respond_to?("#{attr}=") && !NON_PRODUCT_ATTRIBUTES.include?(attr)
|
||||
if respond_to?("#{attr}=") && NON_PRODUCT_ATTRIBUTES.exclude?(attr)
|
||||
public_send("#{attr}=", value)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -77,7 +77,7 @@ module Spree
|
||||
private
|
||||
|
||||
def non_activerecord_attribute?(attribute)
|
||||
table_exists? && !column_names.include?(attribute.to_s)
|
||||
table_exists? && column_names.exclude?(attribute.to_s)
|
||||
rescue ::ActiveRecord::NoDatabaseError
|
||||
# This class is now loaded during `rake db:create` (since Rails 5.2), and not only does the
|
||||
# table not exist, but the database does not even exist yet, and throws a fatal error.
|
||||
|
||||
@@ -8,7 +8,7 @@ RSpec::Matchers.define :have_table_row do |row|
|
||||
|
||||
match_when_negated do |node|
|
||||
@row = row
|
||||
!rows_under(node).include? row # Robust check of columns
|
||||
rows_under(node).exclude? row # Robust check of columns
|
||||
end
|
||||
|
||||
failure_message do |text|
|
||||
|
||||
Reference in New Issue
Block a user