From 16c05ca1d8cf751b3c7fd56574d27460266e9e57 Mon Sep 17 00:00:00 2001 From: Andrew vonderLuft Date: Mon, 18 Nov 2024 12:11:08 -0800 Subject: [PATCH] rubocop linting --- app/controllers/concerns/comfy/reorder_action.rb | 2 +- app/helpers/comfy/admin/cms_helper.rb | 4 ++-- lib/comfortable_media_surfer/content/renderer.rb | 2 +- .../extensions/acts_as_tree.rb | 2 +- lib/comfortable_media_surfer/seeds/layout/importer.rb | 2 +- lib/comfortable_media_surfer/seeds/snippet/importer.rb | 10 ++++------ lib/generators/comfy/scaffold/scaffold_generator.rb | 2 +- test/integration/render_cms_test.rb | 6 +++--- 8 files changed, 14 insertions(+), 16 deletions(-) diff --git a/app/controllers/concerns/comfy/reorder_action.rb b/app/controllers/concerns/comfy/reorder_action.rb index e2e6543b..8be841a6 100644 --- a/app/controllers/concerns/comfy/reorder_action.rb +++ b/app/controllers/concerns/comfy/reorder_action.rb @@ -10,7 +10,7 @@ module Comfy::ReorderAction def reorder resource_class = self.class.reorder_action_resource (params.permit(order: [])[:order] || []).each_with_index do |id, index| - resource_class.where(id:).update_all(position: index) + resource_class.where(id: id).update_all(position: index) end if resource_class == ::Comfy::Cms::Page Comfy::Cms::Page.all.each(&:save!) diff --git a/app/helpers/comfy/admin/cms_helper.rb b/app/helpers/comfy/admin/cms_helper.rb index 83619901..d0225ccf 100644 --- a/app/helpers/comfy/admin/cms_helper.rb +++ b/app/helpers/comfy/admin/cms_helper.rb @@ -4,11 +4,11 @@ module Comfy module Admin module CmsHelper # Wrapper around Comfy::FormBuilder - def comfy_form_with(**options, &) + def comfy_form_with(**options, &block) form_options = options.merge(builder: ComfortableMediaSurfer::FormBuilder) form_options[:bootstrap] = { layout: :horizontal } form_options[:local] = true - bootstrap_form_with(**form_options, &) + bootstrap_form_with(**form_options, &block) end def comfy_admin_partial(path, params = {}) diff --git a/lib/comfortable_media_surfer/content/renderer.rb b/lib/comfortable_media_surfer/content/renderer.rb index 35c78174..a7f8bb24 100644 --- a/lib/comfortable_media_surfer/content/renderer.rb +++ b/lib/comfortable_media_surfer/content/renderer.rb @@ -21,7 +21,7 @@ class Error < StandardError; end MAX_DEPTH = 100 # tags are in this format: {{ cms:tag_class params }} - TAG_REGEX = %r{\{\{\s*?cms:(?\w+)(?.*?)\}\}}.freeze + TAG_REGEX = %r{\{\{\s*?cms:(?\w+)(?.*?)\}\}} class << self # @return [Hash>] diff --git a/lib/comfortable_media_surfer/extensions/acts_as_tree.rb b/lib/comfortable_media_surfer/extensions/acts_as_tree.rb index 062f8621..51fbeda5 100644 --- a/lib/comfortable_media_surfer/extensions/acts_as_tree.rb +++ b/lib/comfortable_media_surfer/extensions/acts_as_tree.rb @@ -104,7 +104,7 @@ def self_and_siblings # BUG: https://github.com/rails/rails/issues/14369 # It's still a bug. Remove it to see failing test def parent_id=(id) - self.parent = self.class.find_by(id:) + self.parent = self.class.find_by(id: id) end end end diff --git a/lib/comfortable_media_surfer/seeds/layout/importer.rb b/lib/comfortable_media_surfer/seeds/layout/importer.rb index 331fe9ab..8341ffc9 100644 --- a/lib/comfortable_media_surfer/seeds/layout/importer.rb +++ b/lib/comfortable_media_surfer/seeds/layout/importer.rb @@ -29,7 +29,7 @@ def import_layout(path, parent) attributes_yaml = content_hash.delete('attributes') attrs = YAML.safe_load(attributes_yaml) - layout = site.layouts.where(identifier:).first_or_initialize + layout = site.layouts.where(identifier: identifier).first_or_initialize layout.parent = parent if fresh_seed?(layout, content_path) diff --git a/lib/comfortable_media_surfer/seeds/snippet/importer.rb b/lib/comfortable_media_surfer/seeds/snippet/importer.rb index d1d936e3..6a73c1f1 100644 --- a/lib/comfortable_media_surfer/seeds/snippet/importer.rb +++ b/lib/comfortable_media_surfer/seeds/snippet/importer.rb @@ -18,22 +18,20 @@ def import! attributes_yaml = content_hash.delete('attributes') attrs = YAML.safe_load(attributes_yaml) - snippet = site.snippets.where(identifier:).first_or_initialize + snippet = site.snippets.where(identifier: identifier).first_or_initialize if fresh_seed?(snippet, path) category_ids = category_names_to_ids(snippet, attrs.delete('categories')) snippet.attributes = attrs.merge( - category_ids:, + category_ids: category_ids, content: content_hash['content'] ) if snippet.save - message = "[CMS SEEDS] Imported Snippet \t #{snippet.identifier}" - ComfortableMediaSurfer.logger.info(message) + ComfortableMediaSurfer.logger.info("[CMS SEEDS] Imported Snippet \t #{snippet.identifier}") else - message = "[CMS SEEDS] Failed to import Snippet \n#{snippet.errors.inspect}" - ComfortableMediaSurfer.logger.warn(message) + ComfortableMediaSurfer.logger.warn("[CMS SEEDS] Failed to import Snippet \n#{snippet.errors.inspect}") end end diff --git a/lib/generators/comfy/scaffold/scaffold_generator.rb b/lib/generators/comfy/scaffold/scaffold_generator.rb index 1ec6492f..6d5a72cc 100644 --- a/lib/generators/comfy/scaffold/scaffold_generator.rb +++ b/lib/generators/comfy/scaffold/scaffold_generator.rb @@ -16,7 +16,7 @@ class ScaffoldGenerator < Rails::Generators::NamedBase argument :model_args, type: :array, default: [], banner: 'attribute:type' - def initialize(*args, &) + def initialize(*args, &block) super @model_attrs = [] model_args.each do |arg| diff --git a/test/integration/render_cms_test.rb b/test/integration/render_cms_test.rb index c6368a12..25a660eb 100644 --- a/test/integration/render_cms_test.rb +++ b/test/integration/render_cms_test.rb @@ -32,7 +32,7 @@ def create_site_b ) site.pages.create!( label: 'default', - layout:, + layout: layout, fragments_attributes: [{ identifier: 'content', content: 'SiteBContent' }] ) end @@ -215,7 +215,7 @@ def test_cms_layout_defaults def test_cms_layout content = '{{cms:text content}} {{cms:text content_b}} {{cms:text content_c}}' - comfy_cms_layouts(:default).update_columns(content:) + comfy_cms_layouts(:default).update_columns(content: content) get '/render-layout?type=layout' assert_response :success assert_equal 'TestText TestPartial TestValue TestTemplate TestValue', response.body @@ -235,7 +235,7 @@ def test_cms_layout_with_status def test_cms_layout_with_action content = '{{cms:text content}} {{cms:text content_b}} {{cms:text content_c}}' - comfy_cms_layouts(:default).update_columns(content:) + comfy_cms_layouts(:default).update_columns(content: content) get '/render-layout?type=layout_with_action' assert_response :success assert_equal "Can render CMS layout and specify action\n ", response.body