voxgig/seneca-owner

View on GitHub
src/Owner.ts

Summary

Maintainability
F
5 days
Test Coverage

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

        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

          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

            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 == 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

                            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 (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 (err) return reply(err)
                    Severity: Major
                    Found in src/Owner.ts - About 45 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

                        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

                                  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

                                    Similar blocks of code found in 2 locations. Consider refactoring.
                                    Open

                                                if (modifiers.list) {
                                                  explain &&
                                                    ((expdata.modifiers.list = true),
                                                      (expdata.orig_list_len = list ? list.length : 0))
                                                  list = modifiers.list.call(self, spec, owner, msg, list)
                                    Severity: Major
                                    Found in src/Owner.ts and 1 other location - About 1 hr to fix
                                    src/Owner.ts on lines 193..198

                                    Duplicated Code

                                    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                    Tuning

                                    This issue has a mass of 67.

                                    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                    Refactorings

                                    Further Reading

                                    Similar blocks of code found in 2 locations. Consider refactoring.
                                    Open

                                                if (modifiers.list) {
                                                  explain &&
                                                    ((expdata.modifiers.list = true),
                                                      (expdata.orig_list_len = list ? list.length : 0))
                                                  list = modifiers.list.call(self, spec, owner, msg, list)
                                    Severity: Major
                                    Found in src/Owner.ts and 1 other location - About 1 hr to fix
                                    src/Owner.ts on lines 216..221

                                    Duplicated Code

                                    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                    Tuning

                                    This issue has a mass of 67.

                                    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                    Refactorings

                                    Further Reading

                                    Similar blocks of code found in 2 locations. Consider refactoring.
                                    Open

                                                      const fail = {
                                                        code: 'create-not-allowed',
                                                        details: {
                                                          why: 'field-mismatch-on-create',
                                                          field: fieldName,
                                    Severity: Minor
                                    Found in src/Owner.ts and 1 other location - About 50 mins to fix
                                    src/Owner.ts on lines 403..413

                                    Duplicated Code

                                    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                    Tuning

                                    This issue has a mass of 51.

                                    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                    Refactorings

                                    Further Reading

                                    Similar blocks of code found in 2 locations. Consider refactoring.
                                    Open

                                                      fail = {
                                                        code: 'update-not-allowed',
                                                        details: {
                                                          why: 'field-mismatch-on-update',
                                                          field: fieldName,
                                    Severity: Minor
                                    Found in src/Owner.ts and 1 other location - About 50 mins to fix
                                    src/Owner.ts on lines 351..361

                                    Duplicated Code

                                    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                    Tuning

                                    This issue has a mass of 51.

                                    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                    Refactorings

                                    Further Reading

                                    Similar blocks of code found in 2 locations. Consider refactoring.
                                    Open

                                          if (null != ignorepat) {
                                            explain && (expdata.ignored = true, expdata.ignorepat = ignorepat)
                                            return intern.prior(self, msg, reply, explain, expdata)
                                          }
                                    Severity: Minor
                                    Found in src/Owner.ts and 1 other location - About 30 mins to fix
                                    src/Owner.ts on lines 256..260

                                    Duplicated Code

                                    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                    Tuning

                                    This issue has a mass of 45.

                                    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                    Refactorings

                                    Further Reading

                                    Similar blocks of code found in 2 locations. Consider refactoring.
                                    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: Minor
                                    Found in src/Owner.ts and 1 other location - About 30 mins to fix
                                    src/Owner.ts on lines 129..132

                                    Duplicated Code

                                    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                    Tuning

                                    This issue has a mass of 45.

                                    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                    Refactorings

                                    Further Reading

                                    There are no issues that match your filters.

                                    Category
                                    Status