Showing 81 of 81 total issues
Method connect_to_server
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def connect_to_server
logger.info "Starting connection to server"
client.run
rescue Adhearsion::Rayo::DisconnectedError => e
# We only care about disconnects if the process is up or booting
- 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 split
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def split(targets = {})
@splitting = true
calls_to_split = @calls.map do |call|
ignoring_ended_calls do
[call.id, call] if call.active?
- 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 dial
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
def dial(to, options = {})
options = options.dup
options[:to] = to
if options[:timeout]
wait_timeout = options[:timeout]
Method split
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
def split(targets = {})
@splitting = true
calls_to_split = @calls.map do |call|
ignoring_ended_calls do
[call.id, call] if call.active?
Method start
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
def start
catch :boot_aborted do
configure_plugins
load_lib_folder
load_app_file
Method execute
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
def execute
max_duration = @component_node.max_duration || -1
raise OptionError, 'Record cannot be used on a call that is not answered.' unless @call.answered?
raise OptionError, 'A start-paused value of true is unsupported.' if @component_node.start_paused
Method dispatch
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
def dispatch(call, callback = nil)
Adhearsion::Events.trigger_immediately :call_routed, call: call, route: self
call_id = call.id # Grab this to use later incase the actor is dead
Similar blocks of code found in 2 locations. Consider refactoring. Open
def init(name = nil, opts = {}, &block)
name = plugin_name unless name
block_given? or raise ArgumentError, "A block must be passed while defining the Plugin initialization process"
opts[:after] ||= initializers.last.name unless initializers.empty? || initializers.find { |i| i.name == opts[:before] }
Adhearsion::Plugin.initializers << Initializer.new(name, self, opts, &block)
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 47.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 2 locations. Consider refactoring. Open
def run(name = nil, opts = {}, &block)
name = plugin_name unless name
block_given? or raise ArgumentError, "A block must be passed while defining the Plugin run process"
opts[:after] ||= runners.last.name unless runners.empty? || runners.find { |i| i.name == opts[:before] }
Adhearsion::Plugin.runners << Initializer.new(name, self, opts, &block)
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 47.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Method execute_from_app_dir!
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def execute_from_app_dir!(path)
if in_app? and running_script_ahn?
return Dir.pwd
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 description
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def description(name, args = {:show_values => true})
desc = StringIO.new
name.nil? and name = :core
if name.eql? :all
- 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 <<
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def <<(digit)
cancel_initial_timer
@buffer << digit unless terminating?(digit)
case (match = get_match)
when RubySpeech::GRXML::NoMatch
- 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 config
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def config(name = nil, &block)
if name.nil?
name = self.plugin_name
else
self.plugin_name = name
- 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 ping_rayo
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def ping_rayo
client.write_with_handler Blather::Stanza::Iq::Ping.new(:get, root_domain) do |response|
begin
handle_error response if response.is_a? Blather::BlatherError
rescue ProtocolError => e
- 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 6 arguments (exceeds 4 allowed). Consider refactoring. Open
def initialize(channel, translator, ami_client, connection, agi_env = nil, id = nil)
Method from_xml
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def self.from_xml(node, call_id = nil, component_id = nil, uri = nil, timestamp = nil)
Method initialize
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def initialize(responder, grammar, initial_timeout = nil, inter_digit_timeout = nil, terminator = nil)
Method dial
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def dial(to, options = {})
options = options.dup
options[:to] = to
if options[:timeout]
wait_timeout = options[:timeout]
- 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 init
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def init(name = nil, opts = {}, &block)
name = plugin_name unless name
block_given? or raise ArgumentError, "A block must be passed while defining the Plugin initialization process"
opts[:after] ||= initializers.last.name unless initializers.empty? || initializers.find { |i| i.name == opts[:before] }
Adhearsion::Plugin.initializers << Initializer.new(name, self, opts, &block)
- 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 7 (exceeds 5 allowed). Consider refactoring. Open
def initialize(options = {})
raise ArgumentError unless (@username = options[:username]) && options[:password]
setup(*[:username, :password, :host, :port, :certs, :connection_timeout].map { |key| options.delete key })
- 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"