mekanika/skematic

View on GitHub
src/validate/validate.js

Summary

Maintainability
C
1 day
Test Coverage

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

    Avoid deeply nested control flow statements.
    Open

                if (!arsub.valid) {
                  if (!errs[key]) errs[key] = {}
                  errs[key][idx] = arsub.errors
                }
    Severity: Major
    Found in src/validate/validate.js - About 45 mins to fix

      Avoid deeply nested control flow statements.
      Open

                  if (er.length) {
                    if (!errs[key]) errs[key] = {}
                    errs[key][idx] = er
                  }
      Severity: Major
      Found in src/validate/validate.js - About 45 mins to fix

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

        function _checkKeys (model, data) {
          let ret = {
            valid: true,
            errors: {}
          }
        Severity: Minor
        Found in src/validate/validate.js - 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

        There are no issues that match your filters.

        Category
        Status