Showing 216 of 688 total issues
Method photo
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def photo
@user = User.find_by(id: params[:uid])
if current_user.uid == @user.uid || current_user.admin?
@user.photo = params[:photo]
if @user.save!
- 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
Function sortGrid
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
function sortGrid(type, selector, headerLink) {
var table = $(selector),
headerLink = $(headerLink),
desc = headerLink.hasClass('desc'),
- Create a ticketCreate a ticket
Function show_list
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
var show_list = function (list) {
$.get(lists[list].feed, function (feed) {
$('.lists').html('');
- Create a ticketCreate a ticket
Function inWords
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
self.inWords = function(timeAgo) {
var seconds = Math.floor((new Date() - new Date(timeAgo)) / 1000),
separator = this.locales.separator || ' ',
words = this.locales.prefix + separator,
- Create a ticketCreate a ticket
Method nodes_by_tagname
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
def self.nodes_by_tagname(tagname, type, limit: 24)
if type.is_a? Array
type1 = type.first
type2 = type.last
pinned = pinned_nodes(tagname)
- Create a ticketCreate a ticket
Method like
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
def self.like(nid, user)
# scope like variable outside the transaction
like = nil
count = nil
- Create a ticketCreate a ticket
Method decision
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
def decision
oidreq = session[:last_oidreq]
session[:last_oidreq] = nil
id_to_send = params[:id_to_send]
identity = oidreq&.identity
- Create a ticketCreate a ticket
Function addGrid
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
function addGrid(map)
{
// A function to return the style of a cell
function create_cell_style(fill) {
return {
- 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 mark_spam_revision
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def mark_spam_revision
@revision = Revision.find_by(vid: params[:vid])
@node = Node.find_by(nid: @revision.nid)
if @node.revisions.size <= 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
Function getFileUploadOptions
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
function getFileUploadOptions(dropZone, isSmallDropzone = false) {
return {
url: "/images",
paramName: "image[photo]",
dropZone: isSmallDropzone ? null : dropZone,
- 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 mark_spam
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def mark_spam
@node = Node.find params[:id]
if logged_in_as(['admin', 'moderator'])
if @node.status == 1 || @node.status == 4
@node.spam
- 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 delete
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def delete
# assume tag, for now
if params[:type] == "tag"
id = Tag.find_by(name: params[:name]).tid
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
Method shortlink
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def shortlink
size = params[:size] || params[:s]
size ||= :large
size = :thumb if size.to_s == 't'
size = :thumb if size.to_s == 'thumbnail'
- 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 notify_tag_added
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def notify_tag_added(node, tag, tagging_user)
subject = '[PublicLab] ' +
(node.has_power_tag('question') ? 'Question: ' : '') +
node.title +
" (##{node.id}) "
- 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 tagNearbyPeople
has 7 arguments (exceeds 4 allowed). Consider refactoring. Open
def tagNearbyPeople(coordinates, tag, field, period = nil, sort_by = nil, order_direction = nil, limit = 10)
- Create a ticketCreate a ticket
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
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
Avoid deeply nested control flow statements. Open
if @user.changed? && @user.save
flash[:notice] = I18n.t('users_controller.password_change_success')
@user.password_checker = 0
@user.save
redirect_to "/dashboard"
- Create a ticketCreate a ticket
Function displayMapContent
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
function displayMapContent(map, markers_hash, mainContent, limit) {
if(typeof mainContent !== "undefined" && mainContent !== ""){
if (mainContent === "people") {
map.on('load viewreset resize zoomend moveend', debounce(peopleMap, 400));
setTimeout(peopleMap,0); // to ensure fetch on initial page load
- 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