Skip to content

Commit

Permalink
Enable Layout/AlignHash rubocop
Browse files Browse the repository at this point in the history
  • Loading branch information
coolo committed Nov 14, 2018
1 parent bfba1b3 commit 02338bf
Show file tree
Hide file tree
Showing 65 changed files with 280 additions and 289 deletions.
9 changes: 0 additions & 9 deletions src/api/.rubocop_todo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,6 @@ Capybara/CurrentPathExpectation:
Capybara/FeatureMethods:
Enabled: false

# Offense count: 257
# Cop supports --auto-correct.
# Configuration parameters: EnforcedHashRocketStyle, EnforcedColonStyle, EnforcedLastArgumentHashStyle.
# SupportedHashRocketStyles: key, separator, table
# SupportedColonStyles: key, separator, table
# SupportedLastArgumentHashStyles: always_inspect, always_ignore, ignore_implicit, ignore_explicit
Layout/AlignHash:
Enabled: false

# Offense count: 3
# Cop supports --auto-correct.
Layout/ClosingHeredocIndentation:
Expand Down
2 changes: 1 addition & 1 deletion src/api/app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ def pass_to_backend(path = nil)

text = response.body
send_data(text, type: response.fetch('content-type'),
disposition: 'inline')
disposition: 'inline')
text
end
public :pass_to_backend
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 @@ -32,7 +32,7 @@ def show
render template: 'attribute_namespace/show'
else
render_error message: "Unknown attribute namespace '#{@namespace}'",
status: 404, errorcode: 'unknown_attribute_namespace'
status: 404, errorcode: 'unknown_attribute_namespace'
end
end

Expand All @@ -47,7 +47,7 @@ def update

unless xml_element['name'] == @namespace
render_error status: 400, errorcode: 'illegal_request',
message: "Illegal request: PUT/POST #{request.path}: path does not match content"
message: "Illegal request: PUT/POST #{request.path}: path does not match content"
return
end

Expand Down
8 changes: 4 additions & 4 deletions src/api/app/controllers/build/file_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def update
unless User.current.is_admin?
# this route can be used publish binaries without history changes in sources
render_error status: 403, errorcode: 'upload_binary_no_permission',
message: 'No permission to upload binaries.'
message: 'No permission to upload binaries.'
return
end

Expand All @@ -32,15 +32,15 @@ def update
def destroy
unless permissions.project_change?(params[:project])
render_error status: 403, errorcode: 'delete_binary_no_permission',
message: "No permission to delete binaries from project #{params[:project]}"
message: "No permission to delete binaries from project #{params[:project]}"
return
end

if params[:package] == '_repository'
pass_to_backend
else
render_error status: 400, errorcode: 'invalid_operation',
message: 'Delete operation of build results is not allowed'
message: 'Delete operation of build results is not allowed'
end

return
Expand Down Expand Up @@ -75,7 +75,7 @@ def check_user_has_permission
return if user_has_permission

render_error status: 403, errorcode: 'download_binary_no_permission',
message: "No permission to download binaries from package #{params[:package]}, project #{params[:project]}"
message: "No permission to download binaries from package #{params[:package]}, project #{params[:project]}"
return
end

Expand Down
16 changes: 8 additions & 8 deletions src/api/app/controllers/build_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def index
pass_to_backend
else
render_error status: 403, errorcode: 'execute_cmd_no_permission',
message: 'Upload of binaries is only permitted for administrators'
message: 'Upload of binaries is only permitted for administrators'
end
end

Expand All @@ -44,13 +44,13 @@ def project_index

unless ['wipe', 'restartbuild', 'killbuild', 'abortbuild', 'rebuild', 'unpublish', 'sendsysrq'].include?(params[:cmd])
render_error status: 400, errorcode: 'illegal_request',
message: "unsupported POST command #{params[:cmd]} to #{request.url}"
message: "unsupported POST command #{params[:cmd]} to #{request.url}"
return
end

unless prj.class == Project
render_error status: 403, errorcode: 'readonly_error',
message: "The project #{params[:project]} is a remote project and therefore readonly."
message: "The project #{params[:project]} is a remote project and therefore readonly."
return
end

Expand All @@ -61,14 +61,14 @@ def project_index
allowed = permissions.project_change?(prj)
unless allowed
render_error status: 403, errorcode: 'execute_cmd_no_permission',
message: "No permission to execute command on package #{pack_name} in project #{prj.name}"
message: "No permission to execute command on package #{pack_name} in project #{prj.name}"
return
end
else
allowed = permissions.package_change?(pkg)
unless allowed
render_error status: 403, errorcode: 'execute_cmd_no_permission',
message: "No permission to execute command on package #{pack_name}"
message: "No permission to execute command on package #{pack_name}"
return
end
end
Expand All @@ -77,7 +77,7 @@ def project_index

unless allowed
render_error status: 403, errorcode: 'execute_cmd_no_permission',
message: "No permission to execute command on project #{params[:project]}"
message: "No permission to execute command on project #{params[:project]}"
return
end

Expand All @@ -88,12 +88,12 @@ def project_index
pass_to_backend
else
render_error status: 403, errorcode: 'execute_cmd_no_permission',
message: "No permission to execute command on project #{params[:project]}"
message: "No permission to execute command on project #{params[:project]}"
end
return
else
render_error status: 400, errorcode: 'illegal_request',
message: "Illegal request: #{request.method.to_s.upcase} #{request.path}"
message: "Illegal request: #{request.method.to_s.upcase} #{request.path}"
return
end
end
Expand Down
8 changes: 4 additions & 4 deletions src/api/app/controllers/person_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ def put_userinfo
unless user.login == User.current.login || User.current.is_admin?
logger.debug 'User has no permission to change userinfo'
render_error(status: 403, errorcode: 'change_userinfo_no_permission',
message: "no permission to change userinfo for user #{user.login}") && return
message: "no permission to change userinfo for user #{user.login}") && return
end
elsif User.current.is_admin?
user = User.create(login: login, password: 'notset', email: 'TEMP')
Expand All @@ -128,7 +128,7 @@ def put_userinfo
user.owner = User.find_by_login!(xml['owner']['userid'])
if user.owner.owner
render_error(status: 400, errorcode: 'subaccount_chaining',
message: "A subaccount can not be assigned to subaccount #{user.owner.login}") && return
message: "A subaccount can not be assigned to subaccount #{user.owner.login}") && return
end
end
end
Expand Down Expand Up @@ -249,14 +249,14 @@ def change_password(login, password)

if login.blank? || password.blank?
render_error status: 404, errorcode: 'failed to change password',
message: 'Failed to change password: missing parameter'
message: 'Failed to change password: missing parameter'
return
end

# change password to LDAP if LDAP is enabled
unless ::Configuration.passwords_changable?(User.current)
render_error status: 404, errorcode: 'change_passwd_failure',
message: 'LDAP passwords can not be changed in OBS. Please refer to your LDAP server to change it.'
message: 'LDAP passwords can not be changed in OBS. Please refer to your LDAP server to change it.'
return
end

Expand Down
2 changes: 1 addition & 1 deletion src/api/app/controllers/search_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ def owner

if owners.nil?
render_error status: 400, errorcode: 'no_binary',
message: "The search needs at least a 'binary' or 'user' parameter"
message: "The search needs at least a 'binary' or 'user' parameter"
return
end

Expand Down
10 changes: 5 additions & 5 deletions src/api/app/controllers/source_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -551,7 +551,7 @@ def project_command_release

if @project.is_a?(String) # remote project
render_error status: 404, errorcode: 'remote_project',
message: 'The release from remote projects is currently not supported'
message: 'The release from remote projects is currently not supported'
return
end

Expand Down Expand Up @@ -608,7 +608,7 @@ def project_command_move
project.packages.each { |package| package.store(commit) }
rescue
render_error status: 400, errorcode: 'move_failed',
message: 'Move operation failed'
message: 'Move operation failed'
return
end

Expand Down Expand Up @@ -855,7 +855,7 @@ def package_command_createSpecFileTemplate
# TODO: No need to read the whole file for knowing if it exists already
Backend::Api::Sources::Package.file(params[:project], params[:package], "#{params[:package]}.spec")
render_error status: 400, errorcode: 'spec_file_exists',
message: 'SPEC file already exists.'
message: 'SPEC file already exists.'
return
rescue Backend::NotFoundError
specfile_content = File.read("#{Rails.root}/files/specfiletemplate")
Expand All @@ -876,7 +876,7 @@ def package_command_rebuild
answer = Backend::Connection.get(request.path_info)
unless answer
render_error status: 400, errorcode: 'unknown_package',
message: "Unknown package '#{package_name}'"
message: "Unknown package '#{package_name}'"
return
end
end
Expand All @@ -885,7 +885,7 @@ def package_command_rebuild
if repo_name
if @package && @package.repositories.find_by_name(repo_name).nil?
render_error status: 400, errorcode: 'unknown_repository',
message: "Unknown repository '#{repo_name}'"
message: "Unknown repository '#{repo_name}'"
return
end
options[:repository] = repo_name
Expand Down
8 changes: 4 additions & 4 deletions src/api/app/controllers/webui/project_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,7 @@ def monitor
monitor_set_filter(defaults)

find_opt = { project: @project, view: 'status', code: @status_filter,
arch: @arch_filter, repository: @repo_filter }
arch: @arch_filter, repository: @repo_filter }
find_opt[:lastbuild] = 1 if @lastbuild_switch.present?

@buildresult = Buildresult.find_hashed(find_opt)
Expand Down Expand Up @@ -769,9 +769,9 @@ def find_maintenance_infos
return unless @is_incident_project

@open_release_requests = BsRequest.find_for(project: @project.name,
states: ['new', 'review'],
types: ['maintenance_release'],
roles: ['source']).pluck(:number)
states: ['new', 'review'],
types: ['maintenance_release'],
roles: ['source']).pluck(:number)
end

def valid_target_name?(name)
Expand Down
6 changes: 3 additions & 3 deletions src/api/app/controllers/webui/request_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -130,9 +130,9 @@ def show
def sourcediff
check_ajax
render partial: 'shared/editor', locals: { text: params[:text],
mode: 'diff', style: { read_only: true },
height: 'auto', width: '750px',
no_border: true, uid: params[:uid] }
mode: 'diff', style: { read_only: true },
height: 'auto', width: '750px',
no_border: true, uid: params[:uid] }
end

def changerequest
Expand Down
2 changes: 1 addition & 1 deletion src/api/app/helpers/webui/buildresult_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def webui2_arch_repo_table_cell(repo, arch, package_name, status = nil, enable_h
capture_haml do
if enable_help && status['code']
concat(content_tag(:i, nil, class: ['fa', 'fa-question-circle', 'text-info', 'mr-1'],
data: { content: Buildresult.status_description(status['code']), placement: 'top', toggle: 'popover' }))
data: { content: Buildresult.status_description(status['code']), placement: 'top', toggle: 'popover' }))
end
if code.in?(['-', 'unresolvable', 'blocked', 'excluded', 'scheduled'])
concat(link_to(code, '#', id: status_id, class: theclass, data: { content: link_title, placement: 'top', toggle: 'popover' }))
Expand Down
8 changes: 4 additions & 4 deletions src/api/app/helpers/webui/project_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,24 +12,24 @@ def show_status_comment(comment, package, firstfail, comments_to_clear)
if User.current.can_modify?(@project.api_obj)
status_comment_html += ' '.html_safe + link_to(image_tag('comment_delete.png', size: '16x16', alt: 'Clear'),
{ action: :clear_failed_comment, project: @project,
package: package, update: valid_xml_id("comment_#{package}") },
package: package, update: valid_xml_id("comment_#{package}") },
remote: true)
comments_to_clear << package
end
elsif User.current.can_modify?(@project.api_obj)
status_comment_html += ' '.html_safe
status_comment_html += link_to(image_tag('comment_edit.png', alt: 'Edit'),
{ action: 'edit_comment_form', comment: comment,
package: package, project: @project,
update: valid_xml_id("comment_edit_#{package}") },
package: package, project: @project,
update: valid_xml_id("comment_edit_#{package}") },
remote: true)
end
elsif firstfail
if User.current.can_modify?(@project.api_obj)
status_comment_html += " <span class='unknown_failure'>Unknown build failure ".html_safe +
link_to(image_tag('comment_edit.png', size: '16x16', alt: 'Edit'),
{ action: 'edit_comment_form', comment: '', package: package,
project: @project, update: valid_xml_id("comment_edit_#{package}") },
project: @project, update: valid_xml_id("comment_edit_#{package}") },
remote: true)
status_comment_html += '</span>'.html_safe
else
Expand Down
2 changes: 1 addition & 1 deletion src/api/app/mixins/has_attributes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ def render_attribute_axml(opts = {})
project.render_main_attributes(xml, opts) if opts[:with_project]
end
builder.doc.to_xml(indent: 2, encoding: 'UTF-8',
save_with: Nokogiri::XML::Node::SaveOptions::NO_DECLARATION |
save_with: Nokogiri::XML::Node::SaveOptions::NO_DECLARATION |
Nokogiri::XML::Node::SaveOptions::FORMAT)
end

Expand Down
24 changes: 12 additions & 12 deletions src/api/app/models/bs_request_action_maintenance_incident.rb
Original file line number Diff line number Diff line change
Expand Up @@ -90,12 +90,12 @@ def _merge_pkg_into_maintenance_incident(incident_project)
package_name = linkinfo['package'] if linkinfo

branch_params = { target_project: incident_project.name,
olinkrev: 'base',
requestid: bs_request.number,
maintenance: 1,
force: 1,
comment: 'Initial new branch from specified release project',
project: target_releaseproject, package: package_name }
olinkrev: 'base',
requestid: bs_request.number,
maintenance: 1,
force: 1,
comment: 'Initial new branch from specified release project',
project: target_releaseproject, package: package_name }
# accept branching from former update incidents or GM (for kgraft case)
linkprj = Project.find_by_name(linkinfo['project']) if linkinfo
if defined?(linkprj) && linkprj
Expand All @@ -118,12 +118,12 @@ def _merge_pkg_into_maintenance_incident(incident_project)
linked_package = linkinfo['package']

branch_params = { target_project: incident_project.name,
olinkrev: 'base',
requestid: bs_request.number,
maintenance: 1,
force: 1,
comment: 'Initial new branch',
project: linked_project, package: linked_package }
olinkrev: 'base',
requestid: bs_request.number,
maintenance: 1,
force: 1,
comment: 'Initial new branch',
project: linked_project, package: linked_package }
ret = BranchPackage.new(branch_params).branch
new_pkg = Package.get_by_project_and_name(ret[:data][:targetproject], ret[:data][:targetpackage])
elsif linkinfo && linkinfo['package'] # a new package for all targets
Expand Down
2 changes: 1 addition & 1 deletion src/api/app/models/bs_request_action_submit.rb
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ def execute_accept(opts)
# source package got used as devel package, link it to the target
# re-create it via branch , but keep current content...
options = { comment: "initialized devel package after accepting #{bs_request.number}",
requestid: bs_request.number, keepcontent: 1, noservice: 1 }
requestid: bs_request.number, keepcontent: 1, noservice: 1 }
Backend::Api::Sources::Package.branch(self.target_project, self.target_package, source_project, source_package, User.current.login, options)
elsif sourceupdate == 'cleanup'
source_cleanup
Expand Down
2 changes: 1 addition & 1 deletion src/api/app/models/cloud/azure/configuration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module Azure
class Configuration < ApplicationRecord
# maximum length has to be 245 (2048 bit RSA keys cannot encrypt more than 245 characters)
validates :application_id, presence: { message: 'ID can\'t be blank' },
length: { maximum: 245, too_long: 'ID is too long (maximum is 245 characters)' }, on: :update
length: { maximum: 245, too_long: 'ID is too long (maximum is 245 characters)' }, on: :update
validates :application_key, presence: true, length: { maximum: 245 }, on: :update

before_save :encrypt_credentials
Expand Down
8 changes: 4 additions & 4 deletions src/api/app/models/cloud/azure/params.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ class Params
attr_accessor :image_name, :application_id, :application_key, :subscription, :container, :storage_account, :resource_group

validates :image_name, presence: true, length: { minimum: 2, maximum: 63 },
format: { with: /\A[[:alnum:]]([\w\.-]*\w)?\z/, message: 'not a valid format' }
format: { with: /\A[[:alnum:]]([\w\.-]*\w)?\z/, message: 'not a valid format' }
validates :subscription, presence: true, length: { minimum: 3 }
validates :container, presence: true, length: { minimum: 3, maximum: 63 },
format: { with: /\A[-a-z0-9]+\z/, message: 'not a valid format' }
format: { with: /\A[-a-z0-9]+\z/, message: 'not a valid format' }
validates :storage_account, presence: true, length: { minimum: 3, maximum: 24 },
format: { with: /\A[a-z0-9]+\z/, message: 'not a valid format' }
format: { with: /\A[a-z0-9]+\z/, message: 'not a valid format' }
validates :resource_group, presence: true, length: { minimum: 1, maximum: 90 },
format: { with: /\A[-\w\.]*[-\w]\z/, message: 'not a valid format' }
format: { with: /\A[-\w\.]*[-\w]\z/, message: 'not a valid format' }

def self.build(params)
new(params.slice(:image_name, :application_id, :application_key, :subscription, :container, :storage_account, :resource_group))
Expand Down

0 comments on commit 02338bf

Please sign in to comment.