diff --git a/.rubocop.yml b/.rubocop.yml index 029c2a478..add8c0264 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -22,3 +22,6 @@ Layout/DotPosition: Layout/LineLength: Max: 120 Enabled: true + +Layout/SpaceBeforeBrackets: + Enabled: true diff --git a/app/helpers/preview_helper.rb b/app/helpers/preview_helper.rb index 19b71ec68..97f3169ec 100644 --- a/app/helpers/preview_helper.rb +++ b/app/helpers/preview_helper.rb @@ -27,8 +27,8 @@ def find_template_data(lookup_context:, template_identifier:) end.flatten # Search for templates the contain `html`. - matching_templates = all_template_paths.find_all do |template| - template =~ /#{template_identifier}*.(html)/ + matching_templates = all_template_paths.find_all do |path| + path =~ /#{template_identifier}*.(html)/ end # In-case of a conflict due to multiple template files with diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index c1acb6863..08fb2492a 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -7,6 +7,10 @@ title: Changelog ## main +* Fix Ruby warnings. + + *Hans Lemuet* + * Place all generator options under `config.generate` namespace. *Simon Fish* diff --git a/lib/view_component/preview.rb b/lib/view_component/preview.rb index b22e9c3e0..bbe899681 100644 --- a/lib/view_component/preview.rb +++ b/lib/view_component/preview.rb @@ -73,8 +73,8 @@ def layout(layout_name) # Returns the relative path (from preview_path) to the preview example template if the template exists def preview_example_template_path(example) preview_path = - Array(preview_paths).detect do |preview_path| - Dir["#{preview_path}/#{preview_name}_preview/#{example}.html.*"].first + Array(preview_paths).detect do |path| + Dir["#{path}/#{preview_name}_preview/#{example}.html.*"].first end if preview_path.nil? diff --git a/lib/view_component/slotable_v2.rb b/lib/view_component/slotable_v2.rb index 2b2b4aac4..dc42d23ce 100644 --- a/lib/view_component/slotable_v2.rb +++ b/lib/view_component/slotable_v2.rb @@ -276,8 +276,8 @@ def set_slot(slot_name, slot_definition = nil, *args, &block) renderable_function = slot_definition[:renderable_function].bind(self) renderable_value = if block_given? - renderable_function.call(*args) do |*args| - view_context.capture(*args, &block) + renderable_function.call(*args) do |*rargs| + view_context.capture(*rargs, &block) end else renderable_function.call(*args) diff --git a/test/view_component/slotable_v2_test.rb b/test/view_component/slotable_v2_test.rb index bb300564b..bf7a6022a 100644 --- a/test/view_component/slotable_v2_test.rb +++ b/test/view_component/slotable_v2_test.rb @@ -477,8 +477,8 @@ def test_component_delegation_slots_work_with_helpers PartialHelper::State.reset assert_nothing_raised do - render_inline WrapperComponent.new do |c| - c.render(PartialSlotHelperComponent.new) do |c| + render_inline WrapperComponent.new do |w| + w.render(PartialSlotHelperComponent.new) do |c| c.header {} end end diff --git a/test/view_component/tasks_test.rb b/test/view_component/tasks_test.rb index 68ab6305c..0f2911af2 100644 --- a/test/view_component/tasks_test.rb +++ b/test/view_component/tasks_test.rb @@ -13,7 +13,7 @@ class TasksTest < ActiveSupport::TestCase test "adds components to rails stats" do Dir.chdir(Rails.root) do - assert_output /ViewComponents/ do + assert_output(/ViewComponents/) do Rake::Task["stats"].invoke end end