fluent/fluentd

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

Summary

Maintainability
C
1 day
Test Coverage

Method filter_with_time has a Cognitive Complexity of 48 (exceeds 5 allowed). Consider refactoring.
Open

    def filter_with_time(tag, time, record)
      raw_value = @accessor.call(record)
      if raw_value.nil?
        if @emit_invalid_record_to_error
          router.emit_error_event(tag, time, record, ArgumentError.new("#{@key_name} does not exist"))
Severity: Minor
Found in lib/fluent/plugin/filter_parser.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 filter_with_time has 62 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def filter_with_time(tag, time, record)
      raw_value = @accessor.call(record)
      if raw_value.nil?
        if @emit_invalid_record_to_error
          router.emit_error_event(tag, time, record, ArgumentError.new("#{@key_name} does not exist"))
Severity: Major
Found in lib/fluent/plugin/filter_parser.rb - About 2 hrs to fix

    Method handle_parsed has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

        def handle_parsed(tag, record, t, values)
          if values && @inject_key_prefix
            values = Hash[values.map { |k, v| [@inject_key_prefix + k, v] }]
          end
          r = @hash_value_field ? {@hash_value_field => values} : values
    Severity: Minor
    Found in lib/fluent/plugin/filter_parser.rb - About 45 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

    Avoid too many return statements within this method.
    Open

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

      There are no issues that match your filters.

      Category
      Status