hannesg/uri_template

View on GitHub

Showing 33 of 33 total issues

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

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

        def each
          scanner = StringScanner.new(@source)
          until scanner.eos?
            expression = scanner.scan(EXPRESSION)
            if expression
    Severity: Minor
    Found in lib/uri_template/rfc6570.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

    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 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

    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

    Avoid too many return statements within this method.
    Open

          return '{'+min.to_s+',}'
    Severity: Major
    Found in lib/uri_template/rfc6570/regex_builder.rb - About 30 mins to fix

      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

        Avoid too many return statements within this method.
        Open

                return nil
        Severity: Major
        Found in lib/uri_template/rfc6570.rb - About 30 mins to fix

          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

          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 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

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

            def initialize(pattern_or_tokens,options={})
              @options = options.dup.freeze
              if pattern_or_tokens.kind_of? String
                @pattern = pattern_or_tokens.dup
                @pattern.freeze
          Severity: Minor
          Found in lib/uri_template/rfc6570.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