Skip to content

Commit

Permalink
Merge pull request #2807 from mschnitzer/enable_rubocop_self_assignment
Browse files Browse the repository at this point in the history
Enable Style/SelfAssignment Rubocop cop
  • Loading branch information
DavidKang committed Mar 13, 2017
2 parents 20e2a03 + 297448c commit 7f6bd05
Show file tree
Hide file tree
Showing 20 changed files with 24 additions and 25 deletions.
4 changes: 4 additions & 0 deletions src/api/.rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,10 @@ Style/ZeroLengthPredicate:
Style/RescueModifier:
Enabled: true

# Enforces the use the shorthand for self-assignment
Style/SelfAssignment:
Enabled: true

##################### Metrics ##################################

# Checks if the length a class exceeds some maximum value
Expand Down
5 changes: 0 additions & 5 deletions src/api/.rubocop_todo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -765,11 +765,6 @@ Style/RedundantParentheses:
Style/RegexpLiteral:
Enabled: false

# Offense count: 20
# Cop supports --auto-correct.
Style/SelfAssignment:
Enabled: false

# Offense count: 14
# Cop supports --auto-correct.
# Configuration parameters: AllowAsExpressionSeparator.
Expand Down
2 changes: 1 addition & 1 deletion src/api/app/controllers/request_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def render_request_collection
xml = ActiveXML::Node.new '<collection/>'
matches = 0
rel.each do |r|
matches = matches + 1
matches += 1
xml.add_node(r.render_xml(params))
end
xml.set_attribute('matches', matches.to_s)
Expand Down
4 changes: 2 additions & 2 deletions src/api/app/controllers/tag_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def get_projects_by_tag(do_render = true)
@projects = tag.projects.group(:name).order(:name)
first_run = false
else
@projects = @projects & tag.projects.group(:name).order(:name)
@projects &= tag.projects.group(:name).order(:name)
end
end

Expand All @@ -93,7 +93,7 @@ def get_packages_by_tag(do_render = true)
@packages = tag.packages.group(:name).order(:name)
first_run = false
else
@packages = @packages & tag.packages.group(:name).order(:name)
@packages &= tag.packages.group(:name).order(:name)
end
end

Expand Down
2 changes: 1 addition & 1 deletion src/api/app/helpers/status_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def self.resample(values, samples = 400)
count += 1
end
if count > 0
value = value / count
value /= count
else
value = lastvalue
end
Expand Down
2 changes: 1 addition & 1 deletion src/api/app/helpers/webui/project_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def project_bread_crumb(*args)
end
@crumb_list << project_list unless project_list.empty?
end
@crumb_list = @crumb_list + args
@crumb_list += args
end

def format_seconds(secs)
Expand Down
2 changes: 1 addition & 1 deletion src/api/app/helpers/webui/webui_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ def sprited_text(icon, text)
end

def next_codemirror_uid
@codemirror_editor_setup = @codemirror_editor_setup + 1
@codemirror_editor_setup += 1
@codemirror_editor_setup
end

Expand Down
2 changes: 1 addition & 1 deletion src/api/app/jobs/project_create_auto_cleanup_requests.rb
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def autoclean_project(prj)
return unless time.past?

# create request, but add some time between to avoid an overload
@cleanupTime = @cleanupTime + 5.minutes
@cleanupTime += 5.minutes

req = BsRequest.new_from_xml('<request>
<action type="delete">
Expand Down
2 changes: 1 addition & 1 deletion src/api/app/models/owner.rb
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ def self.find_assignees(rootproject, binary_name, limit = 1, devel = true, filte

# add matching entry
maintainers << m
limit = limit - 1
limit -= 1
return maintainers if limit < 1 && !match_all
end
end
Expand Down
2 changes: 1 addition & 1 deletion src/api/app/models/package.rb
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,7 @@ def sources_changed(opts = {})
delay.update_if_dirty
rescue ActiveRecord::StatementInvalid
# mysql lock errors in delayed job handling... we need to retry
retries = retries - 1
retries -= 1
retry if retries > 0
end
end
Expand Down
2 changes: 1 addition & 1 deletion src/api/app/models/package_issue.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def self.sync_relations(package, issues)
end
end
rescue ActiveRecord::StatementInvalid, Mysql2::Error
retries = retries - 1
retries -= 1
retry if retries > 0
end
end
Expand Down
4 changes: 2 additions & 2 deletions src/api/app/models/project.rb
Original file line number Diff line number Diff line change
Expand Up @@ -368,12 +368,12 @@ def self.check_access?(dbp = self)
if grouprel && grouprel.group_id
# LOCAL
# if user is in group -> return true
ret = ret + 1 if User.current.is_in_group?(grouprel.group_id)
ret += 1 if User.current.is_in_group?(grouprel.group_id)
# LDAP
# FIXME: please do not do special things here for ldap. please cover this in a generic group model.
if CONFIG['ldap_mode'] == :on && CONFIG['ldap_group_support'] == :on
if UserLdapStrategy.user_in_group_ldap?(User.current, group.group_id)
ret = ret + 1
ret += 1
end
end
#
Expand Down
2 changes: 1 addition & 1 deletion src/api/app/models/tag.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def count(opt = {})
tags = opt[:tags]
@cached_count = 0
tags.each do |tag|
@cached_count = @cached_count + 1 if tag.name == name
@cached_count += 1 if tag.name == name
end
elsif opt[:scope] == "user"
user = opt[:user]
Expand Down
2 changes: 1 addition & 1 deletion src/api/app/models/update_notification_events.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def create_events
end
end
rescue ActiveRecord::StatementInvalid => e
retries = retries - 1
retries -= 1
retry if retries > 0
HoptoadNotifier.notify(e, {failed_job: "RETRYED 10 times: #{type.inspect}: #{data}"})
return
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def change
id = 1
rs.each do |r|
RepositoryArchitecture.create architecture_id: r.architecture_id, repository_id: r.repository_id, position: r.position, id: id
id = id + 1
id += 1
end
end
execute("alter table repository_architectures add PRIMARY KEY (`id`)")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def change
id = 1
gus.each do |gu|
GroupsUser.create group_id: gu.group_id, user_id: gu.user_id, id: id, created_at: gu.created_at, email: gu.email
id = id + 1
id += 1
end
end
execute("alter table groups_users add PRIMARY KEY (`id`)")
Expand Down
2 changes: 1 addition & 1 deletion src/api/lib/activexml/node.rb
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ def each_with_index(symbol = nil)
end
nodes.each do |e|
yield create_node_with_relations(e), index
index = index + 1
index += 1
end
nil
end
Expand Down
2 changes: 1 addition & 1 deletion src/api/lib/opensuse/backend.rb
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ def wait_for_scheduler_start
while counter < 100
return if File.exist?(marker)
sleep 0.5
counter = counter + 1
counter += 1
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion src/api/spec/support/capybara.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
config.after(:each, type: :feature) do
example_filename = RSpec.current_example.full_description
example_filename = example_filename.tr(' ', '_')
example_filename = example_filename + '.html'
example_filename += '.html'
example_filename = File.expand_path(example_filename, Capybara.save_path)
if RSpec.current_example.exception.present?
save_page(example_filename)
Expand Down
2 changes: 1 addition & 1 deletion src/api/test/unit/code_quality_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ def setup
break if score < 80 # they are sorted. 80 means the function still fits on a standard screen
next if class_method.end_with? '#none'
score = Integer(score * 100)
score = score / Float(100)
score /= Float(100)

oldscore = black.delete class_method
if oldscore.nil?
Expand Down

0 comments on commit 7f6bd05

Please sign in to comment.