fluent/fluentd

View on GitHub

Showing 664 of 664 total issues

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

      def filter_stream(tag, es)
        new_es = MultiEventStream.new
        if @has_filter_with_time
          es.each do |time, record|
            begin
Severity: Minor
Found in lib/fluent/plugin/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 before_run has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
Open

    def before_run
      @fluentd_conf = config[:fluentd_conf]
      @rpc_endpoint = nil
      @rpc_server = nil
      @counter = nil
Severity: Minor
Found in lib/fluent/supervisor.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_dot_array_op has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
Open

        def self.parse_dot_array_op(key, param)
          start = key.index('[')
          result = if start.zero?
                     []
                   else
Severity: Minor
Found in lib/fluent/plugin_helper/record_accessor.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 section_build has a Cognitive Complexity of 15 (exceeds 5 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

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

      def write_once(metadata, data, format: nil, size: nil, &block)
        return if data.empty?

        stored = false
        adding_bytesize = nil
Severity: Minor
Found in lib/fluent/plugin/buffer.rb - About 1 hr to fix

    Method flush_thread_run has 47 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

          def flush_thread_run(state)
            flush_thread_interval = @buffer_config.flush_thread_interval
    
            state.next_clock = Fluent::Clock.now + flush_thread_interval
    
    
    Severity: Minor
    Found in lib/fluent/plugin/output.rb - About 1 hr to fix

      Method on_rotate has 46 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

            def on_rotate(stat)
              if @io_handler.nil?
                if stat
                  # first time
                  fsize = stat.size
      Severity: Minor
      Found in lib/fluent/plugin/in_tail.rb - About 1 hr to fix

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

              config_section :service, param_name: :service_configs do
                desc 'The IP address or host name of the server.'
                config_param :host, :string
                desc 'The name of the server. Used for logging and certificate verification in TLS transport (when host is address).'
                config_param :name, :string, default: nil
        Severity: Major
        Found in lib/fluent/plugin/sd_static.rb and 1 other location - About 1 hr to fix
        lib/fluent/plugin/out_forward.rb on lines 130..147

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

        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

            config_section :server, param_name: :servers do
              desc "The IP address or host name of the server."
              config_param :host, :string
              desc "The name of the server. Used for logging and certificate verification in TLS transport (when host is address)."
              config_param :name, :string, default: nil
        Severity: Major
        Found in lib/fluent/plugin/out_forward.rb and 1 other location - About 1 hr to fix
        lib/fluent/plugin/sd_static.rb on lines 26..43

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

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

              def resume
                stage = {}
                queue = []
                exist_broken_file = false
        
        
        Severity: Minor
        Found in lib/fluent/plugin/buf_file.rb - About 1 hr to fix

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

                def configure(conf)
                  super
          
                  @variable_store = Fluent::VariableStore.fetch_or_build(:buf_file)
          
          
          Severity: Minor
          Found in lib/fluent/plugin/buf_file.rb - About 1 hr to fix

            Method get_monitor_info has 45 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                def get_monitor_info(pe, opts={})
                  obj = {}
            
                  # Common plugin information
                  obj['plugin_id'] = pe.plugin_id
            Severity: Minor
            Found in lib/fluent/plugin/in_monitor_agent.rb - About 1 hr to fix

              Method formatter has 45 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  def self.formatter(timezone = nil, format = nil)
                    if timezone.nil?
                      return nil
                    end
              
              
              Severity: Minor
              Found in lib/fluent/timezone.rb - About 1 hr to fix

                Method search has 45 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    def search(type)
                      # search from additional plugin directories
                      if @dir_search_prefix
                        path = "#{@dir_search_prefix}#{type}"
                        files = @paths.filter_map { |lp|
                Severity: Minor
                Found in lib/fluent/registry.rb - About 1 hr to fix

                  Method dump_section_markdown has 44 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

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

                    Method configure has 44 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 rebuild_weight_array has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
                      Open

                            def rebuild_weight_array(nodes)
                              standby_nodes, regular_nodes = nodes.select { |e| e.weight > 0 }.partition {|n|
                                n.standby?
                              }
                      
                      
                      Severity: Minor
                      Found in lib/fluent/plugin/out_forward/load_balancer.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 read_ack_from_sock has a Cognitive Complexity of 14 (exceeds 5 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

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

                      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 check_ping has a Cognitive Complexity of 14 (exceeds 5 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

                      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