trema/trema-edge

View on GitHub

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 )
Severity: Minor
Found in ruby/trema/accessor.rb - About 3 hrs to fix

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

Severity: Minor
Found in ruby/trema/cli.rb - About 3 hrs to fix

    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 }"
    Severity: Major
    Found in src/examples/packet_in/packet-in.rb - About 2 hrs to fix

      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 =
      Severity: Minor
      Found in ruby/trema/dsl/runner.rb - About 2 hrs to fix

      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
      Severity: Minor
      Found in ruby/trema/accessor.rb - About 1 hr to fix

      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
      Severity: Minor
      Found in ruby/trema/accessor.rb - About 1 hr to fix

      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
      Severity: Minor
      Found in ruby/trema/process.rb - About 1 hr to fix

      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
      Severity: Minor
      Found in ruby/trema/dsl/parser.rb - About 1 hr to fix

      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 }"
      Severity: Minor
      Found in src/examples/packet_in/packet-in.rb - About 1 hr to fix

      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 =
      Severity: Minor
      Found in ruby/trema/dsl/runner.rb - About 1 hr to fix

        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
        Severity: Minor
        Found in ruby/trema/accessor.rb - About 1 hr to fix

          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
          Severity: Minor
          Found in ruby/trema/shell/run.rb - About 1 hr to fix

            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
            Severity: Minor
            Found in ruby/trema/command/run.rb - About 55 mins to fix

            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 ) }
            
            
            Severity: Minor
            Found in src/examples/repeater_hub/repeater-hub_spec.rb and 1 other location - About 45 mins to fix
            src/examples/repeater_hub/repeater-hub_spec.rb on lines 70..82

            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

            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 ) }
            
            
            Severity: Minor
            Found in src/examples/repeater_hub/repeater-hub_spec.rb and 1 other location - About 45 mins to fix
            src/examples/repeater_hub/repeater-hub_spec.rb on lines 114..126

            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

            Further Reading

            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
            Severity: Minor
            Found in ruby/trema/cli.rb - About 45 mins to fix

              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 |
              Severity: Minor
              Found in ruby/trema/flow.rb - About 45 mins to fix

              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
              Severity: Minor
              Found in src/examples/simple_router/router-utils.rb - About 35 mins to fix

                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 |
                Severity: Minor
                Found in ruby/trema/accessor.rb - About 35 mins to fix

                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
                Severity: Minor
                Found in ruby/trema/command/run.rb - About 35 mins to fix

                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

                Severity
                Category
                Status
                Source
                Language