Showing 86 of 86 total issues
Method enforce_symbolized_keys
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def enforce_symbolized_keys(type, method)
# Collections have all values processed individually
if [Array, Set].include?(type)
lambda do |val|
method.call(val).tap do |new_val|
- 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 version
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def version(*args, &block)
if args.any?
options = args.extract_options!
options = options.reverse_merge(using: :path)
requested_versions = args.flatten
- 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
Similar blocks of code found in 2 locations. Consider refactoring. Open
module Extensions
module ActiveSupport
module HashWithIndifferentAccess
module ParamBuilder
extend ::ActiveSupport::Concern
- Read upRead up
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 2 locations. Consider refactoring. Open
module Extensions
module Hashie
module Mash
module ParamBuilder
extend ::ActiveSupport::Concern
- Read upRead up
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Method transaction
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def transaction(env)
input, method = *extract_input_and_method(env)
response = yield(input, method)
return response if response && !(cascade = cascade?(response))
- 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 header
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def header(key = nil, val = nil)
if key
val ? header[key.to_s] = val : header.delete(key.to_s)
else
@header ||= {}
- 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_param!
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def validate_param!(attr_name, params)
return if (options_key?(:value) ? @option[:value] : @option) || !params.is_a?(Hash)
value = params[attr_name]
value = value.strip if value.respond_to?(:strip)
- 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 guess_coerce_type
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def guess_coerce_type(coerce_type, *values_list)
return coerce_type unless coerce_type == Array
values_list.each do |values|
next if !values || values.is_a?(Proc)
- 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 call
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def call(message, backtrace, options = {}, env = nil, original_exception = nil)
message = present(message, env)
result = message.is_a?(Hash) ? message : { message: message }
rescue_options = options[:rescue_options] || {}
- 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 error!
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def error!(message, status = options[:default_status], headers = {}, backtrace = [], original_exception = nil)
Method initialize
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def initialize(attrs, options, required, scope, **opts)
Method validate
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def validate(type, options, attrs, doc, opts)
Method call
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def call(message, backtrace, options = {}, env = nil, original_exception = nil)
Method call
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def call(message, backtrace, options = {}, env = nil, original_exception = nil)
Method initialize
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def initialize(attrs, options, required, scope, **opts)
Method initialize
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def initialize(attrs, options, required, scope, *opts)
Method declared_hash_attr
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def declared_hash_attr(passed_params, options, declared_param, params_nested_path, memo)
Method call
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def call(message, backtrace, options = {}, env = nil, original_exception = nil)
Method initialize
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def initialize(attrs, options, required, scope, **opts)
Method initialize
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def initialize(attrs, options, required, scope, **opts)