Showing 18 of 35 total issues
Function exports
has 81 lines of code (exceeds 25 allowed). Consider refactoring. Open
module.exports = (grunt) => {
grunt.file.setBase('..');
// eslint-disable-next-line import/no-extraneous-dependencies
require('load-grunt-tasks')(grunt);
Function init
has 72 lines of code (exceeds 25 allowed). Consider refactoring. Open
const init = async () => {
return new Promise((resolve, reject) => {
async function onDbReady(err) {
if (err) {
if (retries >= 0) {
Function onDbReady
has 66 lines of code (exceeds 25 allowed). Consider refactoring. Open
async function onDbReady(err) {
if (err) {
if (retries >= 0) {
retries--;
logger.error(`Failed to connect to MongoDB uri ${mongoUri}, retrying...`);
Function authorizationMiddleware
has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring. Open
const authorizationMiddleware = async (ctx, next) => {
// Get user from query (delete) or body (post-patch)
const user = { ...(ctx.request.query.loggedUser ? JSON.parse(ctx.request.query.loggedUser) : {}), ...ctx.request.body.loggedUser };
if (user.id === 'microservice') {
await next();
- 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 exports
has 42 lines of code (exceeds 25 allowed). Consider refactoring. Open
module.exports = (() => {
const loadAPI = (app, path, pathApi) => {
const routesFiles = fs.readdirSync(path);
let existIndexRouter = false;
Function validate
has 38 lines of code (exceeds 25 allowed). Consider refactoring. Open
static validate(koaObj) {
logger.info('Validating Metadata Creation');
koaObj.checkBody('language').notEmpty().check((lang) => MetadataValidator.isString(lang)).toLow();
koaObj.checkBody('application').notEmpty().check((application) => MetadataValidator.notEmptyString(application));
koaObj.checkBody('name').optional().check((name) => MetadataValidator.isString(name), 'should be a valid string');
Function serialize
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
static serialize(data) {
const result = {
data: []
};
Function authorizationMiddleware
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
const authorizationMiddleware = async (ctx, next) => {
// Get user from query (delete) or body (post-patch)
const user = { ...(ctx.request.query.loggedUser ? JSON.parse(ctx.request.query.loggedUser) : {}), ...ctx.request.body.loggedUser };
if (user.id === 'microservice') {
await next();
Function loadAPI
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
const loadAPI = (app, path, pathApi) => {
const routesFiles = fs.readdirSync(path);
let existIndexRouter = false;
routesFiles.forEach((file) => {
const newPath = path ? (`${path}/${file}`) : file;
Function getAll
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
static async getAll(filter, extendedFilter) {
const finalFilter = MetadataService.getFilter(filter);
let projection = null;
const options = {};
if (filter.sort) {
Function create
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
static async create(user, dataset, resource, body) {
logger.debug('Checking if metadata exists');
const currentMetadata = await Metadata.findOne({
dataset,
'resource.id': resource.id,
Function update
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
static async update(dataset, resource, body) {
const metadata = await Metadata.findOne({
dataset,
'resource.id': resource.id,
'resource.type': resource.type,
- 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 getAll
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
static async getAll(ctx) {
logger.info('Getting all metadata');
const filter = {};
const extendedFilter = {};
filter.search = ctx.query.search ? ctx.query.search.split(' ').map((elem) => elem.trim()) : [];
- 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 init
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
const init = async () => {
return new Promise((resolve, reject) => {
async function onDbReady(err) {
if (err) {
if (retries >= 0) {
- 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 exports
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
module.exports = (() => {
const loadAPI = (app, path, pathApi) => {
const routesFiles = fs.readdirSync(path);
let existIndexRouter = false;
- 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 getFilter
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
static getFilter(filter) {
let finalFilter = {};
if (filter && filter.application) {
finalFilter.application = { $in: filter.application.split(',') };
}
- 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
Avoid too many return
statements within this function. Open
return;
Avoid too many return
statements within this function. Open
return;