freedomjs/freedom

View on GitHub
src/policy.js

Summary

Maintainability
B
6 hrs
Test Coverage

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

Policy.prototype.isRunning = function(runtime, id, from, fullMatch) {
  var i = 0, j = 0, okay;
  for (i = 0; i < runtime.modules.length; i += 1) {
    if (fullMatch && runtime.modules[i].length === from.length + 1) {
      okay = true;
Severity: Minor
Found in src/policy.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 findDestination has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

Policy.prototype.findDestination = function(lineage, id, constraints) {
  var i;

  // Step 1: if an instance already exists, the m
  if (constraints.isolation !== 'always') {
Severity: Minor
Found in src/policy.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 get has 32 lines of code (exceeds 25 allowed). Consider refactoring.
Open

Policy.prototype.get = function(lineage, id) {
  
  // Make sure that a module isn't getting located twice at the same time.
  // This is resolved by delaying if it until we see it in a 'moduleAdd' event.
  if (this.pending[id]) {
Severity: Minor
Found in src/policy.js - About 1 hr to fix

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

Policy.prototype.add = function(port, policy) {
  var runtime = {
    manager: port,
    modules: []
  };
Severity: Minor
Found in src/policy.js - About 1 hr to fix

There are no issues that match your filters.

Category
Status