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';
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';
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';
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';
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({
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;
- Read upRead up
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');
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;
Function init
has 46 lines of code (exceeds 25 allowed). Consider refactoring. Open
init() {
let formSubmit;
let formValidate;
if ($('#register-form').length) {
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 = [];
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');
Function editServer
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
editServer: function (options) {
utils.mongooseConnect();
const validOptions = ['name', 'domain'];
const finalDatas = {};
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);
}
Function beforeTest
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
function beforeTest() {
let client;
let adminEntity;
let nonAdminEntity;
let adminAccessToken;
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 !== '');
Function grantAuthorizationCode
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
export function grantAuthorizationCode(client, redirectUri, entity, ares, done) {
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) {
- Read upRead up
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);
}
- Read upRead up
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 = {};
- Read upRead up
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"