Showing 32 of 63 total issues
File reports.router.js
has 374 lines of code (exceeds 250 allowed). Consider refactoring. Open
const Router = require('koa-router');
const logger = require('logger');
const ReportsSerializer = require('serializers/reportsSerializer');
const ReportsModel = require('models/reportsModel');
const ReportsValidator = require('validators/reportsValidator');
Function save
has a Cognitive Complexity of 31 (exceeds 5 allowed). Consider refactoring. Open
static* save() {
logger.info('Saving answer');
logger.debug(this.request.body);
const { fields } = this.request.body;
- 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 save
has a Cognitive Complexity of 30 (exceeds 5 allowed). Consider refactoring. Open
static* save() {
logger.info('Saving questionnaire');
logger.debug(this.request.body);
const answer = {
- 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 24 (exceeds 5 allowed). Consider refactoring. Open
static* create(next) {
const request = this.request.body;
logger.debug('Validating body for create template');
this.checkBody('name').notEmpty();
this.checkBody('questions').notEmpty();
- 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 downloadAnswers
has 82 lines of code (exceeds 25 allowed). Consider refactoring. Open
static* downloadAnswers() {
logger.info(`Downloading answers for report ${this.params.id}`);
this.set('Content-disposition', `attachment; filename=${this.params.id}.csv`);
this.set('Content-type', 'text/csv');
this.body = passThrough();
Function init
has 81 lines of code (exceeds 25 allowed). Consider refactoring. Open
async function init() {
return new Promise((resolve, reject) => {
async function onDbReady(err) {
if (err) {
if (retries >= 0) {
Function exports
has 71 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 onDbReady
has 71 lines of code (exceeds 25 allowed). Consider refactoring. Open
async function onDbReady(err) {
if (err) {
if (retries >= 0) {
// eslint-disable-next-line no-plusplus
retries--;
Function save
has 70 lines of code (exceeds 25 allowed). Consider refactoring. Open
static* save() {
logger.info('Saving answer');
logger.debug(this.request.body);
const { fields } = this.request.body;
Function patch
has 70 lines of code (exceeds 25 allowed). Consider refactoring. Open
static* patch() {
logger.info(`Updating template with id ${this.params.id}...`);
const reportFilter = {
$and: [
Function create
has 58 lines of code (exceeds 25 allowed). Consider refactoring. Open
static* create(next) {
const request = this.request.body;
logger.debug('Validating body for create template');
this.checkBody('name').notEmpty();
this.checkBody('questions').notEmpty();
Function patch
has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring. Open
static* patch() {
logger.info(`Updating template with id ${this.params.id}...`);
const reportFilter = {
$and: [
- 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 delete
has 50 lines of code (exceeds 25 allowed). Consider refactoring. Open
static* delete() {
const { role } = this.state.loggedUser;
const aoi = this.state.query && this.state.query.aoi !== null ? this.state.query.aoi.split(',') : null;
logger.info(`Checking report for answers...`);
const answers = yield AnswersModel.count({ report: new ObjectId(this.params.id) });
Function save
has 45 lines of code (exceeds 25 allowed). Consider refactoring. Open
static* save() {
logger.info('Saving questionnaire');
logger.debug(this.request.body);
const answer = {
Function getAllAnswers
has 45 lines of code (exceeds 25 allowed). Consider refactoring. Open
static* getAllAnswers({
reportId, template, loggedUser, team, query
}) {
let filter = {};
let currentManager = false;
Function downloadAnswers
has 43 lines of code (exceeds 25 allowed). Consider refactoring. Open
static* downloadAnswers() {
logger.info(`Download answers of questionnaire ${this.params.id}`);
this.set('Content-disposition', `attachment; filename=${this.params.id}.csv`);
this.set('Content-type', 'text/csv');
this.body = passThrough();
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 downloadAnswers
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
static* downloadAnswers() {
logger.info(`Download answers of questionnaire ${this.params.id}`);
this.set('Content-disposition', `attachment; filename=${this.params.id}.csv`);
this.set('Content-type', 'text/csv');
this.body = passThrough();
- 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 save
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
static* save() {
logger.info('Saving reports', this.request.body);
const request = this.request.body;
if (request.public && this.state.loggedUser.role !== 'ADMIN') {
Function downloadAnswers
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
static* downloadAnswers() {
logger.info(`Downloading answers for report ${this.params.id}`);
this.set('Content-disposition', `attachment; filename=${this.params.id}.csv`);
this.set('Content-type', 'text/csv');
this.body = passThrough();
- 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"