fluent/fluentd

View on GitHub

Showing 664 of 664 total issues

File filter_record_transformer.rb has 255 lines of code (exceeds 250 allowed). Consider refactoring.
Open

require 'socket'
require 'json'
require 'ostruct'

require 'fluent/plugin/filter'
Severity: Minor
Found in lib/fluent/plugin/filter_record_transformer.rb - About 2 hrs to fix

    Method process has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
    Open

        def process(tag, es)
          unless es.repeatable?
            m = Fluent::MultiEventStream.new
            es.each {|time,record|
              m.add(time, record)
    Severity: Minor
    Found in lib/fluent/plugin/out_copy.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 start has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
    Open

        def start
          super
    
          log.info "listening udp socket", bind: @bind, port: @port
          server_create(:in_udp_server, @port, proto: :udp, bind: @bind, resolve_name: !!@source_hostname_key, max_bytes: @message_length_limit, receive_buffer_size: @receive_buffer_size) do |data, sock|
    Severity: Minor
    Found in lib/fluent/plugin/in_udp.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 preprocess_map has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
    Open

          def preprocess_map(value, force_stringify = false)
            new_value = nil
            if value.is_a?(String)
              if @auto_typecast && !force_stringify
                num_placeholders = value.scan('${').size
    Severity: Minor
    Found in lib/fluent/plugin/filter_record_transformer.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 synchronize has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
    Open

          def synchronize(*keys)
            return if keys.empty?
    
            locks = {}
            loop do
    Severity: Minor
    Found in lib/fluent/counter/mutex_hash.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 calc_next_time has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
    Open

            def calc_next_time
              if @forever || !@secondary # primary
                naive = naive_next_time(@steps)
                if @forever
                  naive
    Severity: Minor
    Found in lib/fluent/plugin_helper/retry_state.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 compat_parameters_parser has a Cognitive Complexity of 16 (exceeds 5 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 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 cert_option_create_context has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
    Open

          def cert_option_create_context(version, insecure, ciphers, conf)
            cert, key, extra = cert_option_server_validate!(conf)
    
            ctx = OpenSSL::SSL::SSLContext.new
            # inject OpenSSL::SSL::SSLContext::DEFAULT_PARAMS
    Severity: Minor
    Found in lib/fluent/plugin_helper/cert_option.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 compat_parameters_extract has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
    Open

          def compat_parameters_extract(conf)
            return unless conf.elements('extract').empty?
            return if EXTRACT_PARAMS.keys.all?{|k| !conf.has_key?(k) } && !conf.has_key?('format')
    
            # TODO: warn obsolete parameters if these are deprecated
    Severity: Minor
    Found in lib/fluent/plugin_helper/compat_parameters.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 dump_config_definition has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
    Open

          def dump_config_definition
            dumped_config = {}
            if @argument
              argument_name, _block, options = @argument
              options[:required] = !@defaults.key?(argument_name)
    Severity: Minor
    Found in lib/fluent/config/configure_proxy.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 try_tls_accept has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
    Open

              def try_tls_accept
                return true if @_handler_accepted
    
                begin
                  result = @_handler_socket.accept_nonblock(exception: false) # this method call actually try to do handshake via TLS
    Severity: Minor
    Found in lib/fluent/plugin_helper/server.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 scan_double_quoted_string has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
    Open

          def scan_double_quoted_string
            string = []
            while true
              if skip(/\"/)
                if string.include?(nil)
    Severity: Minor
    Found in lib/fluent/config/literal_parser.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 install_windows_event_handler has 52 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        def install_windows_event_handler
          return unless Fluent.windows?
    
          @pid_signame = "fluentd_#{Process.pid}"
          @signame = config[:signame]
    Severity: Major
    Found in lib/fluent/supervisor.rb - About 2 hrs to fix

      Method child_process_execute_once has 16 arguments (exceeds 4 allowed). Consider refactoring.
      Open

                title, command, arguments, subprocess_name, mode, stderr, env, unsetenv, chdir,
                internal_encoding, external_encoding, scrub, replace_string, wait_timeout, on_exit_callback, &block
      Severity: Major
      Found in lib/fluent/plugin_helper/child_process.rb - About 2 hrs to fix

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

              @or_conditions.each do |or_condition|
                if !or_condition.regexps.empty? && !or_condition.excludes.empty?
                  raise Fluent::ConfigError, "Do not specify both <regexp> and <exclude> in <or>"
                end
                or_condition.regexps.each do |e|
        Severity: Major
        Found in lib/fluent/plugin/filter_grep.rb and 1 other location - About 2 hrs to fix
        lib/fluent/plugin/filter_grep.rb on lines 128..138

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

        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

              @and_conditions.each do |and_condition|
                if !and_condition.regexps.empty? && !and_condition.excludes.empty?
                  raise Fluent::ConfigError, "Do not specify both <regexp> and <exclude> in <and>"
                end
                and_condition.regexps.each do |e|
        Severity: Major
        Found in lib/fluent/plugin/filter_grep.rb and 1 other location - About 2 hrs to fix
        lib/fluent/plugin/filter_grep.rb on lines 142..152

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

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

                def configure(conf)
                  bufconf = CompatOutputUtils.buffer_section(conf)
                  config_style = (bufconf ? :v1 : :v0)
                  if config_style == :v0
                    buf_params = {
          Severity: Minor
          Found in lib/fluent/compat/output.rb - About 1 hr to fix

            Method handle_notify has 48 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                    def handle_notify
                      if limit_bytes_per_second_reached? || group_watcher&.limit_lines_reached?(@path)
                        @metrics.throttled.inc
                        return
                      end
            Severity: Minor
            Found in lib/fluent/plugin/in_tail.rb - About 1 hr to fix

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

                    def parse(text, &block)
                      loop do
                        m =
                          if @unmatched_lines
                            @parser.call(text) do |time, record|
              Severity: Minor
              Found in lib/fluent/plugin/parser_multiline.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