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';
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 _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 _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 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 _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 prepareRequest
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
function prepareRequest(req) {
req.__defineGetter__('httpHost', function getHttpHost() {
const trustProxy = this.app.get('trust proxy');
const host = trustProxy && this.get('X-Forwarded-Host');
- 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"