fluent/fluentd

View on GitHub

Showing 664 of 664 total issues

Avoid too many return statements within this method.
Open

          return Proc.new {|time|
            time = time.to_time
            format.exec(time.localtime(tz.period_for_utc(time).utc_total_offset))
          }
Severity: Major
Found in lib/fluent/timezone.rb - About 30 mins to fix

    Avoid too many return statements within this method.
    Open

              return Proc.new {|time|
                time = time.to_time
                time.localtime(tz.period_for_utc(time).utc_total_offset).iso8601
              }
    Severity: Major
    Found in lib/fluent/timezone.rb - About 30 mins to fix

      Avoid too many return statements within this method.
      Open

              return false
      Severity: Major
      Found in lib/fluent/timezone.rb - About 30 mins to fix

        Avoid too many return statements within this method.
        Open

                  return nil
        Severity: Major
        Found in lib/fluent/timezone.rb - About 30 mins to fix

          Avoid too many return statements within this method.
          Open

                    return Proc.new {|time|
                      time = time.to_time
                      time.localtime(tz.period_for_utc(time).utc_total_offset).strftime(format)
                    }
          Severity: Major
          Found in lib/fluent/timezone.rb - About 30 mins to fix

            Avoid too many return statements within this method.
            Open

                  return nil
            Severity: Major
            Found in lib/fluent/timezone.rb - About 30 mins to fix

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

                        def on_read_without_connection(data)
                          @data_callback.call(data)
                        rescue => e
                          @log.error "unexpected error on reading data", host: @callback_connection.remote_host, port: @callback_connection.remote_port, error: e
                          @log.error_backtrace
              Severity: Minor
              Found in lib/fluent/plugin_helper/server.rb and 1 other location - About 30 mins to fix
              lib/fluent/plugin_helper/server.rb on lines 648..655

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

              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

                        def on_read_without_connection(data)
                          @data_callback.call(data)
                        rescue => e
                          @log.error "unexpected error on reading data", host: @callback_connection.remote_host, port: @callback_connection.remote_port, error: e
                          @log.error_backtrace
              Severity: Minor
              Found in lib/fluent/plugin_helper/server.rb and 1 other location - About 30 mins to fix
              lib/fluent/plugin_helper/server.rb on lines 807..814

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

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

                def overwrite?(dest)
                  return true if @overwrite_all
                  loop do
                    print "Overwrite #{dest}? (enter \"h\" for help) [Ynaqh]"
                    answer = $stdin.gets.chomp
              Severity: Minor
              Found in lib/fluent/command/plugin_generator.rb - About 25 mins 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 plugin_info_by_tag has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

                  def plugin_info_by_tag(tag, opts={})
                    matches = Fluent::Engine.root_agent.event_router.instance_variable_get(:@match_rules)
                    matches.each { |rule|
                      if rule.match?(tag)
                        if rule.collector.is_a?(Fluent::Plugin::Output) || rule.collector.is_a?(Fluent::Output)
              Severity: Minor
              Found in lib/fluent/plugin/in_monitor_agent.rb - About 25 mins 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_formats has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

                    def parse_formats(conf)
                      check_format_range(conf)
              
                      prev_format = nil
                      (1..FORMAT_MAX_NUM).map { |i|
              Severity: Minor
              Found in lib/fluent/plugin/parser_multiline.rb - About 25 mins 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 close has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

                    def close(sock)
                      if @socket_cache
                        @socket_cache.checkin(sock)
                      else
                        sock.close_write rescue nil
              Severity: Minor
              Found in lib/fluent/plugin/out_forward/connection_manager.rb - About 25 mins 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 construct_watcher has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

                  def construct_watcher(target_info)
                    path = target_info.path
              
                    # The file might be rotated or removed after collecting paths, so check inode again here.
                    begin
              Severity: Minor
              Found in lib/fluent/plugin/in_tail.rb - About 25 mins 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 call has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

                  def call
                    parse_options!(@argv)
              
                    target_file = if !!@opts[:target_file]
                                    @opts[:target_file]
              Severity: Minor
              Found in lib/fluent/command/cap_ctl.rb - About 25 mins 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_record has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

                  def on_record(time, record)
                    tag = extract_tag_from_record(record)
                    tag ||= @tag
                    time ||= extract_time_from_record(record) || Fluent::EventTime.now
                    router.emit(tag, time, record)
              Severity: Minor
              Found in lib/fluent/plugin/in_exec.rb - About 25 mins 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 enqueue_chunk has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

                    def enqueue_chunk(metadata)
                      log.on_trace { log.trace "enqueueing chunk", instance: self.object_id, metadata: metadata }
              
                      chunk = synchronize do
                        @stage.delete(metadata)
              Severity: Minor
              Found in lib/fluent/plugin/buffer.rb - About 25 mins 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_encoding has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

                  def configure_encoding
                    unless @encoding
                      if @from_encoding
                        raise Fluent::ConfigError, "tail: 'from_encoding' parameter must be specified with 'encoding' parameter."
                      end
              Severity: Minor
              Found in lib/fluent/plugin/in_tail.rb - About 25 mins 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 template has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

                def template(source, dest)
                  dest.dirname.mkpath
                  contents =
                    if ERB.instance_method(:initialize).parameters.assoc(:key) # Ruby 2.6+
                      ERB.new(source.read, trim_mode: "-")
              Severity: Minor
              Found in lib/fluent/command/plugin_generator.rb - About 25 mins 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_notify has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

                      def on_notify(tw)
                        unless @start && @flush_method
                          return
                        end
              
              
              Severity: Minor
              Found in lib/fluent/plugin/in_tail.rb - About 25 mins 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_timer has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

                def on_timer
                  now = Time.now.to_i
              
                  synchronize {
                    unless @pending.empty?
              Severity: Minor
              Found in lib/fluent/command/cat.rb - About 25 mins 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