Showing 91 of 91 total issues
Method to_swagger
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def to_swagger
@param_descriptions.each do |desc|
context = @context.dup
type = Apipie::Generator::Swagger::TypeExtractor.new(desc.validator).extract
- 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 deep_merge_examples
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def deep_merge_examples(new_examples, old_examples)
new_examples.map do |new_example|
# Use ordered to get compareble output (mainly for the :query)
new_example_ordered = ordered_call(new_example.dup)
- 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
Function applyPlacement
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
, applyPlacement: function(offset, placement){
var $tip = this.tip()
, width = $tip[0].offsetWidth
, height = $tip[0].offsetHeight
, actualWidth
Method to_swagger
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
def to_swagger
@param_descriptions.each do |desc|
context = @context.dup
type = Apipie::Generator::Swagger::TypeExtractor.new(desc.validator).extract
Method returns
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
def returns(pgroup_or_options, desc_or_options = nil, options = {}, &block) #:doc:
return unless Apipie.active_dsl?
if desc_or_options.is_a? Hash
Method initialize
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
def initialize(method, resource, dsl_data)
@method = method.to_s
@resource = resource
@from_concern = dsl_data[:from_concern]
@apis = ApisService.new(resource, method, dsl_data).call
Method populate_api_routes
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def populate_api_routes
@apis_from_routes = Hash.new { |h, k| h[k] = [] }
all_api_routes.each do |route|
controller_path, action = route[:controller], route[:action]
- 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 rails_routes
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def rails_routes(route_set = nil, base_url = "")
return @_rails_routes if route_set.nil? && @_rails_routes
route_set ||= Rails.application.routes
# ensure routes are loaded
- 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 get_language
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def get_language
return nil unless Apipie.configuration.translate
lang = Apipie.configuration.default_locale
[:resource, :method, :version].each do |par|
next unless params[par]
- 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 to_json
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def to_json(version, resource_id, method_name, lang)
return unless valid_search_args?(version, resource_id, method_name)
_resources = if resource_id.blank?
- 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
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def validate(value)
return true if allow_nil && value.nil?
return true if allow_blank && value.blank?
value = normalized_value(value)
if (!allow_nil && value.nil?) || (blank_forbidden? && value.blank?) || !validator.valid?(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 initialize
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
def initialize(method_description, code, options, scope, block, adapter)
@type_ref = options[:param_group]
@is_array_of = options[:array_of] || false
raise ReturnsMultipleDefinitionError, options if @is_array_of && @type_ref
Method refine_params_description
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
def refine_params_description(params_desc, recorded_params)
recorded_params.each do |key, value|
params_desc[key] ||= {}
param_desc = params_desc[key]
Function keydown
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
, keydown: function (e) {
var $this
, $items
, $active
, $parent
Similar blocks of code found in 2 locations. Consider refactoring. Open
this.timeout = setTimeout(function() {
if (self.hoverState == 'in') self.show()
}, self.options.delay.show)
- 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 55.
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
this.timeout = setTimeout(function() {
if (self.hoverState == 'out') self.hide()
}, self.options.delay.hide)
- 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 55.
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 action_awareness
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def action_awareness
if action_aware?
if !@options.key?(:allow_nil)
if @required
@allow_nil = false
- 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 initialize
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def initialize(args)
if args.first.is_a? Hash
args = args.first
elsif args.count == 2
if args.last.is_a? Hash
- 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 get_format
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def get_format
[:resource, :method, :version].each do |par|
next unless params[par]
[:html, :json].each do |format|
extension = ".#{format}"
- 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 initialize
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
def initialize(method_description, name, validator, desc_or_options = nil, options = {}, &block)