Safely autocorrect Lint/SymbolConversion

Inspecting 1530 files
.....................................................................................................................................................................................................................................................................................................................................................W.................................................................................................................................................................................................................................................W..........................................................................................................................................................................................................................................................W.......................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................

Offenses:

app/models/spree/preferences/preferable_class_methods.rb:73:9: W: [Corrected] Lint/SymbolConversion: Unnecessary symbol conversion; use :"preferred_#{name}" instead.
        "preferred_#{name}".to_sym
        ^^^^^^^^^^^^^^^^^^^^^^^^^^
app/models/spree/preferences/preferable_class_methods.rb:77:9: W: [Corrected] Lint/SymbolConversion: Unnecessary symbol conversion; use :"preferred_#{name}=" instead.
        "preferred_#{name}=".to_sym
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^
app/models/spree/preferences/preferable_class_methods.rb:81:9: W: [Corrected] Lint/SymbolConversion: Unnecessary symbol conversion; use :"prefers_#{name}?" instead.
        "prefers_#{name}?".to_sym
        ^^^^^^^^^^^^^^^^^^^^^^^^^
app/models/spree/preferences/preferable_class_methods.rb:85:9: W: [Corrected] Lint/SymbolConversion: Unnecessary symbol conversion; use :"prefers_#{name}=" instead.
        "prefers_#{name}=".to_sym
        ^^^^^^^^^^^^^^^^^^^^^^^^^
app/models/spree/preferences/preferable_class_methods.rb:89:9: W: [Corrected] Lint/SymbolConversion: Unnecessary symbol conversion; use :"preferred_#{name}_default" instead.
        "preferred_#{name}_default".to_sym
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
app/models/spree/preferences/preferable_class_methods.rb:93:9: W: [Corrected] Lint/SymbolConversion: Unnecessary symbol conversion; use :"preferred_#{name}_type" instead.
        "preferred_#{name}_type".to_sym
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
app/models/spree/preferences/preferable_class_methods.rb:97:9: W: [Corrected] Lint/SymbolConversion: Unnecessary symbol conversion; use :"preferred_#{name}_description" instead.
        "preferred_#{name}_description".to_sym
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
app/services/sets/product_set.rb:121:28: W: [Corrected] Lint/SymbolConversion: Unnecessary symbol conversion; use :"variant_#{error.attribute}" instead.
        product.errors.add("variant_#{error.attribute}".to_sym, error.message)
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
lib/spree/core/environment_extension.rb:11:24: W: [Corrected] Lint/SymbolConversion: Unnecessary symbol conversion; use :"#{name}=" instead.
        create_method( "#{name}=".to_sym ) { |val|
                       ^^^^^^^^^^^^^^^^^

1530 files inspected, 9 offenses detected, 9 offenses corrected
This commit is contained in:
David Cook
2024-01-10 09:21:43 +11:00
parent 7c33c9749d
commit fbbaf51522
4 changed files with 9 additions and 19 deletions

View File

@@ -121,16 +121,6 @@ Lint/SelfAssignment:
Exclude:
- 'app/models/spree/order/checkout.rb'
# Offense count: 9
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: EnforcedStyle.
# SupportedStyles: strict, consistent
Lint/SymbolConversion:
Exclude:
- 'app/models/spree/preferences/preferable_class_methods.rb'
- 'app/services/sets/product_set.rb'
- 'lib/spree/core/environment_extension.rb'
# Offense count: 1
# This cop supports unsafe autocorrection (--autocorrect-all).
Lint/UselessMethodDefinition:

View File

@@ -70,31 +70,31 @@ module Spree
end
def preference_getter_method(name)
"preferred_#{name}".to_sym
:"preferred_#{name}"
end
def preference_setter_method(name)
"preferred_#{name}=".to_sym
:"preferred_#{name}="
end
def prefers_getter_method(name)
"prefers_#{name}?".to_sym
:"prefers_#{name}?"
end
def prefers_setter_method(name)
"prefers_#{name}=".to_sym
:"prefers_#{name}="
end
def preference_default_getter_method(name)
"preferred_#{name}_default".to_sym
:"preferred_#{name}_default"
end
def preference_type_getter_method(name)
"preferred_#{name}_type".to_sym
:"preferred_#{name}_type"
end
def preference_description_getter_method(name)
"preferred_#{name}_description".to_sym
:"preferred_#{name}_description"
end
end
end

View File

@@ -118,7 +118,7 @@ module Sets
# Copy any variant errors to product
variant&.errors&.each do |error|
# The name is namespaced to avoid confusion with product attrs of same name.
product.errors.add("variant_#{error.attribute}".to_sym, error.message)
product.errors.add(:"variant_#{error.attribute}", error.message)
end
variant&.errors.blank?
end

View File

@@ -8,7 +8,7 @@ module Spree
def add_class(name)
instance_variable_set "@#{name}", Set.new
create_method( "#{name}=".to_sym ) { |val|
create_method( :"#{name}=" ) { |val|
instance_variable_set( "@" + name, val)
}