yhnavein/express-starter

View on GitHub

Showing 12 of 59 total issues

File userRepository.spec.js has 664 lines of code (exceeds 250 allowed). Consider refactoring.
Open

'use strict';

var expect = require('expect.js');
var userRepo = require('../../../repositories/UserRepository');
var bcrypt = require('bcrypt-nodejs');
Severity: Major
Found in test/integration/repositories/userRepository.spec.js - About 1 day to fix

    File api.js has 532 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    "use strict";
    
    //global requires
    var secrets = require('../config/secrets');
    var querystring = require('querystring');
    Severity: Major
    Found in controllers/api.js - About 1 day to fix

      Function exports has 112 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      module.exports = function(db, DataTypes) {
        var User = db.define('User', {
          id: {
            type: DataTypes.INTEGER,
            autoIncrement: true,
      Severity: Major
      Found in models/sequelize/User.js - About 4 hrs to fix

        File UserRepository.js has 334 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        'use strict';
        
        var db = require('../models/sequelize');
        
        var PSW_RESET_TOKEN_VALID_FOR = 3; //hours
        Severity: Minor
        Found in repositories/UserRepository.js - About 4 hrs to fix

          Function getLastfm has 68 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          exports.getLastfm = function(req, res, next) {
            LastFmNode = require('lastfm').LastFmNode;
          
            var lastfm = new LastFmNode(secrets.lastfm);
            async.parallel({
          Severity: Major
          Found in controllers/api.js - About 2 hrs to fix

            Function getSteam has 38 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            exports.getSteam = function(req, res, next) {
              var steamId = '76561198040657099';
              var query = { l: 'english', steamid: steamId, key: secrets.steam.apiKey };
              async.parallel({
                playerAchievements: function(done) {
            Severity: Minor
            Found in controllers/api.js - About 1 hr to fix

              Function getPayPal has 37 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              exports.getPayPal = function(req, res, next) {
                paypal = require('paypal-rest-sdk');
              
                paypal.configure({
                  mode: 'sandbox',
              Severity: Minor
              Found in controllers/api.js - About 1 hr to fix

                Function postForgot has 35 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                exports.postForgot = function(req, res, next) {
                  crypto = require('crypto');
                
                  req.assert('email', 'Please enter a valid email address.').isEmail();
                  var errors = req.validationErrors();
                Severity: Minor
                Found in controllers/user.js - About 1 hr to fix

                  Function getBitGo has 34 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                  exports.getBitGo = function(req, res, next) {
                    BitGo = require('bitgo');
                  
                    var bitgo = new BitGo.BitGo({ env: 'test', accessToken: secrets.bitgo.accessToken });
                    var walletId = req.session.walletId; // we use the session to store the walletid, but you should store it elsewhere
                  Severity: Minor
                  Found in controllers/api.js - About 1 hr to fix

                    Function postVenmo has 31 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                    exports.postVenmo = function(req, res, next) {
                      req.assert('user', 'Phone, Email or Venmo User ID cannot be blank').notEmpty();
                      req.assert('note', 'Please enter a message to accompany the payment').notEmpty();
                      req.assert('amount', 'The amount you want to pay cannot be blank').notEmpty();
                      var errors = req.validationErrors();
                    Severity: Minor
                    Found in controllers/api.js - About 1 hr to fix

                      Function postReset has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                      exports.postReset = function(req, res, next) {
                        req.assert('password', 'Password must be at least 4 characters long.').len(4);
                        req.assert('confirm', 'Passwords must match.').equals(req.body.password);
                      
                        var errors = req.validationErrors();
                      Severity: Minor
                      Found in controllers/user.js - About 1 hr to fix

                        Function exports has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                        Open

                        module.exports = function(db, DataTypes) {
                          var User = db.define('User', {
                            id: {
                              type: DataTypes.INTEGER,
                              autoIncrement: true,
                        Severity: Minor
                        Found in models/sequelize/User.js - About 55 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