ammar/regexp_parser

View on GitHub
lib/regexp_parser/parser.rb

Summary

Maintainability
D
2 days
Test Coverage

File parser.rb has 485 lines of code (exceeds 250 allowed). Consider refactoring.
Open

require 'regexp_parser/error'
require 'regexp_parser/expression'

class Regexp::Parser
  include Regexp::Expression
Severity: Minor
Found in lib/regexp_parser/parser.rb - About 7 hrs to fix

    Class Parser has 38 methods (exceeds 20 allowed). Consider refactoring.
    Open

    class Regexp::Parser
      include Regexp::Expression
    
      class ParserError < Regexp::Parser::Error; end
    
    
    Severity: Minor
    Found in lib/regexp_parser/parser.rb - About 5 hrs to fix

      Method property has 66 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def property(token)
          case token.token
          when :alnum;                  node << Alnum.new(token, active_opts)
          when :alpha;                  node << Alpha.new(token, active_opts)
          when :ascii;                  node << Ascii.new(token, active_opts)
      Severity: Major
      Found in lib/regexp_parser/parser.rb - About 2 hrs to fix

        Method backref has 30 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          def backref(token)
            case token.token
            when :name_ref
              node << Backreference::Name.new(token, active_opts)
            when :name_recursion_ref
        Severity: Minor
        Found in lib/regexp_parser/parser.rb - About 1 hr to fix

          Method escape has 28 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            def escape(token)
              case token.token
          
              when :backspace;      node << EscapeSequence::Backspace.new(token, active_opts)
          
          
          Severity: Minor
          Found in lib/regexp_parser/parser.rb - About 1 hr to fix

            Method options_group has 26 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              def options_group(token)
                positive, negative = token.text.split('-', 2)
                negative ||= ''
                self.switching_options = token.token.equal?(:options_switch)
            
            
            Severity: Minor
            Found in lib/regexp_parser/parser.rb - About 1 hr to fix

              Method options_group has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
              Open

                def options_group(token)
                  positive, negative = token.text.split('-', 2)
                  negative ||= ''
                  self.switching_options = token.token.equal?(:options_switch)
              
              
              Severity: Minor
              Found in lib/regexp_parser/parser.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 extract_options has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
              Open

                def extract_options(input, options)
                  if options && !input.is_a?(String)
                    raise ArgumentError, 'options cannot be supplied unless parsing a String'
                  end
              
              
              Severity: Minor
              Found in lib/regexp_parser/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 escape has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
              Open

                def escape(token)
                  case token.token
              
                  when :backspace;      node << EscapeSequence::Backspace.new(token, active_opts)
              
              
              Severity: Minor
              Found in lib/regexp_parser/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 assign_referenced_expressions has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

                def assign_referenced_expressions
                  # find all referencable expressions
                  targets = { 0 => root }
                  root.each_expression do |exp|
                    exp.is_a?(Group::Capture) && targets[exp.identifier] = exp
              Severity: Minor
              Found in lib/regexp_parser/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

              There are no issues that match your filters.

              Category
              Status