actionview/lib/action_view/helpers/tag_helper.rb

Summary

Maintainability
D
1 day
Test Coverage

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

        def tag_options(options, escape = true)
          return if options.blank?
          output = +""
          sep    = " "
          options.each_pair do |key, value|
Severity: Minor
Found in actionview/lib/action_view/helpers/tag_helper.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

File tag_helper.rb has 357 lines of code (exceeds 250 allowed). Consider refactoring.
Open

require "active_support/code_generator"
require "active_support/core_ext/enumerable"
require "active_support/core_ext/string/output_safety"
require "active_support/core_ext/string/inflections"
require "set"
Severity: Minor
Found in actionview/lib/action_view/helpers/tag_helper.rb - About 4 hrs to fix

    Method tag_option has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
    Open

            def tag_option(key, value, escape)
              key = ERB::Util.xml_name_escape(key) if escape
    
              case value
              when Array, Hash
    Severity: Minor
    Found in actionview/lib/action_view/helpers/tag_helper.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 tag_options has 36 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

            def tag_options(options, escape = true)
              return if options.blank?
              output = +""
              sep    = " "
              options.each_pair do |key, value|
    Severity: Minor
    Found in actionview/lib/action_view/helpers/tag_helper.rb - About 1 hr to fix

      Method build_tag_values has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
      Open

              def build_tag_values(*args)
                tag_values = []
      
                args.each do |tag_value|
                  case tag_value
      Severity: Minor
      Found in actionview/lib/action_view/helpers/tag_helper.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 content_tag has 5 arguments (exceeds 4 allowed). Consider refactoring.
      Open

            def content_tag(name, content_or_options_with_block = nil, options = nil, escape = true, &block)
      Severity: Minor
      Found in actionview/lib/action_view/helpers/tag_helper.rb - About 35 mins to fix

        Method tag has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

              def tag(name = nil, options = nil, open = false, escape = true)
                if name.nil?
                  tag_builder
                else
                  ensure_valid_html5_tag_name(name)
        Severity: Minor
        Found in actionview/lib/action_view/helpers/tag_helper.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

        There are no issues that match your filters.

        Category
        Status