Showing 33 of 119 total issues
File user.js
has 787 lines of code (exceeds 250 allowed). Consider refactoring. Open
var express = require('express');
var router = express.Router();
var FB = require('facebook-node');
var Twitter = require('twitter');
var async = require('async');
Function objectACL
has a Cognitive Complexity of 33 (exceeds 5 allowed). Consider refactoring. Open
security.objectACL = function (accessControl) {
return function(req, res, next) {
if (!req.body || !Object.getOwnPropertyNames(req.body).length) {
return next(new Models.TelepatError(Models.TelepatError.errors.RequestBodyEmpty));
}
- 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
File object.js
has 369 lines of code (exceeds 250 allowed). Consider refactoring. Open
var express = require('express');
var router = express.Router();
var Models = require('telepat-models');
var security = require('./security');
var microtime = require('microtime-nodejs');
File app.js
has 294 lines of code (exceeds 250 allowed). Consider refactoring. Open
var express = require('express');
var bodyParser = require('body-parser');
var http = require('http');
var https = require('https');
var urlParser = require('url');
Function linkMiddlewaresAndRoutes
has 76 lines of code (exceeds 25 allowed). Consider refactoring. Open
var linkMiddlewaresAndRoutes = function(callback) {
app.use('/proxy', security.applicationIdValidation);
app.use('/proxy', security.apiKeyValidation);
/**
Function linkMiddlewaresAndRoutes
has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring. Open
var linkMiddlewaresAndRoutes = function(callback) {
app.use('/proxy', security.applicationIdValidation);
app.use('/proxy', security.apiKeyValidation);
/**
- 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 objectACL
has 48 lines of code (exceeds 25 allowed). Consider refactoring. Open
security.objectACL = function (accessControl) {
return function(req, res, next) {
if (!req.body || !Object.getOwnPropertyNames(req.body).length) {
return next(new Models.TelepatError(Models.TelepatError.errors.RequestBodyEmpty));
}
Function sendEmail
has 41 lines of code (exceeds 25 allowed). Consider refactoring. Open
function sendEmail(provider, from, to, subject, content) {
var emailService = Object.keys(provider)[0];
var apiKey = provider[emailService];
if (emailService == 'mandrill') {
Function unless
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
var unless = function(paths, middleware) {
return function(req, res, next) {
var excluded = false;
for (var i=0; i<paths.length; i++) {
if (paths[i] === req.path) {
- 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 deeply nested control flow statements. Open
} else if (err)
return next(err);
Avoid deeply nested control flow statements. Open
if (!err) {
return res.status(200).json({status: 200, content: {identifier: req.body.id}});
}
Function addAuthorFilters
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
function addAuthorFilters(channelObject, appSchema, mdl, userId) {
if (channelObject.filter) {
if (!channelObject.filter.and && !channelObject.filter.or) {
channelObject.filter.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 sendEmail
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
function sendEmail(provider, from, to, subject, content) {
Avoid too many return
statements within this function. Open
return next(new Models.TelepatError(Models.TelepatError.errors.InvalidLoginProvider, ['facebook, twitter, username']));
Avoid too many return
statements within this function. Open
return next(new Models.TelepatError(Models.TelepatError.errors.OperationNotAllowed));
Avoid too many return
statements within this function. Open
return next(new Models.TelepatError(Models.TelepatError.errors.ServerNotConfigured,
['twitter login provider']));
Avoid too many return
statements within this function. Open
return next(new Models.TelepatError(Models.TelepatError.errors.InvalidLoginProvider, ['facebook, twitter']));
Avoid too many return
statements within this function. Open
return next(new Models.TelepatError(Models.TelepatError.errors.MissingRequiredField, ['password']));
Avoid too many return
statements within this function. Open
return next(new Models.TelepatError(Models.TelepatError.errors.MissingRequiredField, [hasSomeProperty]));
Avoid too many return
statements within this function. Open
return next(new Models.TelepatError(Models.TelepatError.errors.OperationNotAllowed));