swvitaliy/ifjs

View on GitHub
lib/Interface.js

Summary

Maintainability
F
3 days
Test Coverage

Function ensureImplements has a Cognitive Complexity of 105 (exceeds 5 allowed). Consider refactoring.
Open

Interface.ensureImplements = function(intfs, object) {
  if (Interface.HARDROCK && typeof object[Interface.INTERFACES_PROP] === 'undefined') {
    object[Interface.INTERFACES_PROP] = [];
  }

Severity: Minor
Found in lib/Interface.js - About 2 days 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 ensureImplements has 65 lines of code (exceeds 25 allowed). Consider refactoring.
Open

Interface.ensureImplements = function(intfs, object) {
  if (Interface.HARDROCK && typeof object[Interface.INTERFACES_PROP] === 'undefined') {
    object[Interface.INTERFACES_PROP] = [];
  }

Severity: Major
Found in lib/Interface.js - About 2 hrs to fix

    Function method has 37 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

              object[method] = (function(method, argumentTypes, resultType, fn) {
                  return function() {
                    var argumentType, callArg, callArguments = [].slice.call(arguments, 0);
                    for (var i = 0; i < argumentTypes.length; i += 1) {
                      argumentType = argumentTypes[i];
    Severity: Minor
    Found in lib/Interface.js - About 1 hr to fix

      Function clear has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
      Open

      Interface.clear = function (iface, obj) {
        if (!obj[Interface.FN_STORE_PROP]) {
          obj[Interface.FN_STORE_PROP] = {};
        }
      
      
      Severity: Minor
      Found in lib/Interface.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 Interface has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
      Open

      var Interface = function(name, methods) {
        if (arguments.length !== 2) {
          throw new Error("Interface constructor called with " + arguments.length + "arguments, but expected exactly 2.");
        }
        this.name = name;
      Severity: Minor
      Found in lib/Interface.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

      Avoid deeply nested control flow statements.
      Open

                      if (this[Interface.FN_STORE_PROP]) {
                        _clearAgain(this);
                      }
      Severity: Major
      Found in lib/Interface.js - About 45 mins to fix

        Avoid deeply nested control flow statements.
        Open

                        for (var i = 0; i < argumentTypes.length; i += 1) {
                          argumentType = argumentTypes[i];
                          if (callArguments.length <= i) {
                              throw new Error("Called method \"" + method + "\" - argument #" + i + " not passed");
                          }
        Severity: Major
        Found in lib/Interface.js - About 45 mins to fix

          Avoid deeply nested control flow statements.
          Open

                          if (resultType) {
                            if (_hasNativeType(resultType, ret) || typeof resultType === 'function' &&
                                ret instanceof resultType) {} else {
                              if (_hasIntf(resultType, ret)) {} else {
                                throw new Error("Called method \"" + method + "\" - result not passed or has invalid type");
          Severity: Major
          Found in lib/Interface.js - About 45 mins to fix

            Avoid deeply nested control flow statements.
            Open

                            if (this[Interface.FN_STORE_PROP]) {
                              Interface.restore(this);
                            }
            Severity: Major
            Found in lib/Interface.js - About 45 mins to fix

              Avoid deeply nested control flow statements.
              Open

                              for (i = 0; i < callArguments.length; i += 1) {
                                Interface.restore(callArguments[i]);
                              }
              Severity: Major
              Found in lib/Interface.js - About 45 mins to fix

                There are no issues that match your filters.

                Category
                Status