Showing 25 of 40 total issues
Function createSpecificityComparator
has a Cognitive Complexity of 106 (exceeds 5 allowed). Consider refactoring. Open
createSpecificityComparator: function(options) {
const self = this
options = options || {}
// Ascending order flag, defaults to false
let asc = 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 registerRoutes
has 75 lines of code (exceeds 25 allowed). Consider refactoring. Open
registerRoutes(app, server) {
// Sort the routes so that they are always in the correct express order.
const routes = app.routes.sort(utils.createSpecificityComparator({ order: 'asc' }))
const express = app.config.get('web.express')
const expressRouter = express.Router
Function registerMiddlewares
has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring. Open
registerMiddlewares(app, server) {
server.use(expressBoom())
if (this.cors) {
server.use(cors(this.cors === true ? {} : this.cors))
}
- 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 createSpecificityComparator
has 58 lines of code (exceeds 25 allowed). Consider refactoring. Open
createSpecificityComparator: function(options) {
const self = this
options = options || {}
// Ascending order flag, defaults to false
let asc = false
Function registerViews
has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring. Open
registerViews(app, server) {
const viewEngine = app.config.get('views.engine') || null
const viewEngines = app.config.get('web.views')
if (!viewEngine && !viewEngines) {
- 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 createServer
has 54 lines of code (exceeds 25 allowed). Consider refactoring. Open
createServer(app) {
const main = app.config.get('main')
const sess = app.config.get('session')
const express = app.config.get('web.express')
File server.js
has 254 lines of code (exceeds 250 allowed). Consider refactoring. Open
/* eslint no-console: [0] */
'use strict'
const _ = require('lodash')
const path = require('path')
Function specificityComparator
has 49 lines of code (exceeds 25 allowed). Consider refactoring. Open
return function specificityComparator(routeA, routeB) {
routeA = (routeA.path || '').toLowerCase()
routeB = (routeB.path || '').toLowerCase()
// If it's the default route, push it all the way
// over to one of the ends
Function createResponse
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
createResponse: function(req, res, next) {
const response = (data) => {
return new Promise((resolve, reject) => {
if (!data) {
Function findAssociation
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
findAssociation(req, res) {
const FootprintService = this.app.services.FootprintService
const options = this.app.packs.express.getOptionsFromQuery(req.query)
const criteria = this.app.packs.express.getCriteriaFromQuery(req.query)
const parentModel = req.params.parentModel
Function destroyAssociation
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
destroyAssociation(req, res) {
const FootprintService = this.app.services.FootprintService
const options = this.app.packs.express.getOptionsFromQuery(req.query)
const criteria = this.app.packs.express.getCriteriaFromQuery(req.query)
const parentModel = req.params.parentModel
Function updateAssociation
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
updateAssociation(req, res) {
const FootprintService = this.app.services.FootprintService
const options = this.app.packs.express.getOptionsFromQuery(req.query)
const criteria = this.app.packs.express.getCriteriaFromQuery(req.query)
const parentModel = req.params.parentModel
Function createResponse
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
createResponse: function(req, res, next) {
const response = (data) => {
return new Promise((resolve, reject) => {
if (!data) {
- 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 update
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
update(req, res) {
const FootprintService = this.app.services.FootprintService
const options = this.app.packs.express.getOptionsFromQuery(req.query)
const criteria = this.app.packs.express.getCriteriaFromQuery(req.query)
const id = req.params.id
Function registerMiddlewares
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
registerMiddlewares(app, server) {
server.use(expressBoom())
if (this.cors) {
server.use(cors(this.cors === true ? {} : this.cors))
}
Avoid deeply nested control flow statements. Open
if (joinedA > joinedB) {
return asc ? 1 : -1
}
Avoid deeply nested control flow statements. Open
if (joinedA < joinedB) {
return asc ? -1 : 1
}
Function createServer
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
createServer(app) {
const main = app.config.get('main')
const sess = app.config.get('session')
const express = app.config.get('web.express')
- 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 asc ? 1 : -1
Avoid too many return
statements within this function. Open
return asc ? -1 : 1