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

Similar blocks of code found in 2 locations. Consider refactoring.
Open

module Pio
  module OpenFlow13
    # NXAST_STACK_POP action
    class NiciraStackPop < OpenFlow::NiciraAction
      nicira_action_header action_type: 0xffff,
Severity: Major
Found in lib/pio/open_flow13/nicira_stack_pop.rb and 1 other location - About 2 hrs to fix
lib/pio/open_flow13/nicira_stack_push.rb on lines 6..47

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

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

module Pio
  module OpenFlow13
    # NXAST_STACK_PUSH action
    class NiciraStackPush < OpenFlow::NiciraAction
      nicira_action_header action_type: 0xffff,
Severity: Major
Found in lib/pio/open_flow13/nicira_stack_push.rb and 1 other location - About 2 hrs to fix
lib/pio/open_flow13/nicira_stack_pop.rb on lines 6..47

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

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

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

Similar blocks of code found in 2 locations. Consider refactoring.
Open

  0x11, 0x22, 0x33, 0x44, 0x55, 0x66, # destination_mac
  0x66, 0x55, 0x44, 0x33, 0x22, 0x11, # source_mac
  0x08, 0x00, # ether_type
  0b0100_0101, # ip_version, ip_header_length
  0x00, # ip_type_of_service
Severity: Major
Found in fixtures/icmp/icmp_reply.rb and 1 other location - About 1 hr to fix
fixtures/icmp/icmp_request.rb on lines 4..22

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

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

  0x11, 0x22, 0x33, 0x44, 0x55, 0x66, # destination_mac
  0x66, 0x55, 0x44, 0x33, 0x22, 0x11, # source_mac
  0x08, 0x00, # ether_type
  0b0100_0101, # ip_version, ip_header_length
  0x00, # ip_type_of_service
Severity: Major
Found in fixtures/icmp/icmp_request.rb and 1 other location - About 1 hr to fix
fixtures/icmp/icmp_reply.rb on lines 4..22

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

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

Similar blocks of code found in 5 locations. Consider refactoring.
Open

module Pio
  module OpenFlow13
    # Set a header field.
    class SetSourceMacAddress < OpenFlow::Action
      action_header action_type: 25, action_length: 16
Severity: Major
Found in lib/pio/open_flow13/set_source_mac_address.rb and 4 other locations - About 1 hr to fix
lib/pio/open_flow13/set_arp_operation.rb on lines 6..22
lib/pio/open_flow13/set_arp_sender_hardware_address.rb on lines 6..22
lib/pio/open_flow13/set_arp_sender_protocol_address.rb on lines 6..22
lib/pio/open_flow13/set_destination_mac_address.rb on lines 6..22

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

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 5 locations. Consider refactoring.
Open

module Pio
  module OpenFlow13
    # Set ARP sender hardware address field
    class SetArpSenderHardwareAddress < OpenFlow::Action
      action_header action_type: 25, action_length: 16
Severity: Major
Found in lib/pio/open_flow13/set_arp_sender_hardware_address.rb and 4 other locations - About 1 hr to fix
lib/pio/open_flow13/set_arp_operation.rb on lines 6..22
lib/pio/open_flow13/set_arp_sender_protocol_address.rb on lines 6..22
lib/pio/open_flow13/set_destination_mac_address.rb on lines 6..22
lib/pio/open_flow13/set_source_mac_address.rb on lines 6..22

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

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 5 locations. Consider refactoring.
Open

module Pio
  module OpenFlow13
    # Set ARP sender protocol address field
    class SetArpSenderProtocolAddress < OpenFlow::Action
      action_header action_type: 25, action_length: 16
Severity: Major
Found in lib/pio/open_flow13/set_arp_sender_protocol_address.rb and 4 other locations - About 1 hr to fix
lib/pio/open_flow13/set_arp_operation.rb on lines 6..22
lib/pio/open_flow13/set_arp_sender_hardware_address.rb on lines 6..22
lib/pio/open_flow13/set_destination_mac_address.rb on lines 6..22
lib/pio/open_flow13/set_source_mac_address.rb on lines 6..22

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

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 5 locations. Consider refactoring.
Open

module Pio
  module OpenFlow13
    # Set ARP operation field
    class SetArpOperation < OpenFlow::Action
      action_header action_type: 25, action_length: 16
Severity: Major
Found in lib/pio/open_flow13/set_arp_operation.rb and 4 other locations - About 1 hr to fix
lib/pio/open_flow13/set_arp_sender_hardware_address.rb on lines 6..22
lib/pio/open_flow13/set_arp_sender_protocol_address.rb on lines 6..22
lib/pio/open_flow13/set_destination_mac_address.rb on lines 6..22
lib/pio/open_flow13/set_source_mac_address.rb on lines 6..22

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

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

Severity
Category
Status
Source
Language