Showing 8 of 8 total issues
Method generate_from_regexp_string
has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring. Open
def generate_from_regexp_string(string, opts = {})
string.sub!(/^\^?(.+?)\$?$/, '\1')
string.scan(/(?:\[([^\]]+)\]|\((?:\?<[^>]+>|\?:)?(.*)\)|\\([*+?\\\{\}\[\]WwDdSs.^$])|([^*+?\{\}\[\]]))(\*\??|\+\??|\{(\d*),?(\d*)\})?/).map do |group|
ranges, subexpr, special_char, char, limit, min, max = group
if !ranges.nil?
- Read upRead up
- Create a ticketCreate a ticket
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 genny
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
def self.genny(opts = {})
opts = Genny.symbolize(opts)
opts[:items] = opts[:items].is_a?(::Array) ? opts[:items] : [opts[:items]].compact
raise ArgumentError, "classes must be an array" unless opts[:items].respond_to?(:select)
items = opts[:items].select { |item| item.respond_to?(:genny) }.dup
- Read upRead up
- Create a ticketCreate a ticket
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 genny
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
def self.genny(opts = {})
opts = Genny.symbolize(opts)
viable_formats = @@formats.keys & [*opts[:format]]
return @@formats[viable_formats.sample].call(opts) unless viable_formats.empty?
if (re = ::Regexp.new(opts[:format]) rescue false)
- Read upRead up
- Create a ticketCreate a ticket
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 genny
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def self.genny(opts = {})
opts = Genny.symbolize(opts)
opts[:additional_properties_n] ||= 3
raise "additional_properties_n must be an integer" unless opts[:additional_properties_n] >= 0
opts[:properties] ||= {}
- Read upRead up
- Create a ticketCreate a ticket
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 generate_from_regexp_string
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
def generate_from_regexp_string(string, opts = {})
string.sub!(/^\^?(.+?)\$?$/, '\1')
string.scan(/(?:\[([^\]]+)\]|\((?:\?<[^>]+>|\?:)?(.*)\)|\\([*+?\\\{\}\[\]WwDdSs.^$])|([^*+?\{\}\[\]]))(\*\??|\+\??|\{(\d*),?(\d*)\})?/).map do |group|
ranges, subexpr, special_char, char, limit, min, max = group
if !ranges.nil?
- Create a ticketCreate a ticket
Method genny
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def genny(additional_opts = {})
opts = Genny.symbolize(self.merge(additional_opts))
return opts[:enum].sample if opts.has_key?(:enum)
return schema_from_ref(opts[:'$ref']).genny if opts[:'$ref']
- Read upRead up
- Create a ticketCreate a ticket
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 genny
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def genny(opts = {})
raise NotImplementedError, "This regular expression doesn't seem to support the `source` method" unless self.respond_to?(:source)
begin
str = generate_from_regexp_string(self.source, DEFAULT_OPTS.merge(opts))
raise unless str.match(self)
- Read upRead up
- Create a ticketCreate a ticket
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 schema_from_ref
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def schema_from_ref(name)
if self['definitions'][name]
subschema = self['definitions'][name]
elsif name.match(%r{^#/(.+)$})
subschema = self.dup
- Read upRead up
- Create a ticketCreate a ticket
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"