fluent/fluentd

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

Summary

Maintainability
D
2 days
Test Coverage

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

    def configure(conf)
      compat_parameters_convert(conf, :formatter, :buffer, :inject, default_chunk_key: "time")

      configured_time_slice_format = conf['time_slice_format']

Severity: Minor
Found in lib/fluent/plugin/out_file.rb - About 5 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 find_filepath_available has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
Open

    def find_filepath_available(path_with_placeholder, with_lock: false) # for non-append
      raise "BUG: index placeholder not found in path: #{path_with_placeholder}" unless path_with_placeholder.index('_**')
      i = 0
      dir_path = locked = nil
      while true
Severity: Minor
Found in lib/fluent/plugin/out_file.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 generate_path_template has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
Open

    def generate_path_template(original, timekey, append, compress, path_suffix: '', time_slice_format: nil)
      comp_suffix = compression_suffix(compress)
      index_placeholder = append ? '' : '_**'
      if original.index('*')
        raise "BUG: configuration error must be raised for path including '*' without timekey" unless timekey
Severity: Minor
Found in lib/fluent/plugin/out_file.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 configure has 64 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def configure(conf)
      compat_parameters_convert(conf, :formatter, :buffer, :inject, default_chunk_key: "time")

      configured_time_slice_format = conf['time_slice_format']

Severity: Major
Found in lib/fluent/plugin/out_file.rb - About 2 hrs to fix

    File out_file.rb has 258 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    require 'fileutils'
    require 'zlib'
    require 'time'
    
    require 'fluent/plugin/output'
    Severity: Minor
    Found in lib/fluent/plugin/out_file.rb - About 2 hrs to fix

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

        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

        Avoid deeply nested control flow statements.
        Open

                      raise Fluent::ConfigError, "insufficient timestamp placeholders in path" if time_placeholders.scan(/../).any?{|ph| !original.include?(ph) }
        Severity: Major
        Found in lib/fluent/plugin/out_file.rb - About 45 mins to fix

          There are no issues that match your filters.

          Category
          Status