Showing 216 of 688 total issues
Method publish
has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring. Open
def publish
if logged_in_as(['admin', 'moderator'])
@node = Node.find params[:id]
if @node.status == 1
flash[:notice] = 'Item 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 index
has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring. Open
def index
@toggle = params[:sort] || "uses"
@title = I18n.t('tag_controller.tags')
@paginated = true
- 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 edit
has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring. Open
def edit
@node = Node.find_by(nid: params[:id], type: 'note')
if @node
if current_user.uid == @node.uid || current_user.admin? || @node.has_tag("with:#{current_user.username}")
- 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 56 lines of code (exceeds 25 allowed). Consider refactoring. Open
def create
params[:name] ||= ''
tagnames = params[:name].split(',')
@output = {
errors: [],
- Create a ticketCreate a ticket
File openid_controller.rb
has 259 lines of code (exceeds 250 allowed). Consider refactoring. Open
require 'pathname'
require 'openid'
require 'openid/consumer/discovery'
require 'openid/extensions/sreg'
- Create a ticketCreate a ticket
Method tagNearbyPeople
has 55 lines of code (exceeds 25 allowed). Consider refactoring. Open
def tagNearbyPeople(coordinates, tag, field, period = 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
Class Revision
has 21 methods (exceeds 20 allowed). Consider refactoring. Open
class Revision < ApplicationRecord
self.table_name = 'node_revisions'
self.primary_key = 'vid'
belongs_to :node, foreign_key: 'nid', counter_cache: :drupal_node_revisions_count
- Create a ticketCreate a ticket
Method activity
has 53 lines of code (exceeds 25 allowed). Consider refactoring. Open
def activity
blog = Tag.find_nodes_by_type('blog', 'note', 1).first
# remove "classroom" postings; also switch to an EXCEPT operator in sql, see https://github.com/publiclab/plots2/issues/375
hidden_nids = Node.hidden_response_node_ids
notes = Node.where(type: 'note')
- Create a ticketCreate a ticket
Method replace
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
def replace
@node = Node.find(params[:id])
if params[:before] && params[:after]
# during round trip, strings are getting "\r\n" newlines converted to "\n",
# so we're ensuring they remain "\r\n"; this may vary based on platform, unfortunately
- 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 get_node_from_urls_present
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
def self.get_node_from_urls_present(urls)
urls.each do |url|
next unless url.include? "https://"
if url.last == "."
- 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 is_autoreply
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
def self.is_autoreply(mail)
autoreply = false
autoreply = true if mail.header['Precedence'] && mail.header['Precedence'].value == "list"
autoreply = true if mail.header['Precedence'] && mail.header['Precedence'].value == "junk"
autoreply = true if mail.header['Precedence'] && mail.header['Precedence'].value == "bulk"
- 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 51 lines of code (exceeds 25 allowed). Consider refactoring. Open
def create
return show_banned_flash unless current_user.status == User::Status::NORMAL
saved, @node, @revision = new_note
- Create a ticketCreate a ticket
Method multiple_add
has 51 lines of code (exceeds 25 allowed). Consider refactoring. Open
def multiple_add
return_to = params[:return_to] || "/subscriptions?_=" + Time.now.to_i.to_s
if params[:tagnames].blank?
flash[:notice] = "Please enter tags for subscription in the url."
redirect_to return_to
- Create a ticketCreate a ticket
Method create
has 50 lines of code (exceeds 25 allowed). Consider refactoring. Open
def create
@output = {
errors: [],
saved: []
}
- Create a ticketCreate a ticket
Function graph
has 49 lines of code (exceeds 25 allowed). Consider refactoring. Open
function graph(data, el, labels) {
el = el || "graph-canvas";
data = data || [1, 2, 4, 1, 5];
- Create a ticketCreate a ticket
Method methods
has 49 lines of code (exceeds 25 allowed). Consider refactoring. Open
def methods
@nodes = Node.where(status: 1, type: %w(page))
.where('term_data.name = ?', 'method')
.includes(:revision, :tag)
.references(:node_revision)
- Create a ticketCreate a ticket
Function contentLayerParser
has 49 lines of code (exceeds 25 allowed). Consider refactoring. Open
function contentLayerParser(map, markers_hash, map_tagname, limit) {
var NWlat = map.getBounds().getNorthWest().lat ;
var NWlng = map.getBounds().getNorthWest().lng ;
var SElat = map.getBounds().getSouthEast().lat ;
var SElng = map.getBounds().getSouthEast().lng ;
- Create a ticketCreate a ticket
Method show
has 49 lines of code (exceeds 25 allowed). Consider refactoring. Open
def show
return if redirect_to_node_path?(@node)
if @node
if @node.has_power_tag('question') && @node.status == 1
- Create a ticketCreate a ticket
Function getFileUploadOptions
has 48 lines of code (exceeds 25 allowed). Consider refactoring. Open
function getFileUploadOptions(dropZone, isSmallDropzone = false) {
return {
url: "/images",
paramName: "image[photo]",
dropZone: isSmallDropzone ? null : dropZone,
- Create a ticketCreate a ticket
Method update
has 48 lines of code (exceeds 25 allowed). Consider refactoring. Open
def update
@node = Node.find(params[:id])
if current_user.uid == @node.uid || current_user.admin? || @node.has_tag("with:#{current_user.username}")
@revision = @node.latest
@revision.title = params[:title]
- Create a ticketCreate a ticket