rkh/mustermann

View on GitHub
mustermann/lib/mustermann/pattern.rb

Summary

Maintainability
B
5 hrs
Test Coverage

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

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

    There are no issues that match your filters.

    Category
    Status