Showing 829 of 829 total issues
Method fresh_access_token
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
def fresh_access_token
if authorized_at.nil? || (authorized_at + (token_span || 0) < Time.now - 60)
fail 'Invalid client' unless client.is_a?(Setup::Application)
fail 'Invalid refresh token' unless (token = Cenit::OauthRefreshToken.where(token: refresh_token).first)
fail 'Refresh token app mismatch' unless token.application_id == client.application_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 method_missing
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
def method_missing(symbol, *args)
if (match = /\Adata_(.+)\Z/.match(symbol.to_s)) &&
COLLECTING_PROPERTIES.include?(relation_name = match[1].to_sym) &&
((args.length.zero? && (options = {})) || args.length == 1 && (options = args[0]).is_a?(Hash))
if (items = send(relation_name)).present?
- 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 intuit_reconnect_api_v1_refresh_token
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
def intuit_reconnect_api_v1_refresh_token(authorization)
return unless authorization.authorized_at + 151.days < Time.now
url = 'https://appcenter.intuit.com/api/v1/connection/reconnect'
response = Setup::Connection.get(url).with(authorization).submit(http_proxy_address: Cenit.http_proxy_address,
http_proxy_port: Cenit.http_proxy_port)
- 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 run
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
def run(message)
origin = origin_from(message)
criteria = objects_from(message)
model = data_type.records_model
if model < CrossOrigin::CenitDocument
- 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 config_pull_parameters
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
def config_pull_parameters
unless @config_pull_parameters
@config_pull_parameters = []
[Setup::RemoteOauthClient, Setup::GenericAuthorizationClient].each do |client_model|
clients = COLLECTING_PROPERTIES.detect { |p| reflect_on_association(p).klass == client_model }.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 mapping=
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
def mapping=(data)
return unless style == 'mapping'
unless data.is_a?(Hash)
data =
if data.is_a?(String)
- 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 run
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
def run(message)
clear_hashes
if pull_request_hash.present?
pull_request_hash[:install] = message[:install].to_b if ask_for_install?
if (pull_parameters = message[:pull_parameters]).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 schema
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
def schema
# TODO: Factorize code with algorithms and applications parameters
sch =
if type.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 notification_span_for
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
def notification_span_for(type)
type = type.to_s.to_sym
unless @notification_spans
@notification_spans = {}
regex = Regexp.new("\\A(#{Setup::SystemNotification.type_enum.join('|')})_notifications_span\\Z")
- 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 check_referenced_schema
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
def check_referenced_schema(schema, check_for_array = true)
if schema.is_a?(Hash) && (schema = schema.reject { |key, _| %w(types contextual_params data filter group xml unique title description edi format example enum readOnly default visible referenced_by maxProperties minProperties auto export_embedded exclusive).include?(key) })
property_dt = nil
ns = data_type.namespace
if (ref = schema['$ref']).is_a?(Array)
- 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 native_hash_format
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
def native_hash_format(options = {}, alg_delegator_method)
if (alg_methods = orm_model.data_type.records_methods.select { |alg| %w(to_hash to_json).include?(alg.name) }).present?
alg_delegator_method =
if alg_methods.length == 1 || alg_methods[0].name == alg_delegator_method.to_s
alg_methods[0].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 insert_or_update
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
def insert_or_update(options = {})
if new_record?
r = orm_model.collection.insert_one(attributes)
unless id == r.inserted_ids[0]
self.id = r.inserted_ids[0]
- 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 find_app
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
def find_app
found = false
if (@id_routing && (app = @app)) ||
((ns = Setup::Namespace.where(slug: params[:id_or_ns]).first) &&
(app = Setup::Application.where(namespace: ns.name, slug: params[:app_slug]).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 each_deep_pair
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
def each_deep_pair(&block)
each_pair do |key, value|
if yield(self, key, value)
case value
when 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 detask
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
def detask(message)
report = nil
case task = message.delete(:task)
when Class
task_class = task
- 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 build_in_provider_id
has 43 lines of code (exceeds 25 allowed). Consider refactoring. Open
def build_in_provider_id
unless @build_in_provider_id
basic_attrs = {
namespace: 'Cenit',
name: 'OAuth',
Method simple_translate
has 43 lines of code (exceeds 25 allowed). Consider refactoring. Open
def simple_translate(message, &block)
unless (options = message[:options]).is_a?(Hash)
options = {}
end
task = message[:task]
Method translate_import
has 43 lines of code (exceeds 25 allowed). Consider refactoring. Open
def translate_import(message, &block)
options =
{
headers: message['headers'] || {},
parameters: message['parameters'] || {},
Identical blocks of code found in 2 locations. Consider refactoring. Open
elsif data[:email]
data[:password] = Devise.friendly_token unless data[:password]
data[:password_confirmation] = data[:password] unless data[:password_confirmation]
if (user = User.new(data)).valid?(context: :create)
if (captcha_token = CaptchaToken.create(email: data[:email], data: data)).errors.blank?
- 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 69.
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
elsif data[:email]
data[:password] = Devise.friendly_token unless data[:password]
data[:password_confirmation] = data[:password] unless data[:password_confirmation]
if (user = User.new(data)).valid?(context: :create)
if (captcha_token = CaptchaToken.create(email: data[:email], data: data)).errors.blank?
- 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 69.
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