Skip to content

Commit

Permalink
Merge pull request #4237 from DavidKang/feature/rubocop/rubocop_part_9
Browse files Browse the repository at this point in the history
Rubocop friendly cops part 6
  • Loading branch information
Moisés Déniz Alemán committed Dec 18, 2017
2 parents 09881a4 + dd9cf5d commit 38ba8d1
Show file tree
Hide file tree
Showing 112 changed files with 440 additions and 529 deletions.
92 changes: 0 additions & 92 deletions .rubocop_todo.yml
Expand Up @@ -238,16 +238,6 @@ Naming/PredicateName:
- 'src/api/app/models/user_ldap_strategy.rb'
- 'src/api/lib/activexml/node.rb'

# Offense count: 7
# Configuration parameters: EnforcedStyle, SupportedStyles.
# SupportedStyles: snake_case, camelCase
Naming/VariableName:
Exclude:
- 'src/api/app/mixins/has_relationships.rb'
- 'src/api/app/models/channel_target.rb'
- 'src/api/app/models/package.rb'
- 'src/api/app/models/relationship.rb'

# Offense count: 3
# Configuration parameters: EnforcedStyle, SupportedStyles.
# SupportedStyles: snake_case, normalcase, non_integer
Expand All @@ -262,37 +252,6 @@ Naming/VariableNumber:
Performance/HashEachMethods:
Enabled: false

# Offense count: 15
# Cop supports --auto-correct.
Rails/ApplicationRecord:
Exclude:
- 'docs/dev/model_template_example.rb'
- 'src/api/app/models/bs_request_counter.rb'
- 'src/api/db/migrate/20140908125426_convert_request_history.rb'
- 'src/api/db/migrate/20140908135426_incident_priority_attribute.rb'
- 'src/api/db/migrate/20140916135426_project_maintains.rb'
- 'src/api/db/migrate/20141107135426_embargo_attribute.rb'
- 'src/api/db/migrate/20141201135426_make_origin_older_attribute.rb'
- 'src/api/db/migrate/20150227063641_add_obs_branch_skip_repositories_attribute.rb'
- 'src/api/db/migrate/20150625105426_multiple_incident_counters.rb'
- 'src/api/db/migrate/20150716124906_add_type_to_project.rb'
- 'src/api/db/migrate/20160824132643_fix_bs_request_counter.rb'
- 'src/api/db/migrate/20161123124803_image_templates_attribute.rb'
- 'src/api/db/migrate/20161128115942_add_when_attribute_to_bs_request.rb'

# Offense count: 7
# Cop supports --auto-correct.
# Configuration parameters: NilOrEmpty, NotPresent, UnlessPresent.
Rails/Blank:
Exclude:
- 'src/api/app/controllers/search_controller.rb'
- 'src/api/app/helpers/webui/search_helper.rb'
- 'src/api/app/models/full_text_search.rb'
- 'src/api/app/models/package.rb'
- 'src/api/app/models/project.rb'
- 'src/api/app/models/project/key_info.rb'
- 'src/api/app/models/user_ldap_strategy.rb'

# Offense count: 538
# Cop supports --auto-correct.
# Configuration parameters: Whitelist.
Expand All @@ -304,20 +263,6 @@ Rails/DynamicFindBy:
Rails/FilePath:
Enabled: false

# Offense count: 18
# Cop supports --auto-correct.
# Configuration parameters: Include.
# Include: app/models/**/*.rb
Rails/FindEach:
Exclude:
- 'src/api/app/models/bs_request.rb'
- 'src/api/app/models/bs_request_action_set_bugowner.rb'
- 'src/api/app/models/issue_tracker.rb'
- 'src/api/app/models/owner.rb'
- 'src/api/app/models/package.rb'
- 'src/api/app/models/project.rb'
- 'src/api/app/models/user.rb'

# Offense count: 12
# Configuration parameters: Include.
# Include: app/models/**/*.rb
Expand Down Expand Up @@ -355,25 +300,6 @@ Rails/OutputSafety:
- 'src/api/app/helpers/webui/request_helper.rb'
- 'src/api/app/helpers/webui/webui_helper.rb'

# Offense count: 131
# Cop supports --auto-correct.
# Configuration parameters: NotNilAndNotEmpty, NotBlank, UnlessBlank.
Rails/Present:
Enabled: false

# Offense count: 11
# Cop supports --auto-correct.
# Configuration parameters: Include.
# Include: app/models/**/*.rb
Rails/ReadWriteAttribute:
Exclude:
- 'src/api/app/models/bs_request.rb'
- 'src/api/app/models/event/base.rb'
- 'src/api/app/models/event_subscription.rb'
- 'src/api/app/models/project_log_entry.rb'
- 'src/api/app/models/review.rb'
- 'src/api/app/models/user.rb'

# Offense count: 8
# Configuration parameters: Include.
# Include: db/migrate/*.rb
Expand Down Expand Up @@ -403,24 +329,6 @@ Rails/SkipsModelValidations:
Rails/TimeZone:
Enabled: false

# Offense count: 1
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SupportedStyles.
# SupportedStyles: always, conditionals
Style/AndOr:
Exclude:
- 'src/api/app/views/message/_messages.xml.builder'

# Offense count: 130
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SupportedStyles, ProceduralMethods, FunctionalMethods, IgnoredMethods.
# SupportedStyles: line_count_based, semantic, braces_for_chaining
# ProceduralMethods: benchmark, bm, bmbm, create, each_with_object, measure, new, realtime, tap, with_object
# FunctionalMethods: let, let!, subject, watch
# IgnoredMethods: lambda, proc, it
Style/BlockDelimiters:
Enabled: false

# Offense count: 200
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SupportedStyles.
Expand Down
2 changes: 1 addition & 1 deletion docs/dev/model_template_example.rb
@@ -1,6 +1,6 @@
# This is a model class to represent dogs and is an example of how they have to
# be structured for a better comprehension
class Dog < ActiveRecord::Base
class Dog < ApplicationRecord
#### Includes and extends
include AnimalSystems
include ActiveModel::AttributeMethods
Expand Down
4 changes: 2 additions & 2 deletions src/api/app/controllers/application_controller.rb
Expand Up @@ -152,10 +152,10 @@ def get_request_path
query_string = request.query_string
if request.form_data?
# it's uncommon, but possible that we have both
query_string += "&" unless query_string.blank?
query_string += "&" if query_string.present?
query_string += request.raw_post
end
query_string = "?" + query_string unless query_string.blank?
query_string = "?" + query_string if query_string.present?
path + query_string
end

Expand Down
2 changes: 1 addition & 1 deletion src/api/app/controllers/configurations_controller.rb
Expand Up @@ -48,7 +48,7 @@ def update
value = xml[key.to_s] || params[key.to_s]

# is it defined in options.yml
if value && !value.blank?
if value && value.present?
v = ::Configuration.map_value(key, value)
ov = ::Configuration.map_value(key, ::Configuration::OPTIONS_YML[key])
if ov != v && ov.present?
Expand Down
4 changes: 2 additions & 2 deletions src/api/app/controllers/person_controller.rb
Expand Up @@ -180,8 +180,8 @@ def internal_register
raise ErrRegisterSave, "Missing iChain header"
end
login = request.env['HTTP_X_USERNAME']
email = request.env['HTTP_X_EMAIL'] unless request.env['HTTP_X_EMAIL'].blank?
realname = request.env['HTTP_X_FIRSTNAME'] + " " + request.env['HTTP_X_LASTNAME'] unless request.env['HTTP_X_LASTNAME'].blank?
email = request.env['HTTP_X_EMAIL'] if request.env['HTTP_X_EMAIL'].present?
realname = request.env['HTTP_X_FIRSTNAME'] + " " + request.env['HTTP_X_LASTNAME'] if request.env['HTTP_X_LASTNAME'].present?
end

UnregisteredUser.register(login: login, realname: realname, email:
Expand Down
2 changes: 1 addition & 1 deletion src/api/app/controllers/public_controller.rb
Expand Up @@ -152,7 +152,7 @@ def binary_packages
# do not support it (exception zypp via ymp files)
dist = Distribution.find_by_project_and_repository(pe.link.project.name, pe.link.name)
next unless dist
unless binary_map[repo.name].blank?
if binary_map[repo.name].present?
dist_id = dist.id
@binary_links[dist_id] ||= {}
binary = binary_map[repo.name].select { |bin| bin.value(:name) == @pkg.name }.first
Expand Down
6 changes: 3 additions & 3 deletions src/api/app/controllers/request_controller.rb
Expand Up @@ -142,8 +142,8 @@ def request_create
xml = nil
BsRequest.transaction do
@req = BsRequest.new_from_xml(request.raw_post.to_s)
@req.set_add_revision unless params[:addrevision].blank?
@req.set_ignore_build_state unless params[:ignore_build_state].blank?
@req.set_add_revision if params[:addrevision].present?
@req.set_ignore_build_state if params[:ignore_build_state].present?
@req.save!

xml = @req.render_xml
Expand Down Expand Up @@ -213,7 +213,7 @@ def request_command_setincident
end

def request_command_setacceptat
time = DateTime.parse(params[:time]) unless params[:time].blank?
time = DateTime.parse(params[:time]) if params[:time].present?
@req.set_accept_at!(time)
render_ok
end
Expand Down
8 changes: 4 additions & 4 deletions src/api/app/controllers/search_controller.rb
Expand Up @@ -75,9 +75,9 @@ def owner
Backend::Test.start if Rails.env.test?

obj = nil
obj = params[:binary] unless params[:binary].blank?
obj = User.find_by_login!(params[:user]) unless params[:user].blank?
obj = Group.find_by_title!(params[:group]) unless params[:group].blank?
obj = params[:binary] if params[:binary].present?
obj = User.find_by_login!(params[:user]) if params[:user].present?
obj = Group.find_by_title!(params[:group]) if params[:group].present?
obj = Package.get_by_project_and_name(params[:project], params[:package]) unless params[:project].blank? || params[:package].blank?
obj = Project.get_by_name(params[:project]) if obj.nil? && params[:project].present?

Expand All @@ -99,7 +99,7 @@ def predicate_from_match_parameter(p)
else
p
end
pred = "*" if pred.nil? || pred.empty?
pred = "*" if pred.blank?
pred
end

Expand Down
2 changes: 1 addition & 1 deletion src/api/app/controllers/source_controller.rb
Expand Up @@ -1054,7 +1054,7 @@ def project_command_move
commit = { login: User.current.login,
lowprio: 1,
comment: "Project move from #{params[:oproject]} to #{params[:project]}" }
commit[:comment] = params[:comment] unless params[:comment].blank?
commit[:comment] = params[:comment] if params[:comment].present?
Backend::Api::Sources::Project.move(params[:oproject], params[:project])
project.name = params[:project]
project.store(commit)
Expand Down
4 changes: 2 additions & 2 deletions src/api/app/controllers/webui/feeds_controller.rb
Expand Up @@ -18,7 +18,7 @@ def commits
redirect_to '/403.html', status: :forbidden
return
end
unless params[:starting_at].blank?
if params[:starting_at].present?
@start = (begin
Time.zone.parse(params[:starting_at])
rescue
Expand All @@ -27,7 +27,7 @@ def commits
end
@start ||= 7.days.ago
@finish = nil
unless params[:ending_at].blank?
if params[:ending_at].present?
@finish = (begin
Time.zone.parse(params[:ending_at])
rescue
Expand Down
8 changes: 4 additions & 4 deletions src/api/app/controllers/webui/package_controller.rb
Expand Up @@ -139,7 +139,7 @@ def statistics
rescue ActiveXML::Transport::ForbiddenError
end

return unless @statistics.blank?
return if @statistics.present?
flash[:error] = "No statistics of a successful build could be found in #{@repository}/#{@arch}"
redirect_to controller: 'package', action: :binaries, project: @project,
package: @package, repository: @repository, nextstatus: 404
Expand Down Expand Up @@ -453,7 +453,7 @@ def rdiff

options = {}
[:orev, :opackage, :oproject, :linkrev, :olinkrev].each do |k|
options[k] = params[k] unless params[k].blank?
options[k] = params[k] if params[k].present?
end
options[:rev] = @rev if @rev
return unless get_diff(@project.name, @package.name, options)
Expand Down Expand Up @@ -755,12 +755,12 @@ def set_job_status

begin
jobstatus = get_job_status(@project, @package, @repo, @arch)
unless jobstatus.blank?
if jobstatus.present?
js = Xmlhash.parse(jobstatus)
@workerid = js.get('workerid')
@buildtime = Time.now.to_i - js.get('starttime').to_i
ld = js.get('lastduration')
@percent = (@buildtime * 100) / ld.to_i unless ld.blank?
@percent = (@buildtime * 100) / ld.to_i if ld.present?
end
rescue
@workerid = nil
Expand Down
6 changes: 3 additions & 3 deletions src/api/app/controllers/webui/patchinfo_controller.rb
Expand Up @@ -126,11 +126,11 @@ def save
}
xml = node.patchinfo(attrs) do
params[:selected_binaries].to_a.each do |binary|
unless binary.blank?
if binary.present?
node.binary(binary)
end
end
node.name params[:name] unless params[:name].blank?
node.name params[:name] if params[:name].present?
node.packager params[:packager]
issues.to_a.each do |issue|
unless IssueTracker.find_by_name(issue[1])
Expand Down Expand Up @@ -312,7 +312,7 @@ def get_binaries
end

def require_exists
unless params[:package].blank?
if params[:package].present?
begin
@package = Package.get_by_project_and_name(params[:project], params[:package], use_source: false)
rescue Package::UnknownObjectError
Expand Down

0 comments on commit 38ba8d1

Please sign in to comment.