square/rangeclient

View on GitHub
lib/rangeclient.rb

Summary

Maintainability
C
1 day
Test Coverage

Method _simple_compress has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
Open

  def _simple_compress(nodes)
    # dedup nodes
    set = {}
    nodes.each do |node|
      set[node] = true
Severity: Minor
Found in lib/rangeclient.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 _sort_nodes has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
Open

  def _sort_nodes(nodes)
    sorted = nodes.map { |n|
      # decorate-sort-undecorate
      # FIXME can this all be pushed into sort_by?
      n =~ /\A#{@@NodeRegx}\z/
Severity: Minor
Found in lib/rangeclient.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 _simple_compress has 45 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def _simple_compress(nodes)
    # dedup nodes
    set = {}
    nodes.each do |node|
      set[node] = true
Severity: Minor
Found in lib/rangeclient.rb - About 1 hr to fix

    Method compress has 26 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      def compress(nodes)
        domain_tbl = {}
        no_domain_list = []
        nodes.each do |n|
          # If this is a quoted range, just compress it without collapsing
    Severity: Minor
    Found in lib/rangeclient.rb - About 1 hr to fix

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

        def compress(nodes)
          domain_tbl = {}
          no_domain_list = []
          nodes.each do |n|
            # If this is a quoted range, just compress it without collapsing
      Severity: Minor
      Found in lib/rangeclient.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

      Method initialize has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

        def initialize(options = {})
          @host = 'range'
          @host = ENV['RANGE_HOST'] if ENV.has_key?('RANGE_HOST')
          @host = options[:host] if options.member?(:host)
      
      
      Severity: Minor
      Found in lib/rangeclient.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