drsound/fault_tolerant_router

View on GitHub
lib/fault_tolerant_router/uplink.rb

Summary

Maintainability
D
2 days
Test Coverage

Method test! has a Cognitive Complexity of 58 (exceeds 5 allowed). Consider refactoring.
Open

  def test!
    #save current state
    @previously_up = @up

    successful_tests = 0
Severity: Minor
Found in lib/fault_tolerant_router/uplink.rb - About 1 day 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 test! has 53 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def test!
    #save current state
    @previously_up = @up

    successful_tests = 0
Severity: Major
Found in lib/fault_tolerant_router/uplink.rb - About 2 hrs to fix

    Method initialize has 44 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      def initialize(config, id)
        @id = id
        @rule_priority_1 = BASE_PRIORITY + @id
        @table = BASE_TABLE + @id
        @fwmark = BASE_FWMARK + @id
    Severity: Minor
    Found in lib/fault_tolerant_router/uplink.rb - About 1 hr to fix

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

        def initialize(config, id)
          @id = id
          @rule_priority_1 = BASE_PRIORITY + @id
          @table = BASE_TABLE + @id
          @fwmark = BASE_FWMARK + @id
      Severity: Minor
      Found in lib/fault_tolerant_router/uplink.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 detect_ppp_ips! has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

        def detect_ppp_ips!
          @previous_ip = @ip
          @previous_gateway = @gateway
          if DEMO
            @ip = ['3.0.0.101', '3.0.0.102', nil].sample
      Severity: Minor
      Found in lib/fault_tolerant_router/uplink.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

      Avoid deeply nested control flow statements.
      Open

                  puts "Uplink #{@description}: avoiding more tests because too many have been failed" if DEBUG
      Severity: Major
      Found in lib/fault_tolerant_router/uplink.rb - About 45 mins to fix

        There are no issues that match your filters.

        Category
        Status