senecajs/seneca-entity

View on GitHub

Showing 21 of 31 total issues

Function jsonic_strify has a Cognitive Complexity of 49 (exceeds 5 allowed). Consider refactoring.
Open

function jsonic_strify(val: any, opts: any, depth: number) {
  depth++
  if (null == val) return 'null'

  var type = Object.prototype.toString.call(val).charAt(8)
Severity: Minor
Found in src/lib/make_entity.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 canon$ has a Cognitive Complexity of 42 (exceeds 5 allowed). Consider refactoring.
Open

  canon$(opt?: any) {
    const self = this

    const canon = self.private$.canon

Severity: Minor
Found in src/lib/make_entity.ts - About 6 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 data$ has a Cognitive Complexity of 39 (exceeds 5 allowed). Consider refactoring.
Open

  data$(data?: any, canonkind?: any) {
    const self: any = this
    let val

    // TODO: test for entity$ consistent?
Severity: Minor
Found in src/lib/make_entity.ts - About 5 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 make$ has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
Open

  make$(...args: any[]) {
    const self = this
    let first = args[0]
    let last = args[args.length - 1]
    let promise = self.private$.promise
Severity: Minor
Found in src/lib/make_entity.ts - About 3 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 make$ has 69 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  make$(...args: any[]) {
    const self = this
    let first = args[0]
    let last = args[args.length - 1]
    let promise = self.private$.promise
Severity: Major
Found in src/lib/make_entity.ts - About 2 hrs to fix

    Function normalize_query has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
    Open

    function normalize_query(qin: any, ent: any, flags?: { inject_id: boolean }) {
      let q = qin
    
      let inject_id = flags ? (false === flags.inject_id ? false : true) : true
    
    
    Severity: Minor
    Found in src/lib/make_entity.ts - About 2 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 jsonic_strify has 59 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    function jsonic_strify(val: any, opts: any, depth: number) {
      depth++
      if (null == val) return 'null'
    
      var type = Object.prototype.toString.call(val).charAt(8)
    Severity: Major
    Found in src/lib/make_entity.ts - About 2 hrs to fix

      Function data$ has 53 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        data$(data?: any, canonkind?: any) {
          const self: any = this
          let val
      
          // TODO: test for entity$ consistent?
      Severity: Major
      Found in src/lib/make_entity.ts - About 2 hrs to fix

        Function parsecanon has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
        Open

        function parsecanon(str: CanonSpec) {
          let out: any = {}
        
          if (Array.isArray(str)) {
            return {
        Severity: Minor
        Found in src/lib/make_entity.ts - About 1 hr 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 MakeEntity has 37 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        function MakeEntity(canon: any, seneca: any, opts: any): Entity {
          opts = handle_options(opts, seneca)
        
          const deep = seneca.util.deep
        
        
        Severity: Minor
        Found in src/lib/make_entity.ts - About 1 hr to fix

          Function canon$ has 34 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            canon$(opt?: any) {
              const self = this
          
              const canon = self.private$.canon
          
          
          Severity: Minor
          Found in src/lib/make_entity.ts - About 1 hr to fix

            Function handle_options has 29 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            function handle_options(entopts: any, seneca: any): any {
              entopts = entopts || Object.create(null)
              let Jsonic = seneca.util.Jsonic
            
              if (entopts.hide) {
            Severity: Minor
            Found in src/lib/make_entity.ts - About 1 hr to fix

              Avoid deeply nested control flow statements.
              Open

                      if (null != str) {
                        out.push(str)
                      }
              Severity: Major
              Found in src/lib/make_entity.ts - About 45 mins to fix

                Function MakeEntity has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                Open

                function MakeEntity(canon: any, seneca: any, opts: any): Entity {
                  opts = handle_options(opts, seneca)
                
                  const deep = seneca.util.deep
                
                
                Severity: Minor
                Found in src/lib/make_entity.ts - About 45 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

                Function is$ has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                Open

                  is$(canonspec: any) {
                    const self = this
                
                    const canon = canonspec
                      ? canonspec.entity$
                Severity: Minor
                Found in src/lib/make_entity.ts - About 35 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

                Function remove$ has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                Open

                  remove$(query: any, done?: any) {
                    const self = this
                
                    if ('function' === typeof query) {
                      done = query
                Severity: Minor
                Found in src/lib/make_entity.ts - About 35 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

                Function load$ has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                Open

                  load$(query: any, done?: any) {
                    const self = this
                
                    if ('function' === typeof query) {
                      done = query
                Severity: Minor
                Found in src/lib/make_entity.ts - About 35 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 too many return statements within this function.
                Open

                    return isNaN(val) ? 'null' : val.toString()
                Severity: Major
                Found in src/lib/make_entity.ts - About 30 mins to fix

                  Avoid too many return statements within this function.
                  Open

                      return '{' + out.join(',') + '}'
                  Severity: Major
                  Found in src/lib/make_entity.ts - About 30 mins to fix

                    Avoid too many return statements within this function.
                    Open

                        return '[' + out.join(',') + ']'
                    Severity: Major
                    Found in src/lib/make_entity.ts - About 30 mins to fix
                      Severity
                      Category
                      Status
                      Source
                      Language