actionview/lib/action_view/helpers/form_tag_helper.rb

Summary

Maintainability
C
7 hrs
Test Coverage

File form_tag_helper.rb has 281 lines of code (exceeds 250 allowed). Consider refactoring.
Open

require "cgi"
require "action_view/helpers/content_exfiltration_prevention_helper"
require "action_view/helpers/url_helper"
require "action_view/helpers/text_helper"
require "active_support/core_ext/string/output_safety"
Severity: Minor
Found in actionview/lib/action_view/helpers/form_tag_helper.rb - About 2 hrs to fix

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

            def html_options_for_form(url_for_options, options)
              options.stringify_keys.tap do |html_options|
                html_options["enctype"] = "multipart/form-data" if html_options.delete("multipart")
                # The following URL is unescaped, this is just a hash of options, and it is the
                # responsibility of the caller to escape all the values.
    Severity: Minor
    Found in actionview/lib/action_view/helpers/form_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 select_tag has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

          def select_tag(name, option_tags = nil, options = {})
            option_tags ||= ""
            html_name = (options[:multiple] == true && !name.end_with?("[]")) ? "#{name}[]" : name
    
            if options.include?(:include_blank)
    Severity: Minor
    Found in actionview/lib/action_view/helpers/form_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 field_name has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

          def field_name(object_name, method_name, *method_names, multiple: false, index: nil)
            names = method_names.map! { |name| "[#{name}]" }.join
    
            # a little duplication to construct fewer strings
            case
    Severity: Minor
    Found in actionview/lib/action_view/helpers/form_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 label_tag has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

          def label_tag(name = nil, content_or_options = nil, options = nil, &block)
            if block_given? && content_or_options.is_a?(Hash)
              options = content_or_options = content_or_options.stringify_keys
            else
              options ||= {}
    Severity: Minor
    Found in actionview/lib/action_view/helpers/form_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

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

          def button_tag(content_or_options = nil, options = nil, &block)
            if content_or_options.is_a? Hash
              options = content_or_options
            else
              options ||= {}
    Severity: Minor
    Found in actionview/lib/action_view/helpers/form_tag_helper.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