Skip to content

Commit

Permalink
Rubocop: Adding block method check
Browse files Browse the repository at this point in the history
  • Loading branch information
David Davis committed Oct 8, 2013
1 parent aa05b86 commit 7315e92
Show file tree
Hide file tree
Showing 20 changed files with 77 additions and 50 deletions.
3 changes: 3 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -105,3 +105,6 @@ Documentation:

Encoding:
Enabled: false # don't require utf-8 encoding on every file

MethodCalledOnDoEndBlock:
Enabled: true
4 changes: 2 additions & 2 deletions app/controllers/activation_keys_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -346,8 +346,8 @@ def retrieve_all_pools
next if product.nil?
pool.provider_id = product.provider_id
pool
end.compact
subscriptions = [] if subscriptions.nil?
end
subscriptions.compact!
else
subscriptions = []
end
Expand Down
3 changes: 2 additions & 1 deletion app/controllers/api/v1/distributors_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,8 @@ def report # rubocop:disable MethodLength
:only => [:uuid, :name, :location, :created_at, :updated_at],
:methods => [:environment, :organization, :compliance_color, :compliant_until, :custom_info]
)
end.flatten!
end
data.flatten!

transforms = lambda do |r|
r.organization = r.organization.name
Expand Down
3 changes: 2 additions & 1 deletion app/controllers/api/v1/systems_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,8 @@ def report # rubocop:disable MethodLength
:only => [:uuid, :name, :location, :created_at, :updated_at],
:methods => [:environment, :organization, :compliance_color, :compliant_until, :custom_info]
)
end.flatten!
end
data.flatten!

transforms = lambda do |r|
r.organization = r.organization.name
Expand Down
4 changes: 2 additions & 2 deletions app/controllers/consumers_controller_logic.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ def available_subscriptions(cp_pools, organization = current_organization)

pool.provider_id = product[0].provider_id
pool
end.compact
subscriptions = [] if subscriptions.nil?
end
subscriptions.compact!
else
subscriptions = []
end
Expand Down
3 changes: 2 additions & 1 deletion app/controllers/content_search_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,8 @@ def packages

prod_rows = product_repo_map.collect do |product, reps|
spanned_product_content(view, product, reps, 'package', package_ids)
end.flatten
end
prod_rows.flatten!

if !prod_rows.empty?
rows << view_hash[view.id]
Expand Down
5 changes: 3 additions & 2 deletions app/helpers/menu.rb
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,10 @@ def render_main_sub_menu
def render_sublevel_menu(items = nil, prune = true)
items ||= menu_main
prune_menu(items) if prune
items.collect do |top_level|
result = items.collect do |top_level|
render_navigation(:items => top_level[:items], :expand_all => true) if top_level[:items]
end.compact.join("").html_safe
end
result.compact.join("").html_safe
end

private
Expand Down
5 changes: 3 additions & 2 deletions app/lib/authorization_rules.rb
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def build_bad_params_error_msg(bad_params, params)
def check_hash_params(rule, params)
rule = rule.with_indifferent_access
params = params.with_indifferent_access
rule.keys.collect do |k|
result = rule.keys.collect do |k|
if params[k]
keys = params[k].keys - rule[k].collect { |r| r.to_s }
if keys.empty?
Expand All @@ -77,7 +77,8 @@ def check_hash_params(rule, params)
{k => keys}
end
end
end.compact
end
result.compact
end

def check_array_params(rule, params)
Expand Down
3 changes: 2 additions & 1 deletion app/lib/glue/event.rb
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@ def self.trigger(event_class, *args)
message << step.error['backtrace'].join("\n")
end
message
end.join("\n")
end
log_message = log_message.join("\n")

if execution_plan.failed_steps.any?
::Logging.logger['glue'].error(log_message)
Expand Down
3 changes: 2 additions & 1 deletion app/lib/util/support.rb
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,8 @@ def self.diff_hash_params(rule, params)
end
end
end
end.compact.flatten
end
diff_data = diff_data.compact.flatten

return diff_data unless diff_data.nil? || diff_data.empty?
stringify(params.keys) - stringify(rule.keys)
Expand Down
3 changes: 2 additions & 1 deletion app/models/erratum_rule.rb
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,8 @@ def generate_clauses(repo)
# end.compact.flatten
ids = parameters[:units].collect do |unit|
unit[:id]
end.compact
end
ids.compact!

{"id" => {"$in" => ids}} unless ids.empty?
else
Expand Down
14 changes: 8 additions & 6 deletions app/models/glue/provider.rb
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,10 @@ def refresh_manifest(upstream, options = {})

def sync
Rails.logger.debug "Syncing provider #{name}"
self.products.collect do |p|
syncs = self.products.collect do |p|
p.sync
end.flatten
end
syncs.flatten
end

def synced?
Expand All @@ -71,9 +72,10 @@ def synced?

#get last sync status of all repositories in this provider
def latest_sync_statuses
self.products.collect do |p|
statuses = self.products.collect do |p|
p.latest_sync_statuses
end.flatten
end
statuses.flatten
end

# Get the most relavant status for all the repos in this Provider
Expand Down Expand Up @@ -436,8 +438,8 @@ def index_subscriptions
next if product.nil?
pool.provider_id = product.provider_id # Set so it is saved into elastic search
pool
end.compact
subscriptions = [] if subscriptions.nil?
end
subscriptions.compact!
else
subscriptions = []
end
Expand Down
10 changes: 6 additions & 4 deletions app/models/glue/pulp/errata.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,10 @@ def self.find_by_errata_id(id)
def self.list_by_filter_clauses(clauses)
errata = Katello.pulp_server.extensions.errata.search(::Errata::CONTENT_TYPE, :filters => clauses)
if errata
errata.collect do |attrs|
result = errata.collect do |attrs|
::Errata.new(attrs) if attrs
end.compact
end
result.compact
else
[]
end
Expand All @@ -64,11 +65,12 @@ def initialize(params = {}, options = {})
end

def package_filenames
self.pkglist.collect do |pkgs|
filenames = self.pkglist.collect do |pkgs|
pkgs['packages'].collect do |pk|
pk["filename"]
end
end.flatten
end
filenames.flatten
end

def included_packages
Expand Down
4 changes: 1 addition & 3 deletions app/models/glue/pulp/package_group.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,7 @@ def initialize(params = {}, options = {})
[:default_package_names, :conditional_package_names,
:optional_package_names, :mandatory_package_names].each do |attr|
values = send(attr)
values = values.collect do |v|
v.split(", ")
end.flatten
values = values.collect { |v| v.split(", ") }.flatten
send("#{attr}=", values)
end

Expand Down
6 changes: 4 additions & 2 deletions app/models/glue/pulp/repo.rb
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,8 @@ def purge_empty_groups_errata
# Remove all errata with no packages
errata_to_delete = errata.collect do |erratum|
erratum.errata_id if filenames.intersection(erratum.package_filenames).empty?
end.compact
end
errata_to_delete.compact!

#do the errata remove call
unless errata_to_delete.empty?
Expand All @@ -276,7 +277,8 @@ def purge_empty_groups_errata
# Remove all package groups with no packages
package_groups_to_delete = package_groups.collect do |group|
group.package_group_id if rpm_names.intersection(group.package_names).empty?
end.compact
end
package_groups_to_delete.compact!

unless package_groups_to_delete.empty?
unassociate_by_filter(FilterRule::PACKAGE_GROUP, {"id" => {"$in" => package_groups_to_delete}})
Expand Down
23 changes: 14 additions & 9 deletions app/models/glue/pulp/repos.rb
Original file line number Diff line number Diff line change
Expand Up @@ -109,21 +109,23 @@ def has_package?(id)
end

def find_packages_by_name(env, name)
self.repos(env).collect do |repo|
packages = self.repos(env).collect do |repo|
repo.find_packages_by_name(name).collect do |p|
p[:repo_id] = repo.id
p
end
end.flatten(1)
end
packages.flatten(1)
end

def find_packages_by_nvre(env, name, version, release, epoch)
self.repos(env).collect do |repo|
packages = self.repos(env).collect do |repo|
repo.find_packages_by_nvre(name, version, release, epoch).collect do |p|
p[:repo_id] = repo.id
p
end
end.flatten(1)
end
packages.flatten(1)
end

def distributions(env)
Expand All @@ -136,9 +138,10 @@ def distributions(env)
end

def get_distribution(env, id)
self.repos(env).map do |repo|
distribution = self.repos(env).map do |repo|
repo.distributions.find_all {|d| d.id == id }
end.flatten(1)
end
distribution.flatten(1)
end

def find_latest_packages_by_name(env, name)
Expand All @@ -148,7 +151,8 @@ def find_latest_packages_by_name(env, name)
pack[:repo_id] = repo.id
pack
end
end.flatten(1)
end
packs.flatten!(1)

Util::Package.find_latest_packages packs
end
Expand All @@ -166,9 +170,10 @@ def promoted_to?(target_env)

def sync
Rails.logger.debug "Syncing product #{self.label}"
self.repos(library).collect do |r|
repos = self.repos(library).collect do |r|
r.sync
end.flatten
end
repos.flatten
end

def synced?
Expand Down
18 changes: 11 additions & 7 deletions app/models/kt_environment.rb
Original file line number Diff line number Diff line change
Expand Up @@ -240,21 +240,23 @@ def package_group_categories(search_args = {})
end

def find_packages_by_name(name)
self.products.collect do |prod|
products = self.products.collect do |prod|
prod.find_packages_by_name(self, name).collect do |p|
p[:product_id] = prod.cp_id
p
end
end.flatten(1)
end
products.flatten(1)
end

def find_packages_by_nvre(name, version, release, epoch)
self.products.collect do |prod|
products = self.products.collect do |prod|
prod.find_packages_by_nvre(self, name, version, release, epoch).collect do |p|
p[:product_id] = prod.cp_id
p
end
end.flatten(1)
end
products.flatten(1)
end

def find_latest_packages_by_name(name)
Expand All @@ -264,15 +266,17 @@ def find_latest_packages_by_name(name)
pack[:product_id] = prod.cp_id
pack
end
end.flatten(1)
end
packs.flatten!(1)

Util::Package.find_latest_packages packs
end

def get_distribution(id)
self.products.collect do |prod|
distribution = self.products.collect do |prod|
prod.get_distribution(self, id)
end.flatten(1)
end
distribution.flatten(1)
end

def unset_users_with_default
Expand Down
5 changes: 3 additions & 2 deletions app/models/promotion_changeset.rb
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,10 @@ def promote_content(notify = false)
end

def promote_views(from_env, to_env, views)
views.collect do |view|
views = views.collect do |view|
view.promote(from_env, to_env)
end.flatten
end
views.flatten
end

def update_view_cp_content(to_env)
Expand Down
5 changes: 3 additions & 2 deletions app/models/task_status.rb
Original file line number Diff line number Diff line change
Expand Up @@ -302,9 +302,10 @@ def rmi_error_description
stacktrace.split("(").first
end
elsif errors =~ /^\[.*,.*\]$/m
errors.split(",").map do |error|
result = errors.split(",").map do |error|
error.gsub(/^\W+|\W+$/, "")
end.join("\n")
end
result.join("\n")
else
errors
end
Expand Down
3 changes: 2 additions & 1 deletion script/check-gettext.rb
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,8 @@
end
end
[string, suffix]
end.compact
end
gettext_strings.compact
rescue ArgumentError
next # we can't scan binary files, skipping
end
Expand Down

0 comments on commit 7315e92

Please sign in to comment.