capejs/capejs

View on GitHub
lib/cape/mixins/agent_common_methods.js

Summary

Maintainability
A
2 hrs
Test Coverage

Function ajax has 29 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  ajax: function(httpMethod, path, params, callback, errorHandler) {
    params = params || {}
    errorHandler = errorHandler || this.defaultErrorHandler

    this._.applyAdapter()
Severity: Minor
Found in lib/cape/mixins/agent_common_methods.js - About 1 hr to fix

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

      ajax: function(httpMethod, path, params, callback, errorHandler) {
        params = params || {}
        errorHandler = errorHandler || this.defaultErrorHandler
    
        this._.applyAdapter()
    Severity: Minor
    Found in lib/cape/mixins/agent_common_methods.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 ajax has 5 arguments (exceeds 4 allowed). Consider refactoring.
    Open

      ajax: function(httpMethod, path, params, callback, errorHandler) {
    Severity: Minor
    Found in lib/cape/mixins/agent_common_methods.js - About 35 mins to fix

      The body of a for-in should be wrapped in an if statement to filter unwanted properties from the prototype.
      Open

            for (let key in params) {

      Require Guarding for-in (guard-for-in)

      Looping over objects with a for in loop will include properties that are inherited through the prototype chain. This behavior can lead to unexpected items in your for loop.

      for (key in foo) {
          doSomething(key);
      }

      Note that simply checking foo.hasOwnProperty(key) is likely to cause an error in some cases; see [no-prototype-builtins](no-prototype-builtins.md).

      Rule Details

      This rule is aimed at preventing unexpected behavior that could arise from using a for in loop without filtering the results in the loop. As such, it will warn when for in loops do not filter their results with an if statement.

      Examples of incorrect code for this rule:

      /*eslint guard-for-in: "error"*/
      
      for (key in foo) {
          doSomething(key);
      }

      Examples of correct code for this rule:

      /*eslint guard-for-in: "error"*/
      
      for (key in foo) {
          if (Object.prototype.hasOwnProperty.call(foo, key)) {
              doSomething(key);
          }
          if ({}.hasOwnProperty.call(foo, key)) {
              doSomething(key);
          }
      }

      Related Rules

      • [no-prototype-builtins](no-prototype-builtins.md)

      Further Reading

      There are no issues that match your filters.

      Category
      Status