seeden/maglev

View on GitHub

Showing 23 of 46 total issues

File app.js has 347 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import express from 'express';
import debug from 'debug';
import http from 'http';
import isArray from 'lodash/isArray';

Severity: Minor
Found in src/app.js - About 4 hrs to fix

    File user.js has 328 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    import jwt from 'jsonwebtoken';
    import bcrypt from 'bcryptjs';
    import { genNameUID } from './provider';
    import permalink from 'mongoose-permalink';
    import mongooseHRBAC from 'mongoose-hrbac';
    Severity: Minor
    Found in src/models/user.js - About 3 hrs to fix

      Function createSchema has 71 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      export function createSchema(Schema) {
        // add properties to schema
        const schema = new Schema({
          firstName: { type: String },
          lastName: { type: String },
      Severity: Major
      Found in src/models/user.js - About 2 hrs to fix

        App has 21 functions (exceeds 20 allowed). Consider refactoring.
        Open

        export default class App {
          constructor(server, options = {}) {
            if (!options.root) {
              throw new Error('Root is undefined');
            }
        Severity: Minor
        Found in src/app.js - About 2 hrs to fix

          Function updateUserByFacebookProfile has 46 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          function updateUserByFacebookProfile(user, profile, callback) {
            let changed = false;
          
            if (!user.firstName && profile.first_name) {
              user.firstName = profile.first_name;
          Severity: Minor
          Found in src/models/user.js - About 1 hr to fix

            Function forgot has 42 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            export function forgot(req, res, next) {
              const User = req.models.User;
              const server = req.server;
              const options = server.options;
              const mail = server.mail;
            Severity: Minor
            Found in src/controllers/password.js - About 1 hr to fix

              Function createSchema has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
              Open

              export function createSchema(Schema) {
                // add properties to schema
                const schema = new Schema({
                  firstName: { type: String },
                  lastName: { type: String },
              Severity: Minor
              Found in src/models/user.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 _prepareSession has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
              Open

                _prepareSession() {
                  const app = this.expressApp;
                  const options = this.options;
              
                  if (!options.session) {
              Severity: Minor
              Found in src/app.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 _prepareStatic has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
              Open

                _prepareStatic() {
                  const app = this.expressApp;
                  const options = this.options;
              
                  if (options.flash) {
              Severity: Minor
              Found in src/app.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 ensureBySignedRequest has 31 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              export function ensureBySignedRequest(req, res, next) {
                if (!req.body.signedRequest || !req.body.profile) {
                  return next(new WebError(400));
                }
              
              
              Severity: Minor
              Found in src/controllers/facebook.js - About 1 hr to fix

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

                  _prepareStatic() {
                    const app = this.expressApp;
                    const options = this.options;
                
                    if (options.flash) {
                Severity: Minor
                Found in src/app.js - About 1 hr to fix

                  Function close has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                    close(callback) {
                      const { activeConnections, httpServer, options } = this;
                  
                      if (!httpServer) {
                        return callback(new Error('You need to listen first'));
                  Severity: Minor
                  Found in src/app.js - About 1 hr to fix

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

                    export function error(err, req, res, next) {
                      const server = req.server;
                      const options = server.options;
                    
                      log(err);
                    Severity: Minor
                    Found in src/controllers/page.js - About 1 hr to fix

                      Function handleConnectionEvents has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                        handleConnectionEvents() {
                          // TODO UNHANDLE
                          const { activeConnections, httpServer } = this;
                      
                          httpServer.on('connection', function onConnectionCallback(connection) {
                      Severity: Minor
                      Found in src/app.js - About 1 hr to fix

                        Function _prepareSession has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                          _prepareSession() {
                            const app = this.expressApp;
                            const options = this.options;
                        
                            if (!options.session) {
                        Severity: Minor
                        Found in src/app.js - About 1 hr to fix

                          Function closeGracefully has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                            closeGracefully() {
                              log('Received kill signal (SIGTERM), shutting down gracefully.');
                              if (!this._listening) {
                                log('Ended without any problem');
                                process.exit(0);
                          Severity: Minor
                          Found in src/server.js - About 1 hr to fix

                            Function _prepareHtml has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                              _prepareHtml() {
                                const app = this.expressApp;
                                const options = this.options;
                            
                                if (!options.powered) {
                            Severity: Minor
                            Found in src/app.js - About 1 hr to fix

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

                                _prepareHtml() {
                                  const app = this.expressApp;
                                  const options = this.options;
                              
                                  if (!options.powered) {
                              Severity: Minor
                              Found in src/app.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

                              Function handleConnectionEvents has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                              Open

                                handleConnectionEvents() {
                                  // TODO UNHANDLE
                                  const { activeConnections, httpServer } = this;
                              
                                  httpServer.on('connection', function onConnectionCallback(connection) {
                              Severity: Minor
                              Found in src/app.js - About 45 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 ensureBySignedRequest has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                              Open

                              export function ensureBySignedRequest(req, res, next) {
                                if (!req.body.signedRequest || !req.body.profile) {
                                  return next(new WebError(400));
                                }
                              
                              
                              Severity: Minor
                              Found in src/controllers/facebook.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

                              Severity
                              Category
                              Status
                              Source
                              Language