Showing 6 of 10 total issues
Method run
has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring. Open
def run
begin
require 'vmstat'
rescue LoadError => e
raise unless e.message =~ /vmstat/
- 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 metrics_hash
has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring. Open
def metrics_hash
mem = {}
memp = {}
meminfo_output.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 metrics_hash
has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring. Open
def metrics_hash
mem = {}
meminfo_output.each_line do |line|
mem['total'] = line.split(/\s+/)[1].to_i * 1024 if line =~ /^MemTotal/
mem['free'] = line.split(/\s+/)[1].to_i * 1024 if line =~ /^MemFree/
- 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 47 lines of code (exceeds 25 allowed). Consider refactoring. Open
def run
begin
require 'vmstat'
rescue LoadError => e
raise unless e.message =~ /vmstat/
Method metrics_hash
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
def metrics_hash
mem = {}
memp = {}
meminfo_output.each_line do |line|
Method run
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def run
# Get output from free command
output_swap = `free -m | grep "Swap"`
# Prepare total and used swap
- 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"