Showing 11 of 11 total issues
Class Model
has 24 methods (exceeds 20 allowed). Consider refactoring. Open
class Model
include ActiveModel::Validations
include Validators
include ActiveModel::AttributeMethods
include TypeCastAttributes
Method cast
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
def self.cast(value, type, timezone)
# If it's already the correct type (or nil) then we don't need to do anything
if value.nil? || value.is_a?(type)
value
# Special handling for arrays. When we typecast arrays we actually
- 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 json_errors_local
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def json_errors_local
r = []
# First show special json error
errors.attribute_names.each do |attribute|
r << [nil, errors[:json]] unless errors[:json].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"
Further reading
Method count_is_consistent
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def count_is_consistent
return if count.nil?
if response.respond_to?(:count)
if count != response.count
- 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 split
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def self.split(full_url)
uri = URI.parse(full_url)
url = if (uri.scheme == "http" && uri.port == 80) ||
(uri.scheme == "https" && uri.port == 443)
"#{uri.scheme}://#{uri.host}#{uri.path}"
- 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 applications_url
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def applications_url(options = {})
invalid_options = options.keys - VALID_OPTIONS
raise "Unexpected options used: #{invalid_options.join(',')}" unless invalid_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"
Further reading
Method json_errors_in_children
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def json_errors_in_children
r = []
attributes.each do |attribute_as_string, value|
attribute = attribute_as_string.to_sym
if value.respond_to?(:json_errors)
- 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 validate_each
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def validate_each(record, attribute, value)
if value && !value.is_a?(Array)
message = "should be an array"
message = ErrorMessage[message, options[:spec_section]] if options[:spec_section]
record.errors.add(attribute, message)
- 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 partition_by_used
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def self.partition_by_used(data)
used = {}
unused = {}
if data.respond_to?(:each)
data.each do |key, value|
- 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 previous_is_consistent
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def previous_is_consistent
if previous && current && previous != current - 1
errors.add(
:previous,
ErrorMessage["should be one less than current page number or null if first page", "6.4"]
- 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_from_url
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def self.options_from_url(url)
u = URI.parse(url)
options = query_to_options(u.query)
%i[lodgement_date_start lodgement_date_end last_modified_date_start
last_modified_date_end].each do |k|
- 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"