Showing 829 of 829 total issues
Method check_properties
has a Cognitive Complexity of 65 (exceeds 5 allowed). Consider refactoring. Open
def check_properties(json_schema, options = {})
object_schema =
case json_schema['type']
when 'object'
json_schema
- 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 parser.rb
has 590 lines of code (exceeds 250 allowed). Consider refactoring. Open
module Edi
class Parser
class << self
File webhook_common.rb
has 587 lines of code (exceeds 250 allowed). Consider refactoring. Open
require 'net/ftp'
module Setup
module WebhookCommon
extend ActiveSupport::Concern
Method save_request_data
has a Cognitive Complexity of 62 (exceeds 5 allowed). Consider refactoring. Open
def save_request_data
@data_types ||= {}
@request_id = request.uuid
@webhook_body = request.body.read
@ns_slug = params[:ns]
- 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 57 (exceeds 5 allowed). Consider refactoring. Open
def index
if (tenant = Tenant.where(id: params[:tenant_id]).first)
tenant.switch do
model = nil
if (model_desc = params[:model])
- 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 []=
has a Cognitive Complexity of 57 (exceeds 5 allowed). Consider refactoring. Open
def []=(field, value)
field = field.to_sym
@changed = true
@validated = false
field = :_id if %w(id _id).include?(field.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
File flow.rb
has 537 lines of code (exceeds 250 allowed). Consider refactoring. Open
require 'nokogiri'
module Setup
class Flow
# = Flow
Class Model
has 61 methods (exceeds 20 allowed). Consider refactoring. Open
class Model
include Setup::InstanceModelParser
include MetadataAccess
include PrettyErrors
include ThreadAware
Method pull
has a Cognitive Complexity of 56 (exceeds 5 allowed). Consider refactoring. Open
def pull(shared_collection, pull_request = {})
pull_request = pull_request.with_indifferent_access
pull_request = pull_request(shared_collection, pull_request) if pull_request[:pull_data].nil?
errors = []
if pull_request[:missing_parameters].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 do_parse_json
has 211 lines of code (exceeds 25 allowed). Consider refactoring. Open
def do_parse_json(data_type, model, json, options, json_schema, record = nil, new_record = nil, container = nil, container_schema = nil)
add_new = options.delete(:add_new)
updating = !(record.nil? && new_record.nil?) || options[:add_only]
(primary_fields = options.delete(:primary_field) || options.delete('primary_field')).present? ||
(primary_fields = json.is_a?(Hash) && json['_primary']).present? ||
Method enqueue
has a Cognitive Complexity of 54 (exceeds 5 allowed). Consider refactoring. Open
def enqueue(message, &block)
message = message.with_indifferent_access
task_description = message[:task_description]
auto_retry = message[:auto_retry].presence || Setup::Task.auto_retry_enum.first
scheduler = message.delete(:scheduler)
- 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 model.rb
has 514 lines of code (exceeds 250 allowed). Consider refactoring. Open
module Mongoff
class Model
include Setup::InstanceModelParser
include MetadataAccess
include PrettyErrors
Method validates_configuration
has a Cognitive Complexity of 53 (exceeds 5 allowed). Consider refactoring. Open
def validates_configuration
requires(:name)
errors.add(:type, 'is not valid') unless type_enum.include?(type)
errors.add(:style, 'is not valid') unless style_enum.include?(style)
case 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 submit
has a Cognitive Complexity of 52 (exceeds 5 allowed). Consider refactoring. Open
def submit(*args, &block)
if (options = args[0]).is_a?(Hash)
body_argument = options[:body]
else
body_argument = 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 authorize_account
has a Cognitive Complexity of 52 (exceeds 5 allowed). Consider refactoring. Open
def authorize_account(soft = false)
account_backup = Account.current
user_backup = User.current
Account.current = User.current = error_description = nil
if (auth_header = request.headers['Authorization'])
- 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_attribute
has a Cognitive Complexity of 50 (exceeds 5 allowed). Consider refactoring. Open
def write_attribute(name, value)
if name.to_s == 'map_attributes'
value.delete('_type')
value.delete(:_type)
value.each do |k, v|
- 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 record_to_edi
has a Cognitive Complexity of 50 (exceeds 5 allowed). Consider refactoring. Open
def record_to_edi(data_type, options, schema, record, enclosed_property_name = nil)
output = []
return output unless record
field_sep = options[:field_separator]
segment =
- 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 BuildInDataType
has 54 methods (exceeds 20 allowed). Consider refactoring. Open
class BuildInDataType
include SchemaHandler
include DataTypeParser
attr_reader :model
Method initialize
has a Cognitive Complexity of 49 (exceeds 5 allowed). Consider refactoring. Open
def initialize(scope = '')
@openid = Set.new
@access = {}
@super_methods = Set.new
scope = scope.to_s.strip
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Identical blocks of code found in 2 locations. Consider refactoring. Open
(function () {
Array.from(
document.getElementsByClassName('responsive-box')
).forEach(
rbox => Array.from(rbox.getElementsByClassName('devise box')).forEach(
- 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 186.
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