mekanika/skematic

View on GitHub

Showing 37 of 45 total issues

Function _dive has a Cognitive Complexity of 52 (exceeds 5 allowed). Consider refactoring.
Open

function _dive (skm, payload, opts, parentData) {
  // On the odd chance we reach here with no `skm` model defined
  if (!skm) return payload

  // Placeholder for formatted data
Severity: Minor
Found in src/format.js - 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 _validate has a Cognitive Complexity of 36 (exceeds 5 allowed). Consider refactoring.
Open

function _validate (data, model, opts, parentData = {}) {
  let errs = {}

  // Validate scalars
  // Used by `_sparse()` to check scalar vals -- pass parentObj if exists
Severity: Minor
Found in src/validate/validate.js - 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 checkValue has a Cognitive Complexity of 30 (exceeds 5 allowed). Consider refactoring.
Open

module.exports = function checkValue (val, model, data, opts = {}) {
  let errs = []
  if (!model) return []

  //  1. Check null value status
Severity: Minor
Found in src/validate/checkValue.js - 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

Function _generate has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
Open

function _generate (gen, runOnce, value, data) {
  // Run immediately if `gen` is a function
  if (is.function(gen)) return gen.call(data, value)

  // Prepare the value to return
Severity: Minor
Found in src/compute.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 _makeValue has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
Open

function _makeValue (data = {}, ss = {}, opts, val) {
  // Set defaults
  if (opts.defaults !== false) {
    if (!is.undefined(ss.default)) val = setDefault(val, ss)
  }
Severity: Minor
Found in src/format.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 convertNumber has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
Open

function convertNumber (val, convertor, radix) {
  // Setup defaults
  convertor || (convertor = radix !== undefined ? parseInt : Number)
  radix || (radix = 10)

Severity: Minor
Found in src/plugins/typeconvert.js - 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 equal has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
Open

  equal: (a, b) => {
    if (a === b) return true
    let i = -1

    if (is.array(a)) {
Severity: Minor
Found in src/is.js - 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

pgSQL has 23 functions (exceeds 20 allowed). Consider refactoring.
Open

const pgSQL = {
  ARRAY: (t, opts) => typeToSQL(t.type, opts) + ' ARRAY',
  BOOLEAN: t => t.key,
  BYTEA: t => t.key,
  CHAR: t => 'CHAR' + (t.length ? `(${t.length})` : ''),
Severity: Minor
Found in src/plugins/toSQL.js - About 2 hrs to fix

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

    function _dive (skm, payload, opts, parentData) {
      // On the odd chance we reach here with no `skm` model defined
      if (!skm) return payload
    
      // Placeholder for formatted data
    Severity: Major
    Found in src/format.js - About 2 hrs to fix

      Function _validate has 49 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      function _validate (data, model, opts, parentData = {}) {
        let errs = {}
      
        // Validate scalars
        // Used by `_sparse()` to check scalar vals -- pass parentObj if exists
      Severity: Minor
      Found in src/validate/validate.js - About 1 hr to fix

        Function checkValue has 45 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        module.exports = function checkValue (val, model, data, opts = {}) {
          let errs = []
          if (!model) return []
        
          //  1. Check null value status
        Severity: Minor
        Found in src/validate/checkValue.js - About 1 hr to fix

          Function createFrom has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
          Open

          function createFrom (model, nullValue) {
            let o = {}
          
            if (!model) return o
          
          
          Severity: Minor
          Found in src/format.js - 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 exports has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
          Open

          module.exports = function (v, model) {
            if (!model) return v
          
            const def = function (v, s) {
              // No default, return the value as is
          Severity: Minor
          Found in src/default.js - 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 toString has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
          Open

          function toString (val) {
            if (val === null) return val
          
            // Parse if value is not undefined
            if (val !== undefined) {
          Severity: Minor
          Found in src/plugins/typeconvert.js - 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 _generate has 30 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          function _generate (gen, runOnce, value, data) {
            // Run immediately if `gen` is a function
            if (is.function(gen)) return gen.call(data, value)
          
            // Prepare the value to return
          Severity: Minor
          Found in src/compute.js - About 1 hr to fix

            Function toDate has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
            Open

            function toDate (val) {
              if (val === undefined || val instanceof Array) {
                throw new Error('Failed to cast to Date')
              }
              if (val === null || val === '') return null
            Severity: Minor
            Found in src/plugins/typeconvert.js - 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 fieldToString has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
            Open

            const fieldToString = (name, model, table) => {
              // Define the colun name
              let str = [name]
            
              if (!model.type) {
            Severity: Minor
            Found in src/plugins/toSQL.js - 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

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

            function canCompute (model, opts = {}, val) {
              if (!model || !model.generate) return false
            
              // Shorthand
              const gen = model.generate
            Severity: Minor
            Found in src/compute.js - 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

                    if (data[i] !== out) data[i] = out
            Severity: Major
            Found in src/format.js - About 45 mins to fix

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

              const typeToSQL = (type, opts = {forceUnrecognised: false}) => {
                if (!type) return ''
              
                // Return immediately if no key set on data type
                if (!type.key) {
              Severity: Minor
              Found in src/plugins/toSQL.js - 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

              Severity
              Category
              Status
              Source
              Language