hannesg/uri_template

View on GitHub
lib/uri_template.rb

Summary

Maintainability
B
6 hrs
Test Coverage

Method scheme_and_host has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
Open

  def scheme_and_host
    return @scheme_and_host if @scheme_and_host
    read_chars = ""
    @scheme_and_host = [false,false]
    tokens.each do |token|
Severity: Minor
Found in lib/uri_template.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 coerce has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

  def self.coerce(a,b)
    if a.kind_of? URITemplate
      if a.class == b.class
        return [a,b,false,false]
      end
Severity: Minor
Found in lib/uri_template.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 scheme_and_host has 27 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def scheme_and_host
    return @scheme_and_host if @scheme_and_host
    read_chars = ""
    @scheme_and_host = [false,false]
    tokens.each do |token|
Severity: Minor
Found in lib/uri_template.rb - About 1 hr to fix

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

      def path_concat(other)
        if other.host? or other.scheme?
          raise ArgumentError, "Expected to receive a relative template but got an absoulte one: #{other.inspect}. If you think this is a bug, please report it."
        end
    
    
    Severity: Minor
    Found in lib/uri_template.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

    Avoid too many return statements within this method.
    Open

        return self.class.new( (self.tokens + other.tokens).join )
    Severity: Major
    Found in lib/uri_template.rb - About 30 mins to fix

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

        def normalize_variables( variables )
          raise ArgumentError, "Expected something that responds to :map, but got: #{variables.inspect}" unless variables.respond_to? :map
          if variables.kind_of?(Array)
            return Hash[self.variables.zip(variables)]
          else
      Severity: Minor
      Found in lib/uri_template.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