marionette-wires/wires-events

View on GitHub

Showing 7 of 7 total issues

Function off has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
Open

  off(name, callback, context) {
    if (!this._events || !_eventsApi(this, 'off', name, [callback, context])) {
      return this;
    }

Severity: Minor
Found in src/wires-events.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 off has 36 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  off(name, callback, context) {
    if (!this._events || !_eventsApi(this, 'off', name, [callback, context])) {
      return this;
    }

Severity: Minor
Found in src/wires-events.js - About 1 hr to fix

    Function _triggerEvents has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

    function _triggerEvents(events, args) {
      var ev, i = -1, l = events.length, a1 = args[0], a2 = args[1], a3 = args[2];
      switch (args.length) {
        case 0: while (++i < l) { (ev = events[i]).callback.call(ev.ctx); } return;
        case 1: while (++i < l) { (ev = events[i]).callback.call(ev.ctx, a1); } return;
    Severity: Minor
    Found in src/wires-events.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 listenToOnce has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

      listenToOnce(obj, name, callback) {
        if (typeof name === 'object') {
          for (var event in name) {
            this.listenToOnce(obj, event, name[event]);
          }
    Severity: Minor
    Found in src/wires-events.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 _eventsApi has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

    function _eventsApi(obj, action, name, rest) {
      if (!name) {
        return true;
      }
    
    
    Severity: Minor
    Found in src/wires-events.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

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

      stopListening(obj, name, callback) {
        var listeningTo = this._listeningTo;
    
        if (!listeningTo) {
          return this;
    Severity: Minor
    Found in src/wires-events.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

    Avoid too many return statements within this function.
    Open

        default: while (++i < l) { (ev = events[i]).callback.apply(ev.ctx, args); } return;
    Severity: Major
    Found in src/wires-events.js - About 30 mins to fix
      Severity
      Category
      Status
      Source
      Language