From 44026b16be82dd3eb5b7e1352c61a700c63fe71d Mon Sep 17 00:00:00 2001 From: Nick Schonning Date: Tue, 21 Nov 2023 19:09:01 -0500 Subject: [PATCH] Ignore Style/WordArray in languages_helper --- .rubocop_todo.yml | 7 ------- app/helpers/languages_helper.rb | 3 +++ app/models/concerns/attachmentable.rb | 2 +- spec/requests/api/v1/apps_spec.rb | 2 +- spec/serializers/rest/account_warning_serializer_spec.rb | 2 +- spec/services/translate_status_service_spec.rb | 2 +- spec/support/examples/models/concerns/ranked_trend.rb | 2 +- 7 files changed, 8 insertions(+), 12 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 552054898e..fe28a7d060 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -103,10 +103,3 @@ Style/RedundantConstantBase: Exclude: - 'config/environments/production.rb' - 'config/initializers/sidekiq.rb' - -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: WordRegex. -# SupportedStyles: percent, brackets -Style/WordArray: - EnforcedStyle: percent - MinSize: 3 diff --git a/app/helpers/languages_helper.rb b/app/helpers/languages_helper.rb index 0a8ebcde54..26e1823f41 100644 --- a/app/helpers/languages_helper.rb +++ b/app/helpers/languages_helper.rb @@ -1,6 +1,7 @@ # frozen_string_literal: true module LanguagesHelper + # rubocop:disable Style/WordArray ISO_639_1 = { aa: ['Afar', 'Afaraf'].freeze, ab: ['Abkhaz', 'аҧсуа бызшәа'].freeze, @@ -222,6 +223,8 @@ module LanguagesHelper 'zh-YUE': ['Cantonese', '廣東話'].freeze, }.freeze + # rubocop:enable Style/WordArray + SUPPORTED_LOCALES = {}.merge(ISO_639_1).merge(ISO_639_1_REGIONAL).merge(ISO_639_3).freeze # For ISO-639-1 and ISO-639-3 language codes, we have their official diff --git a/app/models/concerns/attachmentable.rb b/app/models/concerns/attachmentable.rb index a83e178fc4..89c910249a 100644 --- a/app/models/concerns/attachmentable.rb +++ b/app/models/concerns/attachmentable.rb @@ -69,7 +69,7 @@ module Attachmentable original_extension = Paperclip::Interpolations.extension(attachment, :original) proper_extension = extensions_for_mime_type.first.to_s extension = extensions_for_mime_type.include?(original_extension) ? original_extension : proper_extension - extension = 'jpeg' if ['jpe', 'jfif'].include?(extension) + extension = 'jpeg' if %w(jpe jfif).include?(extension) extension end diff --git a/spec/requests/api/v1/apps_spec.rb b/spec/requests/api/v1/apps_spec.rb index 4e9147ba32..18984693b8 100644 --- a/spec/requests/api/v1/apps_spec.rb +++ b/spec/requests/api/v1/apps_spec.rb @@ -45,7 +45,7 @@ RSpec.describe 'Apps' do client_secret_expires_at: 0, name: client_name, website: website, - scopes: ['read', 'write'], + scopes: %w(read write), redirect_uris: redirect_uris, # Deprecated properties as of 4.3: redirect_uri: redirect_uri, diff --git a/spec/serializers/rest/account_warning_serializer_spec.rb b/spec/serializers/rest/account_warning_serializer_spec.rb index a7a9dc5f63..071ffdbbe4 100644 --- a/spec/serializers/rest/account_warning_serializer_spec.rb +++ b/spec/serializers/rest/account_warning_serializer_spec.rb @@ -12,7 +12,7 @@ RSpec.describe REST::AccountWarningSerializer do expect(subject) .to include( 'id' => be_a(String).and(eq('123')), - 'status_ids' => be_a(Array).and(eq(['456', '789'])), + 'status_ids' => be_a(Array).and(eq(%w(456 789))), 'created_at' => match_api_datetime_format ) end diff --git a/spec/services/translate_status_service_spec.rb b/spec/services/translate_status_service_spec.rb index ac7a43ff2a..692d95e8d4 100644 --- a/spec/services/translate_status_service_spec.rb +++ b/spec/services/translate_status_service_spec.rb @@ -18,7 +18,7 @@ RSpec.describe TranslateStatusService do describe '#call' do before do translation_service = TranslationService.new - allow(translation_service).to receive(:languages).and_return({ 'en' => ['es', 'es-MX'] }) + allow(translation_service).to receive(:languages).and_return({ 'en' => %w(es es-MX) }) allow(translation_service).to receive(:translate) do |texts| texts.map do |text| TranslationService::Translation.new( diff --git a/spec/support/examples/models/concerns/ranked_trend.rb b/spec/support/examples/models/concerns/ranked_trend.rb index 827165cc83..94219d149d 100644 --- a/spec/support/examples/models/concerns/ranked_trend.rb +++ b/spec/support/examples/models/concerns/ranked_trend.rb @@ -34,7 +34,7 @@ RSpec.shared_examples 'RankedTrend' do it 'returns unique set of languages' do expect(described_class.locales) - .to eq(['en', 'es']) + .to eq(%w(en es)) end end