ammar/regexp_parser

View on GitHub

Showing 21 of 25 total issues

File unicode_property.rb has 689 lines of code (exceeds 250 allowed). Consider refactoring.
Open

module Regexp::Syntax
  module Token
    module UnicodeProperty
      all = proc { |name| constants.grep(/#{name}/).flat_map(&method(:const_get)) }

Severity: Major
Found in lib/regexp_parser/syntax/token/unicode_property.rb - About 1 day to fix

    File parser.rb has 482 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 67 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

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

          Method strfregexp has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
          Open

              def strfregexp(format = '%a', indent_offset = 0, index = nil)
                have_index    = index ? true : false
          
                part = {}
          
          
          Severity: Minor
          Found in lib/regexp_parser/expression/methods/strfregexp.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 one_of? has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
          Open

              def one_of?(scope, top = true)
                case scope
                when Array
                  scope.include?(:*) || scope.include?(token)
          
          
          Severity: Minor
          Found in lib/regexp_parser/expression/methods/tests.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 lex has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
          Open

            def lex(input, syntax = nil, options: nil, collect_tokens: true, &block)
              syntax = syntax ? Regexp::Syntax.for(syntax) : Regexp::Syntax::CURRENT
          
              self.block = block
              self.collect_tokens = collect_tokens
          Severity: Minor
          Found in lib/regexp_parser/lexer.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 strfregexp has 42 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              def strfregexp(format = '%a', indent_offset = 0, index = nil)
                have_index    = index ? true : false
          
                part = {}
          
          
          Severity: Minor
          Found in lib/regexp_parser/expression/methods/strfregexp.rb - About 1 hr to fix

            Method lex has 38 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              def lex(input, syntax = nil, options: nil, collect_tokens: true, &block)
                syntax = syntax ? Regexp::Syntax.for(syntax) : Regexp::Syntax::CURRENT
            
                self.block = block
                self.collect_tokens = collect_tokens
            Severity: Minor
            Found in lib/regexp_parser/lexer.rb - About 1 hr 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 each has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                  Open

                    def each(opts = {})
                      return enum_for(__method__, opts) unless block_given?
                      limit = opts[:limit] || 1000
                      yielded = 0
                      (min..max).each do |num|
                  Severity: Minor
                  Found in lib/regexp_parser/expression/methods/match_length.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 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 each_expression has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                    Open

                        def each_expression(include_self = false, &block)
                          return enum_for(__method__, include_self) unless block
                    
                          if block.arity == 1
                            block.call(self) if include_self
                    Severity: Minor
                    Found in lib/regexp_parser/expression/methods/traverse.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 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

                    Consider simplifying this complex logical expression.
                    Open

                          if (last = prev_token) &&
                             type == :quantifier &&
                             (
                               (last.type == :literal         && (parts = break_literal(last))) ||
                               (last.token == :codepoint_list && (parts = break_codepoint_list(last)))
                    Severity: Major
                    Found in lib/regexp_parser/lexer.rb - About 40 mins to fix

                      Method deprecated_old_init has 5 arguments (exceeds 4 allowed). Consider refactoring.
                      Open

                          def deprecated_old_init(token, text, _min, _max, _mode = :greedy)
                      Severity: Minor
                      Found in lib/regexp_parser/expression/quantifier.rb - About 35 mins to fix

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

                            def traverse(include_self = false, &block)
                              return enum_for(__method__, include_self) unless block_given?
                        
                              block.call(:enter, self, 0) if include_self
                        
                        
                        Severity: Minor
                        Found in lib/regexp_parser/expression/methods/traverse.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 pretty_print_instance_variables has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                        Open

                            def pretty_print_instance_variables
                              [
                                (:@text unless text.to_s.empty?),
                                (:@quantifier if quantified?),
                                (:@options unless options.empty?),
                        Severity: Minor
                        Found in lib/regexp_parser/expression/methods/printing.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

                        Severity
                        Category
                        Status
                        Source
                        Language