Showing 127 of 127 total issues
Similar blocks of code found in 2 locations. Consider refactoring. Open
def batch_publish_maps
published_maps = 0
unbanned_authors = 0
params[:ids].split(',').uniq.each do |id|
map = Map.find(id)
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 56.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 2 locations. Consider refactoring. Open
def batch_spam_maps
spammed_maps = 0
banned_authors = 0
params[:ids].split(',').uniq.each do |id|
map = Map.find(id)
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 56.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
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) {
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 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 = []
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|
Similar blocks of code found in 2 locations. Consider refactoring. Open
retrieve: function(id, callback) {
this._retrieveResources(id, callback)
.done.call(this, function() {
console.log('retrieved resources');
});
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 53.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 2 locations. Consider refactoring. Open
create: function(annotation, callback) {
this._createResource(annotation, callback)
.done.call(this, function() {
console.log('created new resource');
});
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 53.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Unchecked return value from xmlTextReaderExpand Open
nokogiri (1.13.8)
- Read upRead up
- Exclude checks
Advisory: CVE-2022-23476
Criticality: High
URL: https://github.com/sparklemotion/nokogiri/security/advisories/GHSA-qv4q-mr5r-qprj
Solution: upgrade to >= 1.13.10
Denial of Service Vulnerability in Rack Content-Disposition parsing Open
rack (2.2.4)
- Read upRead up
- Exclude checks
Advisory: CVE-2022-44571
URL: https://github.com/rack/rack/releases/tag/v3.0.4.1
Solution: upgrade to >= 2.0.9.2, ~> 2.0.9, >= 2.1.4.2, ~> 2.1.4, >= 2.2.6.1, ~> 2.2.6, >= 3.0.4.1
Inefficient Regular Expression Complexity in rails-html-sanitizer Open
rails-html-sanitizer (1.4.3)
- Read upRead up
- Exclude checks
Advisory: CVE-2022-23517
Criticality: High
URL: https://github.com/rails/rails-html-sanitizer/security/advisories/GHSA-5x79-w82f-gw8w
Solution: upgrade to >= 1.4.4
Possible XSS vulnerability with certain configurations of rails-html-sanitizer Open
rails-html-sanitizer (1.4.3)
- Read upRead up
- Exclude checks
Advisory: CVE-2022-23520
Criticality: Medium
URL: https://github.com/rails/rails-html-sanitizer/security/advisories/GHSA-rrfc-7g8p-99q8
Solution: upgrade to >= 1.4.4