Showing 54 of 54 total issues

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

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

              for (let stepName of this.config.shutdownSteps) {
                this.logger.debug(`Running shutdown step: ${stepName}`);
          
                /*jshint -W030 */
                yield waigo.load(`support/shutdown/${stepName}`)(this);
          Severity: Major
          Found in src/application.js and 1 other location - About 1 hr to fix
          src/application.js on lines 145..150

          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

              for (let stepName of this.config.startupSteps) {
                this.logger.debug(`Running startup step: ${stepName}`);
                
                /*jshint -W030 */
                yield waigo.load(`support/startup/${stepName}`)(this);
          Severity: Major
          Found in src/application.js and 1 other location - About 1 hr to fix
          src/application.js on lines 171..176

          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 _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

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

                constructor (config, options) {
                  options = _.extend({
                    context: null,
                    state: null,
                  }, options);
              Severity: Minor
              Found in src/support/forms/form.js - About 1 hr to fix

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

                const waigo = global.waigo,
                  _ = waigo._,
                  logger = waigo.load('support/logger').create('RouteMapper'),
                  errors = waigo.load('support/errors');
                Severity: Minor
                Found in src/support/routeMapper.js and 1 other location - About 55 mins to fix
                src/support/notifications/slack.js on lines 5..8

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

                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

                const waigo = global.waigo,
                  _ = waigo._,
                  logger = waigo.load('support/logger').create('SlackNotifier'),
                  Q = waigo.load('support/promise');
                Severity: Minor
                Found in src/support/notifications/slack.js and 1 other location - About 55 mins to fix
                src/support/routeMapper.js on lines 8..11

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

                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

                    let count = yield this.rawQry().count(function(user) {
                      return user('roles').contains('admin')
                    }).run();
                Severity: Minor
                Found in src/models/user.js and 1 other location - About 50 mins to fix
                src/models/user.js on lines 401..403

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

                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

                    let ret = yield this.rawQry().filter(function(user) {
                      return user('roles').contains('admin')
                    }).run();
                Severity: Minor
                Found in src/models/user.js and 1 other location - About 50 mins to fix
                src/models/user.js on lines 412..414

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

                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

                    let ret = yield this.rawQry().filter(function(user) {
                      return user('username').eq(username);
                    }).run();
                Severity: Minor
                Found in src/models/user.js and 1 other location - About 50 mins to fix
                src/models/user.js on lines 499..501

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

                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

                    let ret = yield this.rawQry().filter(function(doc) {
                      return doc('created').ge(date)
                    }).run();
                Severity: Minor
                Found in src/models/user.js and 1 other location - About 50 mins to fix
                src/models/user.js on lines 353..355

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

                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 exports has a Cognitive Complexity of 8 (exceeds 5 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 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 can has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                Open

                  can (resource, user) {
                    this.logger.debug('can', resource, user.id);
                
                    // if resource name is "public" then everyone has access
                    if ('public' === resource) {
                Severity: Minor
                Found in src/support/acl.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 process has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                Open

                  * process (token, options) {
                    options = options || {};
                    
                    this.logger.debug(`Processing action token: ${token}`);
                
                
                Severity: Minor
                Found in src/support/actionTokens.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