fluent/fluentd

View on GitHub
lib/fluent/plugin/buffer.rb

Summary

Maintainability
F
1 wk
Test Coverage

Method write_step_by_step has a Cognitive Complexity of 111 (exceeds 5 allowed). Consider refactoring.
Open

      def write_step_by_step(metadata, data, format, splits_count, &block)
        splits = []
        if splits_count > data.size
          splits_count = data.size
        end
Severity: Minor
Found in lib/fluent/plugin/buffer.rb - About 2 days 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

File buffer.rb has 719 lines of code (exceeds 250 allowed). Consider refactoring.
Open

require 'fluent/plugin/base'
require 'fluent/plugin/owned_by_mixin'
require 'fluent/plugin_id'
require 'fluent/plugin_helper'
require 'fluent/unique_id'
Severity: Major
Found in lib/fluent/plugin/buffer.rb - About 1 day to fix

    Method write_once has a Cognitive Complexity of 48 (exceeds 5 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 7 hrs 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 47 (exceeds 5 allowed). Consider refactoring.
    Open

          def write(metadata_and_data, format: nil, size: nil, enqueue: false)
            return if metadata_and_data.size < 1
            raise BufferOverflowError, "buffer space has too many data" unless storable?
    
            log.on_trace { log.trace "writing events into buffer", instance: self.object_id, metadata_size: metadata_and_data.size }
    Severity: Minor
    Found in lib/fluent/plugin/buffer.rb - About 7 hrs 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

    Class Buffer has 42 methods (exceeds 20 allowed). Consider refactoring.
    Open

        class Buffer < Base
          include OwnedByMixin
          include UniqueId::Mixin
          include PluginId
          include MonitorMixin
    Severity: Minor
    Found in lib/fluent/plugin/buffer.rb - About 5 hrs to fix

      Method write_step_by_step has 116 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

            def write_step_by_step(metadata, data, format, splits_count, &block)
              splits = []
              if splits_count > data.size
                splits_count = data.size
              end
      Severity: Major
      Found in lib/fluent/plugin/buffer.rb - About 4 hrs to fix

        Method write has 95 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

              def write(metadata_and_data, format: nil, size: nil, enqueue: false)
                return if metadata_and_data.size < 1
                raise BufferOverflowError, "buffer space has too many data" unless storable?
        
                log.on_trace { log.trace "writing events into buffer", instance: self.object_id, metadata_size: metadata_and_data.size }
        Severity: Major
        Found in lib/fluent/plugin/buffer.rb - About 3 hrs to fix

          Method cmp_variables has a Cognitive Complexity of 22 (exceeds 5 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 3 hrs 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_all has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
          Open

                def enqueue_all(force_enqueue = false)
                  log.on_trace { log.trace "enqueueing all chunks in buffer", instance: self.object_id }
                  update_timekeys if @enable_update_timekeys
          
                  if block_given?
          Severity: Minor
          Found in lib/fluent/plugin/buffer.rb - About 2 hrs 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 <=> has a Cognitive Complexity of 17 (exceeds 5 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 2 hrs 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 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 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 <=> 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

                  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

                    Avoid deeply nested control flow statements.
                    Open

                                      if adding_bytes > @chunk_limit_size
                                        errors << "concatenated/appended a #{adding_bytes} bytes record (nth: #{writing_splits_index}) is larger than buffer chunk limit size (#{@chunk_limit_size})"
                                        writing_splits_index += 1
                                        next
                                      else
                    Severity: Major
                    Found in lib/fluent/plugin/buffer.rb - About 45 mins to fix

                      Method write_step_by_step has 5 arguments (exceeds 4 allowed). Consider refactoring.
                      Open

                            def write_step_by_step(metadata, data, format, splits_count, &block)
                      Severity: Minor
                      Found in lib/fluent/plugin/buffer.rb - About 35 mins to fix

                        Avoid too many return statements within this method.
                        Open

                                        return -1
                        Severity: Major
                        Found in lib/fluent/plugin/buffer.rb - About 30 mins to fix

                          Avoid too many return statements within this method.
                          Open

                                          return 1
                          Severity: Major
                          Found in lib/fluent/plugin/buffer.rb - About 30 mins to fix

                            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

                            There are no issues that match your filters.

                            Category
                            Status