Showing 32 of 54 total issues

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

module.exports = function(config) {
  /**
   * Server listening port.
   */
  config.port = (process.env.PORT || 3000);
Severity: Major
Found in src/config/base.js - About 5 hrs to fix

    Function init has 100 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    loader.init = function*(options) {
      if (loader[$FILE]) {
        debug('Waigo was already initialised. Re-initialising...');
    
        loader.reset();
    Severity: Major
    Found in src/loader.js - About 4 hrs to fix

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

      "use strict";
      
      const crypto = require('crypto');
      
      const waigo = global.waigo,
      Severity: Minor
      Found in src/models/user.js - About 3 hrs to fix

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

        module.exports = function(options) {
          return function*(context, field, value) {
            let fields = field.form.fields,
              otherField = fields[options.field]
        
        
        Severity: Minor
        Found in src/support/forms/validators/compareToField.js - About 3 hrs 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 init has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
        Open

        loader.init = function*(options) {
          if (loader[$FILE]) {
            debug('Waigo was already initialised. Re-initialising...');
        
            loader.reset();
        Severity: Minor
        Found in src/loader.js - About 2 hrs 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 process has 51 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          * process (token, options) {
            options = options || {};
            
            this.logger.debug(`Processing action token: ${token}`);
        
        
        Severity: Major
        Found in src/support/actionTokens.js - About 2 hrs to fix

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

          module.exports = function(options) {
            return function*(context, field, value) {
              let fields = field.form.fields,
                otherField = fields[options.field]
          
          
          Severity: Minor
          Found in src/support/forms/validators/compareToField.js - About 1 hr to fix

            Function run has 39 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              * run () {
                if (!this.fileExists('package.json')) {
                  return this.log('Please run "npm init" first');
                }
            
            
            Severity: Minor
            Found in src/cli/init-gulp.js - About 1 hr to fix

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

              module.exports = function(App, options) {
                return function*(next) {
                  this.App.logger.debug('assertUser is logged in');
              
                  try {
              Severity: Minor
              Found in src/support/middleware/assertUser.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 _buildRoutes has 35 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                _buildRoutes (commonMiddleware, urlPath, node, parentConfig) {
                  urlPath = parentConfig.urlPath + urlPath;
              
                  logger.debug('Build route', urlPath);
              
              
              Severity: Minor
              Found in src/support/routeMapper.js - About 1 hr to fix

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

                module.exports = function(App, options) {
                  let enabledFormats = {};
                
                  let formatNames = Object.keys(options.formats);
                
                
                Severity: Minor
                Found in src/support/middleware/outputFormats.js - About 1 hr to fix

                  Function getAccessToken has 33 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                    * getAccessToken (code) {
                      let user = this._user();
                  
                      this.logger.info(`Get access token: user=${user ? user.id : 'anon'} code=${code}`);
                  
                  
                  Severity: Minor
                  Found in src/support/oauth/providers/generic.js - About 1 hr to fix

                    Function register has 33 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                      register: function*(properties) {
                        // create user
                        let attrs = {
                          username: properties.username,
                          emails: [],
                    Severity: Minor
                    Found in src/models/user.js - About 1 hr to fix

                      Function setup has 33 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                        * setup (middlewareConfig, routeConfig) {
                          logger.info('Initialise...');
                      
                          require('koa-trie-router')(this.App.koa);
                      
                      
                      Severity: Minor
                      Found in src/support/routeMapper.js - About 1 hr to fix

                        Function toViewObjectYieldable has 32 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                        const toViewObjectYieldable = exports.toViewObjectYieldable = function(inputObject, ctx) {
                        
                          if (inputObject) {
                            // if it's one of our model schema types
                            // (see https://github.com/hiddentao/simple-nosql-schema)
                        Severity: Minor
                        Found in src/support/viewObjects.js - About 1 hr to fix

                          Function validate has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                          Open

                            * validate (context) {
                              let errors = [];
                          
                              // if value is undefined and field is not required then nothing to do
                              if (undefined === this.value || null === this.value || '' === this.value) {
                          Severity: Minor
                          Found in src/support/forms/field.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 toViewObjectYieldable has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                          Open

                          const toViewObjectYieldable = exports.toViewObjectYieldable = function(inputObject, ctx) {
                          
                            if (inputObject) {
                              // if it's one of our model schema types
                              // (see https://github.com/hiddentao/simple-nosql-schema)
                          Severity: Minor
                          Found in src/support/viewObjects.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 createUserAndLogin has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                              function* createUserAndLogin(next) {
                                let ctx = this.context,
                                  App = ctx.App,
                                  User = App.models.User;
                          
                          
                          Severity: Minor
                          Found in src/forms/register.js - About 1 hr to fix

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

                              * _send (mailOptions) {
                                let self = this;
                            
                                mailOptions = yield self._prepareMailOptions(mailOptions);
                            
                            
                            Severity: Minor
                            Found in src/support/mailer/base.js - About 1 hr to fix

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

                              module.exports = function(App, options) {
                                return function*(next) {
                                  this.App.logger.debug('assertUser is logged in');
                              
                                  try {
                              Severity: Minor
                              Found in src/support/middleware/assertUser.js - About 1 hr to fix
                                Severity
                                Category
                                Status
                                Source
                                Language