Showing 19 of 27 total issues
Method run
has a Cognitive Complexity of 123 (exceeds 5 allowed). Consider refactoring. Open
def run
validate_config
save_state
@state['steps'].each do |step|
- 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 validate_config
has a Cognitive Complexity of 86 (exceeds 5 allowed). Consider refactoring. Open
def validate_config
@state['ok_handler'] = validate_command(@state['ok_handler'], 'task success handler') if @state.has_key?('ok_handler')
@state['failure_handler'] = validate_command(@state['failure_handler'], 'task failure handler') if @state.has_key?('failure_handler')
if @state.has_key?('email')
invalid("config email recipients is missing or invalid") unless @state['email'].has_key?('recipients') && @state['email']['recipients'].is_a?(String) || @state['email']['recipients'].is_a?(Array)
- 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 initialize
has a Cognitive Complexity of 64 (exceeds 5 allowed). Consider refactoring. Open
def initialize(options)
@mutex = Mutex.new
Thread.abort_on_exception = true
@log = ''
- 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
File task.rb
has 460 lines of code (exceeds 250 allowed). Consider refactoring. Open
require 'popen4'
require 'pony'
require 'yaml'
require 'timeout'
require 'formatador'
Method interpolate_command
has a Cognitive Complexity of 39 (exceeds 5 allowed). Consider refactoring. Open
def interpolate_command(command,pattern=/^(ENV|ARG|EXEC)\./)
command = command.to_s if command.is_a?(Integer)
command.gsub(/:::([^:]*):::/) do
match = $1
invalid("interpolation type is not valid in this context - :::#{match}:::") if match !~ pattern and match =~ /^(ENV|ARG|EXEC)\./
- 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 validate_config
has 83 lines of code (exceeds 25 allowed). Consider refactoring. Open
def validate_config
@state['ok_handler'] = validate_command(@state['ok_handler'], 'task success handler') if @state.has_key?('ok_handler')
@state['failure_handler'] = validate_command(@state['failure_handler'], 'task failure handler') if @state.has_key?('failure_handler')
if @state.has_key?('email')
invalid("config email recipients is missing or invalid") unless @state['email'].has_key?('recipients') && @state['email']['recipients'].is_a?(String) || @state['email']['recipients'].is_a?(Array)
Method initialize
has 83 lines of code (exceeds 25 allowed). Consider refactoring. Open
def initialize(options)
@mutex = Mutex.new
Thread.abort_on_exception = true
@log = ''
Method run
has 79 lines of code (exceeds 25 allowed). Consider refactoring. Open
def run
validate_config
save_state
@state['steps'].each do |step|
Method thread_wrapper
has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring. Open
def thread_wrapper(i,script)
failures = 0
loop do
begin
- 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 parse
has 54 lines of code (exceeds 25 allowed). Consider refactoring. Open
def self.parse(args)
options = OpenStruct.new
options.args = Object.new
parser = OptionParser.new
Method validate_command
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
def validate_command(command,error_prefix)
if command.is_a?(String)
command = { 'command' => interpolate_command(command) }
elsif command.is_a?(Hash)
invalid(error_prefix + " is missing command attribute") unless command.has_key?('command')
- 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_command
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
def run_command(command,timeout)
result = ""
error = ""
# start = Time.now
- 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_command
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
def run_command(command,timeout)
result = ""
error = ""
# start = Time.now
Method interpolate_command
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
def interpolate_command(command,pattern=/^(ENV|ARG|EXEC)\./)
command = command.to_s if command.is_a?(Integer)
command.gsub(/:::([^:]*):::/) do
match = $1
invalid("interpolation type is not valid in this context - :::#{match}:::") if match !~ pattern and match =~ /^(ENV|ARG|EXEC)\./
Method thread_wrapper
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
def thread_wrapper(i,script)
failures = 0
loop do
begin
Avoid deeply nested control flow statements. Open
Process.kill("TERM", @state['pid']) if @state.has_key?('pid')
Avoid deeply nested control flow statements. Open
rescue Errno::ESRCH
Method run_post_script_handlers
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def run_post_script_handlers(script,status)
handler = nil
if status
handler = 'ok_handler' if script.has_key?('ok_handler')
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 parse
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def self.parse(args)
options = OpenStruct.new
options.args = Object.new
parser = OptionParser.new
- 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"