mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-28 21:07:16 +00:00
Inspecting 1484 files
.............................................................................................................................................................................................................................................................................................................C.............................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................C....................C.....................................................................................................................................................................................................................................................................C.........................................................................................................................................................................................................C...........................................................................................................................................................
Offenses:
app/models/product_import/product_importer.rb:290:35: C: [Corrected] Rails/FilePath: Prefer Rails.root.join('path/to').
return unless @file.path == Rails.root.join('tmp', 'product_import').to_s
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
lib/tasks/karma.rake:42:5: C: [Corrected] Rails/FilePath: Prefer Rails.root.join('path/to').
"#{Rails.root.join(I18n::JS::DEFAULT_EXPORT_DIR_PATH)}/translations.js"
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
lib/tasks/karma.rake:42:5: C: [Correctable] Style/RedundantInterpolation: Prefer to_s over string interpolation.
"#{Rails.root.join(I18n::JS::DEFAULT_EXPORT_DIR_PATH, 'translations.js')}"
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
lib/tasks/karma.rake:42:59: C: [Corrected] Style/StringLiteralsInInterpolation: Prefer single-quoted strings inside interpolations.
"#{Rails.root.join(I18n::JS::DEFAULT_EXPORT_DIR_PATH, "translations.js")}"
^^^^^^^^^^^^^^^^^
spec/base_spec_helper.rb:58:25: C: [Corrected] Rails/FilePath: Prefer Rails.root.join('path/to').
config.fixture_path = "#{::Rails.root}/spec/fixtures"
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
spec/base_spec_helper.rb:58:25: C: [Correctable] Style/RedundantInterpolation: Prefer to_s over string interpolation.
config.fixture_path = "#{Rails.root.join('spec/fixtures')}"
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
spec/base_spec_helper.rb:58:44: C: [Corrected] Style/StringLiteralsInInterpolation: Prefer single-quoted strings inside interpolations.
config.fixture_path = "#{Rails.root.join("spec/fixtures")}"
^^^^^^^^^^^^^^^
spec/models/content_configuration_spec.rb:15:19: C: [Corrected] Rails/FilePath: Prefer Rails.root.join('path/to').to_s.
File.exist?(File.join(Rails.root, 'public', default_url))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
spec/models/content_configuration_spec.rb:15:19: C: [Corrected] Rails/RootPublicPath: Use Rails.public_path.
File.exist?(Rails.root.join('public', default_url).to_s)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
spec/support/downloads_helper.rb:7:5: C: [Corrected] Rails/FilePath: Prefer Rails.root.join('path/to').
Rails.root.join("tmp", "capybara")
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1484 files inspected, 10 offenses detected, 8 offenses corrected, 2 more offenses can be corrected with `rubocop -A`
45 lines
1.2 KiB
Ruby
45 lines
1.2 KiB
Ruby
# frozen_string_literal: true
|
|
|
|
ENV["RAILS_ENV"] ||= 'test'
|
|
|
|
namespace :karma do
|
|
task start: :environment do |_task|
|
|
with_tmp_config :start
|
|
end
|
|
|
|
task run: :environment do |_task|
|
|
with_tmp_config :start, "--single-run"
|
|
end
|
|
|
|
private
|
|
|
|
def with_tmp_config(command, args = nil)
|
|
Tempfile.open('karma_unit.js', Rails.root.join('tmp') ) do |f|
|
|
f.write unit_js(application_spec_files << i18n_file)
|
|
f.flush
|
|
trap('SIGINT') { puts "Killing Karma"; exit }
|
|
exec "node_modules/.bin/karma #{command} #{f.path} #{args}"
|
|
end
|
|
end
|
|
|
|
def application_spec_files
|
|
sprockets = Rails.application.assets
|
|
sprockets.append_path Rails.root.join("spec/javascripts")
|
|
Rails.application.assets.find_asset("application_spec.js").to_a.map { |e| e.pathname.to_s }
|
|
end
|
|
|
|
def unit_js(files)
|
|
puts files
|
|
unit_js = File.open('config/ng-test.conf.js', 'r').read
|
|
unit_js.gsub "APPLICATION_SPEC", "\"#{files.join("\",\n\"")}\""
|
|
end
|
|
|
|
def i18n_file
|
|
raise "I18n::JS module is missing" unless defined?(I18n::JS)
|
|
|
|
I18n::JS::DEFAULT_EXPORT_DIR_PATH.replace('tmp/javascripts')
|
|
I18n::JS.export
|
|
"#{Rails.root.join(I18n::JS::DEFAULT_EXPORT_DIR_PATH, 'translations.js')}"
|
|
end
|
|
end
|