hannesg/uri_template

View on GitHub
lib/uri_template/utils.rb

Summary

Maintainability
B
4 hrs
Test Coverage

Method each has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
Open

    def each(str)
      raise ArgumentError, "RegexpEnumerator#each expects a String, but got #{str.inspect}" unless str.kind_of? String
      return self.to_enum(:each,str) unless block_given?
      rest = str
      loop do
Severity: Minor
Found in lib/uri_template/utils.rb - About 3 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 pair_array_to_hash2 has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    def pair_array_to_hash2(x)
      c = {}
      result = []

      x.each do | (k,v) |
Severity: Minor
Found in lib/uri_template/utils.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 pair_array_to_hash has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    def pair_array_to_hash(x, careful = false )
      if careful ? pair_array?(x) : (x.kind_of?(Array) and ( x.empty? or x.first.kind_of?(Array) ) )
        return Hash[ x ]
      else
        return x
Severity: Minor
Found in lib/uri_template/utils.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

There are no issues that match your filters.

Category
Status