Showing 21 of 27 total issues
Function Owner
has 282 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
function Owner(this: any, options: any) {
const seneca = this
const { deep } = seneca.util
Function checkOwner
has 235 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
const checkOwner: any = function checkOwner(this: any, msg: any, reply: any, meta: any) {
const self = this
const explain = this.explain()
const expdata: any = explain && {
File Owner.ts
has 373 lines of code (exceeds 250 allowed). Consider refactoring. Open
Open
/* Copyright (c) 2018-2020 Voxgig and other contributors, MIT License */
/* $lab:coverage:off$ */
'use strict'
Function refine_query
has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring. Open
Open
export function refine_query(
seneca: any,
msg: any,
queryprop: any,
spec: any,
- 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
Consider simplifying this complex logical expression. Open
Open
if (include.custom) {
let cip, cval, mval
for (cip in include.custom) {
active = active && (
Function refine_query
has 51 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
export function refine_query(
seneca: any,
msg: any,
queryprop: any,
spec: any,
Function refine_query
has 7 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
seneca: any,
msg: any,
queryprop: any,
spec: any,
owner: any,
Avoid deeply nested control flow statements. Open
Open
if (!owner_value.includes(qval)) {
seneca.fail('field-values-not-valid', {
field: fieldName,
entityFieldName,
ownerFieldName,
Avoid deeply nested control flow statements. Open
Open
if (null == msg[queryprop].id) {
explain && ((expdata.query_load = true), (expdata.ent = load_ent))
return intern.reply(self, reply, load_ent, explain, expdata)
}
Avoid deeply nested control flow statements. Open
Open
if (err) return reply(err)
Avoid deeply nested control flow statements. Open
Open
for (let fieldI = 0; fieldI < spec.fields.length; fieldI++) {
const fieldName = spec.fields[fieldI]
const [ownerFieldName, entityFieldName] =
(resolvedFieldNames[fieldName] ||
(resolvedFieldNames[fieldName] =
Avoid deeply nested control flow statements. Open
Open
if (modifiers.entity) {
explain && (expdata.modifiers.entity = true)
spec = modifiers.entity.call(self, spec, owner, msg, load_ent)
explain && (expdata.modifiers.entity_spec = spec)
Avoid deeply nested control flow statements. Open
Open
if (null == load_ent) return reply()
Avoid deeply nested control flow statements. Open
Open
if (null == msg[queryprop].id) {
refine_query(self, msg, queryprop, spec, owner, intern, resolvedFieldNames)
explain && (expdata.query = msg[queryprop])
}
Avoid deeply nested control flow statements. Open
Open
else if ('save' === msg.cmd) {
explain && (expdata.path = 'save')
const ent = msg[entprop]
Consider simplifying this complex logical expression. Open
Open
if (null == ent.id) {
explain && (expdata.path = 'save/create')
for (let fieldI = 0; fieldI < spec.fields.length; fieldI++) {
const fieldName = spec.fields[fieldI]
Function reply
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
reply: function(self: any, reply: any, result: any, explain: any, expdata: any) {
Function prior
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
prior: function(self: any, msg: any, reply: any, explain: any, expdata: any) {
Function fail
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
fail: function(self: any, reply: any, fail: any, explain: any, expdata: any) {
Avoid too many return
statements within this function. Open
Open
return intern.prior(self, msg, reply, explain, expdata)