Skip to content

Commit

Permalink
Merge pull request #16114 from shivanshsoni/master
Browse files Browse the repository at this point in the history
Removed unused Variables
  • Loading branch information
bdunne authored Oct 25, 2017
2 parents 1d9af07 + 78752ce commit 14a0d27
Show file tree
Hide file tree
Showing 43 changed files with 51 additions and 63 deletions.
2 changes: 1 addition & 1 deletion app/models/cloud_tenant.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def self.create_cloud_tenant(ems_id, options = {})
raise ArgumentError, _("ext_management_system cannot be nil") if ext_management_system.nil?

klass = class_by_ems(ext_management_system)
created_cloud_tenant = klass.raw_create_cloud_tenant(ext_management_system, options)
klass.raw_create_cloud_tenant(ext_management_system, options)
end

def self.raw_create_cloud_tenant(_ext_management_system, _options = {})
Expand Down
4 changes: 1 addition & 3 deletions app/models/cloud_volume.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,7 @@ def self.create_volume(ems_id, options = {})
raise ArgumentError, _("ext_management_system cannot be found") if ext_management_system.nil?

klass = class_by_ems(ext_management_system)
tenant = options[:cloud_tenant]

created_volume = klass.raw_create_volume(ext_management_system, options)
klass.raw_create_volume(ext_management_system, options)
end

def self.validate_create_volume(ext_management_system)
Expand Down
1 change: 0 additions & 1 deletion app/models/ems_refresh/save_inventory_infra.rb
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@ def save_ems_infra_inventory(ems, hashes, target = nil, disconnect = true)
end

def save_storages_inventory(ems, hashes, target = nil, _disconnect = true)
target = ems if target.nil?
log_header = "EMS: [#{ems.name}], id: [#{ems.id}]"

# Query for all of the storages ahead of time
Expand Down
2 changes: 0 additions & 2 deletions app/models/ldap_user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,6 @@ def self.update_records_since(ldap_server, updates_since)
rec_count = 0
ldap_server.search(opts) do |entry|
rec_count += 1
dn = MiqLdap.get_attr(entry, :dn)
rec = find_by_dn(dn)
end

_log.info("#{log_header} Completed LDAP User sync for <#{rec_count}> records updated since <#{when_changed}>")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,6 @@ def parse_snapshot(snap)
end

def parse_volume(volume)
log_header = "MIQ(#{self.class.name}.#{__method__})"

uid = volume.id
new_result = {
:ems_ref => uid,
Expand Down
4 changes: 2 additions & 2 deletions app/models/metric/ci_mixin.rb
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ def performances_maintains_value_for_duration?(options)
slope_steepness = options[:slope_steepness].to_f
percentage = options[:percentage] if options[:percentage]
interval_name = options[:interval_name] || "realtime"
klass, meth = Metric::Helper.class_and_association_for_interval_name(interval_name)
_klass, meth = Metric::Helper.class_and_association_for_interval_name(interval_name)
now = options[:now] || Time.now.utc # for testing only

# Turn on for the listing of timestamps and values in the debug log
Expand Down Expand Up @@ -148,7 +148,7 @@ def performances_maintains_value_for_duration?(options)
total_records = total_records[0..start_on_idx]
end

slope, yint = VimPerformanceAnalysis.calc_slope_from_data(total_records.dup, :timestamp, column)
slope, _yint = VimPerformanceAnalysis.calc_slope_from_data(total_records.dup, :timestamp, column)
_log.info("[#{total_records.length}] total records found, slope: #{slope}, counter: [#{column}] criteria: #{interval_name} from [#{total_records.last.timestamp}] to [#{now}]")

# Honor trend direction option by comparing with the calculated slope value
Expand Down
2 changes: 1 addition & 1 deletion app/models/metric/ci_mixin/processing.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def perf_process(interval_name, start_time, end_time, counters_data)

_log.info("#{log_header} Processing for #{log_specific_targets(resources)}, for range [#{start_time} - #{end_time}]...")

dummy, t = Benchmark.realtime_block(:total_time) do
_dummy, t = Benchmark.realtime_block(:total_time) do
# Take the raw metrics and create hashes out of them
rt_rows = {}

Expand Down
4 changes: 2 additions & 2 deletions app/models/metric/ci_mixin/rollup.rb
Original file line number Diff line number Diff line change
Expand Up @@ -74,12 +74,12 @@ def perf_rollup(time, interval_name, time_profile = nil)
raise ArgumentError, _("time_profile must be passed if interval name is 'daily'")
end
time_profile = TimeProfile.extract_objects(time_profile)
klass, meth = Metric::Helper.class_and_association_for_interval_name(interval_name)
_klass, meth = Metric::Helper.class_and_association_for_interval_name(interval_name)

log_header = "[#{interval_name}] Rollup for #{self.class.name} name: [#{name}], id: [#{id}] for time: [#{time}]"
_log.info("#{log_header}...")

dummy, t = Benchmark.realtime_block(:total_time) do
_dummy, t = Benchmark.realtime_block(:total_time) do
new_perf = {
:timestamp => time,
:capture_interval_name => (interval_name == 'historical' ? 'hourly' : interval_name)
Expand Down
2 changes: 1 addition & 1 deletion app/models/metric/processing.rb
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def self.process_derived_columns(obj, attrs, ts = nil)
have_mem_metrics = attrs[:mem_usage_absolute_average] || attrs[:derived_memory_used]

DERIVED_COLS.each do |col|
dummy, group, typ, mode = col.to_s.split("_")
_dummy, group, typ, mode = col.to_s.split("_")
next if group == "vm" && obj.kind_of?(Service) && typ != "count"
case typ
when "available"
Expand Down
2 changes: 1 addition & 1 deletion app/models/miq_report/formatting.rb
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ def format_datetime_range(val, options)
return val unless val.kind_of?(Time) || stime.kind_of?(Date)

col = options[:column]
col, sfx = col.to_s.split("__") # The suffix (month, quarter, year) defines the range
_col, sfx = col.to_s.split("__") # The suffix (month, quarter, year) defines the range

val = val.in_time_zone(get_time_zone("UTC"))
if val.respond_to?("beginning_of_#{sfx}")
Expand Down
2 changes: 1 addition & 1 deletion app/models/miq_report/generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -595,7 +595,7 @@ def build_pivot(data)

group_key = rpt_options[:pivot][:group_cols]
data = generate_subtotals(data, group_key, options)
data = data.inject([]) do |a, (k, v)|
data.inject([]) do |a, (k, v)|
next(a) if k == :_total_
row = col_order.inject({}) do |h, col|
if col.include?("__")
Expand Down
2 changes: 1 addition & 1 deletion app/models/miq_report/generator/html.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module MiqReport::Generator::Html
def build_html_rows(clickable_rows = false)
tz = get_time_zone(Time.zone.name) if Time.zone
get_time_zone(Time.zone.name) if Time.zone
html_rows = []
group_counter = 0
row = 0
Expand Down
2 changes: 1 addition & 1 deletion app/models/miq_report/generator/trend.rb
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ def build_calculate_trend_point(rec, col)
begin
val = MiqStats.solve_for_y(rec.send(CHART_X_AXIS_COLUMN_ADJUSTED).to_i, @trend_data[col][:slope], @trend_data[col][:yint])
return val > 0 ? val : 0
rescue ZeroDivisionError => err
rescue ZeroDivisionError
return nil
end
end
Expand Down
2 changes: 1 addition & 1 deletion app/models/miq_schedule_worker/runner.rb
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,7 @@ def rufus_add_normal_schedule(options)
def rufus_add_monthly_schedule(options)
months = options.delete(:months)
method = options.delete(:method)
interval = options.delete(:interval)
options.delete(:interval)
schedule_id = options.delete(:schedule_id)

# Treat months differently since rufus doesn't support :schedule_every with X.months type of options
Expand Down
1 change: 0 additions & 1 deletion app/models/miq_server/server_smart_proxy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,6 @@ def is_vix_disk_supported?
require 'VMwareWebService/VixDiskLib/VixDiskLib'
caps[:vixDisk] = true
end
rescue Exception => err
# It is ok if we hit an error, it just means the library is not available to load.
end

Expand Down
2 changes: 1 addition & 1 deletion app/models/miq_vim_broker_worker.rb
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def self.drb_uri
def self.drb_port
uri = drb_uri
return nil if uri.nil?
scheme, userinfo, host, port, registry, path, opaque, query, fragment = URI.split(uri)
_scheme, _userinfo, _host, port, _registry, _path, _opaque, _query, _fragment = URI.split(uri)
_log.debug("Active VimBroker DRb Port is #{port}")
port.to_i
end
Expand Down
2 changes: 1 addition & 1 deletion app/models/mixins/file_depot_mixin.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def get_uri_prefix(uri_str)
# Strip any leading and trailing whitespace
uri_str.strip!

scheme, userinfo, host, port, registry, path, opaque, query, fragment = URI.split(URI.encode(uri_str))
scheme, _userinfo, _host, _port, _registry, _path, _opaque, _query, _fragment = URI.split(URI.encode(uri_str))
scheme
end
end
Expand Down
2 changes: 1 addition & 1 deletion app/models/mixins/miq_policy_mixin.rb
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ def rsop_async(event, targets, userid = nil)
:args => [eventobj.name, targets],
:priority => MiqQueue::HIGH_PRIORITY
}
tid = MiqTask.generic_action_with_callback(opts, qopts)
MiqTask.generic_action_with_callback(opts, qopts)
end
end # module ClassMethods
end # module MiqPolicyMixin
2 changes: 1 addition & 1 deletion app/models/mixins/relationship_mixin.rb
Original file line number Diff line number Diff line change
Expand Up @@ -504,7 +504,7 @@ def fulltree_rels_arranged(*args)
options = args.extract_options!
root_id = relationship.try(:root_id)
return {relationship_for_isolated_root => {}} if root_id.nil?
rels = Relationship.subtree_of(root_id).arrange
Relationship.subtree_of(root_id).arrange
Relationship.filter_by_resource_type(Relationship.subtree_of(root_id), options).arrange
end

Expand Down
2 changes: 1 addition & 1 deletion app/models/resource_action.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def automate_queue_hash(target, override_attrs, user)
end

def fqname=(value)
self.ae_namespace, self.ae_class, self.ae_instance, attr_name = MiqAeEngine::MiqAePath.split(value)
self.ae_namespace, self.ae_class, self.ae_instance, _attr_name = MiqAeEngine::MiqAePath.split(value)
end

def fqname
Expand Down
4 changes: 2 additions & 2 deletions app/models/rss_feed.rb
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def generate(host = nil, local = false, proto = nil, user_or_group = nil)
end

def self.to_html(feed, options)
limit = options[:limit_to_count]
options[:limit_to_count]
output = ""
output << '<table class="table table-striped table-bordered table-hover">'
output << '<tbody>'
Expand Down Expand Up @@ -116,7 +116,7 @@ def find_items
end
items
else # Custom find method
items = item_class.send(options[:search_method].to_sym, name, options)
item_class.send(options[:search_method].to_sym, name, options)
end
end

Expand Down
4 changes: 2 additions & 2 deletions app/models/storage.rb
Original file line number Diff line number Diff line change
Expand Up @@ -697,9 +697,9 @@ def perf_capture(interval_name, *_args)

_log.info("#{log_header} Capture for #{log_target}...")

klass, meth = Metric::Helper.class_and_association_for_interval_name(interval_name)
_klass, meth = Metric::Helper.class_and_association_for_interval_name(interval_name)

dummy, t = Benchmark.realtime_block(:total_time) do
_dummy, t = Benchmark.realtime_block(:total_time) do
hour = Metric::Helper.nearest_hourly_timestamp(Time.now.utc + 30.minutes)

interval = case interval_name
Expand Down
6 changes: 3 additions & 3 deletions app/models/vim_performance_analysis.rb
Original file line number Diff line number Diff line change
Expand Up @@ -216,8 +216,8 @@ def how_many_more_can_fit_host_to_cluster_results(result)
chash = v[:count][:storage]
# Calculate storage total based on merged counts.
chash[:total] = chash[:details].inject(0) do|t, h|
k, val = h.to_a.flatten
t += val
_k, val = h.to_a.flatten
t + val
end if v[:count].key?(:storage)
#
chash = v[:count]
Expand Down Expand Up @@ -539,7 +539,7 @@ def self.group_perf_by_timestamp(obj, perfs, cols = nil)
end

result.inject([]) do |recs, k|
ts, v = k
_ts, v = k
cols.each do |c|
next unless v[c].kind_of?(Float)
Metric::Aggregation::Process.column(c, nil, v, counts[k], true, :average)
Expand Down
2 changes: 1 addition & 1 deletion app/models/vim_performance_planning.rb
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ def self.build_results_for_report_planning(options)
next
end

method = case t
case t
when :cpu then vm_profile[t] = "#{vm_profile[t].round} MHz"
when :memory then vm_profile[t] = "#{vm_profile[t].round} MB"
when :storage then vm_profile[t] = "#{(vm_profile[t].to_i / 1.gigabyte).round} GB"
Expand Down
4 changes: 2 additions & 2 deletions app/models/vim_performance_trend.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def self.build(perfs, options)
# :target_pcts => [70, 80, 90, 100],
# }

limit_col = options[:limit_col] ? options[:limit_col] : "limit"
options[:limit_col] ? options[:limit_col] : "limit"

# group data by resource name
grouped_objs = perfs.inject({}) do |h, o|
Expand Down Expand Up @@ -245,7 +245,7 @@ def self.report_cols(options)
col_headers << Dictionary.gettext([options[:trend_db], options[:limit_col]].join("."), :type => "column", :notfound => :titleize)
end

limit_pct_cols = options[:target_pcts].each do |c|
options[:target_pcts].each do |c|
col_order << "limit_pct_value_#{options[:target_pcts].index(c) + 1}"
col_headers << "#{c}%"
end
Expand Down
2 changes: 1 addition & 1 deletion app/models/vm_or_template.rb
Original file line number Diff line number Diff line change
Expand Up @@ -607,7 +607,7 @@ def self.find_by_full_location(path)
_log.info("vm_hash [#{vm_hash.inspect}]")
store = Storage.find_by(:name => vm_hash[:name])
return nil unless store
vmobj = VmOrTemplate.find_by(:location => vm_hash[:location], :storage_id => store.id)
VmOrTemplate.find_by(:location => vm_hash[:location], :storage_id => store.id)
end

def self.repository_parse_path(path)
Expand Down
2 changes: 1 addition & 1 deletion app/models/vm_scan.rb
Original file line number Diff line number Diff line change
Expand Up @@ -475,7 +475,7 @@ def process_cancel(*args)

# Logic to determine if we should abort the job or retry the scan depending on the error
def call_abort_retry(*args)
message, status, skip_retry = args
message, _status, skip_retry = args
if message.to_s.include?("Could not find VM: [") && options[:scan_count].to_i.zero?
# We may need to skip calling the retry if this method is called twice.
return if skip_retry == true
Expand Down
2 changes: 1 addition & 1 deletion app/models/vmdb_index/seeding.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ module ClassMethods
def seed_for_table(table, index)
unless index.kind_of?(self)
_log.info("Creating <#{index}> for Table <#{table.name}> in Database <#{table.vmdb_database.name}>")
index = table.vmdb_indexes.create(:name => index)
table.vmdb_indexes.create(:name => index)
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion lib/extensions/ar_adapter/ar_dba.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def xlog_location_diff(lsn1, lsn2)
end

def client_connections
data = select(<<-SQL, "Client Connections").to_a
select(<<-SQL, "Client Connections").to_a
SELECT client_addr AS client_address
, datname AS database
, pid AS spid
Expand Down
2 changes: 1 addition & 1 deletion lib/extensions/ar_taggable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ def is_vtagged_with?(tag, options = {})
else
subject.send(relationship).any? { |o| o.send(attr).to_s == object }
end
rescue NoMethodError => err
rescue NoMethodError
return false
end
end
Expand Down
2 changes: 1 addition & 1 deletion lib/extensions/ar_to_model_hash.rb
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ def to_model_hash_build_preload(options, parent_class = self.class)

result = columns.select { |c| parent_class.virtual_attribute?(c) }

result += includes.collect do |k, v|
result + includes.collect do |k, v|
association_class = parent_class.reflections_with_virtual[k.to_sym].klass
sub_result = to_model_hash_build_preload(v, association_class)
sub_result.blank? ? k : {k => sub_result}
Expand Down
2 changes: 1 addition & 1 deletion lib/miq_expression/relative_datetime.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def self.normalize(rel_time, tz, mode = "beginning", is_date = nil)

if rt.ends_with?("ago")
# Time spec <value> <interval> Ago
value, interval, ago = rt.split
value, interval, _ago = rt.split
interval = interval.pluralize

if interval == "quarters"
Expand Down
2 changes: 1 addition & 1 deletion lib/miq_expression/where_extraction_visitor.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
class MiqExpression
class WhereExtractionVisitor < Arel::Visitors::PostgreSQL
def visit_Arel_Nodes_SelectStatement(o, collector)
collector = o.cores.inject(collector) do |c, x|
o.cores.inject(collector) do |c, x|
visit_Arel_Nodes_SelectCore(x, c)
end
end
Expand Down
4 changes: 2 additions & 2 deletions lib/miq_ldap.rb
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ def resolve_host(hosts, port)
addresses = host.to_miq_a # Host is already an IP Address, no need to resolve
else
begin
canonical, aliases, type, *addresses = TCPSocket.gethostbyname(host) # Resolve hostname to IP Address
_canonical, _aliases, _type, *addresses = TCPSocket.gethostbyname(host) # Resolve hostname to IP Address
$log.info("MiqLdap.connection: Resolved host [#{host}] has these IP Address: #{addresses.inspect}") if $log
rescue => err
$log.debug("Warning: '#{err.message}', resolving host: [host]")
Expand Down Expand Up @@ -187,7 +187,7 @@ def chase_referrals(objs, opts, seen)
objs.each do |o|
if o.attribute_names.include?(:search_referrals)
o.search_referrals.each do |ref|
scheme, userinfo, host, port, registry, dn, opaque, query, fragment = URI.split(ref)
scheme, _userinfo, host, port, _registry, dn, _opaque, _query, _fragment = URI.split(ref)
port ||= self.class.default_ldap_port(scheme)
dn = normalize(dn.split("/").last)
next if seen[:objects].include?(dn)
Expand Down
2 changes: 1 addition & 1 deletion lib/resource_feeder/lib/resource_feeder/atom.rb
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def atom_feed_for(resources, options = {})
xml.updated((resource.respond_to?(:updated_at) ? call_or_read(options[:item][:pub_date] || :updated_at, resource) : published_at).xmlschema)
xml.link(:rel => 'alternate', :type => 'text/html', :href => call_or_read(options[:item][:link] || options[:item][:guid] || resource_link, resource))

if author = call_or_read(options[:item][:author], resource)
if call_or_read(options[:item][:author], resource)
xml.author do
xml.name
end
Expand Down
2 changes: 1 addition & 1 deletion lib/vmdb/config/validator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ def session(data)

if keys.include?(:interval)
unless data.interval.kind_of?(Integer)
valid, key, message = [false, :interval, "interval, \"#{data.interval}\", invalid. invalid. Should be numeric"]
valid, _key, _message = [false, :interval, "interval, \"#{data.interval}\", invalid. invalid. Should be numeric"]
end

if data.interval == 0
Expand Down
4 changes: 2 additions & 2 deletions product/script/export_policy_profiles.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

# Load the Policy Class so that we get PolicySet defined
begin
p1 = Policy.find(1)
Policy.find(1)
rescue
end

Expand All @@ -22,7 +22,7 @@
f = File.new(fname, "w")
f << contents
f.close
rescue ActiveRecord::RecordNotFound => err
rescue ActiveRecord::RecordNotFound
next
end
end
Loading

0 comments on commit 14a0d27

Please sign in to comment.