fluent/fluentd

View on GitHub

Showing 565 of 654 total issues

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

      def handle_stream_simple(tag, es, enqueue: false)
        if @overrides_emit
          current_emit_count = @emit_count_metrics.get
          size = es.size
          key = data = nil
Severity: Minor
Found in lib/fluent/compat/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

Method build has a Cognitive Complexity of 11 (exceeds 5 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

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 cert_option_create_context has a Cognitive Complexity of 11 (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 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 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 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 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 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 server_create_connection has 31 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 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 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 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 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 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 write has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          def write(chunk)
                            path = extract_placeholders(@path_template, chunk)
                            FileUtils.mkdir_p File.dirname(path), mode: @dir_perm
                      
                            writer = case
                      Severity: Minor
                      Found in lib/fluent/plugin/out_file.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

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

                              def check_ping(message, remote_addr, user_auth_salt, nonce)
                                log.debug "checking ping"
                                # ['PING', self_hostname, shared_key_salt, sha512_hex(shared_key_salt + self_hostname + nonce + shared_key), username || '', sha512_hex(auth_salt + username + password) || '']
                                unless message.size == 6 && message[0] == 'PING'
                                  return false, 'invalid ping message'
                          Severity: Minor
                          Found in lib/fluent/plugin/in_forward.rb - About 1 hr to fix

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

                                def gen_copy_proc
                                  @copy_mode = :shallow if @deep_copy
                            
                                  case @copy_mode
                                  when :no_copy
                            Severity: Minor
                            Found in lib/fluent/plugin/out_copy.rb - About 1 hr to fix
                              Severity
                              Category
                              Status
                              Source
                              Language