hannesg/uri_template

View on GitHub
lib/uri_template/rfc6570/expression.rb

Summary

Maintainability
C
1 day
Test Coverage

File expression.rb has 315 lines of code (exceeds 250 allowed). Consider refactoring.
Open

require 'uri_template/rfc6570'

class URITemplate::RFC6570

    # @private
Severity: Minor
Found in lib/uri_template/rfc6570/expression.rb - About 3 hrs to fix

    Class Expression has 23 methods (exceeds 20 allowed). Consider refactoring.
    Open

      class Expression < Token
    
        include URITemplate::Expression
    
        attr_reader :variables
    Severity: Minor
    Found in lib/uri_template/rfc6570/expression.rb - About 2 hrs to fix

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

          def decode(x, split = true)
            if x.nil?
              return extracted_nil
            elsif split
              result = []
      Severity: Minor
      Found in lib/uri_template/rfc6570/expression.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 expand_partial has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
      Open

          def expand_partial( vars )
            result = []
            follow_up = self.class::FOLLOW_UP
            var_specs = []
            @variable_specs.each do | var, expand , max_length |
      Severity: Minor
      Found in lib/uri_template/rfc6570/expression.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 expand_partial has 27 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          def expand_partial( vars )
            result = []
            follow_up = self.class::FOLLOW_UP
            var_specs = []
            @variable_specs.each do | var, expand , max_length |
      Severity: Minor
      Found in lib/uri_template/rfc6570/expression.rb - About 1 hr to fix

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

            def extract(position,matched)
              name, expand, max_length = @variable_specs[position]
              if matched.nil?
                return [[ name , extracted_nil ]]
              end
        Severity: Minor
        Found in lib/uri_template/rfc6570/expression.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 level has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            def level
              if @variable_specs.none?{|_,expand,ml| expand || (ml > 0) }
                if @variable_specs.size == 1
                  return self.class::BASE_LEVEL
                else
        Severity: Minor
        Found in lib/uri_template/rfc6570/expression.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 to_s has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            def to_s
              return '{' + self.class::OPERATOR + @variable_specs.map{|name,expand,max_length| name + (expand ? '*': '') + (max_length > 0 ? (':' + max_length.to_s) : '') }.join(',') + '}'
            end
        Severity: Minor
        Found in lib/uri_template/rfc6570/expression.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