Showing 829 of 829 total issues
Consider simplifying this complex logical expression. Open
next if property_schema['virtual'] ||
((property_schema['edi'] || {})['discard'] && !(included_anyway = options[:including_discards])) ||
options[:ignore].include?(name.to_sym) ||
(options[:only] && !options[:only].include?(name.to_sym) && !included_anyway)
Method run
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
def run(message)
algorithm_id = message[:algorithm_id]
if (algorithm = agent_from_msg)
result = algorithm.run(message[:input], self).capataz_slave
klass = Setup::BuildInDataType::SCHEMA_TYPE_MAP.keys.detect do |type|
Method diff
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
def diff(other_scope)
other_scope = self.class.new(other_scope.to_s) unless other_scope.is_a?(self.class)
diff = self.class.new
if auth? && !other_scope.auth?
diff.instance_variable_set(:@auth, true)
Method authorize
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
def authorize
if (tenant = Tenant.where(id: params[:tenant_id]).first)
tenant.switch do
errors = nil
auth = @authorization = Setup::Authorization.where(id: params[:id]).first
Method initialize
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
def initialize(user)
@deferred_abilities = []
deferred_abilities <<
if (@user = user)
Method authorize_action
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
def authorize_action(options = {})
success = true
if klass
action_symbol =
case @_action_name
Method new
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
def new
response =
{
success: success_report = {},
errors: broken_report = {}
Identical blocks of code found in 2 locations. Consider refactoring. Open
if (object_ids = options[:object_ids])
model.any_in(id: (limit ? object_ids[offset, limit] : object_ids.from(offset))).to_enum
elsif (objects = options[:objects])
objects
else
- 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 56.
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 (object_ids = options[:object_ids])
model.any_in(id: (limit ? object_ids[offset, limit] : object_ids.from(offset))).to_enum
elsif (objects = options[:objects])
objects
else
- 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 56.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Method run
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
def run(message)
if (script = agent_from_msg)
result = script.run(self)
klass = Setup::BuildInDataType::SCHEMA_TYPE_MAP.keys.detect do |type|
type && (result.class == type || result.class < type)
Method source_ids_from
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
def source_ids_from(message)
if (object_ids = message[:object_ids])
object_ids
elsif (id = message[:source_id])
[id]
Method to_map_schema
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
def to_map_schema(sch)
if sch['type'] == 'object' && (properties = sch['properties']).is_a?(Hash)
new_properties = {}
id_optional = true
properties.each do |property, property_schema|
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 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 bundled_ruby_code
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
def bundled_ruby_code(algorithm)
locals = %w(args)
args_param = false
i = -1
params_initializer =
Method eql_content?
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
def eql_content?(a, b, key = nil, &block)
case a
when Hash
if b.is_a?(Hash)
if a.size < b.size
Method init
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
def init
channel_mutex.lock
if ENV['SKIP_RABBIT_MQ'].to_b
puts 'RabbitMQ SKIPPED'
false
Method request_token
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def request_token(params)
http_client = create_http_client(token_url: token_endpoint, token_method: token_method.to_s.downcase.to_sym)
token = http_client.get_token_with(:auth_code, params[:code]) do |parameters, headers|
parameters.merge!(token_params(parameters, params)) if parameters
headers.merge!(token_headers(headers, params)) if 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
Method run
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def run(message)
collection_id = message[:collection_id]
if (collection = Setup::Collection.where(id: collection_id).first)
Setup::Collection::COLLECTING_PROPERTIES.each do |property|
association = Setup::Collection.reflect_on_association(property)
- 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 process_ftp
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def process_ftp(opts)
result = nil
path = URI.decode(opts[:path])
username, password = check(opts[:template_parameters], :username, :password)
- 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"