Showing 14 of 23 total issues
Method run
has a Cognitive Complexity of 37 (exceeds 5 allowed). Consider refactoring. Open
def run
procs = acquire_procs
if config[:file_pid] && (file_pid = read_pid(config[:file_pid]))
procs.select! { |p| p[:pid].to_i == file_pid }
- 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
Function connection_stats
has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring. Open
def connection_stats(process_handler, metrics_regexp):
tcp_stats = ['total'] + [s.lower() for s in TCP_CONN_STATUSES]
tcp_conns = None
tcp_conns_count = {}
for stat in tcp_stats:
- 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 16 (exceeds 5 allowed). Consider refactoring. Open
def run
if checkrestart?
checkrestart_out = run_checkrestart
if /^Failed/ =~ checkrestart_out[:found]
- 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 48 lines of code (exceeds 25 allowed). Consider refactoring. Open
def run
procs = acquire_procs
if config[:file_pid] && (file_pid = read_pid(config[:file_pid]))
procs.select! { |p| p[:pid].to_i == file_pid }
Method run
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
def run
ipcs_status = run_ipcs
found = false
index = -1
- 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
Function additional_stats
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def additional_stats(process_handler, metrics_regexp):
stats = {}
if metrics_regexp.match('cpu.user'):
stats['cpu.user'] = process_handler.cpu_times().user
- 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 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
def run
ps_table = Sys::ProcTable.ps
processes = ps_table.length
threads = count_threads(ps_table) if config[:threads]
Method count_processes_by_status
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def count_processes_by_status(ps_table)
list_proc = {}
%w[S R D T t X Z].each do |v|
list_proc[v] = 0
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 acquire_cmd_status
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def acquire_cmd_status
stdout = `#{config[:command]}`
# #YELLOW
unless $CHILD_STATUS.exitstatus.to_s == config[:status] # rubocop:disable UnlessElse
critical "#{config[:command]} exited with #{$CHILD_STATUS.exitstatus}"
- 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
Avoid deeply nested control flow statements. Open
if conn.status == tcp_status:
tcp_conns_count[stat] = tcp_conns_count[stat] + 1
stats.update(tcp_conns_count)
Method run_checkrestart
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def run_checkrestart
checkrestart_hash = { found: '', pids: [] }
out = `sudo #{CHECK_RESTART} #{config[:args]} 2>&1`
if $CHILD_STATUS.to_i.nonzero?
- 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
Function find_pids
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def find_pids(matcher):
'''Find process PID using /proc/<pids> with given matcher'''
pids_in_proc = [ pid for pid in os.listdir(PROC_ROOT_DIR) if pid.isdigit() ]
pids = []
- 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 6 (exceeds 5 allowed). Consider refactoring. Open
def run
raise 'You must supply -u USER or -p PROCESSNAME' unless config[:user] || config[:processname]
metrics = {}
pgrep_output = `#{pgrep_command}`
pids = acquire_valid_pids(pgrep_output)
- 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 6 (exceeds 5 allowed). Consider refactoring. Open
def run
ps_table = Sys::ProcTable.ps
processes = ps_table.length
threads = count_threads(ps_table) if config[:threads]
- 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"