freedomjs/freedom

View on GitHub
src/manager.js

Summary

Maintainability
C
1 day
Test Coverage

Function onMessage has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
Open

Manager.prototype.onMessage = function (flow, message) {
  var reverseFlow = this.controlFlows[flow], origin;
  if (!reverseFlow) {
    this.debug.warn("Unknown message source: " + flow);
    return;
Severity: Minor
Found in src/manager.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 onMessage has 54 lines of code (exceeds 25 allowed). Consider refactoring.
Open

Manager.prototype.onMessage = function (flow, message) {
  var reverseFlow = this.controlFlows[flow], origin;
  if (!reverseFlow) {
    this.debug.warn("Unknown message source: " + flow);
    return;
Severity: Major
Found in src/manager.js - About 2 hrs to fix

Function createLink has 40 lines of code (exceeds 25 allowed). Consider refactoring.
Open

Manager.prototype.createLink = function (port, name, destination, destName,
                                         toDest) {
  if (!this.config.global) {
    this.once('config',
      this.createLink.bind(this, port, name, destination, destName));
Severity: Minor
Found in src/manager.js - About 1 hr to fix

Function removeLink has 31 lines of code (exceeds 25 allowed). Consider refactoring.
Open

Manager.prototype.removeLink = function (port, name) {
  var reverse = this.hub.getDestination(name),
    rflow = this.reverseFlowMap[name],
    i;

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

Function setup has 28 lines of code (exceeds 25 allowed). Consider refactoring.
Open

Manager.prototype.setup = function (port) {
  if (!port.id) {
    this.debug.warn("Refusing to setup unidentified port ");
    return false;
  }
Severity: Minor
Found in src/manager.js - About 1 hr to fix

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

Manager.prototype.createLink = function (port, name, destination, destName,
                                         toDest) {
  if (!this.config.global) {
    this.once('config',
      this.createLink.bind(this, port, name, destination, destName));
Severity: Minor
Found in src/manager.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 createLink has 5 arguments (exceeds 4 allowed). Consider refactoring.
Open

Manager.prototype.createLink = function (port, name, destination, destName,
                                         toDest) {
Severity: Minor
Found in src/manager.js - About 35 mins to fix

Avoid too many return statements within this function.
Open

    return;
Severity: Major
Found in src/manager.js - About 30 mins to fix

Function forgetFlow has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

Manager.prototype.forgetFlow = function (id, name) {
  var i;
  if (this.dataFlows[id]) {
    for (i = 0; i < this.dataFlows[id].length; i += 1) {
      if (this.dataFlows[id][i] === name) {
Severity: Minor
Found in src/manager.js - About 25 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