fluent/fluentd

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

Summary

Maintainability
C
1 day
Test Coverage

File in_monitor_agent.rb has 312 lines of code (exceeds 250 allowed). Consider refactoring.
Open

require 'json'
require 'webrick'
require 'cgi'

require 'fluent/config/types'
Severity: Minor
Found in lib/fluent/plugin/in_monitor_agent.rb - About 3 hrs to fix

    Method get_monitor_info has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
    Open

        def get_monitor_info(pe, opts={})
          obj = {}
    
          # Common plugin information
          obj['plugin_id'] = pe.plugin_id
    Severity: Minor
    Found in lib/fluent/plugin/in_monitor_agent.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 get_monitor_info has 45 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        def get_monitor_info(pe, opts={})
          obj = {}
    
          # Common plugin information
          obj['plugin_id'] = pe.plugin_id
    Severity: Minor
    Found in lib/fluent/plugin/in_monitor_agent.rb - About 1 hr to fix

      Method build_object has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
      Open

            def build_object(opts)
              qs = opts[:query]
              if tag = qs['tag'.freeze].first
                # ?tag= to search an output plugin by match pattern
                if obj = @agent.plugin_info_by_tag(tag, opts)
      Severity: Minor
      Found in lib/fluent/plugin/in_monitor_agent.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 build_option has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

            def build_option(req)
              qs = Hash.new { |_, _| [] }
              # parse ?=query string
              if req.query_string
                qs.merge!(CGI.parse(req.query_string))
      Severity: Minor
      Found in lib/fluent/plugin/in_monitor_agent.rb - About 35 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 plugin_info_by_tag has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          def plugin_info_by_tag(tag, opts={})
            matches = Fluent::Engine.root_agent.event_router.instance_variable_get(:@match_rules)
            matches.each { |rule|
              if rule.match?(tag)
                if rule.collector.is_a?(Fluent::Plugin::Output) || rule.collector.is_a?(Fluent::Output)
      Severity: Minor
      Found in lib/fluent/plugin/in_monitor_agent.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

      Method render_ltsv has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

            def render_ltsv(obj, code: 200)
              normalized = JSON.parse(obj.to_json)
              text = ''
              normalized.each do |hash|
                row = []
      Severity: Minor
      Found in lib/fluent/plugin/in_monitor_agent.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