todesking/patm

View on GitHub
lib/patm.rb

Summary

Maintainability
D
2 days
Test Coverage

File patm.rb has 584 lines of code (exceeds 250 allowed). Consider refactoring.
Open

module Patm
  class NoMatchError < StandardError
    def initialize(value)
      super("Pattern not match: value=#{value.inspect}")
      @value = value
Severity: Major
Found in lib/patm.rb - About 1 day to fix

    Method compile_internal has 35 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

          def compile_internal(free_index, target_name = "_obj")
            i = free_index
            ctxs = []
            src = []
    
    
    Severity: Minor
    Found in lib/patm.rb - About 1 hr to fix

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

          def compile
            i = 0
            ctxs = []
            srcs = []
            @rules.each do|pat, block|
      Severity: Minor
      Found in lib/patm.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 execute has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
      Open

            def execute(mmatch, obj)
              return false unless obj.is_a?(Array)
      
              size_min = @head.size + @tail.size
              if @rest
      Severity: Minor
      Found in lib/patm.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 call has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
      Open

              def call(*args)
                if args.size == 1 && args.first.is_a?(::Hash)
                  hash = args.first
                  hash.keys.each do|k|
                    raise ArgumentError, "#{k.inspect} is not member of #{@klass}" unless @klass.members.include?(k)
      Severity: Minor
      Found in lib/patm.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 compile_part has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

              def compile_part(target_name, part, srcs, ctxs, i)
                part.each_with_index do|h, hi|
                  if h.is_a?(Obj)
                    s, c, i = h.compile_internal(i, "#{target_name}[#{hi}]")
                    srcs << "#{s}" if s
      Severity: Minor
      Found in lib/patm.rb - About 55 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 execute has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

            def execute(match, obj)
              return false unless obj.is_a?(::Hash)
              obj.size >= @non_opt_count &&
                (!@exact || obj.keys.all?{|k| @pat.has_key?(k) }) &&
                @pat.all? {|k, pat|
      Severity: Minor
      Found in lib/patm.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 compile_part has 5 arguments (exceeds 4 allowed). Consider refactoring.
      Open

              def compile_part(target_name, part, srcs, ctxs, i)
      Severity: Minor
      Found in lib/patm.rb - About 35 mins to fix

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

              def compile_internal(free_index, target_name = "_obj")
                i = free_index
                ctxs = []
                src = []
        
        
        Severity: Minor
        Found in lib/patm.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 false unless @tail.zip(obj[(-@tail.size)..-1]).all? {|pat, o|
        Severity: Major
        Found in lib/patm.rb - About 30 mins to fix

          There are no issues that match your filters.

          Category
          Status