fluent/fluentd

View on GitHub

Showing 564 of 653 total issues

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

      def thread_wait_until_stop
        timeout_at = Fluent::Clock.now + THREAD_SHUTDOWN_HARD_TIMEOUT_IN_TESTS
        until @_threads_mutex.synchronize{ @_threads.values.reduce(true){|r,t| r && !t[:_fluentd_plugin_helper_thread_running] } }
          break if Fluent::Clock.now > timeout_at
          sleep 0.1
Severity: Minor
Found in lib/fluent/plugin_helper/thread.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 method_missing has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

        def method_missing(name, *args, &block)
          ::Kernel.raise ::ArgumentError, "Configuration DSL Syntax Error: only one argument allowed" if args.size > 1
          value = args.first

          if block
Severity: Minor
Found in lib/fluent/config/dsl.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 filter_stream has 27 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def filter_stream(tag, es)
      new_es = Fluent::MultiEventStream.new
      tag_parts = tag.split('.')
      tag_prefix = tag_prefix(tag_parts)
      tag_suffix = tag_suffix(tag_parts)
Severity: Minor
Found in lib/fluent/plugin/filter_record_transformer.rb - About 1 hr to fix

    Method parse_rfc3164_regex has 27 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

          def parse_rfc3164_regex(text, &block)
            idx = 0
            record = {}
    
            if @with_priority
    Severity: Minor
    Found in lib/fluent/plugin/parser_syslog.rb - About 1 hr to fix

      Method metadata has 27 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

            def metadata(tag, time, record)
              # this arguments are ordered in output plugin's rule
              # Metadata 's argument order is different from this one (timekey, tag, variables)
      
              raise ArgumentError, "tag must be a String: #{tag.class}" unless tag.nil? || tag.is_a?(String)
      Severity: Minor
      Found in lib/fluent/plugin/output.rb - About 1 hr to fix

        Method build_spawn_command has 27 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            def build_spawn_command
              if ENV['TEST_RUBY_PATH']
                fluentd_spawn_cmd = [ENV['TEST_RUBY_PATH']]
              else
                fluentd_spawn_cmd = [ServerEngine.ruby_bin_path]
        Severity: Minor
        Found in lib/fluent/supervisor.rb - About 1 hr to fix

          Method default_options has 27 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              def self.default_options
                {
                  config_path: Fluent::DEFAULT_CONFIG_PATH,
                  plugin_dirs: [Fluent::DEFAULT_PLUGIN_DIR],
                  log_level: Fluent::Log::LEVEL_INFO,
          Severity: Minor
          Found in lib/fluent/supervisor.rb - About 1 hr to fix

            Method synchronize has 27 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                  def synchronize(*keys)
                    return if keys.empty?
            
                    locks = {}
                    loop do
            Severity: Minor
            Found in lib/fluent/counter/mutex_hash.rb - About 1 hr to fix

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

                  def configure(conf)
                    compat_parameters_convert(conf, :parser)
              
                    super
              
              
              Severity: Minor
              Found in lib/fluent/plugin/in_syslog.rb - About 1 hr to fix

                Method <=> has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                        def <=>(o)
                          timekey2 = o.timekey
                          tag2 = o.tag
                          variables2 = o.variables
                          if (!!timekey ^ !!timekey2) || (!!tag ^ !!tag2) || (!!variables ^ !!variables2)
                Severity: Minor
                Found in lib/fluent/plugin/buffer.rb - About 1 hr to fix

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

                        def configure(conf)
                          super
                  
                          unless @queue_limit_length.nil?
                            @total_limit_size = @chunk_limit_size * @queue_limit_length
                  Severity: Minor
                  Found in lib/fluent/plugin/buffer.rb - About 1 hr to fix

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

                      Method fetch_compacted_entries has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                            def fetch_compacted_entries
                              entries = {}
                      
                              @file.pos = 0
                              file_pos = 0
                      Severity: Minor
                      Found in lib/fluent/plugin/in_tail/position_file.rb - About 1 hr to fix

                        Method lifecycle has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                            def lifecycle(desc: false, kind_callback: nil)
                              kind_or_label_list = if desc
                                            [:output, :filter, @labels.values.reverse, :output_with_router, :input].flatten
                                          else
                                            [:input, :output_with_router, @labels.values, :filter, :output].flatten
                        Severity: Minor
                        Found in lib/fluent/root_agent.rb - About 1 hr to fix

                          Method calc_next_time has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                                  def calc_next_time
                                    if @forever || !@secondary # primary
                                      naive = naive_next_time(@steps)
                                      if @forever
                                        naive
                          Severity: Minor
                          Found in lib/fluent/plugin_helper/retry_state.rb - About 1 hr to fix

                            Method format= has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                                def format=(fmt)
                                  return if @format == fmt
                            
                                  @time_format = '%Y-%m-%d %H:%M:%S %z'
                                  @time_formatter = Strftime.new(@time_format) rescue nil
                            Severity: Minor
                            Found in lib/fluent/log.rb - About 1 hr to fix

                              Method shutdown has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                                    def shutdown
                                      @_child_process_mutex.synchronize{ @_child_process_processes.keys }.each do |pid|
                                        process_info = @_child_process_processes[pid]
                                        next if !process_info
                                        process_info.writeio && process_info.writeio.close rescue nil
                              Severity: Minor
                              Found in lib/fluent/plugin_helper/child_process.rb - About 1 hr to fix

                                Method scan_double_quoted_string has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                                Open

                                      def scan_double_quoted_string
                                        string = []
                                        while true
                                          if skip(/\"/)
                                            if string.include?(nil)
                                Severity: Minor
                                Found in lib/fluent/config/literal_parser.rb - About 1 hr to fix

                                  Consider simplifying this complex logical expression.
                                  Open

                                            if (!!timekey ^ !!timekey2) || (!!tag ^ !!tag2) || (!!variables ^ !!variables2)
                                              # One has value in a field, but another doesn't have value in same field
                                              # This case occurs very rarely
                                              if timekey == timekey2 # including the case of nil == nil
                                                if tag == tag2
                                  Severity: Major
                                  Found in lib/fluent/plugin/buffer.rb - About 1 hr to fix

                                    Method expand has 8 arguments (exceeds 4 allowed). Consider refactoring.
                                    Open

                                            def expand(__str_to_eval__, tag, time, record, tag_parts, tag_prefix, tag_suffix, hostname)
                                    Severity: Major
                                    Found in lib/fluent/plugin/filter_record_transformer.rb - About 1 hr to fix
                                      Severity
                                      Category
                                      Status
                                      Source
                                      Language