sonots/haikanko

View on GitHub
pipework/fluentd/server/plugin/out_numeric_monitor.rb

Summary

Maintainability
D
1 day
Test Coverage

Method generate_output has a Cognitive Complexity of 32 (exceeds 5 allowed). Consider refactoring.
Open

  def generate_output(count)
    output = {}
    if @aggregate == :all
      c = count['all']
      if c[:num] then output['num'] = c[:num] end
Severity: Minor
Found in pipework/fluentd/server/plugin/out_numeric_monitor.rb - About 4 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 emit has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

  def emit(tag, es, chain)
    min = nil
    max = nil
    sum = 0
    num = 0
Severity: Minor
Found in pipework/fluentd/server/plugin/out_numeric_monitor.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 countups has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

  def countups(tag, min, max, sum, num, sample)
    if @aggregate == :all
      tag = 'all'
    end

Severity: Minor
Found in pipework/fluentd/server/plugin/out_numeric_monitor.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 generate_output has 39 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def generate_output(count)
    output = {}
    if @aggregate == :all
      c = count['all']
      if c[:num] then output['num'] = c[:num] end
Severity: Minor
Found in pipework/fluentd/server/plugin/out_numeric_monitor.rb - About 1 hr to fix

    Method emit has 28 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      def emit(tag, es, chain)
        min = nil
        max = nil
        sum = 0
        num = 0
    Severity: Minor
    Found in pipework/fluentd/server/plugin/out_numeric_monitor.rb - About 1 hr to fix

      Method count_initialized has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

        def count_initialized(keys=nil)
          # counts['tag'] = {:min => num, :max => num, :sum => num, :num => num [, :sample => [....]]}
          if @aggregate == :all
            if @percentiles
              {'all' => {:min => nil, :max => nil, :sum => nil, :num => 0, :sample => []}}
      Severity: Minor
      Found in pipework/fluentd/server/plugin/out_numeric_monitor.rb - About 55 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 countups has 6 arguments (exceeds 4 allowed). Consider refactoring.
      Open

        def countups(tag, min, max, sum, num, sample)
      Severity: Minor
      Found in pipework/fluentd/server/plugin/out_numeric_monitor.rb - About 45 mins to fix

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

          def configure(conf)
            super
        
            if @unit
              @count_interval = case @unit
        Severity: Minor
        Found in pipework/fluentd/server/plugin/out_numeric_monitor.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

        There are no issues that match your filters.

        Category
        Status