Skip to content

Commit

Permalink
Merge pull request openSUSE#15751 from eduardoj/refactoring/rubocop_o…
Browse files Browse the repository at this point in the history
…ffenses_part_2

Autocorrect Style/SymbolArray RuboCop offenses
  • Loading branch information
eduardoj authored Mar 7, 2024
2 parents 2a5fda1 + 94809e4 commit 874981d
Show file tree
Hide file tree
Showing 140 changed files with 465 additions and 472 deletions.
7 changes: 0 additions & 7 deletions src/api/.rubocop_todo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1209,13 +1209,6 @@ Style/SlicingWithRange:
- 'app/services/package_service/schema_verifier.rb'
- 'test/node_matcher.rb'

# Offense count: 387
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: MinSize.
# SupportedStyles: percent, brackets
Style/SymbolArray:
EnforcedStyle: brackets

# Offense count: 10
ViewComponent/AvoidGlobalState:
Exclude:
Expand Down
2 changes: 1 addition & 1 deletion src/api/app/components/bs_request_state_badge_component.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def decode_state_icon
end

def icon_state_tag
if [:declined, :revoked].include?(state)
if %i[declined revoked].include?(state)
content_tag(
:span,
tag.i(class: "fas fa-#{decode_state_icon}").concat(
Expand Down
2 changes: 1 addition & 1 deletion src/api/app/components/request_decision_component.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def show_add_submitter_as_maintainer_option?

# TODO: Move all those "can_*" checks to a pundit policy
def can_accept_request?
@bs_request.state.in?([:new, :review]) && @is_target_maintainer
@bs_request.state.in?(%i[new review]) && @is_target_maintainer
end

def can_decline_request?
Expand Down
2 changes: 1 addition & 1 deletion src/api/app/controllers/announcements_controller.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
class AnnouncementsController < ApplicationController
before_action :set_status_message, only: [:show, :update, :destroy]
before_action :set_status_message, only: %i[show update destroy]
# Pundit authorization policies control
after_action :verify_authorized

Expand Down
2 changes: 1 addition & 1 deletion src/api/app/controllers/attribute_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ class AttributeController < ApplicationController
validate_action delete: { method: :delete, response: :status }
validate_action update: { method: :put, request: :attrib_type, response: :status }
validate_action update: { method: :post, request: :attrib_type, response: :status }
before_action :load_attribute, only: [:show, :update, :delete]
before_action :load_attribute, only: %i[show update delete]

# GET /attribute/:namespace/:name/_meta
def show
Expand Down
4 changes: 2 additions & 2 deletions src/api/app/controllers/attribute_namespace_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ class AttributeNamespaceController < ApplicationController
validate_action delete: { method: :delete, response: :status }
validate_action update: { method: :put, request: :attribute_namespace_meta, response: :status }
validate_action update: { method: :post, request: :attribute_namespace_meta, response: :status }
before_action :require_namespace, only: [:show, :delete, :update]
before_action :require_admin, only: [:update, :delete]
before_action :require_namespace, only: %i[show delete update]
before_action :require_admin, only: %i[update delete]

def index
if params[:namespace]
Expand Down
4 changes: 2 additions & 2 deletions src/api/app/controllers/cloud/upload_jobs_controller.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
module Cloud
class UploadJobsController < ApplicationController
before_action :require_login
before_action :validate_configuration_presence, only: [:index, :create]
before_action :set_upload_job, only: [:destroy, :show]
before_action :validate_configuration_presence, only: %i[index create]
before_action :set_upload_job, only: %i[destroy show]

def index
render xml: ::Cloud::Backend::UploadJob.all(::User.session!, format: :xml)
Expand Down
2 changes: 1 addition & 1 deletion src/api/app/controllers/comments_controller.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
class CommentsController < ApplicationController
before_action :find_obj, only: [:index, :create]
before_action :find_obj, only: %i[index create]

def index
comments = @obj.comments.includes(:user)
Expand Down
4 changes: 2 additions & 2 deletions src/api/app/controllers/distributions_controller.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
class DistributionsController < ApplicationController
before_action :require_admin, except: [:index, :show, :include_remotes]
before_action :set_body_xml, except: [:index, :show, :include_remotes]
before_action :require_admin, except: %i[index show include_remotes]
before_action :set_body_xml, except: %i[index show include_remotes]

validate_action bulk_replace: { method: :put, request: :distributions }
validate_action bulk_replace: { method: :post, request: :distributions }
Expand Down
2 changes: 1 addition & 1 deletion src/api/app/controllers/group_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ class GroupController < ApplicationController
validate_action groupinfo: { method: :delete, response: :status }

# raise an exception if authorize has not yet been called.
after_action :verify_authorized, except: [:index, :show]
after_action :verify_authorized, except: %i[index show]

rescue_from Pundit::NotAuthorizedError do |exception|
pundit_action = case exception.query.to_s
Expand Down
2 changes: 1 addition & 1 deletion src/api/app/controllers/issue_trackers_controller.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
class IssueTrackersController < ApplicationController
before_action :require_admin, only: [:create, :update, :destroy]
before_action :require_admin, only: %i[create update destroy]

validate_action index: { method: :get, response: :issue_trackers }
validate_action show: { method: :get, response: :issue_tracker }
Expand Down
6 changes: 3 additions & 3 deletions src/api/app/controllers/person_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ class PersonController < ApplicationController
validate_action register: { method: :put, response: :status }
validate_action register: { method: :post, response: :status }

skip_before_action :extract_user, only: [:command, :register]
skip_before_action :require_login, only: [:command, :register]
skip_before_action :extract_user, only: %i[command register]
skip_before_action :require_login, only: %i[command register]

before_action :set_user, only: [:post_userinfo, :change_my_password, :get_watchlist, :put_watchlist]
before_action :set_user, only: %i[post_userinfo change_my_password get_watchlist put_watchlist]

def show
@list = if params[:prefix]
Expand Down
4 changes: 2 additions & 2 deletions src/api/app/controllers/public_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def build
required_parameters :project

if params[:project] == '_result'
pass_to_backend('/build/_result' + build_query_from_hash(params, [:scmrepository, :scmbranch, :locallink, :multibuild, :lastbuild, :code]))
pass_to_backend('/build/_result' + build_query_from_hash(params, %i[scmrepository scmbranch locallink multibuild lastbuild code]))
return
end
# project visible/known ?
Expand Down Expand Up @@ -123,7 +123,7 @@ def source_file
end

path = Package.source_path(params[:project], params[:package], params[:filename])
path += build_query_from_hash(params, [:rev, :limit, :expand, :deleted])
path += build_query_from_hash(params, %i[rev limit expand deleted])
volley_backend_path(path) unless forward_from_backend(path)
end

Expand Down
4 changes: 2 additions & 2 deletions src/api/app/controllers/request_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ class RequestController < ApplicationController
validate_action request_create: { method: :post, response: :request }

# TODO: allow PUT for non-admins
before_action :require_admin, only: [:update, :destroy]
before_action :require_admin, only: %i[update destroy]

# GET /request
def index
Expand All @@ -27,7 +27,7 @@ class SaveError < APIError

def render_request_collection
# if all params areblank, something is wrong
raise RequireFilter if [:project, :user, :states, :types, :reviewstates, :ids].all? { |f| params[f].blank? }
raise RequireFilter if %i[project user states types reviewstates ids].all? { |f| params[f].blank? }

# convert comma seperated values into arrays
params[:roles] = params[:roles].split(',') if params[:roles]
Expand Down
2 changes: 1 addition & 1 deletion src/api/app/controllers/source_attribute_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def show
end

opts = { attrib_type: @at }.with_indifferent_access
[:binary, :with_default, :with_project].each { |p| opts[p] = params[p] }
%i[binary with_default with_project].each { |p| opts[p] = params[p] }
render xml: @attribute_container.render_attribute_axml(opts)
end

Expand Down
66 changes: 33 additions & 33 deletions src/api/app/controllers/source_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,18 @@ class SourceController < ApplicationController

validate_action index: { method: :get, response: :directory }

skip_before_action :extract_user, only: [:lastevents_public, :global_command_orderkiwirepos, :global_command_triggerscmsync]
skip_before_action :require_login, only: [:lastevents_public, :global_command_orderkiwirepos, :global_command_triggerscmsync]
skip_before_action :extract_user, only: %i[lastevents_public global_command_orderkiwirepos global_command_triggerscmsync]
skip_before_action :require_login, only: %i[lastevents_public global_command_orderkiwirepos global_command_triggerscmsync]
# we use an array for the "file" parameter for: package_command_diff, package_command_linkdiff and package_command_servicediff
skip_before_action :validate_params, only: [:package_command]

before_action :require_valid_project_name, except: [:index, :lastevents, :lastevents_public,
:global_command_orderkiwirepos, :global_command_branch,
:global_command_triggerscmsync, :global_command_createmaintenanceincident]
before_action :require_valid_project_name, except: %i[index lastevents lastevents_public
global_command_orderkiwirepos global_command_branch
global_command_triggerscmsync global_command_createmaintenanceincident]

before_action :require_scmsync_host_check, only: [:global_command_triggerscmsync]

before_action :require_package, only: [:show_package, :delete_package, :package_command]
before_action :require_package, only: %i[show_package delete_package package_command]

# GET /source
#########
Expand Down Expand Up @@ -68,11 +68,11 @@ def show_package

# exec
path = request.path_info
path += build_query_from_hash(params, [:rev, :linkrev, :emptylink,
:expand, :view, :extension,
:lastworking, :withlinked, :meta,
:deleted, :parse, :arch,
:repository, :product, :nofilename])
path += build_query_from_hash(params, %i[rev linkrev emptylink
expand view extension
lastworking withlinked meta
deleted parse arch
repository product nofilename])
pass_to_backend(path)
end

Expand Down Expand Up @@ -223,7 +223,7 @@ def get_file
end

path = Package.source_path(project_name, package_name, file)
path += build_query_from_hash(params, [:rev, :meta, :deleted, :limit, :expand, :view])
path += build_query_from_hash(params, %i[rev meta deleted limit expand view])
pass_to_backend(path)
end

Expand Down Expand Up @@ -253,7 +253,7 @@ def update_file

Package.verify_file!(@pack, params[:filename], request.raw_post)

@path += build_query_from_hash(params, [:user, :comment, :rev, :linkrev, :keeplink, :meta])
@path += build_query_from_hash(params, %i[user comment rev linkrev keeplink meta])
pass_to_backend(@path)

# update package timestamp and reindex sources
Expand All @@ -269,7 +269,7 @@ def delete_file

raise DeleteFileNoPermission, 'Insufficient permissions to delete file' unless @allowed

@path += build_query_from_hash(params, [:user, :comment, :meta, :rev, :linkrev, :keeplink])
@path += build_query_from_hash(params, %i[user comment meta rev linkrev keeplink])
Backend::Connection.delete @path

unless @package_name == '_pattern' || @package_name == '_project'
Expand Down Expand Up @@ -319,7 +319,7 @@ def global_command_orderkiwirepos

# POST /source?cmd=triggerscmsync
def global_command_triggerscmsync
pass_to_backend('/source' + build_query_from_hash(params, [:cmd, :scmrepository, :scmbranch, :isdefaultbranch]))
pass_to_backend('/source' + build_query_from_hash(params, %i[cmd scmrepository scmbranch isdefaultbranch]))
end

def set_issues_defaults
Expand Down Expand Up @@ -361,7 +361,7 @@ def show_package_issues
def pubkey_path
# check for project
@prj = Project.get_by_name(params[:project])
request.path_info + build_query_from_hash(params, [:user, :comment, :meta, :rev])
request.path_info + build_query_from_hash(params, %i[user comment meta rev])
end

def check_permissions_for_file
Expand Down Expand Up @@ -442,7 +442,7 @@ def project_command_unlock
# freeze project link, either creating the freeze or updating it
# POST /source/<project>?cmd=freezelink
def project_command_freezelink
pass_to_backend(request.path_info + build_query_from_hash(params, [:cmd, :user, :comment]))
pass_to_backend(request.path_info + build_query_from_hash(params, %i[cmd user comment]))
end

# add channel packages and extend repository list
Expand Down Expand Up @@ -484,7 +484,7 @@ def private_plain_backend_command
Project.find_by_name(params[:project])

path = request.path_info
path += build_query_from_hash(params, [:cmd, :user, :comment])
path += build_query_from_hash(params, %i[cmd user comment])
pass_to_backend(path)
end

Expand Down Expand Up @@ -811,7 +811,7 @@ def package_command_collectbuildenv
Package.get_by_project_and_name(@target_project_name, @target_package_name)

path = request.path_info
path << build_query_from_hash(params, [:cmd, :user, :comment, :orev, :oproject, :opackage])
path << build_query_from_hash(params, %i[cmd user comment orev oproject opackage])
pass_to_backend(path)
end

Expand Down Expand Up @@ -842,7 +842,7 @@ def package_command_undelete
path = request.path_info
raise CmdExecutionNoPermission, 'Only administrators are allowed to set the time' unless User.admin_session? || params[:time].blank?

path += build_query_from_hash(params, [:cmd, :user, :comment, :time])
path += build_query_from_hash(params, %i[cmd user comment time])
pass_to_backend(path)

# read meta data from backend to restore database object
Expand Down Expand Up @@ -905,7 +905,7 @@ def package_command_rebuild
# POST /source/<project>/<package>?cmd=commit
def package_command_commit
path = request.path_info
path += build_query_from_hash(params, [:cmd, :user, :comment, :rev, :linkrev, :keeplink, :repairlink])
path += build_query_from_hash(params, %i[cmd user comment rev linkrev keeplink repairlink])
pass_to_backend(path)

@package.sources_changed if @package # except in case of _project package
Expand All @@ -914,7 +914,7 @@ def package_command_commit
# POST /source/<project>/<package>?cmd=commitfilelist
def package_command_commitfilelist
path = request.path_info
path += build_query_from_hash(params, [:cmd, :user, :comment, :rev, :linkrev, :keeplink, :repairlink, :withvalidate])
path += build_query_from_hash(params, %i[cmd user comment rev linkrev keeplink repairlink withvalidate])
answer = pass_to_backend(path)

@package.sources_changed(dir_xml: answer) if @package # except in case of _project package
Expand All @@ -926,24 +926,24 @@ def package_command_diff
# opackage_name = params[:opackage]

path = request.path_info
path += build_query_from_hash(params, [:cmd, :rev, :orev, :oproject, :opackage, :expand, :linkrev, :olinkrev,
:unified, :missingok, :meta, :file, :filelimit, :tarlimit,
:view, :withissues, :onlyissues, :cacheonly, :nodiff])
path += build_query_from_hash(params, %i[cmd rev orev oproject opackage expand linkrev olinkrev
unified missingok meta file filelimit tarlimit
view withissues onlyissues cacheonly nodiff])
pass_to_backend(path)
end

# POST /source/<project>/<package>?cmd=linkdiff
def package_command_linkdiff
path = request.path_info
path += build_query_from_hash(params, [:cmd, :rev, :unified, :linkrev, :file, :filelimit, :tarlimit,
:view, :withissues, :onlyissues])
path += build_query_from_hash(params, %i[cmd rev unified linkrev file filelimit tarlimit
view withissues onlyissues])
pass_to_backend(path)
end

# POST /source/<project>/<package>?cmd=servicediff
def package_command_servicediff
path = request.path_info
path += build_query_from_hash(params, [:cmd, :rev, :unified, :file, :filelimit, :tarlimit, :view, :withissues, :onlyissues])
path += build_query_from_hash(params, %i[cmd rev unified file filelimit tarlimit view withissues onlyissues])
pass_to_backend(path)
end

Expand All @@ -965,9 +965,9 @@ def package_command_copy

# We need to use the project name of package object, since it might come via a project linked project
path = @package.source_path
path << build_query_from_hash(params, [:cmd, :rev, :user, :comment, :oproject, :opackage, :orev, :expand,
:keeplink, :repairlink, :linkrev, :olinkrev, :requestid,
:withvrev, :noservice, :dontupdatesource, :withhistory])
path << build_query_from_hash(params, %i[cmd rev user comment oproject opackage orev expand
keeplink repairlink linkrev olinkrev requestid
withvrev noservice dontupdatesource withhistory])
pass_to_backend(path)

@package.sources_changed
Expand Down Expand Up @@ -1070,7 +1070,7 @@ def package_command_waitservice
# POST /source/<project>/<package>?cmd=mergeservice
def package_command_mergeservice
path = request.path_info
path += build_query_from_hash(params, [:cmd, :comment, :user])
path += build_query_from_hash(params, %i[cmd comment user])
pass_to_backend(path)

@package.sources_changed
Expand All @@ -1079,7 +1079,7 @@ def package_command_mergeservice
# POST /source/<project>/<package>?cmd=runservice
def package_command_runservice
path = request.path_info
path += build_query_from_hash(params, [:cmd, :comment, :user])
path += build_query_from_hash(params, %i[cmd comment user])
pass_to_backend(path)

@package.sources_changed unless @project.scmsync.present? || params[:package] == '_project'
Expand Down
4 changes: 2 additions & 2 deletions src/api/app/controllers/source_project_config_controller.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
class SourceProjectConfigController < SourceController
# GET /source/:project/_config
before_action :ensure_project_exist, only: [:show, :update]
before_action :ensure_project_exist, only: %i[show update]

def show
config = get_config(@project)
Expand All @@ -27,7 +27,7 @@ def update
params[:user] = User.session!.login
@project.config.file = request.body

response = @project.config.save(slice_and_permit(params, [:user, :comment]))
response = @project.config.save(slice_and_permit(params, %i[user comment]))

unless response
render_404(@project.config.errors.full_messages.to_sentence)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ class SourceProjectPackageMetaController < SourceController
rescue_from Pundit::NotAuthorizedError, with: :user_not_authorized

validate_action update: { request: :package, response: :status }
before_action :require_package_name, only: [:show, :update]
before_action :require_package_name, only: %i[show update]
before_action :set_request_data, only: [:update]

before_action only: [:update] do
Expand All @@ -26,7 +26,7 @@ def show
# check if this comes from a remote project, also true for _project package
# or if meta is specified we need to fetch the meta from the backend
path = request.path_info
path += build_query_from_hash(params, [:meta, :rev, :view])
path += build_query_from_hash(params, %i[meta rev view])
pass_to_backend(path)
return
end
Expand Down
Loading

0 comments on commit 874981d

Please sign in to comment.