drsound/fault_tolerant_router

View on GitHub

Showing 16 of 16 total issues

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 a Cognitive Complexity of 32 (exceeds 5 allowed). Consider refactoring.
Open

  def test!
    commands = []
    messages = []
    @uplinks.each do |uplink|
      c = uplink.test!
Severity: Minor
Found in lib/fault_tolerant_router/uplinks.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 generate_iptables has 98 lines of code (exceeds 25 allowed). Consider refactoring.
Open

def generate_iptables
  puts <<END
#Integrate with your existing "iptables-save" configuration, or adapt to work
#with any other iptables configuration system

Severity: Major
Found in lib/fault_tolerant_router/generate_iptables.rb - About 3 hrs to fix

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

      def update_default_route!
        #select uplinks that are up and with a specified priority group value
        selected = @uplinks.find_all { |uplink| uplink.up && uplink.priority_group }
        puts "Choosing default route: available uplinks: #{selected.map { |uplink| uplink.description }.join(', ')}" if DEBUG
    
    
    Severity: Minor
    Found in lib/fault_tolerant_router/uplinks.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 monitor has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
    Open

    def monitor
      logger = Logger.new(LOG_FILE, LOG_OLD_FILES, LOG_MAX_SIZE)
      command(UPLINKS.initialize_routing!)
    
      list = UPLINKS.select { |uplink| uplink.default_route }.map { |uplink| uplink.description }.join(', ')
    Severity: Minor
    Found in lib/fault_tolerant_router/monitor.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 generate_config has 69 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    def generate_config(file_path)
      if File.exist?(file_path)
        puts "Configuration file #{file_path} already exists, will not overwrite!"
        exit 1
      end
    Severity: Major
    Found in lib/fault_tolerant_router/generate_config.rb - About 2 hrs to fix

      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 generate_iptables has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
          Open

          def generate_iptables
            puts <<END
          #Integrate with your existing "iptables-save" configuration, or adapt to work
          #with any other iptables configuration system
          
          
          Severity: Minor
          Found in lib/fault_tolerant_router/generate_iptables.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 update_default_route! has 34 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            def update_default_route!
              #select uplinks that are up and with a specified priority group value
              selected = @uplinks.find_all { |uplink| uplink.up && uplink.priority_group }
              puts "Choosing default route: available uplinks: #{selected.map { |uplink| uplink.description }.join(', ')}" if DEBUG
          
          
          Severity: Minor
          Found in lib/fault_tolerant_router/uplinks.rb - About 1 hr to fix

            Method test! has 30 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              def test!
                commands = []
                messages = []
                @uplinks.each do |uplink|
                  c = uplink.test!
            Severity: Minor
            Found in lib/fault_tolerant_router/uplinks.rb - About 1 hr to fix

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

              def monitor
                logger = Logger.new(LOG_FILE, LOG_OLD_FILES, LOG_MAX_SIZE)
                command(UPLINKS.initialize_routing!)
              
                list = UPLINKS.select { |uplink| uplink.default_route }.map { |uplink| uplink.description }.join(', ')
              Severity: Minor
              Found in lib/fault_tolerant_router/monitor.rb - About 1 hr to fix

                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

                  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

                  Method command has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                  Open

                  def command(input)
                    input = [input] if input.is_a?(String)
                    input.each do |c|
                      `#{c}` unless DEMO
                      puts "Command: #{c}" if DEBUG
                  Severity: Minor
                  Found in lib/fault_tolerant_router/monitor.rb - About 25 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

                  Severity
                  Category
                  Status
                  Source
                  Language