diff --git a/.rubocop_todo/performance/string_include.yml b/.rubocop_todo/performance/string_include.yml deleted file mode 100644 index 2a2d0559397a61e596d145b91cc403852b16dec4..0000000000000000000000000000000000000000 --- a/.rubocop_todo/performance/string_include.yml +++ /dev/null @@ -1,13 +0,0 @@ ---- -# Cop supports --autocorrect. -Performance/StringInclude: - Exclude: - - 'app/models/snippet_repository.rb' - - 'config/initializers/macos.rb' - - 'config/spring.rb' - - 'ee/app/models/ee/container_registry/event.rb' - - 'ee/lib/gitlab/auth/smartcard/certificate.rb' - - 'lib/kramdown/parser/atlassian_document_format.rb' - - 'lib/prometheus/pid_provider.rb' - - 'spec/features/projects/jobs_spec.rb' - - 'spec/spec_helper.rb' diff --git a/app/models/snippet_repository.rb b/app/models/snippet_repository.rb index a959ad4d548ddaebf5424f53b7771acad72f7e3d..9139dc22a94b8dbd862e6fcf64e80f3705765ebf 100644 --- a/app/models/snippet_repository.rb +++ b/app/models/snippet_repository.rb @@ -121,7 +121,7 @@ def invalid_path_error?(err) def invalid_signature_error?(err) err.is_a?(ArgumentError) && - err.message.downcase.match?(/failed to parse signature/) + err.message.downcase.include?('failed to parse signature') end def only_rename_action?(action) diff --git a/config/initializers/macos.rb b/config/initializers/macos.rb index 1edd6c0a730c7b2ac0684fc8716a550daf112d5a..3b669a73f49509fa49558d19c332d2819d985fed 100644 --- a/config/initializers/macos.rb +++ b/config/initializers/macos.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -if /darwin/ =~ RUBY_PLATFORM +if RUBY_PLATFORM.include?('darwin') Gitlab::Cluster::LifecycleEvents.on_before_fork do require 'fiddle' diff --git a/config/spring.rb b/config/spring.rb index 3f00e6ab23fb2c1a0356daff85bad33837e8066e..f06a707111ccf1fdff242cf1a7ba916e3a34e0d0 100644 --- a/config/spring.rb +++ b/config/spring.rb @@ -10,7 +10,7 @@ Spring.after_fork do if ENV['DEBUGGER_STORED_RUBYLIB'] ENV['DEBUGGER_STORED_RUBYLIB'].split(File::PATH_SEPARATOR).each do |path| - next unless path =~ /ruby-debug-ide/ + next unless path.include?('ruby-debug-ide') load path + '/ruby-debug-ide/multiprocess/starter.rb' end diff --git a/ee/app/models/ee/container_registry/event.rb b/ee/app/models/ee/container_registry/event.rb index ad09df1cce8c2ec23d81fbf76bfde59104e09430..91cdbd2c6b37d5702c641beaf21734ce5ab46114 100644 --- a/ee/app/models/ee/container_registry/event.rb +++ b/ee/app/models/ee/container_registry/event.rb @@ -22,7 +22,7 @@ def handle_after_update! end def media_type_manifest? - event.dig('target', 'mediaType') =~ /manifest/ + event.dig('target', 'mediaType')&.include?('manifest') end def find_container_repository! diff --git a/ee/lib/gitlab/auth/smartcard/certificate.rb b/ee/lib/gitlab/auth/smartcard/certificate.rb index 59377c2d22b08751c281bdd719d1d776ab438d50..0a9ea341010dce2b7cc3a94744f3590b9ca0e17d 100644 --- a/ee/lib/gitlab/auth/smartcard/certificate.rb +++ b/ee/lib/gitlab/auth/smartcard/certificate.rb @@ -51,7 +51,7 @@ def subject end def common_name - subject.split('/').find { |part| part =~ /CN=/ }&.remove('CN=')&.strip + subject.split('/').find { |part| part.include?('CN=') }&.remove('CN=')&.strip end def email @@ -59,7 +59,7 @@ def email if san_enabled? san_extension.email_identity else - subject.split('/').find { |part| part =~ /emailAddress=/ }&.remove('emailAddress=')&.strip + subject.split('/').find { |part| part.include?('emailAddress=') }&.remove('emailAddress=')&.strip end end end diff --git a/ee/spec/models/container_registry/event_spec.rb b/ee/spec/models/container_registry/event_spec.rb index 6d741e44ebd35bc021a47b49da02ee6e96bee318..506a844a4c653a744d656035e875ee381704a6f5 100644 --- a/ee/spec/models/container_registry/event_spec.rb +++ b/ee/spec/models/container_registry/event_spec.rb @@ -76,6 +76,14 @@ with_them do it_behaves_like params[:example_name] end + + context 'without media type' do + let(:action) { 'push' } + let(:repository_path) { 'group/test/container_repository' } + let(:target) { super().without('mediaType') } + + it_behaves_like 'not creating a geo event' + end end end end diff --git a/lib/kramdown/parser/atlassian_document_format.rb b/lib/kramdown/parser/atlassian_document_format.rb index 4ceb879a04c312951573cb1004d685979a47731f..d27697a59a6f2c2468947de112724bedacd5941a 100644 --- a/lib/kramdown/parser/atlassian_document_format.rb +++ b/lib/kramdown/parser/atlassian_document_format.rb @@ -219,7 +219,7 @@ def process_mention(element, ast_node) # opportunity to replace it later. Mention name can have # spaces, so double quote it mention_text = ast_node.dig('attrs', 'text')&.gsub('@', '') - mention_text = %Q("#{mention_text}") if mention_text.match?(/ /) + mention_text = %Q("#{mention_text}") if mention_text&.include?(' ') mention_text = %Q(@adf-mention:#{mention_text}) add_text(mention_text, element, :text) diff --git a/lib/prometheus/pid_provider.rb b/lib/prometheus/pid_provider.rb index 05a2d3bd0c9b68d1db89c69586034495783ed7ce..4d38e9513fb07fcc64d523c991dafb4035fa5540 100644 --- a/lib/prometheus/pid_provider.rb +++ b/lib/prometheus/pid_provider.rb @@ -27,7 +27,7 @@ def sidekiq_worker_id def puma_worker_id if matches = process_name.match(/puma.*cluster worker ([0-9]+):/) "puma_#{matches[1]}" - elsif process_name =~ /puma/ + elsif process_name.include?('puma') "puma_master" else unknown_process_id diff --git a/spec/features/projects/jobs_spec.rb b/spec/features/projects/jobs_spec.rb index 4734a607ef16e861ba66363e020a1469d303d212..40562d22a411bf39242bc7bc228b87e97be97df3 100644 --- a/spec/features/projects/jobs_spec.rb +++ b/spec/features/projects/jobs_spec.rb @@ -302,7 +302,7 @@ click_link 'Download' end - artifact_request = requests.find { |req| req.url.match(%r{artifacts/download}) } + artifact_request = requests.find { |req| req.url.include?('artifacts/download') } expect(artifact_request.response_headers['Content-Disposition']).to eq(%Q{attachment; filename="#{job.artifacts_file.filename}"; filename*=UTF-8''#{job.artifacts_file.filename}}) expect(artifact_request.response_headers['Content-Transfer-Encoding']).to eq("binary") diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 7f2510c5ab90f1dd73c88f559bd14d337de19b28..2d3afb489df08ab46749e1e0aefcd297dc8bb880 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -44,7 +44,7 @@ ENV['RSPEC_PROFILING'] branch_can_be_profiled = (ENV['CI_COMMIT_REF_NAME'] == 'master' || - ENV['CI_COMMIT_REF_NAME'] =~ /rspec-profile/) + ENV['CI_COMMIT_REF_NAME']&.include?('rspec-profile')) if rspec_profiling_is_configured && (!ENV.key?('CI') || branch_can_be_profiled) require 'rspec_profiling/rspec' @@ -105,7 +105,7 @@ location = metadata[:location] metadata[:level] = quality_level.level_for(location) - metadata[:api] = true if location =~ %r{/spec/requests/api/} + metadata[:api] = true if location.include?('/spec/requests/api/') # Do not overwrite migration if it's already set unless metadata.key?(:migration)