fluent/fluentd

View on GitHub
lib/fluent/plugin/out_forward/ack_handler.rb

Summary

Maintainability
B
6 hrs
Test Coverage

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

      def read_ack_from_sock(sock)
        begin
          raw_data = sock.instance_of?(Fluent::PluginHelper::Socket::WrappedSocket::TLS) ? sock.readpartial(@read_length) : sock.recv(@read_length)
        rescue Errno::ECONNRESET, EOFError # ECONNRESET for #recv, #EOFError for #readpartial
          raw_data = ''
Severity: Minor
Found in lib/fluent/plugin/out_forward/ack_handler.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 collect_response has 39 lines of code (exceeds 25 allowed). Consider refactoring.
Open

      def collect_response(select_interval)
        now = Fluent::Clock.now
        sockets = []
        results = []
        begin
Severity: Minor
Found in lib/fluent/plugin/out_forward/ack_handler.rb - About 1 hr to fix

    Method read_ack_from_sock has 33 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

          def read_ack_from_sock(sock)
            begin
              raw_data = sock.instance_of?(Fluent::PluginHelper::Socket::WrappedSocket::TLS) ? sock.readpartial(@read_length) : sock.recv(@read_length)
            rescue Errno::ECONNRESET, EOFError # ECONNRESET for #recv, #EOFError for #readpartial
              raw_data = ''
    Severity: Minor
    Found in lib/fluent/plugin/out_forward/ack_handler.rb - About 1 hr to fix

      Method collect_response has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
      Open

            def collect_response(select_interval)
              now = Fluent::Clock.now
              sockets = []
              results = []
              begin
      Severity: Minor
      Found in lib/fluent/plugin/out_forward/ack_handler.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

      Avoid too many return statements within this method.
      Open

                return info, Result::SUCCESS
      Severity: Major
      Found in lib/fluent/plugin/out_forward/ack_handler.rb - About 30 mins to fix

        There are no issues that match your filters.

        Category
        Status