linagora/openpaas-esn

View on GitHub

Showing 726 of 2,177 total issues

Avoid too many return statements within this function.
Open

      if (typeof value.key !== 'string') { return false; }
Severity: Major
Found in backend/core/db/mongo/schemas/injection.js - About 30 mins to fix

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

    module.exports = dependencies => {
      const esnConfig = dependencies('esn-config'),
            autoconf = require('../../lib/autoconf')(dependencies);
    
      return {
    Severity: Minor
    Found in modules/linagora.esn.autoconf/backend/webserver/autoconf/controller.js - About 25 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 6 (exceeds 5 allowed). Consider refactoring.
    Open

    module.exports = function(dependencies) {
    
      var googleContactToVcard = require('./mapping')(dependencies);
      var importContactClient = dependencies('contact-import').lib.import;
      var CONTACT_IMPORT_ERROR = dependencies('contact-import').constants.CONTACT_IMPORT_ERROR;
    Severity: Minor
    Found in modules/linagora.esn.contact.import.google/backend/lib/importer.js - About 25 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 6 (exceeds 5 allowed). Consider refactoring.
    Open

    module.exports = dependencies => {
      const { constants } = dependencies('esn-config');
      const pubsub = dependencies('pubsub').global;
      const logger = dependencies('logger');
      const {
    Severity: Minor
    Found in modules/linagora.esn.contact/backend/lib/domain-members/index.js - About 25 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 container has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

    GruntfileUtils.prototype.container = function container() {
      var grunt = this.grunt;
    
      function newContainer(createContainerOptions, startContainerOptions, removeContainerOptions, taskOptions) {
        taskOptions = extend({ async: false }, taskOptions);
    Severity: Minor
    Found in tasks/utils/Gruntfile-utils.js - About 25 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 rawClient has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

    function rawClient(options, callback) {
    
      if (!options) {
        return callback(new Error('Options is required'));
      }
    Severity: Minor
    Found in modules/linagora.esn.contact/backend/lib/dav-client.js - About 25 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 updateTracker has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

    function updateTracker(req, timelineEntriesReadable) {
      if (req && req.user && !req.query.before && timelineEntriesReadable && timelineEntriesReadable[0]) {
        // When req.query.after, the last timeline entry is the last element in the result array
        if (req.query.after && timelineEntriesReadable[timelineEntriesReadable.length - 1]) {
          tracker.updateLastTimelineEntry(req.user._id, req.activity_stream._id, timelineEntriesReadable[timelineEntriesReadable.length - 1]._id, function() {});
    Severity: Minor
    Found in backend/webserver/controllers/activitystreams.js - About 25 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 create has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

    function create(req, res) {
      const size = parseInt(req.query.size, 10);
    
      if (isNaN(size) || size < 1) {
        return res.status(400).json({ error: { code: 400, message: 'Bad Parameter', details: 'size parameter should be a positive integer' }});
    Severity: Minor
    Found in backend/webserver/controllers/files.js - About 25 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 addMembershipRequest has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

    function addMembershipRequest(req, res) {
      const collaboration = req.collaboration;
      const userAuthor = req.user;
      const userTargetId = req.params.user_id;
      const objectType = req.params.objectType;
    Severity: Minor
    Found in backend/webserver/controllers/collaborations.js - About 25 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 flagCollaborationManager has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

    function flagCollaborationManager(req, res, next) {
      if (!req.collaboration) {
        return res.status(400).json({error: 400, message: 'Bad request', details: 'Missing collaboration'});
      }
    
    
    Severity: Minor
    Found in backend/webserver/middleware/collaboration.js - About 25 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 profileToUser has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

    module.exports.profileToUser = function(profile, user) {
      user = user || {};
      user.firstname = profile.displayName || profile.username;
      user.description = profile._json.description ? profile._json.description : '';
      user.building_location = profile._json.location ? profile._json.location : '';
    Severity: Minor
    Found in modules/linagora.esn.login.oauth/backend/lib/provision/twitter.js - About 25 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 6 (exceeds 5 allowed). Consider refactoring.
    Open

    module.exports = application => {
      passport.serializeUser((user, done) => {
        if (user && user.emails && user.emails.length && user.emails[0]) {
          return done(null, user.emails[0].value || user.emails[0]);
        }
    Severity: Minor
    Found in backend/webserver/passport.js - About 25 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 requireDomainInfo has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

    function requireDomainInfo(req, res, next) {
      let details;
    
      if (!req.body.name) {
        details = 'Domain does not have name';
    Severity: Minor
    Found in backend/webserver/middleware/domain.js - About 25 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 create has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

    function create(req, res) {
      if (!req.user || !req.user.emails || !req.user.emails.length) {
        return res.status(500).json({ error: { status: 500, message: 'Server Error', details: 'User is not set.'}});
      }
    
    
    Severity: Minor
    Found in backend/webserver/controllers/messages.js - About 25 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 canWriteAdminConfig has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

    function canWriteAdminConfig(req, res, next) {
      const modules = req.body;
    
      const hasUnwritableConfig = modules.some(module => {
        if (!module || !Array.isArray(module.configurations)) {
    Severity: Minor
    Found in backend/webserver/middleware/configuration.js - About 25 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 canWritePlatformConfig has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

    function canWritePlatformConfig(req, res, next) {
      const modules = req.body;
    
      const hasUnwritableConfig = modules.some(module => {
        if (!module || !Array.isArray(module.configurations)) {
    Severity: Minor
    Found in backend/webserver/middleware/configuration.js - About 25 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 6 (exceeds 5 allowed). Consider refactoring.
    Open

    module.exports = () => {
      if (!platformAdminUsername) {
        logger.debug('PlatformAdmin.init - No username set, skipping');
    
        return Promise.resolve(false);
    Severity: Minor
    Found in backend/core/platformadmin/init.js - About 25 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 copy has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

    function copy(id, sharerId, resource, target, callback) {
    
      function getOriginal(callback) {
        mongoose.connection.db.collection(CONSTANTS.MESSAGES_COLLECTION, function(err, collection) {
          var query = {
    Severity: Minor
    Found in backend/core/message/index.js - About 25 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 get has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

    function get(config) {
      let transport;
    
      if (!config) {
        return Promise.reject(new Error('Mail configuration is required'));
    Severity: Minor
    Found in backend/core/email/mail-transport.js - About 25 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 mongooseConnect has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

    function mongooseConnect(reinit) {
      if (defaultConfig.db && defaultConfig.db.reconnectOnConfigurationChange) {
        if (!dbConfigWatcher) {
          dbConfigWatcher = configurationWatcher(logger, getDbConfigurationFile(), reinit);
        }
    Severity: Minor
    Found in backend/core/db/mongo/index.js - About 25 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