crowbar/crowbar-core

View on GitHub
chef/cookbooks/barclamp/libraries/ip.rb

Summary

Maintainability
D
1 day
Test Coverage

Method parse_address has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
Open

    def self.parse_address(a)
      addr,subnet = a.split("/",2)
      unless addr.kind_of?(String) && (addr =~ /^[0-9a-f:]+$/) &&
          (! addr.include?(":::")) && addr.length >= 2
        raise ArgumentError.new("#{addr} is not a valid IP6 address")
Severity: Minor
Found in chef/cookbooks/barclamp/libraries/ip.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

File ip.rb has 274 lines of code (exceeds 250 allowed). Consider refactoring.
Open

class IP
  include Comparable
  protected

  # Translate a CIDR subnet specification into a bitfield
Severity: Minor
Found in chef/cookbooks/barclamp/libraries/ip.rb - About 2 hrs to fix

Method canonical_address has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
Open

    def canonical_address
      f = 0
      in_run = false
      runs = Array.new
      a = self.to_a
Severity: Minor
Found in chef/cookbooks/barclamp/libraries/ip.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 14 (exceeds 5 allowed). Consider refactoring.
Open

  def initialize(*a)
    if a[0].kind_of?(String)
      self.address = a[0]
    elsif a[0].kind_of?(Integer)
      unless self.class::RANGE.include?(a[0].abs)
Severity: Minor
Found in chef/cookbooks/barclamp/libraries/ip.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_address has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

    def self.parse_address(a)
      addr,subnet = a.split("/",2)
      if addr.kind_of?(String) && (addr =~ MATCH_RE)
        addr = addr.split(".").map do |i|
          i = i.to_i
Severity: Minor
Found in chef/cookbooks/barclamp/libraries/ip.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_address has 37 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def self.parse_address(a)
      addr,subnet = a.split("/",2)
      unless addr.kind_of?(String) && (addr =~ /^[0-9a-f:]+$/) &&
          (! addr.include?(":::")) && addr.length >= 2
        raise ArgumentError.new("#{addr} is not a valid IP6 address")
Severity: Minor
Found in chef/cookbooks/barclamp/libraries/ip.rb - About 1 hr to fix

Method address= has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

  def address=(address)
    if address.kind_of?(String)
      @address,s = self.class.parse_address(address)
      if s
        @subnet = s.to_i
Severity: Minor
Found in chef/cookbooks/barclamp/libraries/ip.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

There are no issues that match your filters.

Category
Status