Skip to content

Commit

Permalink
Autocorrect safe rubocop offsenses
Browse files Browse the repository at this point in the history
  • Loading branch information
hennevogel committed Nov 8, 2023
1 parent c74c079 commit 5ec4077
Show file tree
Hide file tree
Showing 8 changed files with 15 additions and 15 deletions.
2 changes: 1 addition & 1 deletion app/controllers/download_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/packages_controller.rb
Original file line number Diff line number Diff line change
@@ -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

Expand Down
2 changes: 1 addition & 1 deletion app/controllers/search_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
12 changes: 6 additions & 6 deletions app/lib/obs.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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'))"
Expand Down
4 changes: 2 additions & 2 deletions app/models/distribution.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions app/views/layouts/_flash.html.haml
Original file line number Diff line number Diff line change
@@ -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',
Expand Down
2 changes: 1 addition & 1 deletion app/views/layouts/_footer.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
.d-flex.justify-content-between
.footer-copyright
&copy; 2011&ndash;
= Time.new.year
= Time.zone.now.year
= _('openSUSE contributors')
.list-inline
- github_link = 'https://github.com/openSUSE/software-o-o'
Expand Down
2 changes: 1 addition & 1 deletion app/views/layouts/application.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 5ec4077

Please sign in to comment.