Showing 216 of 688 total issues
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
elsif tagname == 'blog' && user.basic_user?
errors ? 'Only moderators or admins can use this tag.' : false
elsif tagname.split(':')[0] == 'redirect' && Node.where(slug: one_split).size <= 0
errors ? I18n.t('node.page_does_not_exist') : false
elsif socials[one_split&.to_sym].present?
- Create a ticketCreate a ticket
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 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
Avoid deeply nested control flow statements. Open
if Random.rand(2) == 0
redirect_to Node.find(@node.power_tag('abtest')).path
return
end
- Create a ticketCreate a ticket
Avoid deeply nested control flow statements. Open
elsif current_user.can_moderate?
flash.now[:warning] = "Only moderators and admins see this page, as it is redirected to #{Node.find(@node.power_tag('abtest')).title} roughly around 50% of the time.
To remove this behavior, delete the tag beginning with 'abtest:'"
- 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
errors ? I18n.t('node.only_admins_can_lock') : false
- Create a ticketCreate a ticket
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
unless tag.subscriptions.empty? || isStatusValid || !isMonthOld
SubscriptionMailer.notify_tag_added(self, tag, user).deliver_later
end
- Create a ticketCreate a ticket
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
Avoid deeply nested control flow statements. Open
unless params[:hash_params].to_s.empty?
hash_params = URI.parse("#" + params[:hash_params]).to_s
end
- 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
if oidreq.immediate
oidresp = oidreq.answer(false)
elsif session[:username]
# The user hasn't logged in.
# show_decision_page(oidreq) # this doesnt make sense... it was in the example though
- 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
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"
Further reading
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
tagnames = params[:tagnames].class == Array ? params[:tagnames].join(', ') : params[:tagnames]
- 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