From a0ad312268b90b21300f6bb53e48bb1a54a80b43 Mon Sep 17 00:00:00 2001 From: Will Cosgrove Date: Tue, 30 Jul 2024 23:05:49 -0500 Subject: [PATCH] Fix rubocop violations --- lib/generators/phlex/install/install_generator.rb | 6 +++--- lib/phlex/rails/helpers.rb | 2 +- lib/phlex/rails/helpers/tag.rb | 2 +- lib/phlex/rails/helpers/turbo_stream.rb | 2 +- lib/phlex/rails/html/method_missing.rb | 2 +- lib/phlex/rails/layout.rb | 3 +-- lib/phlex/rails/streaming.rb | 2 +- test/dummy/config/application.rb | 2 +- test/dummy/config/environments/development.rb | 2 +- test/dummy/config/environments/production.rb | 4 ++-- test/dummy/config/environments/test.rb | 2 +- test/dummy/config/routes.rb | 2 +- test/test_helper.rb | 2 +- 13 files changed, 16 insertions(+), 17 deletions(-) diff --git a/lib/generators/phlex/install/install_generator.rb b/lib/generators/phlex/install/install_generator.rb index fb35c0fa..ecbd734f 100644 --- a/lib/generators/phlex/install/install_generator.rb +++ b/lib/generators/phlex/install/install_generator.rb @@ -13,7 +13,7 @@ def autoload_components inject_into_class( APPLICATION_CONFIGURATION_PATH, "Application", - %( config.autoload_paths << "\#{root}/app/views/components"\n) + %( config.autoload_paths << "\#{root}/app/views/components"\n), ) end @@ -23,7 +23,7 @@ def autoload_layouts inject_into_class( APPLICATION_CONFIGURATION_PATH, "Application", - %( config.autoload_paths << "\#{root}/app/views/layouts"\n) + %( config.autoload_paths << "\#{root}/app/views/layouts"\n), ) end @@ -33,7 +33,7 @@ def autoload_views inject_into_class( APPLICATION_CONFIGURATION_PATH, "Application", - %( config.autoload_paths << "\#{root}/app/views"\n) + %( config.autoload_paths << "\#{root}/app/views"\n), ) end diff --git a/lib/phlex/rails/helpers.rb b/lib/phlex/rails/helpers.rb index e9c4fc06..f7d10283 100644 --- a/lib/phlex/rails/helpers.rb +++ b/lib/phlex/rails/helpers.rb @@ -224,7 +224,7 @@ module Phlex::Rails::Helpers StyleSheetPath: :StylesheetPath, StyleSheetURL: :StylesheetURL, URLToJavaScript: :URLToJavascript, - URLToStyleSheet: :URLToStylesheet + URLToStyleSheet: :URLToStylesheet, } def self.const_missing(name) diff --git a/lib/phlex/rails/helpers/tag.rb b/lib/phlex/rails/helpers/tag.rb index f24e7bec..705cb88a 100644 --- a/lib/phlex/rails/helpers/tag.rb +++ b/lib/phlex/rails/helpers/tag.rb @@ -14,7 +14,7 @@ def tag(...) when ActionView::Helpers::TagHelper::TagBuilder Phlex::Rails::Buffered.new( result, - view: self + view: self, ) end end diff --git a/lib/phlex/rails/helpers/turbo_stream.rb b/lib/phlex/rails/helpers/turbo_stream.rb index d0de2748..460827fc 100644 --- a/lib/phlex/rails/helpers/turbo_stream.rb +++ b/lib/phlex/rails/helpers/turbo_stream.rb @@ -8,7 +8,7 @@ module Phlex::Rails::Helpers::TurboStream def turbo_stream(...) Phlex::Rails::Buffered.new( helpers.turbo_stream(...), - view: self + view: self, ) end end diff --git a/lib/phlex/rails/html/method_missing.rb b/lib/phlex/rails/html/method_missing.rb index 42734599..398d2928 100644 --- a/lib/phlex/rails/html/method_missing.rb +++ b/lib/phlex/rails/html/method_missing.rb @@ -8,6 +8,6 @@ def method_missing(name, *args, **kwargs, &block) module_name = Phlex::Rails::Helpers.constants.find { |mod| mod.to_s.underscore.gsub("domid", "dom_id") == const_name } return super unless module_name - raise NoMethodError, "Try including `Phlex::Rails::Helpers::#{module_name}` in #{self.class.name}." + raise NoMethodError.new("Try including `Phlex::Rails::Helpers::#{module_name}` in #{self.class.name}.") end end diff --git a/lib/phlex/rails/layout.rb b/lib/phlex/rails/layout.rb index f5094437..5be47991 100644 --- a/lib/phlex/rails/layout.rb +++ b/lib/phlex/rails/layout.rb @@ -38,8 +38,7 @@ def virtual_path def self.included(klass) unless klass < Phlex::HTML - raise Phlex::ArgumentError, - "👋 #{name} should only be included into Phlex::HTML classes." + raise Phlex::ArgumentError.new("👋 #{name} should only be included into Phlex::HTML classes.") end klass.extend(Interface) diff --git a/lib/phlex/rails/streaming.rb b/lib/phlex/rails/streaming.rb index a7b62eff..64998f83 100644 --- a/lib/phlex/rails/streaming.rb +++ b/lib/phlex/rails/streaming.rb @@ -51,7 +51,7 @@ def stream_html(view) debug_middleware = ActionDispatch::DebugExceptions.new( proc { |_env| raise(e) }, - response_format: :html + response_format: :html, ) _debug_status, _debug_headers, debug_body = debug_middleware.call(request.env) diff --git a/test/dummy/config/application.rb b/test/dummy/config/application.rb index 78775edc..09e69e36 100644 --- a/test/dummy/config/application.rb +++ b/test/dummy/config/application.rb @@ -13,7 +13,7 @@ class Application < Rails::Application config.autoload_paths << "#{root}/app/views" config.autoload_paths << "#{root}/app/views/layouts" config.autoload_paths << "#{root}/app/views/components" - config.load_defaults Rails::VERSION::STRING.to_f + config.load_defaults "#{Rails::VERSION::MAJOR}.#{Rails::VERSION::MINOR}" # Please, add to the `ignore` list any other `lib` subdirectories that do # not contain `.rb` files, or that should not be reloaded or eager loaded. diff --git a/test/dummy/config/environments/development.rb b/test/dummy/config/environments/development.rb index 1c139141..2700b73f 100644 --- a/test/dummy/config/environments/development.rb +++ b/test/dummy/config/environments/development.rb @@ -27,7 +27,7 @@ config.cache_store = :memory_store config.public_file_server.headers = { - "Cache-Control" => "public, max-age=#{2.days.to_i}" + "Cache-Control" => "public, max-age=#{Integer(2.days)}", } else config.action_controller.perform_caching = false diff --git a/test/dummy/config/environments/production.rb b/test/dummy/config/environments/production.rb index 0b48e394..f2dee17f 100644 --- a/test/dummy/config/environments/production.rb +++ b/test/dummy/config/environments/production.rb @@ -49,8 +49,8 @@ # Log to STDOUT by default config.logger = ActiveSupport::Logger.new($stdout) - .tap { |logger| logger.formatter = Logger::Formatter.new } - .then { |logger| ActiveSupport::TaggedLogging.new(logger) } + .tap { |logger| logger.formatter = Logger::Formatter.new } + .then { |logger| ActiveSupport::TaggedLogging.new(logger) } # Prepend all log lines with the following tags. config.log_tags = [:request_id] diff --git a/test/dummy/config/environments/test.rb b/test/dummy/config/environments/test.rb index 2f88cf5b..8d096c32 100644 --- a/test/dummy/config/environments/test.rb +++ b/test/dummy/config/environments/test.rb @@ -22,7 +22,7 @@ # Configure public file server for tests with Cache-Control for performance. config.public_file_server.enabled = true config.public_file_server.headers = { - "Cache-Control" => "public, max-age=#{1.hour.to_i}" + "Cache-Control" => "public, max-age=#{Integer(1.hour)}", } # Show full error reports and disable caching. diff --git a/test/dummy/config/routes.rb b/test/dummy/config/routes.rb index 6cf47850..c05c0d40 100644 --- a/test/dummy/config/routes.rb +++ b/test/dummy/config/routes.rb @@ -5,7 +5,7 @@ # Reveal health status on /up that returns 200 if the app boots with no exceptions, otherwise 500. # Can be used by load balancers and uptime monitors to verify that the app is live. - get "up" => "rails/health#show", as: :rails_health_check + get "up" => "rails/health#show", :as => :rails_health_check # Defines the root path route ("/") root "posts#index" diff --git a/test/test_helper.rb b/test/test_helper.rb index d5cb2a05..75c44da6 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -11,6 +11,6 @@ if ActiveSupport::TestCase.respond_to?(:fixture_paths=) ActiveSupport::TestCase.fixture_paths = [File.expand_path("fixtures", __dir__)] ActionDispatch::IntegrationTest.fixture_paths = ActiveSupport::TestCase.fixture_paths - ActiveSupport::TestCase.file_fixture_path = File.expand_path("fixtures", __dir__) + "/files" + ActiveSupport::TestCase.file_fixture_path = "#{File.expand_path('fixtures', __dir__)}/files" ActiveSupport::TestCase.fixtures :all end