fluent/fluentd

View on GitHub

Showing 577 of 664 total issues

Method dump_stacktrace has 35 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def dump_stacktrace(type, backtrace, level)
      return if @level > level

      time = Time.now

Severity: Minor
Found in lib/fluent/log.rb - About 1 hr to fix

    Method thread_create has 35 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

          def thread_create(title)
            raise ArgumentError, "BUG: title must be a symbol" unless title.is_a? Symbol
            raise ArgumentError, "BUG: callback not specified" unless block_given?
            m = Mutex.new
            m.lock
    Severity: Minor
    Found in lib/fluent/plugin_helper/thread.rb - About 1 hr to fix

      Method initialize has 11 arguments (exceeds 4 allowed). Consider refactoring.
      Open

              def initialize(title, wait, timeout, forever, max_steps, randomize, randomize_width, backoff_base, max_interval, secondary, secondary_threshold)
      Severity: Major
      Found in lib/fluent/plugin_helper/retry_state.rb - About 1 hr to fix

        Method tls_verify_result_name has 34 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

              def self.tls_verify_result_name(code)
                case code
                when OpenSSL::X509::V_OK then 'V_OK'
                when OpenSSL::X509::V_ERR_AKID_SKID_MISMATCH then 'V_ERR_AKID_SKID_MISMATCH'
                when OpenSSL::X509::V_ERR_APPLICATION_VERIFICATION then 'V_ERR_APPLICATION_VERIFICATION'
        Severity: Minor
        Found in lib/fluent/plugin_helper/socket.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 start_tcp_server has 33 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                def start_tcp_server(tls: false)
                  octet_count_frame = @frame_type == :octet_count
            
                  delimiter = octet_count_frame ? " " : @delimiter
                  delimiter_size = delimiter.size
            Severity: Minor
            Found in lib/fluent/plugin/in_syslog.rb - About 1 hr to fix

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

                    def parse(text)
                      m = REGEXP.match(text)
                      unless m
                        yield nil, nil
                        return
              Severity: Minor
              Found in lib/fluent/plugin/parser_apache2.rb - About 1 hr to fix

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

                  def prepare_option_parser
                    @parser = OptionParser.new
                    @parser.version = Fluent::VERSION
                    @parser.banner = <<BANNER
                Usage: #{$0} [options] <type> <name>
                Severity: Minor
                Found in lib/fluent/command/plugin_config_formatter.rb - About 1 hr to fix

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

                        def parse_rfc5424_regex(text, &block)
                          idx = 0
                          record = {}
                  
                          if @with_priority
                  Severity: Minor
                  Found in lib/fluent/plugin/parser_syslog.rb - About 1 hr to fix

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

                          def parse!(allow_include, elem_name = nil, attrs = {}, elems = [])
                            while line = @iterator.next
                              line.force_encoding('UTF-8')
                              @i += 1
                              line.lstrip!
                    Severity: Minor
                    Found in lib/fluent/config/parser.rb - About 1 hr to fix

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

                            def compat_parameters_parser(conf)
                              return unless conf.elements('parse').empty?
                              return if PARSER_PARAMS.keys.all?{|k| !conf.has_key?(k) }
                      
                              # TODO: warn obsolete parameters if these are deprecated
                      Severity: Minor
                      Found in lib/fluent/plugin_helper/compat_parameters.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 install_main_process_signal_handlers has 32 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                              def install_main_process_signal_handlers
                                # Fluentd worker process (worker of ServerEngine) don't use code in serverengine to set signal handlers,
                                # because it does almost nothing.
                                # This method is the only method to set signal handlers in Fluentd worker process.
                          
                          
                          Severity: Minor
                          Found in lib/fluent/supervisor.rb - About 1 hr to fix

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

                                  def server_create_connection(title, port, proto: nil, bind: '0.0.0.0', shared: true, backlog: nil, tls_options: nil, **socket_options, &block)
                                    proto ||= (@transport_config && @transport_config.protocol == :tls) ? :tls : :tcp
                            
                                    raise ArgumentError, "BUG: title must be a symbol" unless title && title.is_a?(Symbol)
                                    raise ArgumentError, "BUG: port must be an integer" unless port && port.is_a?(Integer)
                            Severity: Minor
                            Found in lib/fluent/plugin_helper/server.rb - About 1 hr to fix

                              Method parse has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                              Open

                                    def parse(text)
                                      parsed_json = @load_proc.call(text)
                              
                                      if parsed_json.is_a?(Hash)
                                        time, record = parse_one_record(parsed_json)
                              Severity: Minor
                              Found in lib/fluent/plugin/parser_json.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 setup_watcher has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                              Open

                                  def setup_watcher(target_info, pe)
                                    line_buffer_timer_flusher = @multiline_mode ? TailWatcher::LineBufferTimerFlusher.new(log, @multiline_flush_interval, &method(:flush_buffer)) : nil
                                    read_from_head = !@startup || @read_from_head
                                    tw = TailWatcher.new(target_info, pe, log, read_from_head, @follow_inodes, method(:update_watcher), line_buffer_timer_flusher, method(:io_handler), @metrics)
                              
                              
                              Severity: Minor
                              Found in lib/fluent/plugin/in_tail.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 connect has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                              Open

                                    def connect(host:, port:, hostname:, ack: nil, &block)
                                      if @socket_cache
                                        return connect_keepalive(host: host, port: port, hostname: hostname, ack: ack, &block)
                                      end
                              
                              
                              Severity: Minor
                              Found in lib/fluent/plugin/out_forward/connection_manager.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 run has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                              Open

                                  def run
                                    batch_num    = (@rate / BIN_NUM).to_i
                                    residual_num = (@rate % BIN_NUM)
                                    while thread_current_running?
                                      current_time = Time.now.to_i
                              Severity: Minor
                              Found in lib/fluent/plugin/in_sample.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 parse_plain has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                              Open

                                    def parse_plain(re, time, text, idx, record, capture_list, &block)
                                      m = re.match(text, idx)
                                      if m.nil?
                                        yield nil, nil
                                        return
                              Severity: Minor
                              Found in lib/fluent/plugin/parser_syslog.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 try_rollback_write has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                              Open

                                    def try_rollback_write
                                      @dequeued_chunks_mutex.synchronize do
                                        while @dequeued_chunks.first && @dequeued_chunks.first.expired?
                                          info = @dequeued_chunks.shift
                                          if @buffer.takeback_chunk(info.chunk_id)
                              Severity: Minor
                              Found in lib/fluent/plugin/output.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

                              Severity
                              Category
                              Status
                              Source
                              Language