Showing 829 of 829 total issues
Method days
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
def days
month = @solution[0]
weeks_days = @conf[:weeks_days]
weeks_days = (0..6).to_a if weeks_days.blank?
weeks_month = @conf[:weeks_month]
- 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 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 validate_file_stuff
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
def validate_file_stuff(options = {})
if stash_data.nil?
errors.add(:data, "can't be nil") if new_record?
else
self[:metadata] =
- 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
Method read
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
def read(file, *args)
len = (args.length.positive? && args[0].to_i) || file.length || 0
if (stash_data = file.stash_data)
if stash_data.is_a?(String)
cursor = file.cursor
- 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
Method hash_decode
has 52 lines of code (exceeds 25 allowed). Consider refactoring. Open
def hash_decode(value)
case value
when Hash
r = nil
if value.size == 1
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
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
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
Method run
has 50 lines of code (exceeds 25 allowed). Consider refactoring. Open
def run(message)
if (hook = Cenit::Hook.where(id: message[:hook_id]).first)
slug = message[:slug]
if (hook_channel = hook.channels.where(slug: slug).first)
if (data_type = hook_channel.data_type)
Consider simplifying this complex logical expression. Open
return false if (other_scope.auth? && !auth?) ||
(other_scope.session_access? && !session_access?) ||
(other_scope.offline_access? && !offline_access?) ||
(other_scope.multi_tenant? && !multi_tenant?) ||
!other_scope.openid_set.subset?(openid_set) ||
Method check_properties
has 50 lines of code (exceeds 25 allowed). Consider refactoring. Open
def check_properties(properties, instance, state, data_type, options)
path = options[:path] || '#'
unless (checked_properties = state[:checked_properties])
checked_properties = state[:checked_properties] = Set.new
end
Method find_record
has 50 lines of code (exceeds 25 allowed). Consider refactoring. Open
def find_record(conditions, *scopes)
scopes.each do |original_scope|
scope = original_scope
match_conditions = {}
begin
Consider simplifying this complex logical expression. Open
if (options[:inspecting].include?(:_type) ||
options[:including].include?(:_type) ||
(enclosed_model && !record.orm_model.eql?(enclosed_model)) ||
(options[:polymorphic] && record.orm_model.hereditary?)) && !json['_reference'] && !options[:ignore].include?(:_type) && (!options[:only] || options[:only].include?(:_type))
json['_type'] = model.to_s
Method do_map
has 49 lines of code (exceeds 25 allowed). Consider refactoring. Open
def do_map(source)
plain_properties = []
map_model.properties_schemas.each do |property, schema|
plain_properties << property unless schema[MappingModel::SCHEMA_FLAG]
end
Method do_map
has 49 lines of code (exceeds 25 allowed). Consider refactoring. Open
def do_map(source)
plain_properties = []
map_model.properties_schemas.each do |property, schema|
plain_properties << property unless schema[MappingModel::SCHEMA_FLAG]
end
Method check_items
has 49 lines of code (exceeds 25 allowed). Consider refactoring. Open
def check_items(items_schema, items, state, data_type, options)
path = options[:path] || '#'
if items.is_a?(Mongoff::RecordArray)
items_schema = items.orm_model.schema
data_type = items.orm_model.data_type
Method lookup_messages
has 49 lines of code (exceeds 25 allowed). Consider refactoring. Open
def lookup_messages(opts = {})
channel_mutex.lock
if channel && !channel.closed?
dispatched_ids = []
tenant_tasks = {}
Method validate_model
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
def validate_model
if schema_code.is_a?(Hash)
if schema_changed?
begin
json_schema, _ = validate_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"