erizo-fr/erizo-mail-server

View on GitHub

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

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

    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

            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
              Severity
              Category
              Status
              Source
              Language