Skip to content

Commit

Permalink
[ci] Fix Style/CaseIndentation Rubocop issues
Browse files Browse the repository at this point in the history
  • Loading branch information
Manuel Schnitzer committed Mar 20, 2017
1 parent a5c8b1f commit af832e0
Show file tree
Hide file tree
Showing 12 changed files with 212 additions and 212 deletions.
14 changes: 7 additions & 7 deletions src/api/app/controllers/group_controller.rb
Expand Up @@ -10,13 +10,13 @@ class GroupController < ApplicationController

rescue_from Pundit::NotAuthorizedError do |exception|
pundit_action = case exception.query.to_s
when "index?" then "list"
when "show?" then "view"
when "create?" then "create"
when "new?" then "create"
when "update?" then "update"
when "destroy?" then "delete"
else exception.query
when "index?" then "list"
when "show?" then "view"
when "create?" then "create"
when "new?" then "create"
when "update?" then "update"
when "destroy?" then "delete"
else exception.query
end

render_error status: 403, errorcode: "No permission to #{pundit_action} group"
Expand Down
12 changes: 6 additions & 6 deletions src/api/app/controllers/search_controller.rb
Expand Up @@ -92,12 +92,12 @@ def owner

def predicate_from_match_parameter(p)
pred = case p
when /^\(\[(.*)\]\)$/
$1
when /^\[(.*)\]$/
$1
else
p
when /^\(\[(.*)\]\)$/
$1
when /^\[(.*)\]$/
$1
else
p
end
pred = "*" if pred.nil? || pred.empty?
pred
Expand Down
18 changes: 9 additions & 9 deletions src/api/app/controllers/webui/request_controller.rb
Expand Up @@ -21,15 +21,15 @@ def add_reviewer
begin
opts = {}
case params[:review_type]
when 'user' then
opts[:by_user] = params[:review_user]
when 'group' then
opts[:by_group] = params[:review_group]
when 'project' then
opts[:by_project] = params[:review_project]
when 'package' then
opts[:by_project] = params[:review_project]
opts[:by_package] = params[:review_package]
when 'user' then
opts[:by_user] = params[:review_user]
when 'group' then
opts[:by_group] = params[:review_group]
when 'project' then
opts[:by_project] = params[:review_project]
when 'package' then
opts[:by_project] = params[:review_project]
opts[:by_package] = params[:review_package]
end
opts[:comment] = params[:review_comment] if params[:review_comment]

Expand Down
18 changes: 9 additions & 9 deletions src/api/app/controllers/webui/webui_controller.rb
Expand Up @@ -28,15 +28,15 @@ def handle_unverified_request

rescue_from Pundit::NotAuthorizedError do |exception|
pundit_action = case exception.try(:query).to_s
when "index?" then "list"
when "show?" then "view"
when "create?" then "create"
when "new?" then "create"
when "update?" then "update"
when "edit?" then "edit"
when "destroy?" then "delete"
when "branch?" then "branch"
else exception.try(:query)
when "index?" then "list"
when "show?" then "view"
when "create?" then "create"
when "new?" then "create"
when "update?" then "update"
when "edit?" then "edit"
when "destroy?" then "delete"
when "branch?" then "branch"
else exception.try(:query)
end
if pundit_action && exception.record
message = "Sorry, you are not authorized to #{pundit_action} this #{exception.record.class}."
Expand Down
24 changes: 12 additions & 12 deletions src/api/app/helpers/webui/package_helper.rb
Expand Up @@ -29,18 +29,18 @@ def guess_code_class( filename )
return 'spec' if filename =~ /^macros\.\w+/
ext = Pathname.new(filename).extname.downcase
case ext
when '.group' then return 'xml'
when '.kiwi' then return 'xml'
when '.patch', '.dif' then return 'diff'
when '.pl', '.pm' then return 'perl'
when '.product' then return 'xml'
when '.py' then return 'python'
when '.rb' then return 'ruby'
when '.tex' then return 'latex'
when '.js' then return 'javascript'
when '.sh' then return 'shell'
when '.spec' then return 'rpm-spec'
when '.changes' then return 'rpm-changes'
when '.group' then return 'xml'
when '.kiwi' then return 'xml'
when '.patch', '.dif' then return 'diff'
when '.pl', '.pm' then return 'perl'
when '.product' then return 'xml'
when '.py' then return 'python'
when '.rb' then return 'ruby'
when '.tex' then return 'latex'
when '.js' then return 'javascript'
when '.sh' then return 'shell'
when '.spec' then return 'rpm-spec'
when '.changes' then return 'rpm-changes'
end
ext = ext[1..-1]
return ext if ext.in?(["diff", "php", "html", "xml", "css", "perl"])
Expand Down
130 changes: 65 additions & 65 deletions src/api/app/models/bs_request.rb
Expand Up @@ -525,21 +525,21 @@ def change_state(opts)

params = {request: self, comment: opts[:comment], user_id: User.current.id}
case opts[:newstate]
when "accepted" then
history = HistoryElement::RequestAccepted
when "declined" then
history = HistoryElement::RequestDeclined
when "revoked" then
history = HistoryElement::RequestRevoked
when "superseded" then
history = HistoryElement::RequestSuperseded
params[:description_extension] = superseded_by.to_s
when "review" then
history = HistoryElement::RequestReopened
when "new" then
history = HistoryElement::RequestReopened
else
raise RuntimeError, "Unhandled state #{opts[:newstate]} for history"
when "accepted" then
history = HistoryElement::RequestAccepted
when "declined" then
history = HistoryElement::RequestDeclined
when "revoked" then
history = HistoryElement::RequestRevoked
when "superseded" then
history = HistoryElement::RequestSuperseded
params[:description_extension] = superseded_by.to_s
when "review" then
history = HistoryElement::RequestReopened
when "new" then
history = HistoryElement::RequestReopened
else
raise RuntimeError, "Unhandled state #{opts[:newstate]} for history"
end
history.create(params)
end
Expand Down Expand Up @@ -1051,63 +1051,63 @@ def webui_actions(with_diff = true)
end

case xml.action_type # All further stuff depends on action type...
when :submit then
action[:name] = "Submit #{action[:spkg]}"
action[:sourcediff] = xml.webui_infos if with_diff
creator = User.find_by_login(self.creator)
target_package = Package.find_by_project_and_name(action[:tprj], action[:tpkg])
action[:creator_is_target_maintainer] = true if creator.has_local_role?(Role.rolecache['maintainer'], target_package)

if target_package
linkinfo = target_package.linkinfo
target_package.developed_packages.each do |dev_pkg|
action[:forward] ||= []
action[:forward] << {project: dev_pkg.project.name, package: dev_pkg.name, type: 'devel' }
end
if linkinfo
lprj, lpkg = linkinfo['project'], linkinfo['package']
link_is_already_devel = false
if action[:forward]
action[:forward].each do |forward|
if forward[:project] == lprj && forward[:package] == lpkg
link_is_already_devel = true
break
end
when :submit then
action[:name] = "Submit #{action[:spkg]}"
action[:sourcediff] = xml.webui_infos if with_diff
creator = User.find_by_login(self.creator)
target_package = Package.find_by_project_and_name(action[:tprj], action[:tpkg])
action[:creator_is_target_maintainer] = true if creator.has_local_role?(Role.rolecache['maintainer'], target_package)

if target_package
linkinfo = target_package.linkinfo
target_package.developed_packages.each do |dev_pkg|
action[:forward] ||= []
action[:forward] << {project: dev_pkg.project.name, package: dev_pkg.name, type: 'devel' }
end
if linkinfo
lprj, lpkg = linkinfo['project'], linkinfo['package']
link_is_already_devel = false
if action[:forward]
action[:forward].each do |forward|
if forward[:project] == lprj && forward[:package] == lpkg
link_is_already_devel = true
break
end
end
unless link_is_already_devel
action[:forward] ||= []
action[:forward] << {project: linkinfo['project'], package: linkinfo['package'], type: 'link'}
end
end
unless link_is_already_devel
action[:forward] ||= []
action[:forward] << {project: linkinfo['project'], package: linkinfo['package'], type: 'link'}
end
end
end

when :delete then
if action[:tpkg]
action[:name] = "Delete #{action[:tpkg]}"
elsif action[:trepo]
action[:name] = "Delete #{action[:trepo]}"
else
action[:name] = "Delete #{action[:tprj]}"
end
when :delete then
if action[:tpkg]
action[:name] = "Delete #{action[:tpkg]}"
elsif action[:trepo]
action[:name] = "Delete #{action[:trepo]}"
else
action[:name] = "Delete #{action[:tprj]}"
end

if action[:tpkg] # API / Backend don't support whole project diff currently
action[:sourcediff] = xml.webui_infos if with_diff
end
when :add_role then
action[:name] = 'Add Role'
action[:role] = xml.role
action[:user] = xml.person_name
when :change_devel then
action[:name] = 'Change Devel'
when :set_bugowner then
action[:name] = 'Set Bugowner'
when :maintenance_incident then
action[:name] = "Incident #{action[:spkg]}"
action[:sourcediff] = xml.webui_infos if with_diff
when :maintenance_release then
action[:name] = "Release #{action[:spkg]}"
if action[:tpkg] # API / Backend don't support whole project diff currently
action[:sourcediff] = xml.webui_infos if with_diff
end
when :add_role then
action[:name] = 'Add Role'
action[:role] = xml.role
action[:user] = xml.person_name
when :change_devel then
action[:name] = 'Change Devel'
when :set_bugowner then
action[:name] = 'Set Bugowner'
when :maintenance_incident then
action[:name] = "Incident #{action[:spkg]}"
action[:sourcediff] = xml.webui_infos if with_diff
when :maintenance_release then
action[:name] = "Release #{action[:spkg]}"
action[:sourcediff] = xml.webui_infos if with_diff
end
actions << action
end
Expand Down
54 changes: 27 additions & 27 deletions src/api/app/models/bs_request_permission_check.rb
Expand Up @@ -152,12 +152,12 @@ def check_action_target(action)
else
err = nil
case action.action_type
when :change_devel
err = "Local source package is missing for request #{action.bs_request.number} (type #{action.action_type})"
when :set_bugowner
when :add_role
else
action.source_access_check!
when :change_devel
err = "Local source package is missing for request #{action.bs_request.number} (type #{action.action_type})"
when :set_bugowner
when :add_role
else
action.source_access_check!
end
raise SourceMissing.new err if err
end
Expand Down Expand Up @@ -392,30 +392,30 @@ def require_permissions_in_target_or_source
def extra_permissions_check_changestate
err =
case opts[:newstate]
when 'superseded'
when 'superseded'
# Is the user involved in any project or package ?
unless @write_permission_in_target || @write_permission_in_source
"You have no role in request #{req.number}"
end
when 'accepted'
unless @write_permission_in_target || @write_permission_in_source
"You have no role in request #{req.number}"
end
when 'accepted'
# requires write permissions in all targets, this is already handled in each action check
when 'revoked'
when 'revoked'
# general revoke permission check based on source maintainership. We don't get here if the user is the creator of request
unless @write_permission_in_source
"No permission to revoke request #{req.number}"
end
when 'new'
if (req.state == :revoked && !@write_permission_in_source) ||
(req.state == :declined && !@write_permission_in_target)
"No permission to reopen request #{req.number}"
end
when 'declined'
unless @write_permission_in_target
# at least on one target the permission must be granted on decline
"No permission to decline request #{req.number}"
end
else
"No permission to change request #{req.number} state"
unless @write_permission_in_source
"No permission to revoke request #{req.number}"
end
when 'new'
if (req.state == :revoked && !@write_permission_in_source) ||
(req.state == :declined && !@write_permission_in_target)
"No permission to reopen request #{req.number}"
end
when 'declined'
unless @write_permission_in_target
# at least on one target the permission must be granted on decline
"No permission to decline request #{req.number}"
end
else
"No permission to change request #{req.number} state"
end
raise PostRequestNoPermission.new err if err
end
Expand Down
16 changes: 8 additions & 8 deletions src/api/app/models/cache_line.rb
Expand Up @@ -46,14 +46,14 @@ def self.expanded_key(key) # :nodoc:
return key.cache_key.to_s if key.respond_to?(:cache_key)

case key
when Array
if key.size > 1
key = key.collect { |element| expanded_key(element) }
else
key = key.first
end
when Hash
key = key.sort_by { |k, _| k.to_s }.collect { |k, v| "#{k}=#{v}" }
when Array
if key.size > 1
key = key.collect { |element| expanded_key(element) }
else
key = key.first
end
when Hash
key = key.sort_by { |k, _| k.to_s }.collect { |k, v| "#{k}=#{v}" }
end

key.to_param
Expand Down

0 comments on commit af832e0

Please sign in to comment.