lib/volt/models/url.rb

Summary

Maintainability
B
6 hrs
Test Coverage

Method url_for has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

    def url_for(params)
      host_with_port = host || location.host
      host_with_port += ":#{port}" if port && port != 80
      scheme = scheme || location.scheme

Severity: Minor
Found in lib/volt/models/url.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 assign_from_old has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

    def assign_from_old(params, new_params)
      queued_deletes = []

      params.attributes.each_pair do |name, old_val|
        # If there is a new value, see if it has [name]
Severity: Minor
Found in lib/volt/models/url.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 parse has 29 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def parse(url)
      if url[0] == '#'
        # url only updates fragment
        self.fragment = url[1..-1]
        update!
Severity: Minor
Found in lib/volt/models/url.rb - About 1 hr to fix

    Method url_for has 28 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        def url_for(params)
          host_with_port = host || location.host
          host_with_port += ":#{port}" if port && port != 80
          scheme = scheme || location.scheme
    
    
    Severity: Minor
    Found in lib/volt/models/url.rb - About 1 hr to fix

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

          def parse_query
            query_hash = {}
            qury = query
      
            if qury
      Severity: Minor
      Found in lib/volt/models/url.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 nested_params_hash has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          def nested_params_hash(params, path = [])
            results = {}
      
            params.each_pair do |key, value|
              unless value.nil?
      Severity: Minor
      Found in lib/volt/models/url.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 parse has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          def parse(url)
            if url[0] == '#'
              # url only updates fragment
              self.fragment = url[1..-1]
              update!
      Severity: Minor
      Found in lib/volt/models/url.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