mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-28 21:07:16 +00:00
Inspecting 1513 files
...........................................................................................................................................................................................................................................................................................................................................................C....................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................C........................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................
Offenses:
app/models/spree/shipping_method.rb:69:25: C: [Corrected] Style/RedundantRegexpArgument: Use string ":tracking" as argument instead of regexp /:tracking/.
tracking_url.gsub(/:tracking/, tracking) unless tracking.blank? || tracking_url.blank?
^^^^^^^^^^^
lib/spree/i18n.rb:36:17: C: [Corrected] Style/RedundantRegexpArgument: Use string "spree" as argument instead of regexp /spree/.
path.gsub(/spree/, '')
^^^^^^^
1513 files inspected, 2 offenses detected, 2 offenses corrected
40 lines
887 B
Ruby
40 lines
887 B
Ruby
# frozen_string_literal: true
|
|
|
|
require 'i18n'
|
|
require 'active_support/core_ext/array/extract_options'
|
|
require 'spree/i18n/base'
|
|
|
|
module Spree
|
|
extend ActionView::Helpers::TranslationHelper
|
|
extend ActionView::Helpers::TagHelper
|
|
|
|
class << self
|
|
# Add spree namespace and delegate to Rails TranslationHelper for some nice
|
|
# extra functionality. e.g return reasonable strings for missing translations
|
|
def translate(*args)
|
|
@virtual_path = virtual_path
|
|
|
|
options = args.extract_options!
|
|
options[:scope] = [*options[:scope]].unshift(:spree).uniq
|
|
|
|
super(*args, **options)
|
|
end
|
|
|
|
alias_method :t, :translate
|
|
|
|
def context
|
|
Spree::ViewContext.context
|
|
end
|
|
|
|
def virtual_path
|
|
return unless context
|
|
|
|
path = context.instance_variable_get("@virtual_path")
|
|
|
|
return unless path
|
|
|
|
path.gsub("spree", '')
|
|
end
|
|
end
|
|
end
|