fluent/fluentd

View on GitHub

Showing 664 of 664 total issues

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

        def initialize(title, wait, timeout, forever, max_steps, randomize, randomize_width, secondary, secondary_threshold)
          @title = title

          @start = current_time
          @steps = 0
Severity: Minor
Found in lib/fluent/plugin_helper/retry_state.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 event_emitter_router has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

      def event_emitter_router(label_name)
        if label_name
          if label_name == "@ROOT"
            Engine.root_agent.event_router
          else
Severity: Minor
Found in lib/fluent/plugin_helper/event_emitter.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 option_value_type! has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

      def option_value_type!(name, opts, key, klass=nil, type: nil)
        if opts.has_key?(key)
          if klass && !opts[key].is_a?(klass)
            raise ArgumentError, "#{name}: #{key} must be a #{klass}, but #{opts[key].class}"
          end
Severity: Minor
Found in lib/fluent/config/configure_proxy.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 reload_config has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

    def reload_config(conf, supervisor: false)
      @root_agent_mutex.synchronize do
        # configure first to reduce down time while restarting
        new_agent = RootAgent.new(log: log, system_config: @system_config)
        ret = Fluent::StaticConfigAnalysis.call(conf, workers: system_config.workers)
Severity: Minor
Found in lib/fluent/engine.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 eval_include has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

      def eval_include(attrs, elems, uri)
        # replace space(s)(' ') with '+' to prevent invalid uri due to space(s).
        # See: https://github.com/fluent/fluentd/pull/2780#issuecomment-576081212
        u = URI.parse(uri.tr(' ', '+'))
        if u.scheme == 'file' || (!u.scheme.nil? && u.scheme.length == 1) || u.path == uri.tr(' ', '+') # file path
Severity: Minor
Found in lib/fluent/config/v1_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 dump_section_txt has 31 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def dump_section_txt(base_section, level = 0)
    dumped = ""
    indent = " " * level
    if base_section[:section]
      sections = []
Severity: Minor
Found in lib/fluent/command/plugin_config_formatter.rb - About 1 hr to fix

    Method cmp_variables has 31 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

            def cmp_variables(v1, v2)
              if v1.nil? && v2.nil?
                return 0
              elsif v1.nil? # v2 is non-nil
                return -1
    Severity: Minor
    Found in lib/fluent/plugin/buffer.rb - About 1 hr to fix

      Method configure has 31 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          def configure(supervisor: false)
            setup_global_logger(supervisor: supervisor)
      
            if @show_plugin_config
              show_plugin_config
      Severity: Minor
      Found in lib/fluent/supervisor.rb - About 1 hr to fix

        Method cert_option_create_context has 31 lines of code (exceeds 25 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 1 hr to fix

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

                  if config_style == :v0
                    buf_params = {
                      "flush_mode" => "interval",
                      "retry_type" => "exponential_backoff",
                    }
          Severity: Major
          Found in lib/fluent/compat/output.rb and 1 other location - About 1 hr to fix
          lib/fluent/compat/output.rb on lines 475..491

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

          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

                    i = cursor - 1
                    sq = false
                    @space_count_rfc5424.times do
                      while text[i + 1] == SPLIT_CHAR
                        sq = true
          Severity: Major
          Found in lib/fluent/plugin/parser_syslog.rb and 1 other location - About 1 hr to fix
          lib/fluent/plugin/parser_syslog.rb on lines 307..318

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

          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

                  if config_style == :v0
                    buf_params = {
                      "flush_mode" => "interval",
                      "retry_type" => "exponential_backoff",
                    }
          Severity: Major
          Found in lib/fluent/compat/output.rb and 1 other location - About 1 hr to fix
          lib/fluent/compat/output.rb on lines 256..272

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

          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

                    i = cursor - 1
                    sq = false
                    @space_count_rfc3164.times do
                      while text[i + 1] == SPLIT_CHAR
                        sq = true
          Severity: Major
          Found in lib/fluent/plugin/parser_syslog.rb and 1 other location - About 1 hr to fix
          lib/fluent/plugin/parser_syslog.rb on lines 399..410

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

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

              def try_write(chunk)
                tmpfile = nil
                prog = if chunk.respond_to?(:path)
                         "#{@command} #{chunk.path}"
                       else
          Severity: Minor
          Found in lib/fluent/plugin/out_exec.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 build has 30 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  def self.build(root_agent)
                    log_event_router = nil
              
                    begin
                      log_event_agent = root_agent.find_label(Fluent::Log::LOG_EVENT_LABEL)
              Severity: Minor
              Found in lib/fluent/fluent_log_event_router.rb - About 1 hr to fix

                Method parser_create has 30 lines of code (exceeds 25 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

                  Method formatter_create has 30 lines of code (exceeds 25 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

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

                            def section_build(name, config, indent: 0, arg: nil)
                              sb = SectionBodyBuilder.new(indent + @base_indent)
                    
                              if (v = config.delete('$type'))
                                sb.add_line('@type', v)
                    Severity: Minor
                    Found in lib/fluent/config/yaml_parser/parser.rb - About 1 hr to fix

                      Method try_connect has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                        def try_connect
                          begin
                            now = Time.now.to_i
                      
                            unless @error_history.empty?
                      Severity: Minor
                      Found in lib/fluent/command/cat.rb - About 1 hr to fix
                        Severity
                        Category
                        Status
                        Source
                        Language