seeden/maglev

View on GitHub

Showing 46 of 46 total issues

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

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

          role.remove(ok(next, (isDeleted) => {
            if (!isDeleted) {
              return next(new WebError(400));
            }
      
      
      Severity: Major
      Found in src/controllers/role.js and 1 other location - About 1 hr to fix
      src/controllers/permission.js on lines 60..66

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

      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

          permission.remove(ok(next, (isDeleted) => {
            if (!isDeleted) {
              return next(new WebError(400));
            }
      
      
      Severity: Major
      Found in src/controllers/permission.js and 1 other location - About 1 hr to fix
      src/controllers/role.js on lines 59..65

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

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

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

                      res.jsonp({
                        token: user.generateBearerToken(options.token.secret, options.token.expiration),
                        user: user.toPrivateJSON(),
                      });
                  Severity: Major
                  Found in src/controllers/token.js and 2 other locations - About 55 mins to fix
                  src/controllers/token.js on lines 12..15
                  src/controllers/user.js on lines 71..74

                  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

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

                    res.jsonp({
                      token: user.generateBearerToken(options.token.secret, options.token.expiration),
                      user: user.toPrivateJSON(),
                    });
                  Severity: Major
                  Found in src/controllers/token.js and 2 other locations - About 55 mins to fix
                  src/controllers/token.js on lines 31..34
                  src/controllers/user.js on lines 71..74

                  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

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

                      res.jsonp({
                        token: user.generateBearerToken(options.token.secret, options.token.expiration),
                        user: user.toPrivateJSON(),
                      });
                  Severity: Major
                  Found in src/controllers/user.js and 2 other locations - About 55 mins to fix
                  src/controllers/token.js on lines 12..15
                  src/controllers/token.js on lines 31..34

                  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

                  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

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

                      user.setPassword(req.body.password, ok(next, () => {
                        res.status(204).end();
                      }));
                  Severity: Minor
                  Found in src/controllers/password.js and 1 other location - About 40 mins to fix
                  src/controllers/password.js on lines 59..61

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

                  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

                        user.setPassword(req.body.password, ok(next, () => {
                          res.status(204).end();
                        }));
                  Severity: Minor
                  Found in src/controllers/password.js and 1 other location - About 40 mins to fix
                  src/controllers/password.js on lines 46..48

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

                  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

                      }, ok(callback, (newUser) => {
                        newUser.addProvider('twitter', profile.id, profile, ok(callback, () => {
                          callback(null, newUser);
                        }));
                      }));
                  Severity: Minor
                  Found in src/models/user.js and 1 other location - About 40 mins to fix
                  src/models/user.js on lines 113..117

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

                  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

                      }, ok(callback, (newUser) => {
                        newUser.addProvider('facebook', profile.id, profile, ok(callback, () => {
                          callback(null, newUser);
                        }));
                      }));
                  Severity: Minor
                  Found in src/models/user.js and 1 other location - About 40 mins to fix
                  src/models/user.js on lines 139..143

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

                  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