Showing 18 of 26 total issues
Method run
has a Cognitive Complexity of 56 (exceeds 5 allowed). Consider refactoring. Open
def run
@smart_attributes = JSON.parse(IO.read(config[:json]), symbolize_names: true)[:smart][:attributes]
@smart_debug = config[:debug] == 'on'
# Load in the device configuration
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method check_tests
has a Cognitive Complexity of 36 (exceeds 5 allowed). Consider refactoring. Open
def check_tests(dev)
if dev.str.empty?
@warnings << "#{dev.name}: No self-tests have been logged."
return
end
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method run
has a Cognitive Complexity of 32 (exceeds 5 allowed). Consider refactoring. Open
def run
delim = config[:flatten] == true ? '_' : '.'
# Get disk usage from df with used and avail in megabytes
# #YELLOW
command = if Gem::Platform.local.os == 'solaris'
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method fs_mounts
has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring. Open
def fs_mounts
begin
mounts = Filesystem.mounts
rescue StandardError
unknown 'An error occured getting the mount info'
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method run
has 70 lines of code (exceeds 25 allowed). Consider refactoring. Open
def run
@smart_attributes = JSON.parse(IO.read(config[:json]), symbolize_names: true)[:smart][:attributes]
@smart_debug = config[:debug] == 'on'
# Load in the device configuration
Method check_mounts
has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring. Open
def check_mounts
@fstab.each do |line|
next if line =~ /^\s*#/
next if line =~ /^\s*$/
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method run
has 54 lines of code (exceeds 25 allowed). Consider refactoring. Open
def run
# Get capacity metrics from DF as they don't appear in /proc
command = if Gem::Platform.local.os == 'solaris'
'df -k'
else
Method run
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
def run
# http://www.kernel.org/doc/Documentation/iostats.txt
metrics = %w[reads readsMerged sectorsRead readTime writes writesMerged sectorsWritten writeTime ioInProgress ioTime ioTimeWeighted]
File.open('/proc/diskstats', 'r').each_line do |line|
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method find_devices
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
def find_devices
# Search for devices without number
devices = []
# Return parameter value if it's defined
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method run
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
def run
# Get capacity metrics from DF as they don't appear in /proc
command = if Gem::Platform.local.os == 'solaris'
'df -k'
else
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method check_tests
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
def check_tests(dev)
if dev.str.empty?
@warnings << "#{dev.name}: No self-tests have been logged."
return
end
Method find_devices
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
def find_devices
# Search for devices without number
devices = []
# Return parameter value if it's defined
Method check_mount
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
def check_mount(line)
begin
fs_info = Filesystem.stat(line.mount_point)
rescue StandardError
@warn_fs << "#{line.mount_point} Unable to read."
Method resolve_device
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def resolve_device(device)
if device.start_with?('UUID=')
uuid = device.split('=')[1]
path = File.join('/', 'dev', 'disk', 'by-uuid', uuid)
if File.exist?(path) && File.symlink?(path)
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method check_mount
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def check_mount(line)
begin
fs_info = Filesystem.stat(line.mount_point)
rescue StandardError
@warn_fs << "#{line.mount_point} Unable to read."
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method percent_bytes
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def percent_bytes(fs_info)
if config[:ignore_reserved]
u100 = fs_info.bytes_used * 100.0
nonroot_total = fs_info.bytes_used + fs_info.bytes_available
if nonroot_total.zero?
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method scan_disks!
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def scan_disks!
`lsblk -nro NAME,TYPE`.each_line do |line|
name, type = line.split
if type == 'disk'
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method set_devices
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def set_devices
if config[:devices] == 'all'
`lsblk -plnd -o NAME`.split.each do |name|
unless name =~ /\/dev\/loop.*/
dev = Device.new(name, config[:executable])
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"