fluent/fluentd

View on GitHub

Showing 664 of 664 total issues

Method optimized_filter_stream has 28 lines of code (exceeds 25 allowed). Consider refactoring.
Open

        def optimized_filter_stream(tag, es)
          new_es = MultiEventStream.new
          es.each(unpacker: Fluent::MessagePackFactory.thread_local_msgpack_unpacker) do |time, record|
            filtered_record = record
            filtered_time = time
Severity: Minor
Found in lib/fluent/event_router.rb - About 1 hr to fix

    Method call has 28 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

            def call(request)
              method = request.method
              resp =
                case method
                when HttpServer::Methods::GET
    Severity: Minor
    Found in lib/fluent/plugin_helper/http_server/app.rb - About 1 hr to fix

      Method compat_parameters_inject has 28 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

            def compat_parameters_inject(conf)
              return unless conf.elements('inject').empty?
              return if INJECT_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

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

                  begin
                    file_rename(@chunk, @path, new_chunk_path, ->(new_io) { @chunk = new_io })
                  rescue => e
                    begin
                      file_rename(@chunk, new_chunk_path, @path, ->(new_io) { @chunk = new_io }) if File.exist?(new_chunk_path)
        Severity: Major
        Found in lib/fluent/plugin/buffer/file_single_chunk.rb and 1 other location - About 1 hr to fix
        lib/fluent/plugin/buffer/file_chunk.rb on lines 110..124

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

        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

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

                  begin
                    file_rename(@chunk, @path, new_chunk_path, ->(new_io) { @chunk = new_io })
                  rescue => e
                    begin
                      file_rename(@chunk, new_chunk_path, @path, ->(new_io) { @chunk = new_io }) if File.exist?(new_chunk_path)
        Severity: Major
        Found in lib/fluent/plugin/buffer/file_chunk.rb and 1 other location - About 1 hr to fix
        lib/fluent/plugin/buffer/file_single_chunk.rb on lines 100..114

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

        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 purge_chunk has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
        Open

              def purge_chunk(chunk_id)
                metadata = nil
                synchronize do
                  chunk = @dequeued.delete(chunk_id)
                  return nil unless chunk # purged by other threads
        Severity: Minor
        Found in lib/fluent/plugin/buffer.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 try_connect has a Cognitive Complexity of 10 (exceeds 5 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

        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 update_watcher has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
        Open

            def update_watcher(tail_watcher, pe, new_inode)
              # TODO we should use another callback for this.
              # To supress impact to existing logics, limit the case to `@follow_inodes`.
              # We may not need `@follow_inodes` condition.
              if @follow_inodes && new_inode.nil?
        Severity: Minor
        Found in lib/fluent/plugin/in_tail.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 collect_response has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
        Open

              def collect_response(select_interval)
                now = Fluent::Clock.now
                sockets = []
                results = []
                begin
        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_time has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
        Open

              def parse_time(record)
                if @time_key && record.respond_to?(:has_key?) && record.has_key?(@time_key)
                  src = if @keep_time_key
                          record[@time_key]
                        else
        Severity: Minor
        Found in lib/fluent/plugin/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 on_message has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
        Open

            def on_message(msg)
              unless msg.is_a?(Array)
                log.warn "incoming data is broken:", msg: msg
                return
              end
        Severity: Minor
        Found in lib/fluent/plugin/in_unix.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 configure has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
        Open

            def configure(conf)
              compat_parameters_convert(conf, :extract, :parser)
              ['parse', 'extract'].each do |subsection_name|
                if subsection = conf.elements(subsection_name).first
                  if subsection.has_key?('time_format')
        Severity: Minor
        Found in lib/fluent/plugin/in_exec.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 has a Cognitive Complexity of 10 (exceeds 5 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

        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 10 (exceeds 5 allowed). Consider refactoring.
        Open

            def self.parse(str, fname, basepath = Dir.pwd, v1_config = nil, syntax: :v1)
              parser = if fname =~ /\.rb$/ || syntax == :ruby
                         :ruby
                       elsif v1_config.nil?
                         case syntax
        Severity: Minor
        Found in lib/fluent/config.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 start has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
        Open

            def start
              super
        
              unless @heartbeat_type == :none
                if @heartbeat_type == :udp
        Severity: Minor
        Found in lib/fluent/plugin/out_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

        Method configure has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
        Open

              def configure(conf)
                @include_time_key = false
                @localtime = false
                @timezone = nil
        
        
        Severity: Minor
        Found in lib/fluent/compat/set_time_key_mixin.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_pidfile has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
        Open

            def check_pidfile(pid_path)
              if File.exist?(pid_path)
                if !File.readable?(pid_path) || !File.writable?(pid_path)
                  raise Fluent::ConfigError, "Cannot access pid file: #{pid_path}"
                end
        Severity: Minor
        Found in lib/fluent/daemonizer.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 lookup has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
        Open

              def self.lookup(format)
                # TODO: warn when deprecated to use Plugin.new_parser or RegexpParser.new directly
                if format.nil?
                  raise ConfigError, "'format' parameter is required"
                end
        Severity: Minor
        Found in lib/fluent/compat/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 get_options has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
        Open

            def self.get_options
              options = {}
              DEFAULTS.each { |key, value| options[key] = value }
        
              OPTIONS.each do |key, type|
        Severity: Minor
        Found in lib/fluent/oj_options.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 ignore_same_log? has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
        Open

            def ignore_same_log?(time, message)
              cached_log = Thread.current[:last_same_log]
              if cached_log.nil?
                Thread.current[:last_same_log] = {message => time}
                return false
        Severity: Minor
        Found in lib/fluent/log.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