rhok-melbourne/kingtides-api

View on GitHub

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));

Severity: Major
Found in lib/uploader.js - About 2 hrs to fix

    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');
    Severity: Minor
    Found in routes/index.js - About 2 hrs to fix

      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) {
      Severity: Major
      Found in controllers/tide_events.js - About 2 hrs to fix

        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) {
        Severity: Minor
        Found in controllers/flickr.js - About 1 hr to fix

          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;
          Severity: Critical
          Found in routes/private.js - About 1 hr to fix

            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) {
            Severity: Minor
            Found in lib/base58.js - About 1 hr to fix

            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);
            Severity: Minor
            Found in lib/uploader.js - About 1 hr to fix

              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 = '/';
              Severity: Minor
              Found in lib/uploader.js - About 1 hr to fix

                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
                Severity: Minor
                Found in controllers/photos.js - About 1 hr to fix

                  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) {
                  Severity: Minor
                  Found in lib/base58.js - About 1 hr to fix

                    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))))
                      {
                    Severity: Minor
                    Found in lib/uploader.js - About 1 hr to fix

                    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){
                    Severity: Minor
                    Found in routes/index.js - About 35 mins to fix

                      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);
                      Severity: Minor
                      Found in controllers/photos.js - About 35 mins to fix

                      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;
                      Severity: Minor
                      Found in controllers/photos.js - About 35 mins to fix

                      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}]
                        };
                      Severity: Minor
                      Found in controllers/photos.js - About 25 mins to fix

                      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];
                      Severity: Minor
                      Found in controllers/flickr.js - About 25 mins to fix

                      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

                      Severity
                      Category
                      Status
                      Source
                      Language