File api_controller.rb
has 1591 lines of code (exceeds 250 allowed). Consider refactoring. Open
module Api::V3
class ApiController < ApplicationController
include OAuth2AccountAuthorization
include CorsCheck
Method new_user
has a Cognitive Complexity of 34 (exceeds 5 allowed). Consider refactoring. Open
def new_user
data = (JSON.parse(request_data) rescue {}).keep_if { |key, _| USER_API_FIELDS.include?(key) }
data = data.with_indifferent_access
data.reverse_merge!(email: params[:email], password: pwd = params[:password])
data.reject! { |_, value| value.nil? }
- 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 index
has a Cognitive Complexity of 32 (exceeds 5 allowed). Consider refactoring. Open
def index
setup_viewport
items = select_items
if (distinct = params[:format]&.match(/\Adistinct\((.+)\)\Z/))
json = klass.collection.distinct(distinct[1], items.selector)
- 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 new
has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring. Open
def new
parser_options = self.parser_options.dup
if klass.is_a?(Class) && klass < FieldsInspection
parser_options[:inspect_fields] = Account.current.nil? || !::User.super_access?
end
- 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 post_digest_pull_import
has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring. Open
def post_digest_pull_import(request, options = {})
readable =
if request.content_type.downcase == 'multipart/form-data'
request.params[:data] || request.params[:file] || fail('Missing data (or file) part')
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
Class ApiController
has 29 methods (exceeds 20 allowed). Consider refactoring. Open
class ApiController < ApplicationController
include OAuth2AccountAuthorization
include CorsCheck
Method post_digest_schedule
has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring. Open
def post_digest_schedule(request, _options = {})
sch_data = request.body.read.strip
sch_data = sch_data.empty? ? {} : JSON.parse(sch_data)
scheduler =
if sch_data.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 post_digest_token
has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring. Open
def post_digest_token(request, _options = {})
error_field = '$'
body = request.body.read
payload =
if body.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 authorize_action
has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring. Open
def authorize_action(options = {})
action = options[:action] || @_action_name
success = true
if klass
action_symbol =
- 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 index
has 58 lines of code (exceeds 25 allowed). Consider refactoring. Open
def index
setup_viewport
items = select_items
if (distinct = params[:format]&.match(/\Adistinct\((.+)\)\Z/))
json = klass.collection.distinct(distinct[1], items.selector)
Method post_digest_pull
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
def post_digest_pull(request, _options = {})
options = JSON.parse(request.body.read)
message[:install] = options['install'].to_b if ask_for_install?
unless (pull_parameters = options['pull_parameters']).is_a?(Hash)
pull_parameters = {}
- 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 digest
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
def digest
request.body.rewind
options =
begin
JSON.parse(request.headers['X-Digest-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 new_user
has 45 lines of code (exceeds 25 allowed). Consider refactoring. Open
def new_user
data = (JSON.parse(request_data) rescue {}).keep_if { |key, _| USER_API_FIELDS.include?(key) }
data = data.with_indifferent_access
data.reverse_merge!(email: params[:email], password: pwd = params[:password])
data.reject! { |_, value| value.nil? }
Method post_digest_pull_import
has 42 lines of code (exceeds 25 allowed). Consider refactoring. Open
def post_digest_pull_import(request, options = {})
readable =
if request.content_type.downcase == 'multipart/form-data'
request.params[:data] || request.params[:file] || fail('Missing data (or file) part')
else
Method show
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
def show
item = @item
if (json_path = request.headers['X-JSON-Path']) && json_path =~ /\A\$(.(^[.\[\]])*(\[[0-9]+\])?)+\Z/
json_path = json_path.split('.')
json_path.shift
- 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_delete_digest
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
def handle_delete_digest(controller)
query = where(controller.query_selector)
response =
if query.count == 1
item = query.first
- 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 update
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
def update
parser_options = self.parser_options.dup
parser_options[:add_only] = true
async = klass.is_a?(Class) && klass < Setup::AsynchronousPersistence::Model
if async
- 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_digest_origins
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
def get_digest_origins(_request, _options = {})
model = records_model
origins =
if (model.is_a?(Class) && model < CrossOrigin::Document) || model == Collection
origins = model.origins
- 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 authorize_action
has 38 lines of code (exceeds 25 allowed). Consider refactoring. Open
def authorize_action(options = {})
action = options[:action] || @_action_name
success = true
if klass
action_symbol =
Method post_digest
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def post_digest(request, options = {})
readable =
if request.content_type.downcase == 'multipart/form-data'
request.params[:data] || request.params[:file] || fail('Missing data (or file) part')
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 select_items
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def select_items
asc = true
if (order = query_selector.delete(:order))
order.strip!
asc = !order.match(/^-.*/)
- 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_data_type_by_slug
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
def get_data_type_by_slug(slug)
if slug
@data_types[slug] ||=
begin
build_in = nil
Method new
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
def new
parser_options = self.parser_options.dup
if klass.is_a?(Class) && klass < FieldsInspection
parser_options[:inspect_fields] = Account.current.nil? || !::User.super_access?
end
Method digest
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
def digest
request.body.rewind
options =
begin
JSON.parse(request.headers['X-Digest-Options'])
Method post_digest_cross
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def post_digest_cross(request, _options = {})
fail 'Unable to cross' unless model.is_a?(Class) && (
model < CrossOrigin::Document ||
model == Collection
)
- 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 post_digest
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def post_digest(request, _options = {})
begin
message = JSON.parse(request.body.read)
fail unless message.is_a?(Hash)
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 delete_digest_token
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def delete_digest_token(request, _options = {})
token = OauthAccessToken.where(id: request.params[:id], token: request.params[:token]).first
if token
if token.destroy
{
- 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 post_digest_upload
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def post_digest_upload(request, options = {})
readable =
if request.content_type.downcase == 'multipart/form-data'
request.params[:data] || request.params[:file] || fail('Missing data (or file) part')
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 get_digest_switch_sudo
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def get_digest_switch_sudo(_request, options = {})
if has_role?(:super_admin)
if update(super_admin_enabled: !super_admin_enabled)
{
json: to_hash(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 select_items
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
def select_items
asc = true
if (order = query_selector.delete(:order))
order.strip!
asc = !order.match(/^-.*/)
Method template_options
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
def template_options
@template_options ||=
begin
unless (opts = Cenit::Utility.json_value_of(request.headers['X-Template-Options'])).is_a?(Hash)
opts = {}
Method post_digest_token
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
def post_digest_token(request, _options = {})
error_field = '$'
body = request.body.read
payload =
if body.blank?
Method post_digest
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
def post_digest(request, options = {})
readable =
if request.content_type.downcase == 'multipart/form-data'
request.params[:data] || request.params[:file] || fail('Missing data (or file) part')
else
Method update
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
def update
parser_options = self.parser_options.dup
parser_options[:add_only] = true
async = klass.is_a?(Class) && klass < Setup::AsynchronousPersistence::Model
if async
Method handle_get_digest
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def handle_get_digest(controller)
if (id = controller.request.headers['X-Record-Id'])
controller.setup_request(namespace: ns_slug, klass: records_model, id: id)
controller.show if (item = controller.find_item) && controller.authorize_action(
action: :read,
- 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_digest_retry
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def get_digest_retry(_request, _options = {})
if (execution = self.retry)
if execution.is_a?(Setup::SystemNotification)
fail execution.message
end
- 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_digest_reinstall
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def get_digest_reinstall(_request, _options = {})
if User.current_super_admin?
execution = ::Setup::BuildInAppReinstall.process(
build_in_app_id: id,
task_description: "Re-installing build-in app #{app_module_name}"
- 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 post_digest_access
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def post_digest_access(request, options = {})
scope = ::Cenit::OauthScope.new(JSON.parse(request.body.read)['scope'])
fail 'Is not valid' unless scope.valid?
access_grant = ::Cenit::OauthAccessGrant.where(
application_id_id: application_id_id
- 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_delete_digest
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
def handle_delete_digest(controller)
query = where(controller.query_selector)
response =
if query.count == 1
item = query.first
Method query_selector
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
def query_selector(selector = nil)
parse_query_params =
if selector
@criteria = nil
else
Consider simplifying this complex logical expression. Open
if @ability.can?(action_symbol, options[:item] || options[:klass] || @item || klass) &&
(@oauth_scope.nil? || @oauth_scope.can?(action_symbol, options[:klass] || klass))
@access_token.hit if @access_token
else
success = false
Method post_digest
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def post_digest(request, _options = {})
hash = input = JSON.parse(request.body.read)
if input.is_a?(Array)
hash = parameters.map { |p, index| [p.name, input[index]] }
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 post_digest
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def post_digest(request, _options = {})
hash = input = JSON.parse(request.body.read)
if input.is_a?(Array)
hash = parameters.map { |p, index| [p.name, input[index]] }
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
Avoid deeply nested control flow statements. Open
if !data.key?(:email) || data[:email] == token_data[:email]
data.merge!(captcha_token.data || {}) { |_, left, right| left || right }
captcha_token.destroy
_, status, response = create_user_with(data)
response
Method post_digest
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def post_digest(request, _options = {})
options = JSON.parse(request.body.read)
execution = Setup::Translation.process(
translator_id: id,
data_type_id: (
- 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 post_digest_pull
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def post_digest_pull(request, _options)
data = JSON.parse(request.body.read)
execution = pull(
pull_parameters: data['pull_parameters'] || {}
)
- 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 post_digest
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def post_digest(request, _options = {})
options = JSON.parse(request.body.read)
execution = Setup::Translation.process(
translator_id: id,
data_type_id: (
- 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_digest_config
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def get_digest_config(_request, _options = {})
if (config = self.config).new_record?
config = {}
else
config = config.to_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 post_digest
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def post_digest(request, _options = {})
options = JSON.parse(request.body.read)
execution = Setup::Translation.process(
translator_id: id,
data_type_id: (
- 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 post_digest_push
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def post_digest_push(request, _options = {})
options = JSON.parse(request.body.read)
execution = Setup::Push.process(
source_collection_id: id,
shared_collection_id: (
- 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 post_digest_registration
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def post_digest_registration(request, options = {})
data = JSON.parse(request.body.read).with_indifferent_access
app_id = application_id
if app_id.regist_with(data).valid? && app_id.save
{
- 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_digest_email_data_type
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def self.get_digest_email_data_type(_request, _options = {})
if (data_type = Setup::Configuration.singleton_record.email_data_type)
{
json: {
id: data_type.id.to_s,
- 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 digest_schema
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def digest_schema(request, options = {})
data =
if request.get?
merged_schema(options)
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 post_digest_config
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def post_digest_config(request, _options = {})
self.configuration = request.body.read
if save
{
body: nil
- 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_digest_switch_trust
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def get_digest_switch_trust(_request, options = {})
self.trusted = !trusted
if save
{
json: to_hash(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 setup_request
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def setup_request(options = {})
if (@klass = options[:klass])
@ns_name = @klass.data_type.namespace
else
@ns_name = nil
- 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_get_digest_download
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def handle_get_digest_download(controller)
file = where(controller.query_selector).first
if file
controller.send_data(file.data, filename: file.filename, type: file.contentType)
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 get_digest_access
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def get_digest_access(_request, options = {})
access_grant = ::Cenit::OauthAccessGrant.where(
application_id_id: application_id_id
).first
if access_grant
- 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
Identical blocks of code found in 2 locations. Consider refactoring. Open
if (token = data[:token] || params[:token])
if (captcha_token = CaptchaToken.where(token: token).first)
if (code = data[:code] || params[:code])
if code == captcha_token.code
token_data = captcha_token.data || {}
- 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 80.
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 3 locations. Consider refactoring. Open
UpdaterTransformation.class_eval do
def post_digest(request, _options = {})
options = JSON.parse(request.body.read)
execution = Setup::Translation.process(
- 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 78.
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 3 locations. Consider refactoring. Open
Template.class_eval do
def post_digest(request, _options = {})
options = JSON.parse(request.body.read)
execution = Setup::Translation.process(
- 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 78.
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 3 locations. Consider refactoring. Open
ConverterTransformation.class_eval do
def post_digest(request, _options = {})
options = JSON.parse(request.body.read)
execution = Setup::Translation.process(
- 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 78.
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
Identical blocks of code found in 2 locations. Consider refactoring. Open
fields_option =
case fields_option
when Array
fields_option
when Hash
- 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 29.
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