From ae51eb366b656b69ff12ebf04ad92d90e7a2195a Mon Sep 17 00:00:00 2001 From: Alexander Meindl Date: Sat, 31 Aug 2024 17:24:40 +0200 Subject: [PATCH] Fix rubocop offenses --- app/helpers/additionals_menu_helper.rb | 2 +- lib/additionals/helpers.rb | 2 +- lib/additionals/patches/issue_patch.rb | 2 +- lib/additionals/patches/principal_patch.rb | 2 +- lib/additionals/patches/query_patch.rb | 4 ++-- lib/additionals/wiki_macros/gmap_macro.rb | 2 +- lib/additionals/wiki_macros/meteoblue_macro.rb | 2 +- .../wiki_macros/slideshare_macro.rb | 2 +- test/fixtures/hrm_user_types.yml | 18 ++++++++++++++++++ test/global_test_helper.rb | 6 +++--- test/unit/query_test.rb | 2 ++ 11 files changed, 32 insertions(+), 12 deletions(-) create mode 100644 test/fixtures/hrm_user_types.yml diff --git a/app/helpers/additionals_menu_helper.rb b/app/helpers/additionals_menu_helper.rb index 09c94ef8..e27467ca 100644 --- a/app/helpers/additionals_menu_helper.rb +++ b/app/helpers/additionals_menu_helper.rb @@ -132,7 +132,7 @@ module AdditionalsMenuHelper s << if item[:title] == '-' tag.li tag.hr else - html_options = { class: +"help_item_#{id}" } + html_options = { class: "help_item_#{id}" } if item[:url].include? '://' html_options[:class] << ' external' html_options[:target] = '_blank' diff --git a/lib/additionals/helpers.rb b/lib/additionals/helpers.rb index edacb063..2c6917d2 100644 --- a/lib/additionals/helpers.rb +++ b/lib/additionals/helpers.rb @@ -38,7 +38,7 @@ module Additionals end def render_query_block_columns(query, entry, tr_classes:, with_buttons: false, with_checkbox: true) - td_colspan = query.inline_columns.size + 1 + td_colspan = query.inline_columns.size td_colspan += 1 if with_buttons content = [] diff --git a/lib/additionals/patches/issue_patch.rb b/lib/additionals/patches/issue_patch.rb index 9b7e5bc6..8302bbcc 100644 --- a/lib/additionals/patches/issue_patch.rb +++ b/lib/additionals/patches/issue_patch.rb @@ -26,7 +26,7 @@ module Additionals class_methods do def join_issue_status(is_closed: nil) - sql = +"JOIN #{IssueStatus.table_name} ON #{IssueStatus.table_name}.id = #{table_name}.status_id" + sql = "JOIN #{IssueStatus.table_name} ON #{IssueStatus.table_name}.id = #{table_name}.status_id" return sql if is_closed.nil? sql << " AND #{IssueStatus.table_name}.is_closed = #{is_closed ? connection.quoted_true : connection.quoted_false}" diff --git a/lib/additionals/patches/principal_patch.rb b/lib/additionals/patches/principal_patch.rb index 50af2ab2..77b67fcd 100644 --- a/lib/additionals/patches/principal_patch.rb +++ b/lib/additionals/patches/principal_patch.rb @@ -37,7 +37,7 @@ module Additionals if user.admin? || AdditionalsPlugin.active_hrm? && user.hrm_allowed_to?(:view_hrm) all else - view_all_active = if user.memberships.to_a.any? + view_all_active = if user.memberships.any? user.memberships .includes([:roles]) .any? { |m| m.roles.any? { |r| r.users_visibility == 'all' } } diff --git a/lib/additionals/patches/query_patch.rb b/lib/additionals/patches/query_patch.rb index ef80056d..c030b5cb 100644 --- a/lib/additionals/patches/query_patch.rb +++ b/lib/additionals/patches/query_patch.rb @@ -98,9 +98,9 @@ module Additionals " HAVING #{options[:aggr]}(#{options[:having_table]}.#{options[:field]})" null_all_sql = if options[:use_sub_query_for_all] - +"#{options[:sub_query]} AND" + "#{options[:sub_query]} AND" else - +"#{options[:sub_table]} WHERE" + "#{options[:sub_table]} WHERE" end null_all_sql << " #{options[:sub_table]}.#{options[:group_field]} = #{queried_table_name}.#{options[:join_field]})" diff --git a/lib/additionals/wiki_macros/gmap_macro.rb b/lib/additionals/wiki_macros/gmap_macro.rb index bed643cd..8932cac0 100644 --- a/lib/additionals/wiki_macros/gmap_macro.rb +++ b/lib/additionals/wiki_macros/gmap_macro.rb @@ -78,7 +78,7 @@ module Additionals raise 'The correct usage is {{gmap([q=QUERY, mode=MODE, widths=x, height=y])}}' end - src = +"https://www.google.com/maps/embed/v1/#{mode}?key=" + Additionals.setting(:google_maps_api_key) + src = "https://www.google.com/maps/embed/v1/#{mode}?key=" + Additionals.setting(:google_maps_api_key) if options[:q].present? src << "&q=#{ERB::Util.url_encode options[:q]}" elsif mode == 'search' diff --git a/lib/additionals/wiki_macros/meteoblue_macro.rb b/lib/additionals/wiki_macros/meteoblue_macro.rb index 925cc740..2d7e8bb7 100644 --- a/lib/additionals/wiki_macros/meteoblue_macro.rb +++ b/lib/additionals/wiki_macros/meteoblue_macro.rb @@ -98,7 +98,7 @@ module Additionals end def self.meteoblue_flag(options, name, default = tue) - flag = +"#{name}=" + flag = "#{name}=" flag << if RedminePluginKit.true?(options[name]) || default '1' else diff --git a/lib/additionals/wiki_macros/slideshare_macro.rb b/lib/additionals/wiki_macros/slideshare_macro.rb index f872b9c4..57379142 100644 --- a/lib/additionals/wiki_macros/slideshare_macro.rb +++ b/lib/additionals/wiki_macros/slideshare_macro.rb @@ -35,7 +35,7 @@ module Additionals raise 'The correct usage is {{slideshare([, width=x, height=y, slide=number])}}' if args.empty? v = args[0] - src = +"//www.slideshare.net/slideshow/embed_code/#{v}" + src = "//www.slideshare.net/slideshow/embed_code/#{v}" src += "?startSlide=#{slide}" if slide.positive? tag.iframe width:, height:, src:, frameborder: 0, allowfullscreen: 'true' diff --git a/test/fixtures/hrm_user_types.yml b/test/fixtures/hrm_user_types.yml new file mode 100644 index 00000000..240e907f --- /dev/null +++ b/test/fixtures/hrm_user_types.yml @@ -0,0 +1,18 @@ +internal_everybody: + is_default: true + name: Internal + is_internal: true + view_hrm: false + view_superiors: false + view_user_type_icon: false + view_attendance: false + view_groups: false + manage_users: false + manage_groups: false + manage_holidays: false + manage_working_calendars: false + with_help_menu: true + with_mypage_menu: true + with_watched_projects: true + icon: fas_car + custom_menu_items: diff --git a/test/global_test_helper.rb b/test/global_test_helper.rb index 5868e962..e301e42a 100644 --- a/test/global_test_helper.rb +++ b/test/global_test_helper.rb @@ -84,7 +84,7 @@ module Additionals .gsub('user.cf', 'user_cf') .tr('.', '-') - spec = +"td.#{c}" + spec = "td.#{c}" spec << "[colspan='#{colspan}']" if colspan assert_select spec @@ -112,8 +112,8 @@ module Additionals end end - colspan = inline_columns.count + 2 - colspan -= 1 unless with_checkbox + colspan = inline_columns.count + colspan += 1 if with_checkbox assert_select block_tr_select do block_columns.each do |column_name| assert_select_td_column column_name, colspan: diff --git a/test/unit/query_test.rb b/test/unit/query_test.rb index 7d9ca268..7ee11a67 100644 --- a/test/unit/query_test.rb +++ b/test/unit/query_test.rb @@ -10,6 +10,8 @@ class QueryTest < Additionals::TestCase :roles, :repositories + fixtures :hrm_user_types if AdditionalsPlugin.active_hrm? + def setup User.current = nil end