actionview/lib/action_view/helpers/url_helper.rb

Summary

Maintainability
D
1 day
Test Coverage

Method button_to has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
Open

      def button_to(name = nil, options = nil, html_options = nil, &block)
        html_options, options = options, name if block_given?
        html_options ||= {}
        html_options = html_options.stringify_keys

Severity: Minor
Found in actionview/lib/action_view/helpers/url_helper.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

File url_helper.rb has 265 lines of code (exceeds 250 allowed). Consider refactoring.
Open

require "active_support/core_ext/array/access"
require "active_support/core_ext/hash/keys"
require "active_support/core_ext/string/output_safety"
require "action_view/helpers/content_exfiltration_prevention_helper"
require "action_view/helpers/tag_helper"
Severity: Minor
Found in actionview/lib/action_view/helpers/url_helper.rb - About 2 hrs to fix

    Method button_to has 44 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

          def button_to(name = nil, options = nil, html_options = nil, &block)
            html_options, options = options, name if block_given?
            html_options ||= {}
            html_options = html_options.stringify_keys
    
    
    Severity: Minor
    Found in actionview/lib/action_view/helpers/url_helper.rb - About 1 hr to fix

      Method current_page? has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
      Open

            def current_page?(options = nil, check_parameters: false, **options_as_kwargs)
              unless request
                raise "You cannot use helpers that need to determine the current " \
                      "page unless your view context provides a Request object " \
                      "in a #request method"
      Severity: Minor
      Found in actionview/lib/action_view/helpers/url_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 to_form_params has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

              def to_form_params(attribute, namespace = nil)
                attribute = if attribute.respond_to?(:permitted?)
                  attribute.to_h
                else
                  attribute
      Severity: Minor
      Found in actionview/lib/action_view/helpers/url_helper.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 convert_options_to_data_attributes has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

              def convert_options_to_data_attributes(options, html_options)
                if html_options
                  html_options = html_options.stringify_keys
                  html_options["data-remote"] = "true" if link_to_remote_options?(options) || link_to_remote_options?(html_options)
      
      
      Severity: Minor
      Found in actionview/lib/action_view/helpers/url_helper.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

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

              def method_for_options(options)
                if options.is_a?(Array)
                  method_for_options(options.last)
                elsif options.respond_to?(:persisted?)
                  options.persisted? ? :patch : :post
      Severity: Minor
      Found in actionview/lib/action_view/helpers/url_helper.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

      Method link_to_unless has 5 arguments (exceeds 4 allowed). Consider refactoring.
      Open

            def link_to_unless(condition, name, options = {}, html_options = {}, &block)
      Severity: Minor
      Found in actionview/lib/action_view/helpers/url_helper.rb - About 35 mins to fix

        Method link_to_if has 5 arguments (exceeds 4 allowed). Consider refactoring.
        Open

              def link_to_if(condition, name, options = {}, html_options = {}, &block)
        Severity: Minor
        Found in actionview/lib/action_view/helpers/url_helper.rb - About 35 mins to fix

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

                def _filtered_referrer # :nodoc:
                  if controller.respond_to?(:request)
                    referrer = controller.request.env["HTTP_REFERER"]
                    if referrer && URI(referrer).scheme != "javascript"
                      referrer
          Severity: Minor
          Found in actionview/lib/action_view/helpers/url_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 token_tag has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

                  def token_tag(token = nil, form_options: {})
                    if token != false && defined?(protect_against_forgery?) && protect_against_forgery?
                      token =
                        if token == true || token.nil?
                          form_authenticity_token(form_options: form_options.merge(authenticity_token: token))
          Severity: Minor
          Found in actionview/lib/action_view/helpers/url_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 link_to_if has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

                def link_to_if(condition, name, options = {}, html_options = {}, &block)
                  if condition
                    link_to(name, options, html_options)
                  else
                    if block_given?
          Severity: Minor
          Found in actionview/lib/action_view/helpers/url_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

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

                def sms_to(phone_number, name = nil, html_options = {}, &block)
                  html_options, name = name, nil if name.is_a?(Hash)
                  html_options = (html_options || {}).stringify_keys
          
                  country_code = html_options.delete("country_code").presence
          Severity: Minor
          Found in actionview/lib/action_view/helpers/url_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