nodexo/object-fx

View on GitHub

Showing 7 of 7 total issues

Function flatten has a Cognitive Complexity of 40 (exceeds 5 allowed). Consider refactoring.
Open

  static flatten (objExp, userOptions) {
    if (Object.prototype.toString.call(objExp) !== '[object Object]' && Object.prototype.toString.call(objExp) !== '[object Array]') {
      return null
    }
    const options = this._mergeOptions(userOptions)
Severity: Minor
Found in index.js - 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 expand has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
Open

  static expand (objFlat, userOptions) {
    if (Object.prototype.toString.call(objFlat) !== '[object Object]') {
      return null
    }
    const options = this._mergeOptions(userOptions)
Severity: Minor
Found in index.js - 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 flatten has 46 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  static flatten (objExp, userOptions) {
    if (Object.prototype.toString.call(objExp) !== '[object Object]' && Object.prototype.toString.call(objExp) !== '[object Array]') {
      return null
    }
    const options = this._mergeOptions(userOptions)
Severity: Minor
Found in index.js - About 1 hr to fix

    Function expand has 42 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      static expand (objFlat, userOptions) {
        if (Object.prototype.toString.call(objFlat) !== '[object Object]') {
          return null
        }
        const options = this._mergeOptions(userOptions)
    Severity: Minor
    Found in index.js - About 1 hr to fix

      Function recurse has 28 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          const recurse = (cur, prop, lev) => {
            if (options.MaxDepth > 0 && lev >= options.MaxDepth) {
              result[prop] = cur
              return
            }
      Severity: Minor
      Found in index.js - About 1 hr to fix

        Avoid deeply nested control flow statements.
        Open

                    if ((options.AutocreateArrays && this._isValidArrayIndex(nextChunk)) ||
                      (options.ExplicitArrays && this._containsValidArrayIndex(nextChunk))) {
                      obj[currChunk] = []
                    } else {
                      obj[currChunk] = {}
        Severity: Major
        Found in index.js - About 45 mins to fix

          Function _mergeOptions has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

            static _mergeOptions (userOptions) {
              if (Object.prototype.toString.call(userOptions) === '[object Object]') {
                for (let key of Object.keys(userOptions)) {
                  if (defaultOptions.hasOwnProperty(key) === false) {
                    throw new Error('Unsupported option: ' + key)
          Severity: Minor
          Found in index.js - About 25 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

          Severity
          Category
          Status
          Source
          Language