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)) }
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 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 = {}
- 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 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)
- 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 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
- 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 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 = {}
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
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 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|
- 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 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 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
- 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
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)))
Method deprecated_old_init
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def deprecated_old_init(token, text, _min, _max, _mode = :greedy)
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
- 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 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?),
- 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"