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
Class Parser
has 38 methods (exceeds 20 allowed). Consider refactoring. Open
class Regexp::Parser
include Regexp::Expression
class ParserError < Regexp::Parser::Error; end
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)
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
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)
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)
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)
- Read upRead up
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
- Read upRead up
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)
- Read upRead up
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"