Showing 216 of 688 total issues
Function diffString
has 39 lines of code (exceeds 25 allowed). Consider refactoring. Open
function diffString( o, n ) {
o = o.replace(/\s+$/, '');
n = n.replace(/\s+$/, '');
var out = diff(o == "" ? [] : o.split(/\s+/), n == "" ? [] : n.split(/\s+/) );
- Create a ticketCreate a ticket
Method create
has 38 lines of code (exceeds 25 allowed). Consider refactoring. Open
def create
@user = User.new(user_params)
@user.status = 1
using_recaptcha = !params[:spamaway] && Rails.env == "production"
recaptcha = verify_recaptcha(model: @user) if using_recaptcha
- Create a ticketCreate a ticket
Method subscribe_multiple_tag
has 38 lines of code (exceeds 25 allowed). Consider refactoring. Open
def subscribe_multiple_tag(tag_list)
if !tag_list || tag_list == ''
flash[:notice] = "Please enter tags for subscription in the url."
else
if tag_list.is_a? String
- Create a ticketCreate a ticket
Method subscribe_multiple_tag
has 38 lines of code (exceeds 25 allowed). Consider refactoring. Open
def subscribe_multiple_tag(tag_list)
if !tag_list || tag_list == ''
flash[:notice] = "Please enter tags for subscription in the url."
else
if tag_list.is_a? String
- Create a ticketCreate a ticket
Method new_note
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
def self.new_note(params)
saved = false
author = User.find(params[:uid])
node = Node.new(uid: author.uid,
title: params[:title],
- Create a ticketCreate a ticket
Method tagNearbyNodes
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
def tagNearbyNodes(coordinates, tag, period = { "from" => nil, "to" => nil }, sort_by = nil, order_direction = nil, limit = 10)
raise("Must contain all four coordinates") if coordinates["nwlat"].nil?
raise("Must contain all four coordinates") if coordinates["nwlng"].nil?
raise("Must contain all four coordinates") if coordinates["selat"].nil?
raise("Must contain all four coordinates") if coordinates["selng"].nil?
- Create a ticketCreate a ticket
Function diffString2
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
function diffString2( o, n ) {
o = o.replace(/\s+$/, '');
n = n.replace(/\s+$/, '');
var out = diff(o == "" ? [] : o.split(/\s+/), n == "" ? [] : n.split(/\s+/) );
- Create a ticketCreate a ticket
Method publish_comment
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def publish_comment
if logged_in_as(['admin', 'moderator'])
@comment = Comment.find params[:id]
if @comment.status == 1
flash[:notice] = 'Comment already published.'
- 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 create
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def create
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
Method send_digest_spam
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def send_digest_spam(nodes, frequency_digest)
if frequency_digest == User::Frequency::DAILY
@subject = 'Your daily digest for moderation'
elsif frequency_digest == User::Frequency::WEEKLY
@subject = 'Your weekly digest for moderation'
- 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 alert_and_redirect_moderated
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def alert_and_redirect_moderated
if @node.author.status == User::Status::BANNED && !(logged_in_as(['admin', 'moderator']))
flash[:error] = I18n.t('application_controller.author_has_been_banned')
redirect_to '/'
elsif @node.status == 4 && (logged_in_as(['admin', 'moderator']))
- 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 parse_comment_from_email
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
def self.parse_comment_from_email(mail, node_id, user, reply_to = [false, nil])
node = Node.where(nid: node_id).first
if node && mail&.html_part
mail_doc = Nokogiri::HTML(mail&.html_part&.body&.decoded) # To parse the mail to extract comment content and reply content
domain = get_domain mail.from.first
- Create a ticketCreate a ticket
Method reset
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
def reset
if params[:key] && !params[:key].nil?
@user = User.find_by(reset_key: params[:key])
if @user
if params[:user] && params[:user][:password]
- Create a ticketCreate a ticket
Function urlMapHash
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
function urlMapHash() {
// This is based off of jywarren's urlhash, made specific to our map hash needs
const paramArray = ["zoom", "lat", "lon"];
- Create a ticketCreate a ticket
Method index
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
def index
range
if @start > @end
flash.now[:warning] = "Start date must come before end date"
end
- Create a ticketCreate a ticket
Method create
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
def create
@node = Node.find params[:id]
@body = params[:body]
@user = current_user
begin
- Create a ticketCreate a ticket
Function diff
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
function diff( o, n ) {
var ns = new Object();
var os = new Object();
for ( var i = 0; i < n.length; i++ ) {
- Create a ticketCreate a ticket
Function SignUpFormValidator
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
function SignUpFormValidator(formClass) {
var signUpForm = document.querySelector(formClass);
if (!signUpForm) return;
- Create a ticketCreate a ticket
Method notify_tag_added
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
def notify_tag_added(node, tag, tagging_user)
subject = '[PublicLab] ' +
(node.has_power_tag('question') ? 'Question: ' : '') +
node.title +
" (##{node.id}) "
- Create a ticketCreate a ticket
Method create
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
def create
if params[:i]
@image = Image.new(remote_url: params[:i],
uid: current_user.uid)
flash[:error] = 'The image could not be saved.' unless @image.save!
- Create a ticketCreate a ticket