ManageIQ/manageiq-gems-pending

View on GitHub

Showing 88 of 217 total issues

Method create_directory_structure has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

def create_directory_structure(directory_path)
pwd = ftp.pwd
directory_path.to_s.split('/').each do |directory|
unless ftp.nlst.include?(directory)
_log.info("creating #{directory}")
Severity: Minor
Found in lib/gems/pending/util/miq_ftp_lib.rb - About 1 hr to fix

Method fru_info has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

def fru_info
return @devices unless @devices.nil?
 
@devices = []
dev_id = nil
Severity: Minor
Found in lib/gems/pending/util/miq-ipmi.rb - About 1 hr to fix

Method process_hash has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

def process_hash(node)
hsh = {}
node.each_element do |e|
# Nokogiri starts its element indexing at 0, while others start at 1.
index1 = MiqXml.nokogiri? ? 0 : 1
Severity: Minor
Found in lib/gems/pending/util/win32/miq-powershell.rb - About 1 hr to fix

Method tail has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

def self.tail(filename, last)
return nil unless File.file?(filename)
 
lines = nil
if Sys::Platform::OS == :unix
Severity: Minor
Found in lib/gems/pending/util/miq-system.rb - About 1 hr to fix

Method findElementInt has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

def self.findElementInt(paths, ele)
if paths.length > 0
searchStr = paths[0]
paths = paths[1..paths.length]
# puts "Search String: #{searchStr}"
Severity: Minor
Found in lib/gems/pending/util/xml/xml_utils.rb - About 1 hr to fix

Method findNamedElement_hash has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

def self.findNamedElement_hash(findStr, ele)
ele.each_element do |e|
if e.name == :value && e.attributes[:name].downcase == findStr.downcase
return e.text
end # if
Severity: Minor
Found in lib/gems/pending/util/xml/xml_utils.rb - About 1 hr to fix

Method process_list_wmi has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

def self.process_list_wmi(wmi = nil, pid = nil)
pl = {}
wmi = WMIHelper.connectServer if wmi.nil?
os_data = wmi.get_instance('select TotalVisibleMemorySize from Win32_OperatingSystem')
proc_query = 'select PageFileUsage,Name,Handle,WorkingSetSize,Priority,UserModeTime,KernelModeTime from Win32_Process'
Severity: Minor
Found in lib/gems/pending/util/miq-process.rb - About 1 hr to fix

Method initialize has 27 lines of code (exceeds 25 allowed). Consider refactoring.
Open

def initialize(first, second = nil, parent = nil)
@normalized = @unnormalized = @element = nil
if first.kind_of? Attribute
self.name = first.expanded_name
@value = first.value
Severity: Minor
Found in lib/gems/pending/util/xml/miq_rexml.rb - About 1 hr to fix

Method miq_patch_process_element has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

def miq_patch_process_element(ele, data, path, compare_roots, direction, parent_node, node, xml, stats)
if compare_roots == true
ele = xml.root
else
if node == :updates || direction == XML_DIFF_DEL
Severity: Minor
Found in lib/gems/pending/util/xml/xml_patch.rb - About 55 mins to fix

Method log_require has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

def log_require(path, mode, timing = nil, memory_consumed = nil, features_loaded = nil)
$req_depth -= 1 if mode == true || mode == false || mode == :fail
$req_log.puts "#{$req_depth.to_s.rjust(3)} #{REQ_LOG_OPERS[mode]} #{REQ_LOG_TREE * $req_depth}#{path.inspect[1..-2]}#{timing.nil? ? '' : " (#{"%.6f seconds" % timing})"}#{memory_consumed.nil? ? '' : " (#{memory_consumed} KB)"}#{features_loaded.nil? ? '' : " (#{features_loaded} features loaded)"}"
$req_depth += 1 if mode == :enter || mode == :reenter
end
Severity: Minor
Found in lib/gems/pending/util/require_with_logging.rb - About 55 mins to fix

Method to_png has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

def self.to_png(data, options = {})
require 'gruff'
 
graph = case options[:graph_type]
when :line then Gruff::Line.new
Severity: Minor
Found in lib/gems/pending/util/miq_logger_processor.rb - About 55 mins to fix

Method read_single_chunk has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

def read_single_chunk(chunksize = DEFAULT_CHUNKSIZE)
@buf_left ||= byte_count
return DONE_READING.dup unless @buf_left.nil? || @buf_left.positive?
cur_readsize = if @buf_left.nil? || @buf_left - chunksize >= 0
chunksize
Severity: Minor
Found in lib/gems/pending/util/miq_object_storage.rb - About 45 mins to fix

Method [] has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

def [](index, _name = nil)
if index.kind_of? Integer
raise "index (#{index}) must be >= 1" if index < 1
return @element.children[index - 1]
else
Severity: Minor
Found in lib/gems/pending/util/xml/xml_hash.rb - About 45 mins to fix

Method each_element_with_attribute has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

def each_element_with_attribute(key, value = nil, max = 0, _name = nil, &_block) # :yields: Element
# Note: optional "name" parameter is not implemented here.
eCount = 0
each do |e|
if e.attributes.key?(key) && (value.nil? || e.attributes[key] == value)
Severity: Minor
Found in lib/gems/pending/util/xml/xml_hash.rb - About 45 mins to fix

Method process_named_elements has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

def process_named_elements(node)
hsh = {}
node.each_element do |e|
name = e.attributes['N']
name = name.value if name.respond_to?(:value)
Severity: Minor
Found in lib/gems/pending/util/win32/miq-powershell.rb - About 45 mins to fix

Method memory has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

def self.memory
result = {}
case Sys::Platform::IMPL
when :mswin, :mingw
# raise "MiqSystem.memory: Windows Not Supported"
Severity: Minor
Found in lib/gems/pending/util/miq-system.rb - About 45 mins to fix

Method run_command has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

def run_command(ipmi_cmd, *args)
# -E: The remote server password is specified by the environment variable IPMI_PASSWORD.
continue_on_error = args.pop if [true, false, nil].any? { |type| args.last == type }
continue_on_error ||= false
ENV['IPMI_PASSWORD'] = @password
Severity: Minor
Found in lib/gems/pending/util/miq-ipmi.rb - About 45 mins to fix

Method get_windows_version has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

def get_windows_version
stdout_text = ""
stderr_text = ""
command_line = "winexe -U #{@server}/#{@username} //#{@server} \"cmd\""
Open3.popen3(command_line) do |stdin, stdout, stderr|
Severity: Minor
Found in lib/gems/pending/util/win32/miq-wmi-linux.rb - About 45 mins to fix

Method log_require has 5 arguments (exceeds 4 allowed). Consider refactoring.
Open

def log_require(path, mode, timing = nil, memory_consumed = nil, features_loaded = nil)
Severity: Minor
Found in lib/gems/pending/util/require_with_logging.rb - About 35 mins to fix

Method miq_patch_update_element has 5 arguments (exceeds 4 allowed). Consider refactoring.
Open

def miq_patch_update_element(element, data, compare_roots, direction, stats)
Severity: Minor
Found in lib/gems/pending/util/xml/xml_patch.rb - About 35 mins to fix
Severity
Category
Status
Source
Language