lib/pio/open_flow13/match.rb

Summary

Maintainability
F
4 days
Test Coverage

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 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

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 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

There are no issues that match your filters.

Category
Status