BohemiaInteractive/bi-service

View on GitHub
lib/utils.js

Summary

Maintainability
C
1 day
Test Coverage

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

function resolveSchemaRefs(val, validator, _root) {

    _root = _root || val;
    resolve(val, '', val);
    return val;
Severity: Minor
Found in lib/utils.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 getPaginationMeta has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

function getPaginationMeta(opt) {

    opt = opt || {};

    opt.limit = typeof opt.limit !== 'number' ?
Severity: Minor
Found in lib/utils.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 registerCustomKeywords has 35 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function registerCustomKeywords(ajv) {
    //register $desc - aka. property description keyword
    ajv.addKeyword('$desc', {
        schema: false,
        valid: true,
Severity: Minor
Found in lib/utils.js - About 1 hr to fix

    Function resolveSchemaRefs has 32 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    function resolveSchemaRefs(val, validator, _root) {
    
        _root = _root || val;
        resolve(val, '', val);
        return val;
    Severity: Minor
    Found in lib/utils.js - About 1 hr to fix

      Function getPaginationMeta has 32 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      function getPaginationMeta(opt) {
      
          opt = opt || {};
      
          opt.limit = typeof opt.limit !== 'number' ?
      Severity: Minor
      Found in lib/utils.js - About 1 hr to fix

        Function resolve has 27 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            function resolve(val, key, object) {
                if (_.isPlainObject(val)) {
                    if (   val.hasOwnProperty('$ref')
                        && typeof val.$ref === 'string'
                    ) {
        Severity: Minor
        Found in lib/utils.js - About 1 hr to fix

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

          function _stderr(err) {
          
              if (typeof err === 'object' && err !== null) {
                  if (err.toLogger instanceof Function) {
                      err = err.toLogger();
          Severity: Minor
          Found in lib/utils.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

          Function validate has 6 arguments (exceeds 4 allowed). Consider refactoring.
          Open

                  validate: function(schema, data, parentSchema, dataPath, parentData, prop) {
          Severity: Minor
          Found in lib/utils.js - About 45 mins to fix

            There are no issues that match your filters.

            Category
            Status