fluent/fluentd

View on GitHub

Showing 664 of 664 total issues

Method on_record has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

    def on_record(time, record)
      tag = extract_tag_from_record(record)
      tag = @added_prefix_string + tag if tag && @add_prefix
      tag ||= @tag
      time ||= extract_time_from_record(record) || Fluent::EventTime.now
Severity: Minor
Found in lib/fluent/plugin/out_exec_filter.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 parser_create has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

      def parser_create(usage: '', type: nil, conf: nil, default_type: nil)
        parser = @_parsers[usage]
        return parser if parser && !type && !conf

        type = if type
Severity: Minor
Found in lib/fluent/plugin_helper/parser.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 formatter_create has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

      def formatter_create(usage: '', type: nil, conf: nil, default_type: nil)
        formatter = @_formatters[usage]
        return formatter if formatter && !type && !conf

        type = if type
Severity: Minor
Found in lib/fluent/plugin_helper/formatter.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_multilines has 35 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def parse_multilines(lines, tail_watcher)
      lb = tail_watcher.line_buffer_timer_flusher.line_buffer
      es = Fluent::MultiEventStream.new
      if @parser.has_firstline?
        tail_watcher.line_buffer_timer_flusher.reset_timer
Severity: Minor
Found in lib/fluent/plugin/in_tail.rb - About 1 hr to fix

    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 configure has 35 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          def configure(conf)
            compat_parameters_convert(conf, :parser)
            parser_config = conf.elements('parse').first
            unless parser_config
              raise Fluent::ConfigError, "<parse> section is required."
      Severity: Minor
      Found in lib/fluent/plugin/in_tcp.rb - About 1 hr to fix

        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

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

                  (1..REGEXP_MAX_NUM).each do |i|
                    next unless conf["regexp#{i}"]
                    key, regexp = conf["regexp#{i}"].split(/ /, 2)
                    raise Fluent::ConfigError, "regexp#{i} does not contain 2 parameters" unless regexp
                    raise Fluent::ConfigError, "regexp#{i} contains a duplicated key, #{key}" if regexp_and_conditions[key]
            Severity: Major
            Found in lib/fluent/plugin/filter_grep.rb and 1 other location - About 1 hr to fix
            lib/fluent/plugin/filter_grep.rb on lines 104..109

            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 59.

            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

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

                  (1..REGEXP_MAX_NUM).each do |i|
                    next unless conf["exclude#{i}"]
                    key, exclude = conf["exclude#{i}"].split(/ /, 2)
                    raise Fluent::ConfigError, "exclude#{i} does not contain 2 parameters" unless exclude
                    raise Fluent::ConfigError, "exclude#{i} contains a duplicated key, #{key}" if exclude_or_conditions[key]
            Severity: Major
            Found in lib/fluent/plugin/filter_grep.rb and 1 other location - About 1 hr to fix
            lib/fluent/plugin/filter_grep.rb on lines 96..101

            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 59.

            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

            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
                                Severity
                                Category
                                Status
                                Source
                                Language