fluent/fluentd

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

Summary

Maintainability
F
4 days
Test Coverage

File out_forward.rb has 649 lines of code (exceeds 250 allowed). Consider refactoring.
Open

require 'fluent/output'
require 'fluent/config/error'
require 'fluent/clock'
require 'fluent/tls'
require 'base64'
Severity: Major
Found in lib/fluent/plugin/out_forward.rb - About 1 day to fix

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

        def configure(conf)
          compat_parameters_convert(conf, :buffer, default_chunk_key: 'tag')
    
          super
    
    
    Severity: Minor
    Found in lib/fluent/plugin/out_forward.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 configure has 80 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        def configure(conf)
          compat_parameters_convert(conf, :buffer, default_chunk_key: 'tag')
    
          super
    
    
    Severity: Major
    Found in lib/fluent/plugin/out_forward.rb - About 3 hrs to fix

      Class ForwardOutput has 24 methods (exceeds 20 allowed). Consider refactoring.
      Open

        class ForwardOutput < Output
          Fluent::Plugin.register_output('forward', self)
      
          helpers :socket, :server, :timer, :thread, :compat_parameters, :service_discovery
      
      
      Severity: Minor
      Found in lib/fluent/plugin/out_forward.rb - About 2 hrs to fix

        Method establish_connection has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
        Open

              def establish_connection(sock, ri)
                while ri.state != :established
                  begin
                    # TODO: On Ruby 2.2 or earlier, read_nonblock doesn't work expectedly.
                    # We need rewrite around here using new socket/server plugin helper.
        Severity: Minor
        Found in lib/fluent/plugin/out_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 create_transfer_socket has 35 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            def create_transfer_socket(host, port, hostname, &block)
              case @transport
              when :tls
                socket_create_tls(
                  host, port,
        Severity: Minor
        Found in lib/fluent/plugin/out_forward.rb - About 1 hr to fix

          Method establish_connection has 32 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

                def establish_connection(sock, ri)
                  while ri.state != :established
                    begin
                      # TODO: On Ruby 2.2 or earlier, read_nonblock doesn't work expectedly.
                      # We need rewrite around here using new socket/server plugin helper.
          Severity: Minor
          Found in lib/fluent/plugin/out_forward.rb - About 1 hr to fix

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

                  def initialize(sender, server, failure:, connection_manager:, ack_handler:)
                    @sender = sender
                    @log = sender.log
                    @compress = sender.compress
                    @server = server
            Severity: Minor
            Found in lib/fluent/plugin/out_forward.rb - About 1 hr to fix

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

                  def start
                    super
              
                    unless @heartbeat_type == :none
                      if @heartbeat_type == :udp
              Severity: Minor
              Found in lib/fluent/plugin/out_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 ack_check has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
              Open

                  def ack_check(select_interval)
                    @ack_handler.collect_response(select_interval) do |chunk_id, node, sock, result|
                      @connection_manager.close(sock)
              
                      case result
              Severity: Minor
              Found in lib/fluent/plugin/out_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

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

                    def tick
                      now = Time.now.to_f
                      unless available?
                        if @failure.hard_timeout?(now)
                          @failure.clear
              Severity: Minor
              Found in lib/fluent/plugin/out_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

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

                  def on_heartbeat_timer
                    need_rebuild = false
                    service_discovery_services.each do |n|
                      begin
                        log.trace "sending heartbeat", host: n.host, port: n.port, heartbeat_type: @heartbeat_type
              Severity: Minor
              Found in lib/fluent/plugin/out_forward.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

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

                    def send_heartbeat
                      begin
                        dest_addr = resolved_host
                        @resolved_once = true
                      rescue ::SocketError => e
              Severity: Minor
              Found in lib/fluent/plugin/out_forward.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

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

                    def initialize(sender, server, failure:, connection_manager:, ack_handler:)
                      @sender = sender
                      @log = sender.log
                      @compress = sender.compress
                      @server = server
              Severity: Minor
              Found in lib/fluent/plugin/out_forward.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

              Similar blocks of code found in 2 locations. Consider refactoring.
              Open

                  config_section :server, param_name: :servers do
                    desc "The IP address or host name of the server."
                    config_param :host, :string
                    desc "The name of the server. Used for logging and certificate verification in TLS transport (when host is address)."
                    config_param :name, :string, default: nil
              Severity: Major
              Found in lib/fluent/plugin/out_forward.rb and 1 other location - About 1 hr to fix
              lib/fluent/plugin/sd_static.rb on lines 26..43

              Duplicated Code

              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

              Tuning

              This issue has a mass of 72.

              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

              Refactorings

              Further Reading

              There are no issues that match your filters.

              Category
              Status