Showing 216 of 688 total issues
Function attachSaveListener
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
attachSaveListener() {
// remove any other existing eventHandler
$("textarea").off("input.save"); // input.save is a custom jQuery eventHandler
const thisEditor = this; // save a reference to this editor, because inside the eventListener, "this" points to e.target
//implementing a debounce function on save method
- Create a ticketCreate a ticket
Method new
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
def new
@revision = Revision.new
if current_user &.first_time_poster
flash[:notice] = "You can create a wiki once your research note/question has been approved by moderators. Click <a href='https://publiclab.org/notes/tester/04-23-2016/new-moderation-system-for-first-time-posters'>here</a> to learn why."
redirect_to '/'
- Create a ticketCreate a ticket
Method create
has 32 lines of code (exceeds 25 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
- Create a ticketCreate a ticket
Method delete
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
def delete
node_tag = NodeTag.where(nid: params[:nid], tid: params[:tid]).first
node = Node.where(nid: params[:nid]).first
# only admins, mods can delete other peoples' tags if the note/wiki contains the locked tag
if (node_tag.uid == current_user.uid && !node.has_tag('locked')) || logged_in_as(['admin', 'moderator']) || (node.uid == current_user.uid && !node.has_tag('locked'))
- Create a ticketCreate a ticket
Function TimeAgo
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
var TimeAgo = (function() {
var self = {};
// Public Methods
self.locales = {
- 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 reducer
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
const reducer = (state, action) => {
switch(action.type) {
// COMMENT actions
case "CREATE COMMENT":
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 create
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def create
@node = Node.find params[:id]
@body = params[:body]
@user = current_user
begin
- 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 11 (exceeds 5 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!
- 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 show
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def show
return if redirect_to_node_path?(@node)
if @node
if @node.has_power_tag('question') && @node.status == 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 delete
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
def delete
output = {
status: false,
tid: 0,
errors: []
- Create a ticketCreate a ticket
Function promptTag
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
function promptTag(val) {
var input;
switch(val) {
case "series:":
- Create a ticketCreate a ticket
Function setupWiki
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
function setupWiki(node_id, title, raw, logged_in) {
// insert inline forms
if (raw && logged_in) {
$('#content-raw-markdown').html(shortCodePrompt($('#content-raw-markdown')[0], {
submitUrl: '/wiki/replace/' + node_id
- Create a ticketCreate a ticket
Method create
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
def create
if current_user.status == 1
# we no longer allow custom urls, just titles which are parameterized automatically into urls
# slug = params[:title].parameterize
# slug = params[:id].parameterize if params[:id] != "" && !params[:id].nil?
- Create a ticketCreate a ticket
Method can_tag
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
def can_tag(tagname, user, errors = false)
one_split = tagname.split(':')[1]
socials = { facebook: 'Facebook', github: 'Github', google_oauth2: 'Google', twitter: 'Twitter' }
if tagname[0..4] == 'with:'
- Create a ticketCreate a ticket
Method publish
has 29 lines of code (exceeds 25 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.'
- Create a ticketCreate a ticket
Method delete
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
def delete
@comment = Comment.find params[:id]
comments_node_and_path
- Create a ticketCreate a ticket
Method stats
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
def stats
@start = params[:start] ? Time.parse(params[:start].to_s) : Time.now - 1.year
@end = params[:end] ? Time.parse(params[:end].to_s) : Time.now
tagname = params[:id]
- Create a ticketCreate a ticket
Method range
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
def range
flash.now[:notice] = "Data is cached and recalculated daily"
if params[:options].present? && params[:options] != 'For all time'
params[:start] = Time.now - to_keyword(params[:options])
params[:end] = Time.now
- Create a ticketCreate a ticket
Method new
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def new
@revision = Revision.new
if current_user &.first_time_poster
flash[:notice] = "You can create a wiki once your research note/question has been approved by moderators. Click <a href='https://publiclab.org/notes/tester/04-23-2016/new-moderation-system-for-first-time-posters'>here</a> to learn why."
redirect_to '/'
- 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 save_settings
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def save_settings
user_settings = [
'notify-comment-direct:false',
'notify-likes-direct:false',
'notify-comment-indirect:false',
- 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"