rhok-melbourne/kingtides-api

View on GitHub

Showing 33 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

            Identical blocks of code found in 2 locations. Consider refactoring.
            Open

              Photo.findOne({flickrId: id}, function(err, data) {
                if (err) {
                  if(cb) cb(err)
                  else res.json(500, err);
                  return;
            Severity: Major
            Found in controllers/photos.js and 1 other location - About 1 hr to fix
            controllers/photos.js on lines 50..58

            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 64.

            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

            Further Reading

            Identical blocks of code found in 2 locations. Consider refactoring.
            Open

              Photo.findById(id, function(err, data) {
                if (err) {
                  if(cb) cb(err);
                  else res.json(500, err);
                  return;
            Severity: Major
            Found in controllers/photos.js and 1 other location - About 1 hr to fix
            controllers/photos.js on lines 61..69

            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 64.

            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

            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

              Identical blocks of code found in 2 locations. Consider refactoring.
              Open

                  .exec(function(err,data){
                  if (err) {
                    if(cb) cb(err);
                    res.json(500, err);
                    return;
              Severity: Major
              Found in controllers/photos.js and 1 other location - About 1 hr to fix
              controllers/photos.js on lines 118..126

              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 63.

              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

              Further Reading

              Identical blocks of code found in 2 locations. Consider refactoring.
              Open

                  .count(search, function(err,data){
                  if (err) {
                    if(cb) cb(err);
                    res.json(500, err);
                    return;
              Severity: Major
              Found in controllers/photos.js and 1 other location - About 1 hr to fix
              controllers/photos.js on lines 139..147

              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 63.

              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

              Further Reading

              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

                    Similar blocks of code found in 2 locations. Consider refactoring.
                    Open

                      if (params.max_taken_date) {
                        search.dateTaken = search.dateTaken || {};
                        search.dateTaken['$lte'] = new Date(params.max_taken_date*1000);
                      }
                    Severity: Major
                    Found in controllers/photos.js and 1 other location - About 1 hr to fix
                    controllers/photos.js on lines 78..81

                    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 58.

                    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

                    Further Reading

                    Similar blocks of code found in 2 locations. Consider refactoring.
                    Open

                      if (params.min_taken_date) {
                        search.dateTaken = search.dateTaken || {};
                        search.dateTaken['$gte'] = new Date(params.min_taken_date*1000);
                      }
                    Severity: Major
                    Found in controllers/photos.js and 1 other location - About 1 hr to fix
                    controllers/photos.js on lines 82..85

                    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 58.

                    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

                    Further Reading

                    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

                    Similar blocks of code found in 6 locations. Consider refactoring.
                    Open

                    router.get('/flickr/:id', cors, function (req, res) {
                      var id = req.params.id;
                      controllers.flickr.getPhoto(res, id);
                    });
                    Severity: Major
                    Found in routes/index.js and 5 other locations - About 50 mins to fix
                    routes/index.js on lines 46..49
                    routes/index.js on lines 51..54
                    routes/index.js on lines 222..225
                    routes/index.js on lines 226..229
                    routes/index.js on lines 286..289

                    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 51.

                    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

                    Further Reading

                    Similar blocks of code found in 6 locations. Consider refactoring.
                    Open

                    router.get('/photos/deleteFid/:flickrId', cors, function (req, res) {
                      var id = req.params.flickrId;
                      controllers.flickr.deleteIfDoesntExistOnFlickr(res, id);
                    });
                    Severity: Major
                    Found in routes/index.js and 5 other locations - About 50 mins to fix
                    routes/index.js on lines 46..49
                    routes/index.js on lines 51..54
                    routes/index.js on lines 226..229
                    routes/index.js on lines 281..284
                    routes/index.js on lines 286..289

                    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 51.

                    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

                    Further Reading

                    Similar blocks of code found in 6 locations. Consider refactoring.
                    Open

                    router.get('/photos', cors, function (req, res) {
                      var email = req.query.email;
                      controllers.photos.getAllPhotos(res, email);
                    });
                    Severity: Major
                    Found in routes/index.js and 5 other locations - About 50 mins to fix
                    routes/index.js on lines 46..49
                    routes/index.js on lines 222..225
                    routes/index.js on lines 226..229
                    routes/index.js on lines 281..284
                    routes/index.js on lines 286..289

                    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 51.

                    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

                    Further Reading

                    Severity
                    Category
                    Status
                    Source
                    Language