SylowTech/sylow

View on GitHub

Showing 19 of 148 total issues

File admin.test.js has 492 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import request from 'supertest-as-promised';
import cheerio from 'cheerio';
import httpStatus from 'http-status';
import chai, { expect } from 'chai';

Severity: Minor
Found in tests/admin.test.js - About 7 hrs to fix

    File auth.test.js has 385 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    import request from 'supertest-as-promised';
    import httpStatus from 'http-status';
    import cheerio from 'cheerio';
    import chai, { expect } from 'chai';
    
    
    Severity: Minor
    Found in tests/auth.test.js - About 5 hrs to fix

      File document.test.js has 290 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      import request from 'supertest-as-promised';
      import httpStatus from 'http-status';
      import chai, { expect } from 'chai';
      import uuidV4 from 'uuid/v4';
      
      
      Severity: Minor
      Found in tests/document.test.js - About 2 hrs to fix

        File admin.controller.js has 281 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        import httpStatus from 'http-status';
        import fs from 'fs';
        import path from 'path';
        import decamelize from 'decamelize';
        
        
        Severity: Minor
        Found in server/controllers/admin.controller.js - About 2 hrs to fix

          Consider simplifying this complex logical expression.
          Open

              if (doc.id && doc.deleted) {
                docPromise = Document.findOneAndRemove({ _id: docId, entityId: entity._id })
                  .then(deletedDoc => ({ id: deletedDoc._id, deleted: true }));
              } else {
                docPromise = Document.findOneAndUpdate({
          Severity: Critical
          Found in server/controllers/document.controller.js - About 2 hrs to fix

            Function getActions has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
            Open

            function getActions(req, res, next) {
              const filter = {};
              const finder = {};
              const query = req.query;
              filter.contentType = query.contentType;
            Severity: Minor
            Found in server/controllers/document.controller.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 newServer has 51 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              newServer: function (domain, options) {
                utils.mongooseConnect();
                const validOptions = ['name', 'description'];
                if (!domain) {
                  console.error('Domain missing');
            Severity: Major
            Found in cli/server.js - About 2 hrs to fix

              Function getActions has 47 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              function getActions(req, res, next) {
                const filter = {};
                const finder = {};
                const query = req.query;
                filter.contentType = query.contentType;
              Severity: Minor
              Found in server/controllers/document.controller.js - About 1 hr to fix

                Function init has 46 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                  init() {
                    let formSubmit;
                    let formValidate;
                
                    if ($('#register-form').length) {
                Severity: Minor
                Found in admin/controllers/entity.controller.js - About 1 hr to fix

                  Function create has 43 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                  function create(req, res, next) {
                    let newDocuments = req.body;
                    const entity = req.user.entity;
                    const docPromises = [];
                  
                  
                  Severity: Minor
                  Found in server/controllers/document.controller.js - About 1 hr to fix

                    Function newEntity has 39 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                    module.exports = function newEntity(username, domain, admin) {
                      utils.mongooseConnect();
                    
                      if (!username) {
                        console.error('Name missing');
                    Severity: Minor
                    Found in cli/new-entity.js - About 1 hr to fix

                      Function editServer has 32 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                        editServer: function (options) {
                          utils.mongooseConnect();
                          const validOptions = ['name', 'domain'];
                      
                          const finalDatas = {};
                      Severity: Minor
                      Found in cli/server.js - About 1 hr to fix

                        Function create has 32 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                        function create(req, res, next) {
                          if (!config.allowSignups && req.body.authoritative) {
                            const err = new APIError('New signups not allowed', httpStatus.BAD_REQUEST, true);
                            return next(err);
                          }
                        Severity: Minor
                        Found in server/controllers/entity.controller.js - About 1 hr to fix

                          Function beforeTest has 31 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                          function beforeTest() {
                            let client;
                            let adminEntity;
                            let nonAdminEntity;
                            let adminAccessToken;
                          Severity: Minor
                          Found in server/helpers/Pretest.js - About 1 hr to fix

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

                            export function updateSettings(req, res) {
                              const envFile = path.join(__dirname, '../../.env');
                              const inputDatas = req.body;
                            
                              inputDatas.schemaDomainWhitelist = inputDatas.schemaDomainWhitelist.filter(n => n !== '');
                            Severity: Minor
                            Found in server/controllers/admin.controller.js - About 1 hr to fix

                              Function grantAuthorizationCode has 5 arguments (exceeds 4 allowed). Consider refactoring.
                              Open

                              export function grantAuthorizationCode(client, redirectUri, entity, ares, done) {
                              Severity: Minor
                              Found in server/helpers/OAuth.js - About 35 mins to fix

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

                                function getNewConfig(datas, settableConfig) {
                                  const lines = datas.split('\n');
                                  const newConfig = [];
                                
                                  for (let i = 0; i < lines.length; i += 1) {
                                Severity: Minor
                                Found in server/controllers/admin.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 create has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                                Open

                                function create(req, res, next) {
                                  if (!config.allowSignups && req.body.authoritative) {
                                    const err = new APIError('New signups not allowed', httpStatus.BAD_REQUEST, true);
                                    return next(err);
                                  }
                                Severity: Minor
                                Found in server/controllers/entity.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 editServer has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                                Open

                                  editServer: function (options) {
                                    utils.mongooseConnect();
                                    const validOptions = ['name', 'domain'];
                                
                                    const finalDatas = {};
                                Severity: Minor
                                Found in cli/server.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