Showing 686 of 688 total issues
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
Function 'diff' has a complexity of 11. Open
function diff( o, n ) {
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
Limit Cyclomatic Complexity (complexity)
Cyclomatic complexity measures the number of linearly independent paths through a program's source code. This rule allows setting a cyclomatic complexity threshold.
function a(x) {
if (true) {
return x; // 1st path
} else if (false) {
return x+1; // 2nd path
} else {
return 4; // 3rd path
}
}
Rule Details
This rule is aimed at reducing code complexity by capping the amount of cyclomatic complexity allowed in a program. As such, it will warn when the cyclomatic complexity crosses the configured threshold (default is 20
).
Examples of incorrect code for a maximum of 2:
/*eslint complexity: ["error", 2]*/
function a(x) {
if (true) {
return x;
} else if (false) {
return x+1;
} else {
return 4; // 3rd path
}
}
Examples of correct code for a maximum of 2:
/*eslint complexity: ["error", 2]*/
function a(x) {
if (true) {
return x;
} else {
return 4;
}
}
Options
Optionally, you may specify a max
object property:
"complexity": ["error", 2]
is equivalent to
"complexity": ["error", { "max": 2 }]
Deprecated: the object property maximum
is deprecated. Please use the property max
instead.
When Not To Use It
If you can't determine an appropriate complexity limit for your code, then it's best to disable this rule.
Further Reading
Related Rules
- [max-depth](max-depth.md)
- [max-len](max-len.md)
- [max-nested-callbacks](max-nested-callbacks.md)
- [max-params](max-params.md)
- [max-statements](max-statements.md) Source: http://eslint.org/docs/rules/
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
Function 'diffString2' has a complexity of 9. Open
function diffString2( o, n ) {
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
Limit Cyclomatic Complexity (complexity)
Cyclomatic complexity measures the number of linearly independent paths through a program's source code. This rule allows setting a cyclomatic complexity threshold.
function a(x) {
if (true) {
return x; // 1st path
} else if (false) {
return x+1; // 2nd path
} else {
return 4; // 3rd path
}
}
Rule Details
This rule is aimed at reducing code complexity by capping the amount of cyclomatic complexity allowed in a program. As such, it will warn when the cyclomatic complexity crosses the configured threshold (default is 20
).
Examples of incorrect code for a maximum of 2:
/*eslint complexity: ["error", 2]*/
function a(x) {
if (true) {
return x;
} else if (false) {
return x+1;
} else {
return 4; // 3rd path
}
}
Examples of correct code for a maximum of 2:
/*eslint complexity: ["error", 2]*/
function a(x) {
if (true) {
return x;
} else {
return 4;
}
}
Options
Optionally, you may specify a max
object property:
"complexity": ["error", 2]
is equivalent to
"complexity": ["error", { "max": 2 }]
Deprecated: the object property maximum
is deprecated. Please use the property max
instead.
When Not To Use It
If you can't determine an appropriate complexity limit for your code, then it's best to disable this rule.
Further Reading
Related Rules
- [max-depth](max-depth.md)
- [max-len](max-len.md)
- [max-nested-callbacks](max-nested-callbacks.md)
- [max-params](max-params.md)
- [max-statements](max-statements.md) Source: http://eslint.org/docs/rules/
Function 'setupLEL' has a complexity of 9. Open
function setupLEL(map, markers_hash = null, params = {}) {
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
Limit Cyclomatic Complexity (complexity)
Cyclomatic complexity measures the number of linearly independent paths through a program's source code. This rule allows setting a cyclomatic complexity threshold.
function a(x) {
if (true) {
return x; // 1st path
} else if (false) {
return x+1; // 2nd path
} else {
return 4; // 3rd path
}
}
Rule Details
This rule is aimed at reducing code complexity by capping the amount of cyclomatic complexity allowed in a program. As such, it will warn when the cyclomatic complexity crosses the configured threshold (default is 20
).
Examples of incorrect code for a maximum of 2:
/*eslint complexity: ["error", 2]*/
function a(x) {
if (true) {
return x;
} else if (false) {
return x+1;
} else {
return 4; // 3rd path
}
}
Examples of correct code for a maximum of 2:
/*eslint complexity: ["error", 2]*/
function a(x) {
if (true) {
return x;
} else {
return 4;
}
}
Options
Optionally, you may specify a max
object property:
"complexity": ["error", 2]
is equivalent to
"complexity": ["error", { "max": 2 }]
Deprecated: the object property maximum
is deprecated. Please use the property max
instead.
When Not To Use It
If you can't determine an appropriate complexity limit for your code, then it's best to disable this rule.
Further Reading
Related Rules
- [max-depth](max-depth.md)
- [max-len](max-len.md)
- [max-nested-callbacks](max-nested-callbacks.md)
- [max-params](max-params.md)
- [max-statements](max-statements.md) Source: http://eslint.org/docs/rules/
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