Showing 213 of 251 total issues
Avoid too many return
statements within this method. Open
return 'guest' if guest?
Avoid too many return
statements within this method. Open
return 7.pt
Avoid too many return
statements within this method. Open
return 12.pt if num_of_lines_required(str, 12.pt) < 5
Avoid too many return
statements within this method. Open
return 8.pt if num_of_lines_required(str, 8.pt) < 8
Avoid too many return
statements within this method. Open
return 10.pt if num_of_lines_required(str, 10.pt) < 6
Method rescue_from_too_big_to_marshal
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def rescue_from_too_big_to_marshal(block_without_caching, &block_with_caching)
begin
yield
rescue ArgumentError, NameError => exc
if exc.message.include? 'year too big to marshal'
- 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 link_to_add_profile_field
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def link_to_add_profile_field( args )
raise ActionController::ParameterMissing, "expected argument 'profileable'" unless args[:profileable].present?
raise ActionController::ParameterMissing, "expected argument 'profile_field_type'" unless args[:profile_field_type].present?
raise ActionController::ParameterMissing, "expected argument 'profile_section'" unless args[:profile_section].present?
label_in_english_with_underscores = args[:profile_field_type].demodulize.underscore
- 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 fill_in_template_profile_information
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def fill_in_template_profile_information
self.profile_fields.create(label: :personal_title, type: "ProfileFields::General")
self.profile_fields.create(label: :academic_degree, type: "ProfileFields::AcademicDegree")
self.profile_fields.create(label: :work_address, type: "ProfileFields::Address")
- 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 rights_for_everyone
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def rights_for_everyone
# Feature switches
#
can :use, :semester_calendars
- 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 destroy_dag_links
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def destroy_dag_links
# destory only child and parent links, since the indirect links
# are destroyed automatically by the DagLink model then.
links = self.links_as_parent + self.links_as_child
- 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 value
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def value
v = super
v = v.to_i if ( not v.to_i == nil ) and ( v.to_i.to_s == v ) if v.respond_to?( :to_i )
v = true if v == "true"
v = false if v == "false"
- 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 role_for
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def role_for( structureable )
return nil if not structureable.respond_to? :parent_groups
# return :main_admin if self.main_admin_of? structureable
return :admin if self.admin_of? structureable
return :member if self.member_of? structureable
- 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 reference
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def reference
ref = super
if ref.kind_of? DagLink
if ref.ancestor_type == "Group" and ref.descendant_type == "User"
ref.becomes(Membership)
- 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
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def process(options = {})
if sender_user && recipient_group && recipient_group.has_flag?(:mail_test_group)
recipient_group.child_users << sender_user unless recipient_group.child_users.include? sender_user
recipient_group.update mailing_list_sender_filter: :open
recipient_group.delete_cache
- 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 to_csv
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def to_csv
CSV.generate(csv_options) do |csv|
csv << headers
data.each do |row|
csv << columns.collect do |column_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 create
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def create
authorize! :submit, term_report
raise ActionController::BadRequest, "term report #{term_report.id} cannot be submitted because it has already been accepted." if term_report.accepted?
raise ActionController::BadRequest, "term report #{term_report.id} cannot be submitted because it has already been submitted." if term_report.submitted? && (term_report.submitted_at > term_report.rejected_at)
raise ActionController::BadRequest, "term report #{term_report.id} is not due." unless term_report.due?
- 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 change_type_according_to_other_attributes
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def change_type_according_to_other_attributes
self.type = "Membership" if ancestor_type == "Group" and descendant_type == "User"
self.type = "Memberships::Status" if self.type == "Membership" and ancestor.kind_of?(StatusGroup)
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 allowed_preview_roles
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def allowed_preview_roles
return ['global_admin', 'admin', 'officer', 'global_officer', 'user', 'public'] if global_admin?
return ['admin', 'officer', 'user', 'public'] if admin?
return ['officer', 'global_officer', 'user', 'public'] if global_officer? and officer?
return ['officer', 'user', 'public'] if officer?
- 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 global_logo_url
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def global_logo_url
unless @logo_url
@logo_url = Attachment.logos.first.try(:file).try(:url)
# TODO # #current_navable.nav_node.breadcrumb_root
- 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 fill_cached_method
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def fill_cached_method(method)
Sidekiq::Logging.logger.info "#{title} # fill_cached_method #{method}" if Sidekiq::Logging.logger && (! Rails.env.test?)
if Rails.cache.running_from_background_job && Rails.cache.renew_at
# When running from a background job, split it into sub-tasks.
self.renew_cache_later method: method
- 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"