Showing 102 of 130 total issues
Method check_statistics_params
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def check_statistics_params
if params[:statistics].present?
from = params[:statistics][:starts_on_time]
to = params[:statistics][:ends_on_time]
date_format = I18n.t('_other.datetimepicker.datepick_rails')
- 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 handle
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def self.handle mailer, message, error, action, args
Method leave
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def leave
permission = @space.permissions.find_by_user_id(current_user)
if permission
permission.destroy
- 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 notify_admins_of_spaces_pending_approval
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def self.notify_admins_of_spaces_pending_approval
# The Activities with keys space.created are used to inform the admins that a new space was created.
activities = get_recent_activity
.where(trackable_type: 'Space', notified: [nil, false], key: 'space.create')
- 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 handle_access_denied
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def handle_access_denied(exception)
if ['new', 'create'].include? action_name
if user_signed_in?
flash[:error] = t('flash.events.create.permission_error')
redirect_to events_path
- 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 user_is_owner_or_belongs_to_rooms_space
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def user_is_owner_or_belongs_to_rooms_space(user, room)
if (room.owner_type == "User" && room.owner.id == user.id)
true
elsif (room.owner_type == "Space")
space = Space.find_by(id: room.owner.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 user_is_owner_or_admin_of_rooms_space
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def user_is_owner_or_admin_of_rooms_space(user, room)
if (room.owner_type == "User" && room.owner.id == user.id)
true
elsif (room.owner_type == "Space")
space = Space.find_by(id: room.owner.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 new_activity_approved
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def new_activity_approved
if self.new_record?
# no notifications for new records
saved_and_not_approved = false
else
- 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 icon_constructor
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def icon_constructor(title=nil, cls=nil, options={})
options[:class] = options.has_key?(:class) ? cls + " " + options[:class] : cls
title = title.nil? ? options[:title] : title
unless title.nil? or title.blank?
options = options_for_tooltip(title, 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 crop_indexes
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def self.crop_indexes(indexes)
idx = indexes.clone
idx = idx.sort_by{ |id| id[0] }
i = 0
while i+1 < idx.length
- 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 first_name
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def first_name(min_length = 4)
unless self.full_name.blank?
# parse_name(self.full_name)[:first_name]
names = self.full_name.split(' ')
names.inject('') do |memo, 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
Avoid too many return
statements within this method. Open
return fail(:not_found_in_database) if resource.created_by_ldap?
Method index
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def index
authorize! :index_event, @space
all_events = @space.events(:order => "end_on DESC")
- 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 format_time
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def format_time(date)
if date.present?
if date.is_a?(Integer) && date.to_s.length == 13
value = Time.at(date/1000)
else
- 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 get_user_locale
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def get_user_locale(user, use_session=true)
current_site ||= Site.current
# user locale
if user_has_locale?(user)
- 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 ldap_filter
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def ldap_filter(configs)
base = nil
unless configs.ldap_filter.blank?
begin
base = Net::LDAP::Filter.construct(configs.ldap_filter)
- 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 get_formatted_date
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def get_formatted_date(date=nil, with_tz=true)
if date.nil?
if with_tz
I18n::localize(start_on, :format => "%A, %d %b %Y, %H:%M (#{time_zone})")
else
- 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 show
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def show
frontpage = Rails.application.config.external_frontpage
if frontpage.blank?
respond_to do |format|
- 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_params
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def allowed_params
is_space_admin = @space.present? && can?(:manage_join_requests, @space)
if params[:action] == "create"
if is_space_admin
[ :role_id, :comment ]
- 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 formatted_time_ago
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def formatted_time_ago(date, options = {}, time_ago_options = {})
base_classes = "thread-updated-at updated-at"
options[:class] = options.key?(:class) ? "#{base_classes} #{options[:class]}" : base_classes
options[:title] = I18n.l(date, format: :long)
- 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"