Skip to content

Commit

Permalink
[frontend] Fix Rails/Blank offenses
Browse files Browse the repository at this point in the history
  • Loading branch information
bgeuken authored and DavidKang committed Dec 15, 2017
1 parent ec14222 commit de8d669
Show file tree
Hide file tree
Showing 8 changed files with 7 additions and 20 deletions.
13 changes: 0 additions & 13 deletions .rubocop_todo.yml
Expand Up @@ -270,19 +270,6 @@ Rails/ApplicationRecord:
- '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 Down
2 changes: 1 addition & 1 deletion src/api/app/controllers/search_controller.rb
Expand Up @@ -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/helpers/webui/search_helper.rb
Expand Up @@ -4,7 +4,7 @@ module Webui::SearchHelper
# @param [Symbol] type :user if the names are logins, :group if they are
# group names
def search_owners_list(names, type = :user)
return [] if names.nil? || names.empty?
return [] if names.blank?
output = []
names.each do |role, list|
if type == :group
Expand Down
2 changes: 1 addition & 1 deletion src/api/app/models/full_text_search.rb
Expand Up @@ -69,7 +69,7 @@ def attributes
def search_str
if text.blank?
nil
elsif fields.nil? || fields.empty?
elsif fields.blank?
Riddle::Query.escape(text)
else
"@(#{fields.map(&:to_s).join(',')}) #{Riddle::Query.escape(text)}"
Expand Down
2 changes: 1 addition & 1 deletion src/api/app/models/package.rb
Expand Up @@ -1329,7 +1329,7 @@ def commit(rev = nil)

def self.verify_file!(pkg, name, content)
# Prohibit dotfiles (files with leading .) and files with a / character in the name
raise IllegalFileName, "'#{name}' is not a valid filename" if (!name.present? || !(name =~ /^[^\.\/][^\/]+$/))
raise IllegalFileName, "'#{name}' is not a valid filename" if (name.blank? || !(name =~ /^[^\.\/][^\/]+$/))

# file is an ActionDispatch::Http::UploadedFile and Suse::Validator.validate
# will call to_s therefore we have to read the content first
Expand Down
2 changes: 1 addition & 1 deletion src/api/app/models/project.rb
Expand Up @@ -1623,7 +1623,7 @@ def get_removed_repositories(request_data)
result = []
removed.each do |name|
repository = repositories.find_by(name: name)
result << repository unless repository.remote_project_name.present?
result << repository if repository.remote_project_name.blank?
end
result
end
Expand Down
2 changes: 1 addition & 1 deletion src/api/app/models/project/key_info.rb
Expand Up @@ -18,7 +18,7 @@ def self.find_by_project(project)

parsed_response = Xmlhash.parse(response)

return unless parsed_response['pubkey'].present?
return if parsed_response['pubkey'].blank?

key_info_params = {
origin: parsed_response['project'],
Expand Down
2 changes: 1 addition & 1 deletion src/api/app/models/user_ldap_strategy.rb
Expand Up @@ -249,7 +249,7 @@ def self.find_with_ldap(login, password)
when :ldap then
# ruby-ldap returns true if password is empty
# https://github.com/ruby-ldap/ruby-net-ldap/issues/5
return unless password.present?
return if password.blank?
# Don't match the passwd locally, try to bind to the ldap server
user_con = initialize_ldap_con(user['dn'], password)
if user_con.nil?
Expand Down

0 comments on commit de8d669

Please sign in to comment.