hannesg/uri_template

View on GitHub
lib/uri_template/rfc6570.rb

Summary

Maintainability
C
7 hrs
Test Coverage

File rfc6570.rb has 259 lines of code (exceeds 250 allowed). Consider refactoring.
Open

require 'strscan'
require 'set'
require 'forwardable'

require 'uri_template'
Severity: Minor
Found in lib/uri_template/rfc6570.rb - About 2 hrs to fix

    Method extract_matchdata has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

      def extract_matchdata(matchdata, post_processing)
        bc = 1
        vars = []
        tokens.each{|part|
          next if part.literal?
    Severity: Minor
    Found in lib/uri_template/rfc6570.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 try_convert has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

        def try_convert(x)
          if x.class == self
            return x
          elsif x.kind_of? String and valid? x
            return new(x)
    Severity: Minor
    Found in lib/uri_template/rfc6570.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 extract has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

      def extract(uri_or_match, post_processing = DEFAULT_PROCESSING )
        if uri_or_match.kind_of? String
          m = self.to_r.match(uri_or_match)
        elsif uri_or_match.kind_of?(MatchData)
          if uri_or_match.respond_to?(:regexp) and uri_or_match.regexp != self.to_r
    Severity: Minor
    Found in lib/uri_template/rfc6570.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 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

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

      There are no issues that match your filters.

      Category
      Status