Showing 54 of 94 total issues
Function _getPathOperationObject
has 136 lines of code (exceeds 25 allowed). Consider refactoring. Open
swaggerPaths._getPathOperationObject = options => {
const pathDefinition = {
tags: [ options.resourceName ],
description: options.description,
parameters: [ ],
Function _getResourceDefinition
has a Cognitive Complexity of 31 (exceeds 5 allowed). Consider refactoring. Open
swaggerPaths._getResourceDefinition = resourceConfig => {
if (Object.keys(resourceConfig.handlers || { }).length === 0) return undefined
const resourceDefinition = {
description: resourceConfig.description,
- 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 _arrayToTree
has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring. Open
includePP._arrayToTree = (request, includes, filters, callback) => {
const validationErrors = [ ]
const tree = {
_dataItems: null,
_resourceConfig: [ ].concat(request.resourceConfig)
- 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 _getResourceDefinition
has 106 lines of code (exceeds 25 allowed). Consider refactoring. Open
swaggerPaths._getResourceDefinition = resourceConfig => {
if (Object.keys(resourceConfig.handlers || { }).length === 0) return undefined
const resourceDefinition = {
description: resourceConfig.description,
Function _getPathOperationObject
has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring. Open
swaggerPaths._getPathOperationObject = options => {
const pathDefinition = {
tags: [ options.resourceName ],
description: options.description,
parameters: [ ],
- 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 paths.js
has 308 lines of code (exceeds 250 allowed). Consider refactoring. Open
'use strict'
const swaggerPaths = module.exports = { }
const jsonApi = require('../../')
const _ = {
uniq: require('lodash.uniq')
Function register
has 81 lines of code (exceeds 25 allowed). Consider refactoring. Open
removeRelationRoute.register = () => {
router.bindRoute({
verb: 'delete',
path: ':type/:id/relationships/:relation'
}, (request, resourceConfig, res) => {
Function _getSwaggerBase
has 80 lines of code (exceeds 25 allowed). Consider refactoring. Open
swagger._getSwaggerBase = () => {
const swaggerConfig = jsonApi._apiConfig.swagger || { }
let basePath, host, protocol
if (jsonApi._apiConfig.urlPrefixAlias) {
const urlObj = url.parse(jsonApi._apiConfig.urlPrefixAlias)
Function _fillIncludeTree
has 78 lines of code (exceeds 25 allowed). Consider refactoring. Open
includePP._fillIncludeTree = (includeTree, request, callback) => {
/** **
includeTree = {
_dataItems: [ ],
_filter: { },
Function register
has 61 lines of code (exceeds 25 allowed). Consider refactoring. Open
foreignKeySearchRoute.register = () => {
router.bindRoute({
verb: 'get',
path: ':type/relationships/?'
}, (request, resourceConfig, res) => {
Function register
has 59 lines of code (exceeds 25 allowed). Consider refactoring. Open
createRoute.register = () => {
router.bindRoute({
verb: 'post',
path: ':type'
}, (request, resourceConfig, res) => {
Function register
has 58 lines of code (exceeds 25 allowed). Consider refactoring. Open
relatedRoute.register = () => {
router.bindRoute({
verb: 'get',
path: ':type/:id/:relation'
}, (request, resourceConfig, res) => {
Function _arrayToTree
has 55 lines of code (exceeds 25 allowed). Consider refactoring. Open
includePP._arrayToTree = (request, includes, filters, callback) => {
const validationErrors = [ ]
const tree = {
_dataItems: null,
_resourceConfig: [ ].concat(request.resourceConfig)
Function _addDeepPaths
has 54 lines of code (exceeds 25 allowed). Consider refactoring. Open
swaggerPaths._addDeepPaths = (paths, resourceName, resourceConfig, relationName, relation) => {
const relationType = resourceConfig.attributes[relationName]._settings.__many ? 'many' : 'one'
if (resourceConfig.handlers.find) {
paths[`/${resourceName}/{id}/${relationName}`] = {
Function register
has 54 lines of code (exceeds 25 allowed). Consider refactoring. Open
updateRoute.register = () => {
router.bindRoute({
verb: 'patch',
path: ':type/:id'
}, (request, resourceConfig, res) => {
Function register
has 54 lines of code (exceeds 25 allowed). Consider refactoring. Open
addRelationRoute.register = () => {
router.bindRoute({
verb: 'post',
path: ':type/:id/relationships/:relation'
}, (request, resourceConfig, res) => {
Function _generateLink
has 51 lines of code (exceeds 25 allowed). Consider refactoring. Open
responseHelper._generateLink = (item, schemaProperty, linkProperty) => {
const link = {
meta: {
relation: 'primary',
// type: schemaProperty._settings.__many || schemaProperty._settings.__one,
Function register
has 50 lines of code (exceeds 25 allowed). Consider refactoring. Open
updateRelationRoute.register = () => {
router.bindRoute({
verb: 'patch',
path: ':type/:id/relationships/:relation'
}, (request, resourceConfig, res) => {
Function register
has 50 lines of code (exceeds 25 allowed). Consider refactoring. Open
relationshipsRoute.register = () => {
router.bindRoute({
verb: 'get',
path: ':type/:id/relationships/:relation'
}, (request, resourceConfig, res) => {
Function _filterKeepObject
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
filter._filterKeepObject = (someObject, filters) => {
for (const filterName in filters) {
const whitelist = filters[filterName]
if (someObject.attributes.hasOwnProperty(filterName) || (filterName === 'id')) {
- 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"