fluent/fluentd

View on GitHub
lib/fluent/plugin/in_forward.rb

Summary

Maintainability
F
3 days
Test Coverage

Method on_message has a Cognitive Complexity of 48 (exceeds 5 allowed). Consider refactoring.
Open

    def on_message(msg, chunk_size, conn)
      if msg.nil?
        # for future TCP heartbeat_request
        return
      end
Severity: Minor
Found in lib/fluent/plugin/in_forward.rb - About 7 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 in_forward.rb has 382 lines of code (exceeds 250 allowed). Consider refactoring.
Open

require 'fluent/plugin/input'
require 'fluent/msgpack_factory'
require 'yajl'
require 'digest'
require 'securerandom'
Severity: Minor
Found in lib/fluent/plugin/in_forward.rb - About 5 hrs to fix

    Method configure has a Cognitive Complexity of 32 (exceeds 5 allowed). Consider refactoring.
    Open

        def configure(conf)
          super
    
          if @source_hostname_key
            # TODO: add test
    Severity: Minor
    Found in lib/fluent/plugin/in_forward.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 on_message has 64 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        def on_message(msg, chunk_size, conn)
          if msg.nil?
            # for future TCP heartbeat_request
            return
          end
    Severity: Major
    Found in lib/fluent/plugin/in_forward.rb - About 2 hrs to fix

      Method handle_connection has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
      Open

          def handle_connection(conn)
            send_data = ->(serializer, data){ conn.write serializer.call(data) }
      
            log.trace "connected fluent socket", addr: conn.remote_addr, port: conn.remote_port
            state = :established
      Severity: Minor
      Found in lib/fluent/plugin/in_forward.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 configure has 49 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          def configure(conf)
            super
      
            if @source_hostname_key
              # TODO: add test
      Severity: Minor
      Found in lib/fluent/plugin/in_forward.rb - About 1 hr to fix

        Method check_ping has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
        Open

            def check_ping(message, remote_addr, user_auth_salt, nonce)
              log.debug "checking ping"
              # ['PING', self_hostname, shared_key_salt, sha512_hex(shared_key_salt + self_hostname + nonce + shared_key), username || '', sha512_hex(auth_salt + username + password) || '']
              unless message.size == 6 && message[0] == 'PING'
                return false, 'invalid ping message'
        Severity: Minor
        Found in lib/fluent/plugin/in_forward.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 handle_connection has 40 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            def handle_connection(conn)
              send_data = ->(serializer, data){ conn.write serializer.call(data) }
        
              log.trace "connected fluent socket", addr: conn.remote_addr, port: conn.remote_port
              state = :established
        Severity: Minor
        Found in lib/fluent/plugin/in_forward.rb - About 1 hr to fix

          Method check_ping has 29 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              def check_ping(message, remote_addr, user_auth_salt, nonce)
                log.debug "checking ping"
                # ['PING', self_hostname, shared_key_salt, sha512_hex(shared_key_salt + self_hostname + nonce + shared_key), username || '', sha512_hex(auth_salt + username + password) || '']
                unless message.size == 6 && message[0] == 'PING'
                  return false, 'invalid ping message'
          Severity: Minor
          Found in lib/fluent/plugin/in_forward.rb - About 1 hr to fix

            Method read_messages has 28 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                def read_messages(conn, &block)
                  feeder = nil
                  serializer = nil
                  bytes = 0
                  conn.data do |data|
            Severity: Minor
            Found in lib/fluent/plugin/in_forward.rb - About 1 hr to fix

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

                  def read_messages(conn, &block)
                    feeder = nil
                    serializer = nil
                    bytes = 0
                    conn.data do |data|
              Severity: Minor
              Found in lib/fluent/plugin/in_forward.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 too many return statements within this method.
              Open

                      return if record.nil?
              Severity: Major
              Found in lib/fluent/plugin/in_forward.rb - About 30 mins to fix

                Avoid too many return statements within this method.
                Open

                      return true, shared_key_salt, shared_key
                Severity: Major
                Found in lib/fluent/plugin/in_forward.rb - About 30 mins to fix

                  There are no issues that match your filters.

                  Category
                  Status