Showing 23 of 46 total issues
File app.js
has 347 lines of code (exceeds 250 allowed). Consider refactoring. Open
import express from 'express';
import debug from 'debug';
import http from 'http';
import isArray from 'lodash/isArray';
File user.js
has 328 lines of code (exceeds 250 allowed). Consider refactoring. Open
import jwt from 'jsonwebtoken';
import bcrypt from 'bcryptjs';
import { genNameUID } from './provider';
import permalink from 'mongoose-permalink';
import mongooseHRBAC from 'mongoose-hrbac';
Function createSchema
has 71 lines of code (exceeds 25 allowed). Consider refactoring. Open
export function createSchema(Schema) {
// add properties to schema
const schema = new Schema({
firstName: { type: String },
lastName: { type: String },
App
has 21 functions (exceeds 20 allowed). Consider refactoring. Open
export default class App {
constructor(server, options = {}) {
if (!options.root) {
throw new Error('Root is undefined');
}
Function updateUserByFacebookProfile
has 46 lines of code (exceeds 25 allowed). Consider refactoring. Open
function updateUserByFacebookProfile(user, profile, callback) {
let changed = false;
if (!user.firstName && profile.first_name) {
user.firstName = profile.first_name;
Function forgot
has 42 lines of code (exceeds 25 allowed). Consider refactoring. Open
export function forgot(req, res, next) {
const User = req.models.User;
const server = req.server;
const options = server.options;
const mail = server.mail;
Function createSchema
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
export function createSchema(Schema) {
// add properties to schema
const schema = new Schema({
firstName: { type: String },
lastName: { type: String },
- 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 _prepareSession
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
_prepareSession() {
const app = this.expressApp;
const options = this.options;
if (!options.session) {
- 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 _prepareStatic
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
_prepareStatic() {
const app = this.expressApp;
const options = this.options;
if (options.flash) {
- 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 ensureBySignedRequest
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
export function ensureBySignedRequest(req, res, next) {
if (!req.body.signedRequest || !req.body.profile) {
return next(new WebError(400));
}
Function _prepareStatic
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
_prepareStatic() {
const app = this.expressApp;
const options = this.options;
if (options.flash) {
Function close
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
close(callback) {
const { activeConnections, httpServer, options } = this;
if (!httpServer) {
return callback(new Error('You need to listen first'));
Function error
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
export function error(err, req, res, next) {
const server = req.server;
const options = server.options;
log(err);
Function handleConnectionEvents
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
handleConnectionEvents() {
// TODO UNHANDLE
const { activeConnections, httpServer } = this;
httpServer.on('connection', function onConnectionCallback(connection) {
Function _prepareSession
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
_prepareSession() {
const app = this.expressApp;
const options = this.options;
if (!options.session) {
Function closeGracefully
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
closeGracefully() {
log('Received kill signal (SIGTERM), shutting down gracefully.');
if (!this._listening) {
log('Ended without any problem');
process.exit(0);
Function _prepareHtml
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
_prepareHtml() {
const app = this.expressApp;
const options = this.options;
if (!options.powered) {
Function _prepareHtml
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
_prepareHtml() {
const app = this.expressApp;
const options = this.options;
if (!options.powered) {
- 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 handleConnectionEvents
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
handleConnectionEvents() {
// TODO UNHANDLE
const { activeConnections, httpServer } = this;
httpServer.on('connection', function onConnectionCallback(connection) {
- 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 ensureBySignedRequest
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
export function ensureBySignedRequest(req, res, next) {
if (!req.body.signedRequest || !req.body.profile) {
return next(new WebError(400));
}
- 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"