Showing 83 of 103 total issues
Method valid?
has a Cognitive Complexity of 161 (exceeds 5 allowed). Consider refactoring. Open
def valid?
@errors = Hash.new {|h,k| h[k] = []}
self.class._validations.each do |validation|
value = self.send(validation[:field_name])
allow_nil = validation[:options].fetch(: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
File request.rb
has 883 lines of code (exceeds 250 allowed). Consider refactoring. Open
require "cgi"
require "multi_json"
require 'crack'
require 'crack/xml'
Method call
has a Cognitive Complexity of 63 (exceeds 5 allowed). Consider refactoring. Open
def call(explicit_parameters=nil)
@instrumentation_name = "#{class_name}##{@method[:name]}"
result = nil
cached = nil
ActiveSupport::Notifications.instrument("request_call.flexirest", :name => @instrumentation_name, quiet: quiet?) do
- 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 handle_response
has a Cognitive Complexity of 50 (exceeds 5 allowed). Consider refactoring. Open
def handle_response(response, cached = nil)
@response = response
status = @response.status || 200
if @response.body.blank? && !@method[:options][:ignore_empty_response]
@response.response_headers['Content-Type'] = "application/json"
- 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 prepare_params
has a Cognitive Complexity of 48 (exceeds 5 allowed). Consider refactoring. Open
def prepare_params
if http_method == :post || http_method == :put || http_method == :patch
params = (@object._attributes rescue {}).merge(@params || {}) rescue {}
else
params = @params || @object._attributes rescue {}
- 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 do_request
has a Cognitive Complexity of 43 (exceeds 5 allowed). Consider refactoring. Open
def do_request(etag)
http_headers = {}
http_headers["If-None-Match"] = etag if etag && !@method[:options][:skip_caching]
http_headers["Accept"] = "application/hal+json, application/json;q=0.5"
headers.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 generate_new_object
has a Cognitive Complexity of 43 (exceeds 5 allowed). Consider refactoring. Open
def generate_new_object(options={})
if @response.body.is_a?(Array) || @response.body.is_a?(Hash)
body = @response.body
elsif is_json_response?
begin
- 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
Class Request
has 47 methods (exceeds 20 allowed). Consider refactoring. Open
class Request
include AttributeParsing
include JsonAPIProxy
include ActiveSupport::Inflector
attr_accessor :post_params, :get_params, :url, :path, :headers, :method, :object, :body, :forced_url, :original_url, :retrying
Method prepare_request_body
has a Cognitive Complexity of 36 (exceeds 5 allowed). Consider refactoring. Open
def prepare_request_body(params = nil)
if proxy == :json_api
if http_method == :get || (http_method == :delete && !@method[:options][:send_delete_body])
@body = ""
else
- 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 write_cached_response
has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring. Open
def write_cached_response(request, response, result, quiet)
return if result.is_a? Symbol
return unless perform_caching
return unless !result.respond_to?(:_status) || [200, 304].include?(result._status)
headers = response.response_headers
- 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
File configuration.rb
has 330 lines of code (exceeds 250 allowed). Consider refactoring. Open
require 'cgi'
module Flexirest
module Configuration
module ClassMethods
Method set_corresponding_value
has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring. Open
def set_corresponding_value(value, key = nil, object = nil, overridden_name = nil)
optional_args = [key, object, overridden_name]
value_from_object = optional_args.all? # trying to parse a JSON Hash value
value_from_other_type = optional_args.none? # trying to parse anything else
raise Flexirest::InvalidArgumentsException.new("Optional args need all to be filled or none") unless value_from_object || value_from_other_type
- 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 method_missing
has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring. Open
def method_missing(name, *args)
if name.to_s[-1,1] == "="
name = name.to_s.chop.to_sym
_set_attribute(name, args.first)
else
- 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 86 lines of code (exceeds 25 allowed). Consider refactoring. Open
def call(explicit_parameters=nil)
@instrumentation_name = "#{class_name}##{@method[:name]}"
result = nil
cached = nil
ActiveSupport::Notifications.instrument("request_call.flexirest", :name => @instrumentation_name, quiet: quiet?) do
Method do_request
has 83 lines of code (exceeds 25 allowed). Consider refactoring. Open
def do_request(etag)
http_headers = {}
http_headers["If-None-Match"] = etag if etag && !@method[:options][:skip_caching]
http_headers["Accept"] = "application/hal+json, application/json;q=0.5"
headers.each do |key,value|
Class BaseWithoutValidation
has 26 methods (exceeds 20 allowed). Consider refactoring. Open
class BaseWithoutValidation
include Mapping
include Configuration
include Callbacks
include Caching
Method prepare_params
has 73 lines of code (exceeds 25 allowed). Consider refactoring. Open
def prepare_params
if http_method == :post || http_method == :put || http_method == :patch
params = (@object._attributes rescue {}).merge(@params || {}) rescue {}
else
params = @params || @object._attributes rescue {}
Method valid?
has 72 lines of code (exceeds 25 allowed). Consider refactoring. Open
def valid?
@errors = Hash.new {|h,k| h[k] = []}
self.class._validations.each do |validation|
value = self.send(validation[:field_name])
allow_nil = validation[:options].fetch(:allow_nil, false)
Method handle_response
has 70 lines of code (exceeds 25 allowed). Consider refactoring. Open
def handle_response(response, cached = nil)
@response = response
status = @response.status || 200
if @response.body.blank? && !@method[:options][:ignore_empty_response]
@response.response_headers['Content-Type'] = "application/json"
Method prepare_request_body
has 69 lines of code (exceeds 25 allowed). Consider refactoring. Open
def prepare_request_body(params = nil)
if proxy == :json_api
if http_method == :get || (http_method == :delete && !@method[:options][:send_delete_body])
@body = ""
else