Showing 216 of 688 total issues
Method smtp_test
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def smtp_test
require 'socket'
s = TCPSocket.new ActionMailer::Base.smtp_settings[:address], ActionMailer::Base.smtp_settings[:port]
- Read upRead up
- Create a ticketCreate a ticket
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 update
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def update
if !current_user.admin?
flash[:warning] = 'Only admins may edit features.'
redirect_to "/features?_=#{Time.now.to_i}"
else
- Read upRead up
- Create a ticketCreate a ticket
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
errors ? I18n.t('node.cannot_add_yourself_coauthor') : false
- Create a ticketCreate a ticket
Method useremail
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def useremail
if logged_in_as(['admin', 'moderator'])
if params[:address]
# address was submitted. find the username(s) and return.
@address = params[:address]
- Read upRead up
- Create a ticketCreate a ticket
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 add_comment
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def add_comment(params = {})
thread = !comments.empty? && !comments.last.nil? && !comments.last.thread.nil? ? comments.last.next_thread : '01/'
comment_via_status = params[:comment_via].nil? ? 0 : params[:comment_via].to_i
user = User.find(params[:uid])
status = user.first_time_poster && user.first_time_commenter ? 4 : 1
- Read upRead up
- Create a ticketCreate a ticket
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 revisions
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def revisions
@node = Node.find_wiki(params[:id])
if @node
@revisions = @node.revisions
@pagy_revisions, @revisions = pagy(@revisions.where(status: 1), items: 20) unless current_user&.can_moderate?
- Read upRead up
- Create a ticketCreate a ticket
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
unless tag.subscriptions.empty? || isStatusValid || !isMonthOld
SubscriptionMailer.notify_tag_added(self, tag, user).deliver_later
end
- Create a ticketCreate a ticket
Method update_node_attributes
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def update_node_attributes
ActiveRecord::Base.transaction do
@node.vid = @revision.vid
@node.title = @revision.title
- Read upRead up
- Create a ticketCreate a ticket
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
rescue StandardError
return [false, tag.destroy]
- Create a ticketCreate a ticket
Avoid deeply nested control flow statements. Open
errors ? I18n.t('node.only_admins_can_lock') : false
- Create a ticketCreate a ticket
Method rich
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def rich
if params[:main_image] && Image.find_by(id: params[:main_image])
@main_image = Image.find_by(id: params[:main_image]).path
end
- Read upRead up
- Create a ticketCreate a ticket
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
PasswordResetMailer.reset_notify(user, key).deliver_later unless user.nil? # respond the same to both successes and failures; security
- Create a ticketCreate a ticket
Method tagNearbyNodes
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
def tagNearbyNodes(coordinates, tag, period = { "from" => nil, "to" => nil }, sort_by = nil, order_direction = nil, limit = 10)
- Create a ticketCreate a ticket
Avoid deeply nested control flow statements. Open
tagnames = params[:tagnames].class == Array ? params[:tagnames].join(', ') : params[:tagnames]
- Create a ticketCreate a ticket
Avoid deeply nested control flow statements. Open
if session[:openid_return_to] # for openid login, redirects back to openid auth process
return_to = session[:openid_return_to]
session[:openid_return_to] = nil
redirect_to return_to + hash_params
elsif params[:return_to] && params[:return_to].split('/')[0..3] == ["", "subscribe", "multiple", "tag"]
- Create a ticketCreate a ticket
Avoid deeply nested control flow statements. Open
rescue ActiveRecord::RecordInvalid
flash[:error] = tag.errors.full_messages
redirect_to return_to
return false
- Create a ticketCreate a ticket
Avoid deeply nested control flow statements. Open
if session[:openid_return_to] # for openid login, redirects back to openid auth process
return_to = session[:openid_return_to]
session[:openid_return_to] = nil
redirect_to return_to + hash_params
else
- Create a ticketCreate a ticket
Avoid deeply nested control flow statements. Open
params[:user_session][:openid_identifier] = 'https://old.publiclab.org/people/' + username + '/identity' if username
- Create a ticketCreate a ticket
Avoid deeply nested control flow statements. Open
render json: { status: status, message: message, id: tag.tid, tagname: params[:name], url: "/tags" + "?_=" + Time.now.to_i.to_s } if current_user
- Create a ticketCreate a ticket
Method decision
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def decision
oidreq = session[:last_oidreq]
session[:last_oidreq] = nil
id_to_send = params[:id_to_send]
identity = oidreq&.identity
- Read upRead up
- Create a ticketCreate a ticket
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"