Showing 18 of 48 total issues

File match.rb has 927 lines of code (exceeds 250 allowed). Consider refactoring.
Open

require 'bindata'
require 'pio/open_flow/flow_match'
require 'pio/type/ip_address'
require 'pio/type/ipv6_address'
require 'pio/type/mac_address'
Severity: Major
Found in lib/pio/open_flow13/match.rb - About 2 days to fix

Method choose_tlv_value has a Cognitive Complexity of 37 (exceeds 5 allowed). Consider refactoring.
Open

          def choose_tlv_value
            case oxm_field
            when InPort::OXM_FIELD
              InPort
            when Metadata::OXM_FIELD
Severity: Minor
Found in lib/pio/open_flow13/match.rb - About 5 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 to_ruby has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring.
Open

    def to_ruby
      pack_template = ''
      bytes = ''
      bit = false
      bit_names = []
Severity: Minor
Found in lib/pio/ruby_dumper.rb - About 4 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 choose_tlv_value has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
Open

          def choose_tlv_value
            case oxm_field
            when Reg0::OXM_FIELD
              masked? ? MaskedReg0 : Reg0
            when Reg1::OXM_FIELD
Severity: Minor
Found in lib/pio/open_flow13/match.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

Method choose_tlv_value has 80 lines of code (exceeds 25 allowed). Consider refactoring.
Open

          def choose_tlv_value
            case oxm_field
            when InPort::OXM_FIELD
              InPort
            when Metadata::OXM_FIELD
Severity: Major
Found in lib/pio/open_flow13/match.rb - About 3 hrs to fix

Class Dhcp has 22 methods (exceeds 20 allowed). Consider refactoring.
Open

  class Dhcp
    # Dhcp Field Read Methods.
    module FieldUtil
      def message_type
        get_tlv_field(53)
Severity: Minor
Found in lib/pio/dhcp/field_util.rb - About 2 hrs to fix

Method to_ruby has 50 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def to_ruby
      pack_template = ''
      bytes = ''
      bit = false
      bit_names = []
Severity: Minor
Found in lib/pio/ruby_dumper.rb - About 2 hrs to fix

Method choose_tlv_value has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

          def choose_tlv_value
            case oxm_field
            when PacketReg0::OXM_FIELD
              masked? ? MaskedPacketReg0 : PacketReg0
            when PacketReg1::OXM_FIELD
Severity: Minor
Found in lib/pio/open_flow13/match.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 initialize has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

        def initialize(user_attrs)
          @match_fields = []

          %i[in_port ether_type ip_protocol vlan_vid vlan_pcp
             ip_dscp ip_ecn tcp_source_port tcp_destination_port
Severity: Minor
Found in lib/pio/open_flow13/match.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 initialize has 28 lines of code (exceeds 25 allowed). Consider refactoring.
Open

        def initialize(user_attrs)
          @match_fields = []

          %i[in_port ether_type ip_protocol vlan_vid vlan_pcp
             ip_dscp ip_ecn tcp_source_port tcp_destination_port
Severity: Minor
Found in lib/pio/open_flow13/match.rb - About 1 hr to fix

Method set has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

        def set(params)
          self.flags = params.inject(0) do |memo, (key, val)|
            memo |
              case key
              when :source_ip_address, :destination_ip_address
Severity: Minor
Found in lib/pio/open_flow10/match.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 parse_options has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

    def parse_options(user_options)
      options = {}
      self.class.options.each_pair do |key, attrs|
        if !attrs[:value] && !attrs[:default]
          begin
Severity: Minor
Found in lib/pio/message.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 method_missing has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

        def method_missing(method, *args, &block)
          match_fields.each do |each|
            if each.oxm_class == OpenFlowBasicValue::OXM_CLASS || each.oxm_class == NiciraMatchExtensionValue::OXM_CLASS || each.oxm_class == PacketRegistersValue::OXM_CLASS
              next unless each.class_payload.tlv_value.respond_to?(method)
              return each.class_payload.tlv_value.__send__(
Severity: Minor
Found in lib/pio/open_flow13/match.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 inspect has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    def inspect
      "#<#{self.class.name} " +
        field_names.map do |each|
          next if each == :padding
          next unless __send__("#{each}?")
Severity: Minor
Found in lib/pio/instance_inspector.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 method_missing has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

      def self.method_missing(method, *args, &block)
        begin
          const_get(:Format).__send__ method, *args, &block
        rescue NameError
          klass = Class.new(BinData::Record)
Severity: Minor
Found in lib/pio/open_flow/message.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 initialize has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

      def initialize(user_options = {})
        flags = Wildcards::FLAGS.each_with_object({}) do |each, memo|
          memo[each] = true unless user_options.key?(each)
        end
        Wildcards::NW_FLAGS.each_with_object(flags) do |each, memo|
Severity: Minor
Found in lib/pio/open_flow10/match.rb - About 25 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 get has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

        def get
          BITS.each_with_object(Hash.new(0)) do |(key, bit), memo|
            next if (flags & bit).zero?
            if /(source_ip_address|destination_ip_address)(\d)/=~ key
              memo[$LAST_MATCH_INFO[1].to_sym] |= 1 << $LAST_MATCH_INFO[2].to_i
Severity: Minor
Found in lib/pio/open_flow10/match.rb - About 25 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 set has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

      def set(port)
        if reserved_port_name?(port)
          self.port = reserved_port_number(port)
        else
          port_num = port.to_i
Severity: Minor
Found in lib/pio/open_flow/port.rb - About 25 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