senecajs/seneca-mem-store

View on GitHub

Showing 11 of 11 total issues

Function listents has a Cognitive Complexity of 95 (exceeds 5 allowed). Consider refactoring.
Open

  static listents(seneca: any, entmap: any, qent: any, q: any, done: any) {
    let list = []

    let canon = qent.canon$({ object: true })
    let base = canon.base
Severity: Minor
Found in src/intern.ts - About 1 day 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

Function mem_store has 238 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function mem_store(this: any, options: Options) {
  let seneca: any = this

  let init = seneca.export('entity/init')

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

    Function mem_store has a Cognitive Complexity of 47 (exceeds 5 allowed). Consider refactoring.
    Open

    function mem_store(this: any, options: Options) {
      let seneca: any = this
    
      let init = seneca.export('entity/init')
    
    
    Severity: Minor
    Found in src/mem-store.ts - About 7 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

    Function save has 97 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        save: function (this: any, msg: any, reply: any) {
          // Take a reference to Seneca
          // and the entity to save
          let seneca = this
          let ent = msg.ent
    Severity: Major
    Found in src/mem-store.ts - About 3 hrs to fix

      Consider simplifying this complex logical expression.
      Open

                      if (
                        (null != qv.$ne && qv.$ne == ev) ||
                        (null != qv.$gte && qv.$gte > ev) ||
                        (null != qv.$gt && qv.$gt >= ev) ||
                        (null != qv.$lt && qv.$lt <= ev) ||
      Severity: Critical
      Found in src/intern.ts - About 3 hrs to fix

        Function listents has 88 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          static listents(seneca: any, entmap: any, qent: any, q: any, done: any) {
            let list = []
        
            let canon = qent.canon$({ object: true })
            let base = canon.base
        Severity: Major
        Found in src/intern.ts - About 3 hrs to fix

          Function do_save has 70 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

                function do_save(id?: any, isnew?: boolean) {
                  entmap[base] = entmap[base] || {}
                  entmap[base][name] = entmap[base][name] || {}
          
                  // NOTE: It looks like `ent` is stripped of any private fields
          Severity: Major
          Found in src/mem-store.ts - About 2 hrs to fix

            File mem-store.ts has 275 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            /* Copyright (c) 2010-2022 Richard Rodger and other contributors, MIT License */
            'use strict'
            
            // TODO: use `undefined` as no-error value consistently
            
            
            Severity: Minor
            Found in src/mem-store.ts - About 2 hrs to fix

              Function remove has 33 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  remove: function (this: any, msg: any, reply: any) {
                    let seneca = this
                    let qent = msg.qent
                    let q = msg.q || {}
                    let all = q.all$
              Severity: Minor
              Found in src/mem-store.ts - About 1 hr to fix

                Function find_mement has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                Open

                  static find_mement(entmap: any, base_ent: any, filter: any): any {
                    const { base, name } = base_ent.canon$({ object: true })
                    const entset = entmap[base] && entmap[base][name]
                
                    if (null == entset) {
                Severity: Minor
                Found in src/intern.ts - About 55 mins 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

                Avoid deeply nested control flow statements.
                Open

                        next_ent: for (let id of entids) {
                          ent = entset[id]
                          for (let p in q) {
                            let qv = q[p] // query val
                            let ev = ent[p] // ent val
                Severity: Major
                Found in src/intern.ts - About 45 mins to fix
                  Severity
                  Category
                  Status
                  Source
                  Language