voxgig/seneca-owner

View on GitHub

Showing 21 of 27 total issues

Function Owner has 282 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function Owner(this: any, options: any) {
  const seneca = this

  const { deep } = seneca.util

Severity: Major
Found in src/Owner.ts - About 1 day to fix

    Function checkOwner has 235 lines of code (exceeds 25 allowed). Consider refactoring.
    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 && {
    Severity: Major
    Found in src/Owner.ts - About 1 day to fix

      File Owner.ts has 373 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      /* Copyright (c) 2018-2020 Voxgig and other contributors, MIT License */
      /* $lab:coverage:off$ */
      'use strict'
      
      
      
      Severity: Minor
      Found in src/Owner.ts - About 4 hrs to fix

        Function refine_query has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring.
        Open

        export function refine_query(
          seneca: any,
          msg: any,
          queryprop: any,
          spec: any,
        Severity: Minor
        Found in src/refine_query.ts - About 4 hrs to fix

        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

                if (include.custom) {
                  let cip, cval, mval
                  for (cip in include.custom) {
                    active = active && (
        
        
        Severity: Critical
        Found in src/Owner.ts - About 3 hrs to fix

          Function refine_query has 51 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          export function refine_query(
            seneca: any,
            msg: any,
            queryprop: any,
            spec: any,
          Severity: Major
          Found in src/refine_query.ts - About 2 hrs to fix

            Function refine_query has 7 arguments (exceeds 4 allowed). Consider refactoring.
            Open

              seneca: any,
              msg: any,
              queryprop: any,
              spec: any,
              owner: any,
            Severity: Major
            Found in src/refine_query.ts - About 50 mins to fix

              Avoid deeply nested control flow statements.
              Open

                          for (let fieldI = 0; fieldI < spec.fields.length; fieldI++) {
                            const fieldName = spec.fields[fieldI]
                            const [ownerFieldName, entityFieldName] =
                              (resolvedFieldNames[fieldName] ||
                                (resolvedFieldNames[fieldName] =
              Severity: Major
              Found in src/Owner.ts - About 45 mins to fix

                Avoid deeply nested control flow statements.
                Open

                            if (null == msg[queryprop].id) {
                              explain && ((expdata.query_load = true), (expdata.ent = load_ent))
                
                              return intern.reply(self, reply, load_ent, explain, expdata)
                            }
                Severity: Major
                Found in src/Owner.ts - About 45 mins to fix

                  Avoid deeply nested control flow statements.
                  Open

                            if (!owner_value.includes(qval)) {
                              seneca.fail('field-values-not-valid', {
                                field: fieldName,
                                entityFieldName,
                                ownerFieldName,
                  Severity: Major
                  Found in src/refine_query.ts - About 45 mins to fix

                    Avoid deeply nested control flow statements.
                    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)
                    Severity: Major
                    Found in src/Owner.ts - About 45 mins to fix

                      Avoid deeply nested control flow statements.
                      Open

                                  if (err) return reply(err)
                      Severity: Major
                      Found in src/Owner.ts - About 45 mins to fix

                        Avoid deeply nested control flow statements.
                        Open

                                  if (null == msg[queryprop].id) {
                                    refine_query(self, msg, queryprop, spec, owner, intern, resolvedFieldNames)
                                    explain && (expdata.query = msg[queryprop])
                                  }
                        Severity: Major
                        Found in src/Owner.ts - About 45 mins to fix

                          Avoid deeply nested control flow statements.
                          Open

                                  else if ('save' === msg.cmd) {
                                    explain && (expdata.path = 'save')
                          
                                    const ent = msg[entprop]
                          
                          
                          Severity: Major
                          Found in src/Owner.ts - About 45 mins to fix

                            Avoid deeply nested control flow statements.
                            Open

                                        if (null == load_ent) return reply()
                            Severity: Major
                            Found in src/Owner.ts - About 45 mins to fix

                              Consider simplifying this complex logical expression.
                              Open

                                        if (null == ent.id) {
                                          explain && (expdata.path = 'save/create')
                              
                                          for (let fieldI = 0; fieldI < spec.fields.length; fieldI++) {
                                            const fieldName = spec.fields[fieldI]
                              Severity: Major
                              Found in src/Owner.ts - About 40 mins to fix

                                Function reply has 5 arguments (exceeds 4 allowed). Consider refactoring.
                                Open

                                  reply: function(self: any, reply: any, result: any, explain: any, expdata: any) {
                                Severity: Minor
                                Found in src/Owner.ts - About 35 mins to fix

                                  Function fail has 5 arguments (exceeds 4 allowed). Consider refactoring.
                                  Open

                                    fail: function(self: any, reply: any, fail: any, explain: any, expdata: any) {
                                  Severity: Minor
                                  Found in src/Owner.ts - About 35 mins to fix

                                    Function prior has 5 arguments (exceeds 4 allowed). Consider refactoring.
                                    Open

                                      prior: function(self: any, msg: any, reply: any, explain: any, expdata: any) {
                                    Severity: Minor
                                    Found in src/Owner.ts - About 35 mins to fix

                                      Avoid too many return statements within this function.
                                      Open

                                                  return intern.prior(self, msg, reply, explain, expdata)
                                      Severity: Major
                                      Found in src/Owner.ts - About 30 mins to fix
                                        Severity
                                        Category
                                        Status
                                        Source
                                        Language