ammar/regexp_parser

View on GitHub

Showing 28 of 28 total issues

File unicode_property.rb has 660 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 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 lex has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
          Open

            def lex(input, syntax = "ruby/#{RUBY_VERSION}", options: nil, &block)
              syntax = Regexp::Syntax.for(syntax)
          
              self.tokens = []
              self.nesting = 0
          Severity: Minor
          Found in lib/regexp_parser/lexer.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 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 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 30 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              def lex(input, syntax = "ruby/#{RUBY_VERSION}", options: nil, &block)
                syntax = Regexp::Syntax.for(syntax)
            
                self.tokens = []
                self.nesting = 0
            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

                    Similar blocks of code found in 2 locations. Consider refactoring.
                    Open

                      def ascend(type, token)
                        case type
                        when :group, :assertion
                          self.nesting = nesting - 1 if CLOSING_TOKENS.include?(token)
                        when :set
                    Severity: Minor
                    Found in lib/regexp_parser/lexer.rb and 1 other location - About 45 mins to fix
                    lib/regexp_parser/lexer.rb on lines 82..89

                    Duplicated Code

                    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                    Tuning

                    This issue has a mass of 41.

                    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                    Refactorings

                    Further Reading

                    Similar blocks of code found in 2 locations. Consider refactoring.
                    Open

                      def descend(type, token)
                        case type
                        when :group, :assertion
                          self.nesting = nesting + 1 if OPENING_TOKENS.include?(token)
                        when :set
                    Severity: Minor
                    Found in lib/regexp_parser/lexer.rb and 1 other location - About 45 mins to fix
                    lib/regexp_parser/lexer.rb on lines 71..78

                    Duplicated Code

                    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                    Tuning

                    This issue has a mass of 41.

                    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                    Refactorings

                    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 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 ascend has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                      Open

                        def ascend(type, token)
                          case type
                          when :group, :assertion
                            self.nesting = nesting - 1 if CLOSING_TOKENS.include?(token)
                          when :set
                      Severity: Minor
                      Found in lib/regexp_parser/lexer.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 descend has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                      Open

                        def descend(type, token)
                          case type
                          when :group, :assertion
                            self.nesting = nesting + 1 if OPENING_TOKENS.include?(token)
                          when :set
                      Severity: Minor
                      Found in lib/regexp_parser/lexer.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