From 5ec40777ade4ee08b9f0089e006869c3411ee4c8 Mon Sep 17 00:00:00 2001 From: Henne Vogelsang Date: Wed, 8 Nov 2023 17:49:03 +0100 Subject: [PATCH] Autocorrect safe rubocop offsenses --- app/controllers/download_controller.rb | 2 +- app/controllers/packages_controller.rb | 2 +- app/controllers/search_controller.rb | 2 +- app/lib/obs.rb | 12 ++++++------ app/models/distribution.rb | 4 ++-- app/views/layouts/_flash.html.haml | 4 ++-- app/views/layouts/_footer.html.haml | 2 +- app/views/layouts/application.html.haml | 2 +- 8 files changed, 15 insertions(+), 15 deletions(-) diff --git a/app/controllers/download_controller.rb b/app/controllers/download_controller.rb index 595d39f97..0e5bb208d 100644 --- a/app/controllers/download_controller.rb +++ b/app/controllers/download_controller.rb @@ -159,7 +159,7 @@ def set_distro_flavor(distro) def set_flavors return head :forbidden unless @data - @flavors = @data.values.collect { |i| i[:flavor] }.uniq.sort_by(&:downcase) + @flavors = @data.values.pluck(:flavor).uniq.sort_by(&:downcase) end def get_image_type(filename) diff --git a/app/controllers/packages_controller.rb b/app/controllers/packages_controller.rb index 5be0a7bdc..3c84bbd96 100644 --- a/app/controllers/packages_controller.rb +++ b/app/controllers/packages_controller.rb @@ -1,6 +1,6 @@ class PackagesController < ApplicationController before_action :set_distribution - before_action :set_package, only: %i[show update] + before_action :set_package, only: :show def show; end diff --git a/app/controllers/search_controller.rb b/app/controllers/search_controller.rb index a256f81c8..851e7b7e7 100644 --- a/app/controllers/search_controller.rb +++ b/app/controllers/search_controller.rb @@ -56,7 +56,7 @@ def index (a[:summary].match(/#{Regexp.quote(@search_term)}/i) || a[:name].match(/#{Regexp.quote(@search_term)}/i)) end - @packagenames += appdata_hits.map { |a| a[:pkgname] } + @packagenames += appdata_hits.pluck(:pkgname) end @packagenames = @packagenames.uniq diff --git a/app/lib/obs.rb b/app/lib/obs.rb index d348089e6..321162863 100644 --- a/app/lib/obs.rb +++ b/app/lib/obs.rb @@ -77,20 +77,20 @@ def self.xpath_for(query, opts = {}) words = query.split.reject { |part| part.match(/^[0-9_.-]+$/) } versrel = query.split.select { |part| part.match(/^[0-9_.-]+$/) } - Rails.logger.debug "splitted words and versrel: #{words.inspect} #{versrel.inspect}" + Rails.logger.debug { "splitted words and versrel: #{words.inspect} #{versrel.inspect}" } raise InvalidSearchTerm, 'Please provide a valid search term' if words.blank? && versrel.blank? raise InvalidSearchTerm, 'The package name is required when searching for a version' if words.blank? && versrel.present? xpath_items = [] - xpath_items << "@project = '#{project}' " unless project.blank? + xpath_items << "@project = '#{project}' " if project.present? substring_words = words.reject { |word| word.match(/^".+"$/) }.map { |word| "'#{word.gsub(/['"()]/, '')}'" }.join(', ') - xpath_items << "contains-ic(@name, #{substring_words})" unless substring_words.blank? + xpath_items << "contains-ic(@name, #{substring_words})" if substring_words.present? words.select { |word| word.match(/^".+"$/) }.map { |word| word.delete('"') }.each do |word| xpath_items << "@name = '#{word.gsub(/['"()]/, '')}' " end - xpath_items << "path/project='#{baseproject}'" unless baseproject.blank? - xpath_items << "not(contains-ic(@project, '#{exclude_filter}'))" if !exclude_filter.blank? && project.blank? - xpath_items << versrel.map { |part| "starts-with(@versrel,'#{part}')" }.join(' and ') unless versrel.blank? + xpath_items << "path/project='#{baseproject}'" if baseproject.present? + xpath_items << "not(contains-ic(@project, '#{exclude_filter}'))" if exclude_filter.present? && project.blank? + xpath_items << versrel.map { |part| "starts-with(@versrel,'#{part}')" }.join(' and ') if versrel.present? if exclude_debug xpath_items << "not(contains-ic(@name, '-debuginfo')) and not(contains-ic(@name, '-debugsource')) " \ "and not(contains-ic(@name, '-devel')) and not(contains-ic(@name, '-lang'))" diff --git a/app/models/distribution.rb b/app/models/distribution.rb index 305f1be20..853566718 100644 --- a/app/models/distribution.rb +++ b/app/models/distribution.rb @@ -8,8 +8,8 @@ class Distribution < ApplicationRecord validates :vendor, :name, :version, :obs_repo_names, presence: true def sync - repositories.where(updateinfo: false).each(&:sync) - repositories.where(updateinfo: true).each(&:sync) + repositories.where(updateinfo: false).find_each(&:sync) + repositories.where(updateinfo: true).find_each(&:sync) end def full_name diff --git a/app/views/layouts/_flash.html.haml b/app/views/layouts/_flash.html.haml index 9082dce9c..9a14fe23a 100644 --- a/app/views/layouts/_flash.html.haml +++ b/app/views/layouts/_flash.html.haml @@ -1,7 +1,7 @@ -- unless flash.blank? +- if flash.present? .container#flash-messages - %w[success error warn note notice info].each do |flash_type| - - if flash[flash_type] && !flash[flash_type].empty? + - if flash[flash_type].present? :ruby states = { error: 'alert alert-danger', diff --git a/app/views/layouts/_footer.html.haml b/app/views/layouts/_footer.html.haml index d493d5f6a..c1a7acd58 100644 --- a/app/views/layouts/_footer.html.haml +++ b/app/views/layouts/_footer.html.haml @@ -3,7 +3,7 @@ .d-flex.justify-content-between .footer-copyright © 2011– - = Time.new.year + = Time.zone.now.year = _('openSUSE contributors') .list-inline - github_link = 'https://github.com/openSUSE/software-o-o' diff --git a/app/views/layouts/application.html.haml b/app/views/layouts/application.html.haml index 24086c7ad..6126618e0 100644 --- a/app/views/layouts/application.html.haml +++ b/app/views/layouts/application.html.haml @@ -22,7 +22,7 @@ build_service: @build_service, current_language: @lang } - - unless flash.blank? + - if flash.present? = render(partial: 'layouts/flash', object: flash) %main.page-content.flex-fill#content