Showing 16 of 33 total issues
Function streamToFlickr
has 58 lines of code (exceeds 25 allowed). Consider refactoring. Open
function streamToFlickr(photoId, payloadData, callback) {
// save the photo data
var api = getFlickrAPI();
console.info('Processing photo upload:' + JSON.stringify(payloadData));
File index.js
has 260 lines of code (exceeds 250 allowed). Consider refactoring. Open
'use strict';
var express = require('express');
var router = express.Router();
var conf = require('../lib/config');
Function getTide
has 52 lines of code (exceeds 25 allowed). Consider refactoring. Open
exports.getTide = function(res, tideId) {
KingTideEvent.findOne({
_id: tideId
}, function (err, event) {
if (event == null) {
Function updatePhoto
has 47 lines of code (exceeds 25 allowed). Consider refactoring. Open
exports.updatePhoto = function(res, id, cb){
var msg = '';
Photo.getPhotoByFlickrId(res, id, function(err, photo){
if(err) {
Consider simplifying this complex logical expression. Open
if (event == null)
res.send(404);
else {
event.location = req.body['location'] || event.location;
event.state = req.body['state'] || event.state;
Function base58
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
var base58 = (function(alpha) {
var alphabet = alpha || '123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ',
base = alphabet.length;
return {
encode: function(enc) {
- 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 handleMultipart
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
Uploader.prototype.handleMultipart = function(req, res) {
var form = new multiparty.Form();
form.parse(req, function(err, fields, files) {
if (err) {
res.json(500, err);
Function handleJson
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
Uploader.prototype.handleJson = function(req, res) {
var payload = req.body;
var pathSeparator = '';
if (os.tmpdir()[os.tmpdir().length - 1] !== '/') {
pathSeparator = '/';
Function paginatedSearch
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
exports.paginatedSearch = function (res, req) {
var params = {
search: getSearchParams(getPhotoSearchParams(req)),
count: 100,
page: req.query['page'] || 1
Function base58
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
var base58 = (function(alpha) {
var alphabet = alpha || '123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ',
base = alphabet.length;
return {
encode: function(enc) {
Function checkSetDate
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
function checkSetDate(photo, callback)
{
var api = getFlickrAPI();
if(photo.dateTaken && !(isNaN(Date.parse(photo.dateTaken))))
{
- 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 printNav
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
var printNav = function(count,perPage,page,queryString,res){
Function getPhoto
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
exports.getPhoto = function(res, id, cb) {
Photo.findById(id, function(err, data) {
if (err) {
if(cb) cb(err);
else res.json(500, err);
- 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 clusters
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
exports.clusters = function (res, req) {
Photo.find(getSearchParams(getPhotoSearchParams(req)), function (err, docs) {
if(err) {
res.status(500).json(err);
return;
- 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 getSearchParams
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
var getSearchParams = function(params){
var search = {
flickrUrl: {$exists: true}
,$or: [ {deleted: {$eq: null}}, {deleted: false}]
};
- 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 isFlickrAdmin
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
exports.isFlickrAdmin = function(res, users){
var flickrPage = conf.get('FLICKR_USER_ID').trim();
var regex = new RegExp('^' + flickrPage + '$', 'gi');
if(typeof(users) === 'string'){
users = [users];
- 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"