rkh/mustermann

View on GitHub

Showing 23 of 23 total issues

Class Pattern has 31 methods (exceeds 20 allowed). Consider refactoring.
Open

  class Pattern
    include Mustermann
    @@uri ||= URI::Parser.new

    # List of supported options.
Severity: Minor
Found in mustermann/lib/mustermann/pattern.rb - About 3 hrs to fix

    Class StringScanner has 25 methods (exceeds 20 allowed). Consider refactoring.
    Open

      class StringScanner
        # Exception raised if scan/unscan operation cannot be performed.
        ScanError     = Class.new(::ScanError)
        PATTERN_CACHE = PatternCache.new
        private_constant :PATTERN_CACHE
    Severity: Minor
    Found in mustermann-contrib/lib/mustermann/string_scanner.rb - About 2 hrs to fix

      Method compile! has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
      Open

          def compile!(verb, path, block, except: nil, capture: nil, pattern: { }, **options)
            if path.respond_to? :to_str
              pattern[:except]  = except  if except
              pattern[:capture] = capture if capture
      
      
      Severity: Minor
      Found in mustermann/lib/mustermann/extension.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 compile has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
      Open

          def compile(greedy: true, uri_decode: true, space_matches_plus: true, **options)
            pattern = @string.gsub(/[^\?\%\\\/\:\*\w]/) { |c| encoded(c, uri_decode, space_matches_plus) }
            pattern.gsub!(/((:\w+)|\*)/) do |match|
              match == "*" ? "(?<splat>.*?)" : "(?<#{$2[1..-1]}>[^/?#]+#{?? unless greedy})"
            end
      Severity: Minor
      Found in mustermann-contrib/lib/mustermann/simple.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 glob has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
      Open

          def glob(*pattern, **options, &block)
            raise ArgumentError, "no pattern given" if pattern.empty?
            pattern, glob_pattern = pattern_with_glob_pattern(*pattern, **options)
            results               = [] unless block
            Dir.glob(glob_pattern) do |result|
      Severity: Minor
      Found in mustermann-contrib/lib/mustermann/file_utils.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 cast has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

          def cast(hash)
            return hash if empty?
            merge = {}
            hash.delete_if do |key, value|
              next unless casted = lazy.map { |e| e.cast(key, value) }.detect { |e| e }
      Severity: Minor
      Found in mustermann/lib/mustermann/caster.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 on has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

              def self.on(regexp, type = nil, &callback)
                return regexp.map  { |key, value| on(key, value, &callback) } if regexp.is_a? Hash
                raise ArgumentError, 'needs type or callback' unless type or callback
                callback    ||= proc { |matched| element(type, matched) }
                regexp        = Regexp.new(Regexp.escape(regexp)) unless regexp.is_a? Regexp
      Severity: Minor
      Found in mustermann-contrib/lib/mustermann/visualizer/highlighter/ad_hoc.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 min_size has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

            def min_size(start, stop, node)
              stop  ||= start
              start ||= stop
              node.start = start unless node.start and node.start < start
              node.stop  = stop  unless node.stop  and node.stop  > stop
      Severity: Minor
      Found in mustermann/lib/mustermann/ast/parser.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 new has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

          def self.new(string, ignore_unknown_options: false, **options)
            if ignore_unknown_options
              options = options.select { |key, value| supported?(key, **options) if key != :ignore_unknown_options }
            else
              unsupported = options.keys.detect { |key| not supported?(key, **options) }
      Severity: Minor
      Found in mustermann/lib/mustermann/pattern.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 new has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

        def self.new(*input, type: DEFAULT_TYPE, operator: :|, **options)
          type ||= DEFAULT_TYPE
          input  = input.first if input.size < 2
          case input
          when Pattern then input
      Severity: Minor
      Found in mustermann/lib/mustermann.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_leaf has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

            def each_leaf(&block)
              return enum_for(__method__) unless block_given?
              called = false
              Array(payload).each do |entry|
                next unless entry.respond_to? :each_leaf
      Severity: Minor
      Found in mustermann/lib/mustermann/ast/node.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 read_args has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

            def read_args(key_separator, close, separator: ?,, symbol_keys: true, **options)
              list, map = [], {}
              while buffer.peek(1) != close
                scan(separator)
                entries = read_list(close, separator, separator: key_separator, **options)
      Severity: Minor
      Found in mustermann/lib/mustermann/ast/parser.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 + has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

            def +(other)
              other &&= Mustermann.new(other, type: :identity, **options)
              if (patterns = look_ahead(other)) && !patterns.empty?
                concat = (self + patterns.inject(:+))
                concat + other.patterns.slice(patterns.length..-1).inject(:+)
      Severity: Minor
      Found in mustermann/lib/mustermann/concat.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 add has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

          def add(*patterns)
            patterns.each do |pattern|
              pattern = Mustermann.new(pattern, **@options)
              if block_given?
                @api_expander.add(yield(pattern))
      Severity: Minor
      Found in mustermann/lib/mustermann/expander.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 read_list has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

            def read_list(*close, separator: ?,, escape: ?\\, quotes: [?", ?'], ignore: " ", **options)
              result = []
              while current = getch
                element = result.empty? ? result : result.last
                case current
      Severity: Minor
      Found in mustermann/lib/mustermann/ast/parser.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 params has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          def params(string = nil, captures: nil, offset: 0)
            return unless captures ||= match(string)
            params   = named_captures.map do |name, positions|
              values = positions.map { |pos| map_param(name, captures[pos + offset]) }.flatten
              values = values.first if values.size < 2 and not always_array? name
      Severity: Minor
      Found in mustermann/lib/mustermann/pattern.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 converters has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          def self.converters(inherited = true)
            return @converters ||= {} unless inherited
            defaults = superclass.respond_to?(:converters) ? superclass.converters : {}
            defaults.merge(converters(false))
          end
      Severity: Minor
      Found in mustermann-contrib/lib/mustermann/flask.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 between has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

            def between(min, max)
              self.convert = proc do |input|
                value = yield(input)
                value = yield(min) if min and value < yield(min)
                value = yield(max) if max and value > yield(max)
      Severity: Minor
      Found in mustermann-contrib/lib/mustermann/flask.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 expand has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          def expand(behavior = nil, values = {})
            return to_s if values.empty? or behavior == :ignore
            raise ExpandError,    "cannot expand with keys %p" % values.keys.sort if behavior == :raise
            raise ArgumentError,  "unknown behavior %p"        % behavior         if behavior != :append
            params    = values.map { |key, value| @@uri.escape(key.to_s) + "=" + @@uri.escape(value.to_s, /[^\w]/) }
      Severity: Minor
      Found in mustermann/lib/mustermann/identity.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 encoded has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

            def encoded(char, uri_decode: true, space_matches_plus: true, **options)
              return Regexp.escape(char) unless uri_decode
              encoded = escape(char, escape: /./)
              list    = [escape(char), encoded.downcase, encoded.upcase].uniq.map { |c| Regexp.escape(c) }
              if char == " "
      Severity: Minor
      Found in mustermann/lib/mustermann/ast/compiler.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