erizo-fr/erizo-mail-server

View on GitHub

Showing 20 of 20 total issues

Function boxInList has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
Open

function boxInList(searchedBoxPath, boxes) {
    logger.debug('Test if ' + searchedBoxPath + ' is in ' + boxes);
    for (var boxName in boxes) {
        if (boxes.hasOwnProperty(boxName)) {
            let box = boxes[boxName];
Severity: Minor
Found in lib/services/boxService.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

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

module.exports.getBox = function * (next) {
    this.checkParams('box').notEmpty().match(sanitizerHelper.PATTERN_BOX);
    
    if (!sanitizerHelper.hasError.call(this)) {
        yield next;
Severity: Major
Found in lib/sanitizers/boxSanitizer.js and 1 other location - About 2 hrs to fix
lib/sanitizers/boxSanitizer.js on lines 29..35

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

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

module.exports.deleteBox = function * (next) {
    this.checkParams('box').notEmpty().match(sanitizerHelper.PATTERN_BOX);
    
    if (!sanitizerHelper.hasError.call(this)) {
        yield next;
Severity: Major
Found in lib/sanitizers/boxSanitizer.js and 1 other location - About 2 hrs to fix
lib/sanitizers/boxSanitizer.js on lines 13..19

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

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 getMessages has 48 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function getMessages(imapConnection, boxName, ids, seqs, options, callback) {
    logger.info('Getting messages by seqs#' + seqs + ' or ids#' + ids + ' in box#' + boxName + ' with options ' + JSON.stringify(options));
    if (ids && seqs || (!ids && !seqs)) { 
        callback(new Error('Either ids or seqs must be defined'), null);
        return;
Severity: Minor
Found in lib/services/messageService.js - About 1 hr to fix

    Function findBoxBySpecialAttribute has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
    Open

    function findBoxBySpecialAttribute(boxes, attribute, path) {
        let matchingBoxes = [];
        for (let boxName in boxes) {
            if (boxes.hasOwnProperty(boxName)) {
                let box = boxes[boxName];
    Severity: Minor
    Found in lib/imapHelper.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

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

        let options = {
            bodies: this.query.bodies,
            markSeen: this.query.markSeen,
            struct: this.query.fetchStruct,
            envelope: this.query.fetchEnvelope,
    Severity: Major
    Found in lib/controllers/messageController.js and 1 other location - About 1 hr to fix
    lib/controllers/messageController.js on lines 39..45

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

    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

        let options = {
            bodies: this.query.bodies,
            markSeen: this.query.markSeen,
            struct: this.query.fetchStruct,
            envelope: this.query.fetchEnvelope,
    Severity: Major
    Found in lib/controllers/messageController.js and 1 other location - About 1 hr to fix
    lib/controllers/messageController.js on lines 62..68

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

    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

    module.exports.getUserPreferences = function * () {
        let result = yield accountService.getUserPreferences(this.session.username);
        this.body = result;
        this.status = 200;
    };
    Severity: Major
    Found in lib/controllers/accountController.js and 1 other location - About 1 hr to fix
    lib/controllers/accountController.js on lines 7..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 67.

    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

    module.exports.getUserData = function * () {
        let result = yield accountService.getUserData(this.session.username);
        this.body = result;
        this.status = 200;
    };
    Severity: Major
    Found in lib/controllers/accountController.js and 1 other location - About 1 hr to fix
    lib/controllers/accountController.js on lines 13..17

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

    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 29 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    module.exports = function (opts) {
      return function *(next) {
        // request
        var start = new Date;
        logger.debug('  \x1B[90m<-- \x1B[;1m%s\x1B[0;90m %s\x1B[0m', this.method, this.url);
    Severity: Minor
    Found in lib/koaLogger.js - About 1 hr to fix

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

      function createConnection(username, password) {
          logger.debug('Create connection structure for user#' + username);
          connections[username] = {
              "connection" : createImapConnection(username, password),
              "callbacks" : [],
      Severity: Minor
      Found in lib/managers/imapManager.js - About 1 hr to fix

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

        function log(ctx, start, len, err, event) {
          // get the status code of the response
          var status = err
            ? (err.status || 500)
            : (ctx.status || 404);
        Severity: Minor
        Found in lib/koaLogger.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 exports has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

        module.exports = function (opts) {
          return function *(next) {
            // request
            var start = new Date;
            logger.debug('  \x1B[90m<-- \x1B[;1m%s\x1B[0;90m %s\x1B[0m', this.method, this.url);
        Severity: Minor
        Found in lib/koaLogger.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 getMessages has 6 arguments (exceeds 4 allowed). Consider refactoring.
        Open

        function getMessages(imapConnection, boxName, ids, seqs, options, callback) {
        Severity: Minor
        Found in lib/services/messageService.js - About 45 mins to fix

          Avoid deeply nested control flow statements.
          Open

                              if (boxInList(newSearchedBoxPath, box.children)) {
                                  return true;
                              }
          Severity: Major
          Found in lib/services/boxService.js - About 45 mins to fix

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

                this.body = JSON.stringify(result, function (key, value) {
                    if (key === 'parent') {
                        return undefined;
                    } else {
                        return value;
            Severity: Minor
            Found in lib/controllers/boxController.js and 1 other location - About 40 mins to fix
            lib/controllers/boxController.js on lines 15..21

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

            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

                this.body = JSON.stringify(result, function (key, value) {
                    if (key === 'parent') {
                        return undefined;
                    } else {
                        return value;
            Severity: Minor
            Found in lib/controllers/boxController.js and 1 other location - About 40 mins to fix
            lib/controllers/boxController.js on lines 41..47

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

            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 log has 5 arguments (exceeds 4 allowed). Consider refactoring.
            Open

            function log(ctx, start, len, err, event) {
            Severity: Minor
            Found in lib/koaLogger.js - About 35 mins to fix

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

              module.exports.getConnectionT = function (username, password) {
                  return function(callback) {
                      module.exports.getConnection(username, password, callback);
                  };
              };
              Severity: Minor
              Found in lib/managers/imapManager.js and 1 other location - About 35 mins to fix
              lib/managers/imapManager.js on lines 51..55

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

              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

              module.exports.getKeepAliveConnectionT = function (username, password) {
                  return function(callback) {
                      module.exports.getKeepAliveConnection(username, password, callback);
                  };
              };
              Severity: Minor
              Found in lib/managers/imapManager.js and 1 other location - About 35 mins to fix
              lib/managers/imapManager.js on lines 29..33

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

              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