mbleigh/subdomain-fu

View on GitHub

Showing 5 of 5 total issues

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

  def self.needs_rewrite?(subdomain, host)
    return false unless host && host.count('.') >= config.tld_size
    case subdomain
      when nil
        #rewrite when there is a preferred mirror set and there is no subdomain on the host
Severity: Minor
Found in lib/subdomain_fu/subdomain_fu.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 url_for_with_subdomains has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

      def url_for_with_subdomains(options, path_segments=nil)
        if SubdomainFu.needs_rewrite?(options[:subdomain], (options[:host] || (@request && @request.host_with_port))) || options[:only_path] == false
          options[:only_path] = false if SubdomainFu.override_only_path?
          options[:host] = SubdomainFu.rewrite_host_for_subdomains(options.delete(:subdomain), options[:host] || (@request && @request.host_with_port))
        else
Severity: Minor
Found in lib/subdomain_fu/url_rewriter.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

Consider simplifying this complex logical expression.
Open

        if SubdomainFu.needs_rewrite?(options[:subdomain], (options[:host] || (@request && @request.host_with_port))) || options[:only_path] == false
          options[:only_path] = false if SubdomainFu.override_only_path?
          options[:host] = SubdomainFu.rewrite_host_for_subdomains(options.delete(:subdomain), options[:host] || (@request && @request.host_with_port))
        else
          options.delete(:subdomain)
Severity: Major
Found in lib/subdomain_fu/url_rewriter.rb - About 40 mins to fix

    Avoid too many return statements within this method.
    Open

              return false if is_mirror?(h)
    Severity: Major
    Found in lib/subdomain_fu/subdomain_fu.rb - About 30 mins to fix

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

        def self.rewrite_host_for_subdomains(subdomain, host)
          if needs_rewrite?(subdomain, host)
            change_subdomain_of_host(subdomain || SubdomainFu.config.preferred_mirror, host)
          else
            if has_subdomain?(subdomain) || preferred_mirror?(subdomain_from(host)) ||
      Severity: Minor
      Found in lib/subdomain_fu/subdomain_fu.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

      Severity
      Category
      Status
      Source
      Language