From b495fdcf33645a4edfd027d1c46d114be3487afc Mon Sep 17 00:00:00 2001 From: "depfu[bot]" <23717796+depfu[bot]@users.noreply.github.com> Date: Tue, 26 May 2020 12:50:48 +0000 Subject: [PATCH 1/2] Update rubocop to version 0.83.0 --- Gemfile.lock | 99 ++++++++++++++++++++++++++-------------------------- 1 file changed, 49 insertions(+), 50 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 183e7420d..67c372498 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,43 +1,43 @@ GEM remote: https://rubygems.org/ specs: - actioncable (5.2.4.2) - actionpack (= 5.2.4.2) + actioncable (5.2.4.3) + actionpack (= 5.2.4.3) nio4r (~> 2.0) websocket-driver (>= 0.6.1) - actionmailer (5.2.4.2) - actionpack (= 5.2.4.2) - actionview (= 5.2.4.2) - activejob (= 5.2.4.2) + actionmailer (5.2.4.3) + actionpack (= 5.2.4.3) + actionview (= 5.2.4.3) + activejob (= 5.2.4.3) mail (~> 2.5, >= 2.5.4) rails-dom-testing (~> 2.0) - actionpack (5.2.4.2) - actionview (= 5.2.4.2) - activesupport (= 5.2.4.2) + actionpack (5.2.4.3) + actionview (= 5.2.4.3) + activesupport (= 5.2.4.3) rack (~> 2.0, >= 2.0.8) rack-test (>= 0.6.3) rails-dom-testing (~> 2.0) rails-html-sanitizer (~> 1.0, >= 1.0.2) - actionview (5.2.4.2) - activesupport (= 5.2.4.2) + actionview (5.2.4.3) + activesupport (= 5.2.4.3) builder (~> 3.1) erubi (~> 1.4) rails-dom-testing (~> 2.0) rails-html-sanitizer (~> 1.0, >= 1.0.3) - activejob (5.2.4.2) - activesupport (= 5.2.4.2) + activejob (5.2.4.3) + activesupport (= 5.2.4.3) globalid (>= 0.3.6) - activemodel (5.2.4.2) - activesupport (= 5.2.4.2) - activerecord (5.2.4.2) - activemodel (= 5.2.4.2) - activesupport (= 5.2.4.2) + activemodel (5.2.4.3) + activesupport (= 5.2.4.3) + activerecord (5.2.4.3) + activemodel (= 5.2.4.3) + activesupport (= 5.2.4.3) arel (>= 9.0) - activestorage (5.2.4.2) - actionpack (= 5.2.4.2) - activerecord (= 5.2.4.2) + activestorage (5.2.4.3) + actionpack (= 5.2.4.3) + activerecord (= 5.2.4.3) marcel (~> 0.3.1) - activesupport (5.2.4.2) + activesupport (5.2.4.3) concurrent-ruby (~> 1.0, >= 1.0.2) i18n (>= 0.7, < 2) minitest (~> 5.1) @@ -96,7 +96,7 @@ GEM io-like (0.3.0) jaro_winkler (1.5.4) locale (2.1.2) - loofah (2.4.0) + loofah (2.5.0) crass (~> 1.0.2) nokogiri (>= 1.5.9) mail (2.7.1) @@ -105,11 +105,11 @@ GEM mimemagic (~> 0.3.2) maruku (0.7.3) method_source (1.0.0) - mimemagic (0.3.4) + mimemagic (0.3.5) mini_magick (4.10.1) mini_mime (1.0.2) mini_portile2 (2.4.0) - minitest (5.14.0) + minitest (5.14.1) multi_xml (0.6.0) multipart-post (2.1.1) nio4r (2.5.2) @@ -117,7 +117,7 @@ GEM mini_portile2 (~> 2.4.0) open_uri_redirections (0.2.1) parallel (1.19.1) - parser (2.7.1.0) + parser (2.7.1.2) ast (~> 2.4.0) pkg-config (1.3.2) prometheus_exporter (0.5.1) @@ -130,18 +130,18 @@ GEM rack (2.2.2) rack-test (1.1.0) rack (>= 1.0, < 3) - rails (5.2.4.2) - actioncable (= 5.2.4.2) - actionmailer (= 5.2.4.2) - actionpack (= 5.2.4.2) - actionview (= 5.2.4.2) - activejob (= 5.2.4.2) - activemodel (= 5.2.4.2) - activerecord (= 5.2.4.2) - activestorage (= 5.2.4.2) - activesupport (= 5.2.4.2) + rails (5.2.4.3) + actioncable (= 5.2.4.3) + actionmailer (= 5.2.4.3) + actionpack (= 5.2.4.3) + actionview (= 5.2.4.3) + activejob (= 5.2.4.3) + activemodel (= 5.2.4.3) + activerecord (= 5.2.4.3) + activestorage (= 5.2.4.3) + activesupport (= 5.2.4.3) bundler (>= 1.3.0) - railties (= 5.2.4.2) + railties (= 5.2.4.3) sprockets-rails (>= 2.0.0) rails-dom-testing (2.0.3) activesupport (>= 4.2.0) @@ -151,9 +151,9 @@ GEM rails-i18n (5.1.3) i18n (>= 0.7, < 2) railties (>= 5.0, < 6) - railties (5.2.4.2) - actionpack (= 5.2.4.2) - activesupport (= 5.2.4.2) + railties (5.2.4.3) + actionpack (= 5.2.4.3) + activesupport (= 5.2.4.3) method_source rake (>= 0.8.7) thor (>= 0.19.0, < 2.0) @@ -164,14 +164,13 @@ GEM reverse_markdown (1.4.0) nokogiri rexml (3.2.4) - rubocop (0.80.1) - jaro_winkler (~> 1.5.1) + rubocop (0.83.0) parallel (~> 1.10) parser (>= 2.7.0.1) rainbow (>= 2.2.2, < 4.0) rexml ruby-progressbar (~> 1.7) - unicode-display_width (>= 1.4.0, < 1.7) + unicode-display_width (>= 1.4.0, < 2.0) rubocop-performance (1.5.2) rubocop (>= 0.71.0) ruby-progressbar (1.10.1) @@ -188,7 +187,7 @@ GEM selenium-webdriver (3.142.7) childprocess (>= 0.5, < 4.0) rubyzip (>= 1.2.2) - solargraph (0.38.5) + solargraph (0.39.7) backport (~> 1.1) benchmark bundler (>= 1.17.2) @@ -201,8 +200,8 @@ GEM rubocop (~> 0.52) thor (~> 1.0) tilt (~> 2.0) - yard (~> 0.9) - sprockets (3.7.2) + yard (~> 0.9, >= 0.9.24) + sprockets (4.0.0) concurrent-ruby (~> 1.0) rack (> 1, < 3) sprockets-rails (3.2.1) @@ -210,14 +209,14 @@ GEM activesupport (>= 4.0) sprockets (>= 3.0.0) text (1.3.1) - thor (0.20.3) + thor (1.0.1) thread_safe (0.3.6) tilt (2.0.10) tzinfo (1.2.7) thread_safe (~> 0.1) uglifier (4.2.0) execjs (>= 0.3.0, < 3) - unicode-display_width (1.6.1) + unicode-display_width (1.7.0) vcr (5.1.0) web-console (3.7.0) actionview (>= 5.0) @@ -228,14 +227,14 @@ GEM addressable (>= 2.3.6) crack (>= 0.3.2) hashdiff (>= 0.4.0, < 2.0.0) - websocket-driver (0.7.1) + websocket-driver (0.7.2) websocket-extensions (>= 0.1.0) websocket-extensions (0.1.4) xmlhash (1.3.7) pkg-config xpath (3.2.0) nokogiri (~> 1.8) - yard (0.9.24) + yard (0.9.25) PLATFORMS ruby From 6b04d083be79db8cd344bb821084d54dd884f3b1 Mon Sep 17 00:00:00 2001 From: Alexander Graul Date: Tue, 26 May 2020 14:59:42 +0200 Subject: [PATCH 2/2] Correct rubocop offenses The search_controller needs a real refactor at some point, for now I find it better to leave the style as is. A guard clause here does not improve readability. --- app/controllers/search_controller.rb | 2 ++ lib/api_connect.rb | 2 +- lib/obs.rb | 24 ++++++++++++------------ 3 files changed, 15 insertions(+), 13 deletions(-) diff --git a/app/controllers/search_controller.rb b/app/controllers/search_controller.rb index bff1e0225..44e092f9e 100644 --- a/app/controllers/search_controller.rb +++ b/app/controllers/search_controller.rb @@ -48,6 +48,7 @@ def index end @packagenames = @packagenames.uniq + # rubocop:disable Style/GuardClause if @packagenames.size == 1 redirect_to(controller: :package, action: :show, package: @packagenames.first, search_term: @search_term) && return elsif request.xhr? @@ -56,6 +57,7 @@ def index render('find') && return end end + # rubocop:enable Style/GuardClause def find; end end diff --git a/lib/api_connect.rb b/lib/api_connect.rb index 83c7dfdfc..96cf36d8c 100644 --- a/lib/api_connect.rb +++ b/lib/api_connect.rb @@ -6,7 +6,7 @@ class Error < RuntimeError; end def self.get(path, limit = 10) config = Rails.configuration.x uri_str = "#{config.api_host}/#{path}".gsub(' ', '%20') - uri_str = path if path =~ /^http/ + uri_str = path if /^http/.match?(path) uri = URI.parse(uri_str) logger.debug "Loading from api: #{uri_str}" begin diff --git a/lib/obs.rb b/lib/obs.rb index bf3e34a73..132680d9e 100644 --- a/lib/obs.rb +++ b/lib/obs.rb @@ -173,18 +173,18 @@ def self.search_published_binary(query, opts = {}) def self.add_binary_relevance(binary, query) quoted_query = Regexp.quote(query) binary.relevance = 0 - binary.relevance += 15 if binary.name =~ /^#{quoted_query}$/i - binary.relevance += 5 if binary.name =~ /^#{quoted_query}/i - binary.relevance += 15 if binary.project =~ /^openSUSE:/i - binary.relevance += 5 if binary.project =~ /^#{quoted_query}$/i - binary.relevance += 2 if binary.project =~ /^#{quoted_query}/i - binary.relevance -= 5 if binary.project =~ /unstable/i - binary.relevance -= 10 if binary.project =~ /^home:/ - binary.relevance -= 20 if binary.project =~ /^openSUSE:Maintenance/i - binary.relevance -= 10 if binary.name =~ /-debugsource$/ - binary.relevance -= 10 if binary.name =~ /-debuginfo$/ - binary.relevance -= 3 if binary.name =~ /-devel$/ - binary.relevance -= 3 if binary.name =~ /-doc$/ + binary.relevance += 15 if /^#{quoted_query}$/i.match?(binary.name) + binary.relevance += 5 if /^#{quoted_query}/i.match?(binary.name) + binary.relevance += 15 if /^openSUSE:/i.match?(binary.project) + binary.relevance += 5 if /^#{quoted_query}$/i.match?(binary.project) + binary.relevance += 2 if /^#{quoted_query}/i.match?(binary.project) + binary.relevance -= 5 if /unstable/i.match?(binary.project) + binary.relevance -= 10 if /^home:/.match?(binary.project) + binary.relevance -= 20 if /^openSUSE:Maintenance/i.match?(binary.project) + binary.relevance -= 10 if /-debugsource$/.match?(binary.name) + binary.relevance -= 10 if /-debuginfo$/.match?(binary.name) + binary.relevance -= 3 if /-devel$/.match?(binary.name) + binary.relevance -= 3 if /-doc$/.match?(binary.name) binary end