Showing 251 of 251 total issues
Method execute
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def execute( params )
raise RuntimeError, 'no user_id given' unless params[ :user_id ]
raise RuntimeError, 'no group_id given' unless params[ :group_id ]
user = User.find( params[ :user_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 restore_profile
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def restore_profile
raise "This user (#{id}) already has an existing profile. Not restoring from backup file." if profile_fields.any?
hash = ActiveSupport::JSON.decode(File.read(latest_backup_file))
if (address = hash['profile_fields'].select { |pf| pf['type'] == "ProfileFields::Address" }.first) && address['children'].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
Avoid deeply nested control flow statements. Open
book_rate_line(address_label) if @book_rate and address_label
Avoid deeply nested control flow statements. Open
rescue Prawn::Errors::IncompatibleStringEncoding
logger.warn "PDF ADDRESS LABEL EXPORT ENCODING ISSUE for #{address_label.name}."
text "ENCODING ISSUE!"
Avoid deeply nested control flow statements. Open
part.body.raw_source.replace part.body.decoded.gsub(search, replace) if part.body.decoded.include? search
Method fill_small_map_address_fields
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def fill_small_map_address_fields
# On collection groups, e.g. the corporations_parent group, only the
# groups should be shown on the map. These groups have a lot of
# child groups with address profile fields.
#
- 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 create
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def create
authorize! :update, room
terminate_existing_occupancies
- 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
sender_line if @sender and address.to_s.present?
Avoid deeply nested control flow statements. Open
address.gsub!("\nDeutschland", "") if I18n.locale == :de # in order to save space for in-country deliveries.
Similar blocks of code found in 2 locations. Consider refactoring. Open
if str.present?
return 12.pt if num_of_lines_required(str, 12.pt) < 5
return 10.pt if num_of_lines_required(str, 10.pt) < 6
return 8.pt if num_of_lines_required(str, 8.pt) < 8
end
- 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 38.
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 2 locations. Consider refactoring. Open
if str.present?
return 10.pt if num_of_lines_required(str, 12.pt) < 5
return 8.pt if num_of_lines_required(str, 10.pt) < 6
return 6.pt if num_of_lines_required(str, 8.pt) < 8
end
- 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 38.
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
Consider simplifying this complex logical expression. Open
if self.value_changed? && (! @do_not_save_parent) && self.parent && self.parent.reload && self.parent.children.reload && (self.parent.value != (composed_value = self.parent.composed_value))
self.parent.update_attributes value: composed_value
@do_not_save_parent = false
end
Method initialize
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def initialize(name, address_field, name_surrounding_field, personal_title = '', company = '')
Method support_request_email
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def support_request_email(sender_user, receiver_email, text, meta_data, navable)
Method identify
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def self.identify(login_string)
# Priorization: Check alias first. (Bug fix)
user_identified_by_alias = User.find_by_alias(login_string)
users_that_match_the_login_string = [ User.find_by_alias(login_string) ] if user_identified_by_alias
- 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 7 (exceeds 5 allowed). Consider refactoring. Open
def <<(child)
unless child.in? self.children
if child.in? self.descendants
link = DagLink.where(
ancestor_type: 'Page', ancestor_id: self.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 geo_information
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def geo_information( key )
return nil if self.value == "—"
return geo_location.send(key).strip if self.value.present? && geo_location.send(key).kind_of?(String) && geo_location.send(key).strip.present?
return geo_location.send(key) if self.value.present? && geo_location.send(key).present?
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 access_indicator
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def access_indicator
if current_navable.respond_to?(:draft?) && current_navable.draft?
content_tag :span, t(:draft), class: 'label label-primary draft_label'
elsif current_access
css = 'access-indicator has_tooltip'
- 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 generate_for
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def self.generate_for(user)
raise RuntimeError, 'no user given' if not user
raise RuntimeError, 'the given user has no last_name' if not user.last_name.present?
raise RuntimeError, 'the given user has no first_name' if not user.first_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 needs_review=
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def needs_review=(new_needs_review)
new_needs_review = false if new_needs_review == "false"
if new_needs_review != self.needs_review
attribute_will_change!(:needs_review)
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"