Skip to content

Commit

Permalink
[ci] Enable Style/IndentationWith
Browse files Browse the repository at this point in the history
Checks for indentation that doesn't use two spaces.
  • Loading branch information
DavidKang committed Jan 9, 2017
1 parent bff864d commit 9894a56
Show file tree
Hide file tree
Showing 60 changed files with 675 additions and 677 deletions.
4 changes: 4 additions & 0 deletions src/api/.rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,10 @@ Style/IndentAssignment:
Enabled: true
IndentationWidth: 2

# Checks for indentation that doesn't use two spaces.
Style/IndentationWidth:
Enabled: true

# Use Kernel#loop for infinite loops
Style/InfiniteLoop:
Enabled: true
Expand Down
6 changes: 0 additions & 6 deletions src/api/.rubocop_todo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -541,12 +541,6 @@ Style/IndentationConsistency:
- 'test/unit/ichain_notifier_test.rb'
- 'test/unit/validator_test.rb'

# Offense count: 106
# Cop supports --auto-correct.
# Configuration parameters: Width.
Style/IndentationWidth:
Enabled: false

# Offense count: 45
# Cop supports --auto-correct.
Style/LineEndConcatenation:
Expand Down
24 changes: 12 additions & 12 deletions src/api/app/controllers/attribute_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,11 @@ def namespace_definition

db = AttribNamespace.where(name: namespace).first
if db
logger.debug "* updating existing attribute namespace"
db.update_from_xml(xml_element)
logger.debug "* updating existing attribute namespace"
db.update_from_xml(xml_element)
else
logger.debug "* create new attribute namespace"
AttribNamespace.create(name: namespace).update_from_xml(xml_element)
logger.debug "* create new attribute namespace"
AttribNamespace.create(name: namespace).update_from_xml(xml_element)
end

logger.debug "--- finished updating attribute namespace definitions ---"
Expand All @@ -101,9 +101,9 @@ def attribute_definition
name = params[:name]
ans = AttribNamespace.where(name: namespace).first
unless ans
render_error status: 400, errorcode: 'unknown_attribute_namespace',
message: "Specified attribute namespace does not exist: '#{namespace}'"
return
render_error status: 400, errorcode: 'unknown_attribute_namespace',
message: "Specified attribute namespace does not exist: '#{namespace}'"
return
end

if request.get?
Expand Down Expand Up @@ -136,12 +136,12 @@ def attribute_definition

entry = ans.attrib_types.where("name = ?", name ).first
if entry
db = AttribType.find( entry.id ) # get a writable object
logger.debug "* updating existing attribute definitions"
db.update_from_xml(xml_element)
db = AttribType.find( entry.id ) # get a writable object
logger.debug "* updating existing attribute definitions"
db.update_from_xml(xml_element)
else
logger.debug "* create new attribute definition"
AttribType.new(name: name, attrib_namespace: ans ).update_from_xml(xml_element)
logger.debug "* create new attribute definition"
AttribType.new(name: name, attrib_namespace: ans ).update_from_xml(xml_element)
end

logger.debug "--- finished updating attribute namespace definitions ---"
Expand Down
4 changes: 2 additions & 2 deletions src/api/app/controllers/person_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ class PersonController < ApplicationController

def show
if params[:prefix]
@list = User.where("login LIKE ?", params[:prefix] + '%')
@list = User.where("login LIKE ?", params[:prefix] + '%')
else
@list = User.all
@list = User.all
end
end

Expand Down
2 changes: 1 addition & 1 deletion src/api/app/controllers/public_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ def binary_packages
@pkg = Package.find_by_project_and_name(params[:project], params[:package])

begin
binaries = Collection.find :id, what: 'published/binary', match: "@project='#{params[:project]}' and @package='#{params[:package]}'"
binaries = Collection.find :id, what: 'published/binary', match: "@project='#{params[:project]}' and @package='#{params[:package]}'"
rescue
render_error status: 400, errorcode: 'search_failure', message: "The search can't get executed."
return
Expand Down
6 changes: 3 additions & 3 deletions src/api/app/controllers/search_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -93,11 +93,11 @@ def owner
def predicate_from_match_parameter(p)
pred = case p
when /^\(\[(.*)\]\)$/
$1
$1
when /^\[(.*)\]$/
$1
$1
else
p
p
end
pred = "*" if pred.nil? || pred.empty?
pred
Expand Down
22 changes: 11 additions & 11 deletions src/api/app/controllers/source_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ def show_package
end

if params[:view] == 'issues'
show_package_issues && return
show_package_issues && return
end

# exec
Expand Down Expand Up @@ -1506,19 +1506,19 @@ def package_command_release
end

def _package_command_release_manual_target(pkg)
verify_can_modify_target!
verify_can_modify_target!

if params[:target_repository].blank? || params[:repository].blank?
raise MissingParameterError.new 'release action with specified target project needs also "repository" and "target_repository" parameter'
end
targetrepo=Repository.find_by_project_and_name(@target_project_name, params[:target_repository])
raise UnknownRepository.new "Repository does not exist #{params[:target_repository]}" unless targetrepo
if params[:target_repository].blank? || params[:repository].blank?
raise MissingParameterError.new 'release action with specified target project needs also "repository" and "target_repository" parameter'
end
targetrepo=Repository.find_by_project_and_name(@target_project_name, params[:target_repository])
raise UnknownRepository.new "Repository does not exist #{params[:target_repository]}" unless targetrepo

repo=pkg.project.repositories.where(name: params[:repository])
raise UnknownRepository.new "Repository does not exist #{params[:repository]}" unless repo.count > 0
repo=repo.first
repo=pkg.project.repositories.where(name: params[:repository])
raise UnknownRepository.new "Repository does not exist #{params[:repository]}" unless repo.count > 0
repo=repo.first

release_package(pkg, targetrepo, pkg.name, repo, nil, params[:setrelease], true)
release_package(pkg, targetrepo, pkg.name, repo, nil, params[:setrelease], true)
end
private :_package_command_release_manual_target

Expand Down
10 changes: 5 additions & 5 deletions src/api/app/controllers/tag_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -339,11 +339,11 @@ def save_tags(object, tagCreator, tags)
# create an entry in the join table (taggings) if necessary
def create_relationship(object, tagCreator, tag)
Tagging.transaction do
@jointable = Tagging.new
object.taggings << @jointable
tagCreator.taggings << @jointable
tag.taggings << @jointable
@jointable.save
@jointable = Tagging.new
object.taggings << @jointable
tagCreator.taggings << @jointable
tag.taggings << @jointable
@jointable.save
end
end

Expand Down
18 changes: 9 additions & 9 deletions src/api/app/controllers/test_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,14 @@ def killme

# we need a way so the API uprises fully
def startme
if @@started
render_ok
return
end
@@started = true
WebMock.disable_net_connect!(allow_localhost: true)
CONFIG['global_write_through'] = true
backend.direct_http(URI("/"))
render_ok
if @@started
render_ok
return
end
@@started = true
WebMock.disable_net_connect!(allow_localhost: true)
CONFIG['global_write_through'] = true
backend.direct_http(URI("/"))
render_ok
end
end
2 changes: 1 addition & 1 deletion src/api/app/controllers/trigger_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def runservice
# token is not bound to a package, but event may have specified it
pkg = Package.get_by_project_and_name(params[:project].to_s, params[:package].to_s, use_source: true)
unless token.user.is_active? && token.user.can_modify_package?(pkg)
raise NoPermission.new "no permission for package #{pkg.name} in project #{pkg.project.name}"
raise NoPermission.new "no permission for package #{pkg.name} in project #{pkg.project.name}"
end
end

Expand Down
10 changes: 5 additions & 5 deletions src/api/app/controllers/webui/package_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -194,8 +194,8 @@ def binaries
required_parameters :repository
@repository = params[:repository]
begin
@buildresult = Buildresult.find_hashed(project: @project, package: @package,
repository: @repository, view: %w(binarylist status))
@buildresult = Buildresult.find_hashed(project: @project, package: @package,
repository: @repository, view: %w(binarylist status))
rescue ActiveXML::Transport::Error => e
flash[:error] = e.message
redirect_back(fallback_location: { controller: :package, action: :show, project: @project, package: @package })
Expand Down Expand Up @@ -566,10 +566,10 @@ def branch
redirect_to(package_show_path(project: created_project_name, package: created_package_name),
notice: "Successfully branched package")
rescue BranchPackage::DoubleBranchPackageError
redirect_to(package_show_path(project: User.current.branch_project_name(@project), package: @package),
notice: 'You have already branched this package')
redirect_to(package_show_path(project: User.current.branch_project_name(@project), package: @package),
notice: 'You have already branched this package')
rescue APIException => e
redirect_back(fallback_location: root_path, error: e.message)
redirect_back(fallback_location: root_path, error: e.message)
end

def save_new_link
Expand Down
12 changes: 6 additions & 6 deletions src/api/app/controllers/webui/user_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,12 @@ def show
@owned = @displayed_user.owned_packages

if User.current == @displayed_user
@reviews = @displayed_user.involved_reviews
@patchinfos = @displayed_user.involved_patchinfos
@requests_in = @displayed_user.incoming_requests
@requests_out = @displayed_user.outgoing_requests
@declined_requests = @displayed_user.declined_requests
@user_have_requests = @displayed_user.requests?
@reviews = @displayed_user.involved_reviews
@patchinfos = @displayed_user.involved_patchinfos
@requests_in = @displayed_user.incoming_requests
@requests_out = @displayed_user.outgoing_requests
@declined_requests = @displayed_user.declined_requests
@user_have_requests = @displayed_user.requests?
end
end

Expand Down
4 changes: 2 additions & 2 deletions src/api/app/controllers/webui/webui_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -242,8 +242,8 @@ def check_display_user
redirect_back(fallback_location: root_path, error: "User not found #{params['user']}") unless @displayed_user
end
else
@displayed_user = User.current
@displayed_user ||= User.find_nobody!
@displayed_user = User.current
@displayed_user ||= User.find_nobody!
end
end

Expand Down
2 changes: 1 addition & 1 deletion src/api/app/helpers/event_mailer_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ def project_or_package_text(project, package, opts = {})
end
if opts[:short].nil?
if package.present?
"package #{text}"
"package #{text}"
else
"project #{text}"
end
Expand Down
4 changes: 2 additions & 2 deletions src/api/app/helpers/public_helper.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module PublicHelper
def ymp_url(path)
url = ::Configuration.ymp_url
path && url ? File.join(url, path) : ""
url = ::Configuration.ymp_url
path && url ? File.join(url, path) : ""
end
end
30 changes: 15 additions & 15 deletions src/api/app/jobs/project_status_calculator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -135,23 +135,23 @@ def parse_jobhistory(dname, repo, arch)
data = Xmlhash.parse(d)

data.elements('jobhist') do |p|
line = {
'name' => p['package'],
'code' => p['code'],
'versrel' => p['versrel'],
'verifymd5' => p['verifymd5']
}

if p.has_key?('readytime')
if p['readytime'].respond_to?(:to_i)
line['readytime'] = p['readytime'].to_i
else
line['readytime'] = 0
end
line = {
'name' => p['package'],
'code' => p['code'],
'versrel' => p['versrel'],
'verifymd5' => p['verifymd5']
}

if p.has_key?('readytime')
if p['readytime'].respond_to?(:to_i)
line['readytime'] = p['readytime'].to_i
else
line['readytime'] = 0
line['readytime'] = 0
end
ret << line
else
line['readytime'] = 0
end
ret << line
end
ret
end
Expand Down
2 changes: 1 addition & 1 deletion src/api/app/mailers/admin_mailer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def mail_sender
end

def error(message)
warning(message, "ERROR")
warning(message, "ERROR")
end

def warning(message, level = "Warning")
Expand Down
4 changes: 2 additions & 2 deletions src/api/app/mixins/has_relationships.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ def groups
def bugowner_emails
ret = []
relationships.where(role: Role.rolecache['bugowner']).joins(:user).each do |bugowner|
mail = bugowner.user.email
ret.push(mail.to_s) if mail
mail = bugowner.user.email
ret.push(mail.to_s) if mail
end
ret
end
Expand Down
4 changes: 2 additions & 2 deletions src/api/app/models/attrib_type.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class UnknownAttributeTypeError < APIException

#### Class methods using self. (public and then private)
def self.find_by_name!(name)
find_by_name(name, true)
find_by_name(name, true)
end

def self.find_by_name(name, or_fail = false)
Expand All @@ -35,7 +35,7 @@ def self.find_by_name(name, or_fail = false)
end

def self.find_by_namespace_and_name!(namespace, name)
find_by_namespace_and_name(namespace, name, true)
find_by_namespace_and_name(namespace, name, true)
end

def self.find_by_namespace_and_name(namespace, name, or_fail = false)
Expand Down
4 changes: 2 additions & 2 deletions src/api/app/models/binary_release.rb
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ def self.update_binary_releases_via_json(repository, json, time = Time.now)
entry.binary_supportstatus == binary["supportstatus"] &&
entry.binary_buildtime.to_datetime.utc == ::Time.at(binary["buildtime"].to_i).to_datetime.utc
# same binary, don't touch
processed_item[entry.id] = true
next
processed_item[entry.id] = true
next
end
# same binary name and location, but updated content or meta data
entry.modify_time = time
Expand Down
16 changes: 8 additions & 8 deletions src/api/app/models/bs_request.rb
Original file line number Diff line number Diff line change
Expand Up @@ -109,14 +109,14 @@ def check_creator
end

def assign_number
return if number
# to assign a unique and steady incremental number.
# Using MySQL auto-increment mechanism is not working on clusters.
BsRequest.transaction do
request_counter = BsRequestCounter.lock(true).first_or_create
self.number = request_counter.counter
request_counter.increment!(:counter)
end
return if number
# to assign a unique and steady incremental number.
# Using MySQL auto-increment mechanism is not working on clusters.
BsRequest.transaction do
request_counter = BsRequestCounter.lock(true).first_or_create
self.number = request_counter.counter
request_counter.increment!(:counter)
end
end

def check_supersede_state
Expand Down
2 changes: 1 addition & 1 deletion src/api/app/models/configuration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def map_value(key, value)
# the data from the first instance
def method_missing(method_name, *args, &block)
unless first
Configuration.create(name: 'private', title: 'Open Build Service', description: 'Private OBS Instance')
Configuration.create(name: 'private', title: 'Open Build Service', description: 'Private OBS Instance')
end
if first.respond_to?(method_name)
first.send(method_name, *args, &block)
Expand Down
Loading

0 comments on commit 9894a56

Please sign in to comment.