From e6aa0db293fbfab61fe0a0e330c5209ef4c0ba23 Mon Sep 17 00:00:00 2001 From: Brian Kephart Date: Fri, 8 Dec 2023 17:21:59 -0600 Subject: [PATCH] Update RuboCop target version --- .rubocop.yml | 2 +- app/apps/plugins/front_cache/admin_controller.rb | 10 ++++------ .../admin/appearances/nav_menus_controller.rb | 4 ++-- app/decorators/camaleon_cms/post_decorator.rb | 4 ++-- app/helpers/camaleon_cms/html_helper.rb | 4 ++-- app/helpers/camaleon_cms/short_code_helper.rb | 2 +- app/helpers/camaleon_cms/uploader_helper.rb | 2 +- app/models/camaleon_cms/site.rb | 2 +- app/models/concerns/camaleon_cms/custom_fields_read.rb | 4 ++-- .../camaleon_cms/default_theme/sitemap.xml.builder | 2 +- lib/ext/hash.rb | 2 +- 11 files changed, 18 insertions(+), 20 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index 2d8182ce..32b1248b 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -9,7 +9,7 @@ AllCops: - /**/vendor/**/* # Exclude downloaded gem code in CI NewCops: disable SuggestExtensions: false - TargetRubyVersion: 2.7 + TargetRubyVersion: 3.0 Lint/MissingSuper: Enabled: false diff --git a/app/apps/plugins/front_cache/admin_controller.rb b/app/apps/plugins/front_cache/admin_controller.rb index ff4f0223..faa14003 100644 --- a/app/apps/plugins/front_cache/admin_controller.rb +++ b/app/apps/plugins/front_cache/admin_controller.rb @@ -8,12 +8,10 @@ def settings end def save_settings - current_site.set_meta('front_cache_elements', { paths: ((params[:cache][:paths] || []).delete_if do |a| - !a.present? - end || []), - posts: (params[:cache][:posts] || []), - post_types: (params[:cache][:post_type] || []), - skip_posts: (params[:cache][:skip_posts] || []), + current_site.set_meta('front_cache_elements', { paths: (params[:cache][:paths] || []).compact_blank || [], + posts: params[:cache][:posts] || [], + post_types: params[:cache][:post_type] || [], + skip_posts: params[:cache][:skip_posts] || [], cache_login: params[:cache][:cache_login], home: params[:cache][:home], preserve_cache_on_restart: params[:cache][:preserve_cache_on_restart], diff --git a/app/controllers/camaleon_cms/admin/appearances/nav_menus_controller.rb b/app/controllers/camaleon_cms/admin/appearances/nav_menus_controller.rb index 8b1bf880..b2f4e58d 100644 --- a/app/controllers/camaleon_cms/admin/appearances/nav_menus_controller.rb +++ b/app/controllers/camaleon_cms/admin/appearances/nav_menus_controller.rb @@ -105,7 +105,7 @@ def add_items end if params[:custom_items].present? # custom menu items - params[:custom_items].each do |_index, item| + params[:custom_items].each_value do |item| type = item['kind'].present? ? item['kind'] : 'external' item = @nav_menu.append_menu_item({ label: item['label'], link: item['url'], type: type }) items << item @@ -113,7 +113,7 @@ def add_items end if params[:items].present? - params[:items].each do |_index, item| + params[:items].each_value do |item| item = @nav_menu.append_menu_item({ label: 'auto', link: item['id'], type: item['kind'] }) items << item end diff --git a/app/decorators/camaleon_cms/post_decorator.rb b/app/decorators/camaleon_cms/post_decorator.rb index 78203d63..e36d5b92 100644 --- a/app/decorators/camaleon_cms/post_decorator.rb +++ b/app/decorators/camaleon_cms/post_decorator.rb @@ -41,8 +41,8 @@ def the_thumb_url(default = nil) if th.present? th else - (default || object.post_type.get_option('default_thumb', - nil) || h.asset_url('camaleon_cms/image-not-found.png')) + default || object.post_type.get_option('default_thumb', + nil) || h.asset_url('camaleon_cms/image-not-found.png') end end alias the_image_url the_thumb_url diff --git a/app/helpers/camaleon_cms/html_helper.rb b/app/helpers/camaleon_cms/html_helper.rb index d64d5a29..9eb4c757 100644 --- a/app/helpers/camaleon_cms/html_helper.rb +++ b/app/helpers/camaleon_cms/html_helper.rb @@ -72,14 +72,14 @@ def cama_draw_pre_asset_contents def cama_draw_custom_assets cama_html_helpers_init unless @_assets_libraries.present? libs = [] - @_assets_libraries.each do |_key, assets| + @_assets_libraries.each_value do |assets| libs += assets[:css] if assets[:css].present? end stylesheets = libs.uniq css = stylesheet_link_tag(*stylesheets, media: 'all') libs = [] - @_assets_libraries.each do |_key, assets| + @_assets_libraries.each_value do |assets| libs += assets[:js] if assets[:js].present? end javascripts = libs.uniq diff --git a/app/helpers/camaleon_cms/short_code_helper.rb b/app/helpers/camaleon_cms/short_code_helper.rb index 404f4c2c..632450ed 100644 --- a/app/helpers/camaleon_cms/short_code_helper.rb +++ b/app/helpers/camaleon_cms/short_code_helper.rb @@ -15,7 +15,7 @@ def shortcodes_init return args[:shortcode] unless attrs.present? cama_load_libraries(*attrs['data'].to_s.split(',')) - return '' + '' }, "Permit to load libraries on demand, sample: [load_libraries data='datepicker,tinymce']") diff --git a/app/helpers/camaleon_cms/uploader_helper.rb b/app/helpers/camaleon_cms/uploader_helper.rb index ff5713e8..743438f1 100644 --- a/app/helpers/camaleon_cms/uploader_helper.rb +++ b/app/helpers/camaleon_cms/uploader_helper.rb @@ -45,7 +45,7 @@ def upload_file(uploaded_io, settings = {}) generate_thumb: true, temporal_time: 0, filename: begin - (cached_name || uploaded_io.original_filename) + cached_name || uploaded_io.original_filename rescue StandardError uploaded_io.path.split('/').last end.cama_fix_filename, diff --git a/app/models/camaleon_cms/site.rb b/app/models/camaleon_cms/site.rb index 7fb74a0d..5c1eb48a 100644 --- a/app/models/camaleon_cms/site.rb +++ b/app/models/camaleon_cms/site.rb @@ -91,7 +91,7 @@ def get_theme_slug # return theme model with slug theme_slug for this site # theme_slug: (optional) if it is null, this will return current theme for this site def get_theme(theme_slug = nil) - themes.where(slug: (theme_slug || get_theme_slug), status: nil).first_or_create! + themes.where(slug: theme_slug || get_theme_slug, status: nil).first_or_create! end # return plugin model with slug plugin_slug diff --git a/app/models/concerns/camaleon_cms/custom_fields_read.rb b/app/models/concerns/camaleon_cms/custom_fields_read.rb index 84560859..53362364 100644 --- a/app/models/concerns/camaleon_cms/custom_fields_read.rb +++ b/app/models/concerns/camaleon_cms/custom_fields_read.rb @@ -131,7 +131,7 @@ def get_field_values(_key, group_number = 0) # puts res[0]['my_slug1'].first ==> "val 1" def get_fields_grouped(field_keys) res = [] - custom_field_values.where(custom_field_slug: field_keys).order(group_number: :asc).group_by(&:group_number).each do |_group_number, group_fields| + custom_field_values.where(custom_field_slug: field_keys).order(group_number: :asc).group_by(&:group_number).each_value do |group_fields| group = {} field_keys.each do |field_key| _tmp = [] @@ -243,7 +243,7 @@ def set_field_values(datas = {}) ActiveRecord::Base.transaction do custom_field_values.delete_all - datas.each do |_index, fields_data| + datas.each_value do |fields_data| fields_data.each do |field_key, values| next unless values[:values].present? diff --git a/app/views/camaleon_cms/default_theme/sitemap.xml.builder b/app/views/camaleon_cms/default_theme/sitemap.xml.builder index d991baaa..9e38d58b 100644 --- a/app/views/camaleon_cms/default_theme/sitemap.xml.builder +++ b/app/views/camaleon_cms/default_theme/sitemap.xml.builder @@ -54,7 +54,7 @@ xml.urlset 'xmlns' => 'http://www.sitemaps.org/schemas/sitemap/0.9' do end end - @r[:custom].each do |_key, item| + @r[:custom].each_value do |item| xml.url do xml.loc item[:url] xml.lastmod item[:lastmod] || Date.today.to_s diff --git a/lib/ext/hash.rb b/lib/ext/hash.rb index 757d20bc..c45106d4 100644 --- a/lib/ext/hash.rb +++ b/lib/ext/hash.rb @@ -19,7 +19,7 @@ def to_attr_url_format # used for hash of objects def find_by(val, attr = 'id') - each do |_key, p| + each_value do |p| return p if p[attr].to_s == val.to_s end nil