diff --git a/Gemfile.lock b/Gemfile.lock index 964fe3a8a..dff98dbe9 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -502,13 +502,13 @@ GEM rspec-support (~> 3.10) rspec-support (3.10.2) rszr (0.5.2) - rubocop (1.23.0) + rubocop (1.24.1) parallel (~> 1.10) parser (>= 3.0.0.0) rainbow (>= 2.2.2, < 4.0) regexp_parser (>= 1.8, < 3.0) rexml - rubocop-ast (>= 1.12.0, < 2.0) + rubocop-ast (>= 1.15.1, < 2.0) ruby-progressbar (~> 1.7) unicode-display_width (>= 1.4.0, < 3.0) rubocop-ast (1.15.1) diff --git a/app/controllers/concerns/has_publishing.rb b/app/controllers/concerns/has_publishing.rb index dec4d3754..fe462a7f2 100644 --- a/app/controllers/concerns/has_publishing.rb +++ b/app/controllers/concerns/has_publishing.rb @@ -18,8 +18,7 @@ module HasPublishing params_for_update = params .permit(:id, :internal_at, :published_at, :archived_at) .to_h - .map { |k, v| [k.to_sym, v == '--now--' ? Time.zone.now : v] } - .to_h + .to_h { |k, v| [k.to_sym, v == '--now--' ? Time.zone.now : v] } model_update_render(klass, params_for_update) end diff --git a/app/helpers/knowledge_base_rich_text_helper.rb b/app/helpers/knowledge_base_rich_text_helper.rb index c3b76037e..57367c8de 100644 --- a/app/helpers/knowledge_base_rich_text_helper.rb +++ b/app/helpers/knowledge_base_rich_text_helper.rb @@ -33,8 +33,7 @@ module KnowledgeBaseRichTextHelper settings = match .slice(1...-1) .split(',') - .map { |pair| pair.split(':').map(&:strip) } - .to_h + .to_h { |pair| pair.split(':').map(&:strip) } .symbolize_keys url = case settings[:provider] diff --git a/app/models/calendar.rb b/app/models/calendar.rb index 624719d27..d9fbc20be 100644 --- a/app/models/calendar.rb +++ b/app/models/calendar.rb @@ -93,9 +93,9 @@ returns data = YAML.load_file(Rails.root.join('config/holiday_calendars.yml')) url = data['url'] - data['countries'].map do |country, domain| + data['countries'].to_h do |country, domain| [format(url, domain: domain), country] - end.to_h + end end =begin diff --git a/app/models/channel/email_parser.rb b/app/models/channel/email_parser.rb index 98cf100dd..fb52a81d0 100644 --- a/app/models/channel/email_parser.rb +++ b/app/models/channel/email_parser.rb @@ -561,7 +561,7 @@ process unprocessable_mails (tmp/unprocessable_mail/*.eml) again end def message_header_hash(mail) - imported_fields = mail.header.fields.map do |f| + imported_fields = mail.header.fields.to_h do |f| begin value = if f.value.match?(ISO2022JP_REGEXP) value = header_field_unpack_japanese(f) @@ -582,7 +582,7 @@ process unprocessable_mails (tmp/unprocessable_mail/*.eml) again value = f.decoded.to_utf8(fallback: :read_as_sanitized_binary) end [f.name.downcase, value] - end.to_h + end # imported_fields = mail.header.fields.map { |f| [f.name.downcase, f.to_utf8] }.to_h raw_fields = mail.header.fields.index_by { |f| "raw-#{f.name.downcase}" } @@ -910,9 +910,7 @@ process unprocessable_mails (tmp/unprocessable_mail/*.eml) again md5 = Digest::MD5.hexdigest(msg) file_path = Rails.root.join('tmp', folder, "#{md5}.eml") - File.open(file_path, 'wb') do |file| - file.write msg - end + File.binwrite(file_path, msg) file_path end diff --git a/app/models/store.rb b/app/models/store.rb index 578d9a125..7b89b4828 100644 --- a/app/models/store.rb +++ b/app/models/store.rb @@ -211,9 +211,7 @@ returns if !path path = Rails.root.join('tmp', filename) end - ::File.open(path, 'wb') do |handle| - handle.write file.content - end + ::File.binwrite(path, file.content) path end diff --git a/lib/sequencer/unit/import/common/mapping/flat_keys.rb b/lib/sequencer/unit/import/common/mapping/flat_keys.rb index a1ae65cec..0014e4b57 100644 --- a/lib/sequencer/unit/import/common/mapping/flat_keys.rb +++ b/lib/sequencer/unit/import/common/mapping/flat_keys.rb @@ -25,9 +25,9 @@ class Sequencer def mapped @mapped ||= begin resource_with_indifferent_access = resource.with_indifferent_access - mapping.symbolize_keys.collect do |source, local| + mapping.symbolize_keys.to_h do |source, local| [local, resource_with_indifferent_access[source]] - end.to_h.with_indifferent_access + end.with_indifferent_access end end diff --git a/lib/sequencer/unit/import/exchange/folder_contacts/total.rb b/lib/sequencer/unit/import/exchange/folder_contacts/total.rb index 448da06fd..e7fbaacff 100644 --- a/lib/sequencer/unit/import/exchange/folder_contacts/total.rb +++ b/lib/sequencer/unit/import/exchange/folder_contacts/total.rb @@ -35,12 +35,12 @@ class Sequencer end def folder_total_map - ews_folder_ids.collect do |folder_id| + ews_folder_ids.to_h do |folder_id| folder = ews_folder.find(folder_id) display_path = ews_folder.display_path(folder) [display_path, folder.total_count] - end.to_h + end end end end diff --git a/lib/sequencer/unit/import/zendesk/ticket/custom_fields.rb b/lib/sequencer/unit/import/zendesk/ticket/custom_fields.rb index 128216b5f..f7c5daf8e 100644 --- a/lib/sequencer/unit/import/zendesk/ticket/custom_fields.rb +++ b/lib/sequencer/unit/import/zendesk/ticket/custom_fields.rb @@ -16,12 +16,12 @@ class Sequencer return {} if custom_fields.blank? custom_fields.select { |custom_field| ticket_field_map[ custom_field['id'] ].present? } - .map do |custom_field| + .to_h do |custom_field| [ ticket_field_map[ custom_field['id'] ].to_sym, # remote_name custom_field['value'] ] - end.to_h + end end end end diff --git a/lib/sessions/store/file.rb b/lib/sessions/store/file.rb index 15c8ff441..2c905f59e 100644 --- a/lib/sessions/store/file.rb +++ b/lib/sessions/store/file.rb @@ -20,9 +20,7 @@ class Sessions::Store::File # store session data in session file FileUtils.mkpath path_tmp - File.open(session_file, 'wb') do |file| - file.write content - end + File.binwrite(session_file, content) # destroy old session if needed if File.exist?(path) diff --git a/spec/requests/user/permission_spec.rb b/spec/requests/user/permission_spec.rb index a532ee03e..d0d3c5799 100644 --- a/spec/requests/user/permission_spec.rb +++ b/spec/requests/user/permission_spec.rb @@ -88,7 +88,7 @@ RSpec.describe 'User endpoint', type: :request do context 'parameter groups' do let(:group_names_access_map) do - Group.all.map { |g| [g.name, ['full']] }.to_h + Group.all.to_h { |g| [g.name, ['full']] } end let(:payload) do @@ -103,7 +103,7 @@ RSpec.describe 'User endpoint', type: :request do context 'parameter group_ids' do let(:group_ids_access_map) do - Group.all.map { |g| [g.id, ['full']] }.to_h + Group.all.to_h { |g| [g.id, ['full']] } end let(:payload) do @@ -436,7 +436,7 @@ RSpec.describe 'User endpoint', type: :request do let(:privileged) do { - groups: Group.all.map { |g| [g.name, ['full']] }.to_h + groups: Group.all.to_h { |g| [g.name, ['full']] } } end @@ -448,7 +448,7 @@ RSpec.describe 'User endpoint', type: :request do let(:privileged) do { - group_ids: Group.all.map { |g| [g.id, ['full']] }.to_h + group_ids: Group.all.to_h { |g| [g.id, ['full']] } } end diff --git a/spec/system/system/object_manager_spec.rb b/spec/system/system/object_manager_spec.rb index 3df5edc03..71e88feb2 100644 --- a/spec/system/system/object_manager_spec.rb +++ b/spec/system/system/object_manager_spec.rb @@ -167,7 +167,7 @@ RSpec.describe 'System > Objects', type: :system do context 'when checking field sorting', db_strategy: :reset do # lexicographically ordered list of option strings let(:options) { %w[0 000.000 1 100.100 100.200 2 200.100 200.200 3 ä b n ö p sr ß st t ü v] } - let(:options_hash) { options.reverse.collect { |o| [o, o] }.to_h } + let(:options_hash) { options.reverse.to_h { |o| [o, o] } } let(:object_attribute) do attribute = create(:object_manager_attribute_select, data_option: { options: options_hash, default: 0 }, position: 999) diff --git a/test/browser_test_helper.rb b/test/browser_test_helper.rb index ec9ada927..7493fb805 100644 --- a/test/browser_test_helper.rb +++ b/test/browser_test_helper.rb @@ -4681,7 +4681,7 @@ wait untill text in selector disabppears =end def set_setting(name, value) - name_to_id = fetch_settings.map { |s| [s['name'], s['id']] }.to_h + name_to_id = fetch_settings.to_h { |s| [s['name'], s['id']] } id = name_to_id[name] url = URI.parse(browser_url)