Showing 41 of 41 total issues
Method define_accessor_meth
has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring. Open
def define_accessor_meth meth
self.class.class_eval do
define_method :"#{ meth }" do | *args |
attrs = args
opts = extract_options!( args )
- 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
Class Cli
has 28 methods (exceeds 20 allowed). Consider refactoring. Open
class Cli
def initialize host
@host = host
end
Method packet_in
has 65 lines of code (exceeds 25 allowed). Consider refactoring. Open
def packet_in datapath_id, event
puts "received a packet_in"
info "datapath_id: #{ datapath_id.to_hex }"
info "transaction_id: #{ event.transaction_id.to_hex }"
info "buffer_id: #{ event.buffer_id.to_hex }"
Method maybe_run_switch_manager
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
def maybe_run_switch_manager
# FIXME
return if FileTest.exists? File.join( Trema.pid, "switch_manager.pid" )
switch_manager =
- 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 13 (exceeds 5 allowed). Consider refactoring. Open
def initialize options=nil
setters = self.class.instance_methods.select{ | i | i.to_s =~ /[a-z].+=$/ }
required_attributes = self.class.attributes.required_attributes
if required_attributes.empty?
required_attributes = self.class.superclass.attributes.required_attributes
- 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 define_accessor
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
def define_accessor attr_name, opts
self.class_eval do
define_method attr_name do
instance_variable_get "@#{ attr_name }"
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 kill!
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def kill!
return if @pid_file.nil?
return if dead?
puts "Shutting down #{ @name }..." if $verbose
10.times do
- 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 configure
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def configure &block
config = Configuration.new
block.call config
Trema::Link.each do | each |
peers = each.peers
- 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 packet_in
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def packet_in datapath_id, event
puts "received a packet_in"
info "datapath_id: #{ datapath_id.to_hex }"
info "transaction_id: #{ event.transaction_id.to_hex }"
info "buffer_id: #{ event.buffer_id.to_hex }"
- 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 maybe_run_switch_manager
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
def maybe_run_switch_manager
# FIXME
return if FileTest.exists? File.join( Trema.pid, "switch_manager.pid" )
switch_manager =
Method initialize
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
def initialize options=nil
setters = self.class.instance_methods.select{ | i | i.to_s =~ /[a-z].+=$/ }
required_attributes = self.class.attributes.required_attributes
if required_attributes.empty?
required_attributes = self.class.superclass.attributes.required_attributes
Method run
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
def run controller
assert_trema_is_built
if controller
if /\.rb\Z/=~ controller.split.first
Method trema_run
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def trema_run options
@config_file = options[ :conf ] || nil
if options[ :daemonize ]
$run_as_daemon = true
- 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
Similar blocks of code found in 2 locations. Consider refactoring. Open
describe "host" do
before { send_packets "host1", "host2" }
subject { vhost( host_name ) }
- 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 41.
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
describe "host" do
before { send_packets "host1", "host2" }
subject { vhost( host_name ) }
- 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 41.
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 initialize
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
def initialize ip_dst, tp_dst, ip_src, tp_src, n_pkts, n_octets
Method parse
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def self.parse line
flow = self.new
# to simplify parsing
line.sub!(/actions=.*,.*$/) { | match | match.gsub(/,/,'/') }
line.strip.split( /[,\s]\s*/ ).each do | each |
- 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 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def initialize type, tha, sha, tpa, spa
Method inherited
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def inherited klass
map_ofp_type klass
primitive_sizes.each do | each |
define_accessor_meth :"unsigned_int#{ each }"
define_method :"check_unsigned_int#{ each }" do | number, 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 load_config
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def load_config
config = nil
dsl_parser = Trema::DSL::Parser.new
if @config_file
- 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"