Showing 52 of 127 total issues
Method create
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def create
@openid_url_base = "https://publiclab.org/people/"
@openid_url_suffix = "/identity"
back_to = params[:back_to]
# we pass a temp username; on line 75 it'll be overwritten by the real one in PublicLab.org's response:
- Read upRead up
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 synchronizeData
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
synchronizeData: function(warpables) {
var layers = [];
map.eachLayer(function(l) {layers.push(l)});
layers = layers.filter(image => !!image._url);
warpables.forEach(function(warpable) {
Function initialize
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
initialize: function(options) {
MapKnitter.Resources.prototype.initialize.call(this, options);
var map = options.map,
drawOptions = {};
Function _initEvents
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
_initEvents: function() {
var map = this._map;
map.on('draw:created', function(event) {
var layer = event.layer;
Function geocodeImageFromId
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
geocodeImageFromId: function (dom_id, id, url) {
mapknitter.geocodeImage(
$(dom_id)[0],
function (lat, lng, id, angle, altitude) {
/* Display button to place this image with GPS tags. */
Method errors_for
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def errors_for(object, message = nil)
html = ""
unless object.nil? || object.errors.blank?
html << "<div class='alert alert-error #{object.class.name.humanize.downcase}Errors'>\n"
html << if message.blank?
- Read upRead up
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 10 (exceeds 5 allowed). Consider refactoring. Open
def create
if logged_in?
@comment = current_user.comments.new(comment_params)
@map = @comment.map
- Read upRead up
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 setup
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
setup: function() {
Glop.observe('glop:predraw', function() { $C.clear();})
// disable default "delete" key (in Chrome it goes "back")
window.addEventListener ('keydown', function (e) {
// If the key pressed was a backspace key, handle it specially
Function fetchStatusUrl
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
function fetchStatusUrl(opts) {
console.log('fetch status json', opts);
var scale = 0;
opts.collection.forEach(function(img) {
Method update
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
def update
@warpable = Warpable.find(params[:warpable_id])
if Map.find(@warpable.map_id).anonymous? || logged_in?
nodes = []
Function saveImage
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
saveImage: function () {
var img = this;
img._corner_state = JSON.stringify(img._corners); // reset change state string:
$.ajax('/images/' + img.warpable_id, { // send save request
type: 'PATCH',
Method collect_ways
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
def self.collect_ways(features)
# collected_ways variable unused review this function
collected_ways = []
nodes = {}
features['osm']['node'].each do |node|
Method check_and_ban
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def check_and_ban(resource, type) # toggle between directly banning a user or banning them via their map
if type == 'map'
# check and ban a map's author as long as the author is unbanned and non-anonymous
resource.user.ban unless resource.anonymous? || resource.user.status == User::Status::BANNED
elsif type == 'user'
- Read upRead up
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 addImage
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
addImage: function(url,id,lat,lng,angle,altitude) {
Method alert_and_redirect_if_banned
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def alert_and_redirect_if_banned
if @map.anonymous? && @map.status != Map::Status::NORMAL && !current_user&.can_moderate?
true
elsif !@map.anonymous? && @map.user.status == User::Status::BANNED && !(current_user&.login == @map.user.login || current_user&.can_moderate?)
flash[:error] = 'The author of that map has been banned'
- Read upRead up
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 check_and_unban
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def check_and_unban(resource, type) # toggle between directly unbanning a user or unbanning them via their map
if type == 'map'
# check and unban a map's author as long as the author is banned and non-anonymous
resource.user.unban unless resource.anonymous? || resource.user.status != User::Status::BANNED
elsif type == 'user'
- Read upRead up
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 bbox
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def self.bbox(minlat, minlon, maxlat, maxlon, tag = nil)
Method grouped_images_histogram
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def grouped_images_histogram(binsize)
hist = []
warpables.each do |warpable|
res = warpable.cm_per_pixel
next if res.nil?
- Read upRead up
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 withWarpables
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
withWarpables: function (callback) {
if (this._warpables) {
if (callback) { callback(this._warpables); }
} else {
jQuery.getJSON(this._warpablesUrl, function (warpablesData) {
- Read upRead up
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 progress
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def progress
map = Map.find_by(id: params[:id])
export = map.export
output = if export.present?
if export.status == 'complete'
- Read upRead up
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"