fluent/fluentd

View on GitHub
lib/fluent/config/section.rb

Summary

Maintainability
F
3 days
Test Coverage

Method generate has a Cognitive Complexity of 138 (exceeds 5 allowed). Consider refactoring.
Open

      def self.generate(proxy, conf, logger, plugin_class, stack = [], strict_config_value = false)
        return nil if conf.nil?

        section_stack = ""
        unless stack.empty?
Severity: Minor
Found in lib/fluent/config/section.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

Method generate has 107 lines of code (exceeds 25 allowed). Consider refactoring.
Open

      def self.generate(proxy, conf, logger, plugin_class, stack = [], strict_config_value = false)
        return nil if conf.nil?

        section_stack = ""
        unless stack.empty?
Severity: Major
Found in lib/fluent/config/section.rb - About 4 hrs to fix

    Method check_unused_section has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
    Open

          def self.check_unused_section(proxy, conf, plugin_class)
            elems = conf.respond_to?(:elements) ? conf.elements : []
            elems.each { |e|
              next if plugin_class.nil? && Fluent::Config::V1Parser::ELEM_SYMBOLS.include?(e.name) # skip pre-defined non-plugin elements because it doesn't have proxy section
              next if e.unused_in && e.unused_in.empty? # the section is used at least once
    Severity: Minor
    Found in lib/fluent/config/section.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

    Avoid deeply nested control flow statements.
    Open

                    logger.error "config error in:\n#{conf}" if logger
    Severity: Major
    Found in lib/fluent/config/section.rb - About 45 mins to fix

      Method generate has 6 arguments (exceeds 4 allowed). Consider refactoring.
      Open

            def self.generate(proxy, conf, logger, plugin_class, stack = [], strict_config_value = false)
      Severity: Minor
      Found in lib/fluent/config/section.rb - About 45 mins to fix

        Avoid deeply nested control flow statements.
        Open

                        logger.error "config error in:\n#{conf}" if logger
        Severity: Major
        Found in lib/fluent/config/section.rb - About 45 mins to fix

          There are no issues that match your filters.

          Category
          Status