freedomjs/freedom

View on GitHub

Showing 177 of 262 total issues

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 SimpleDataPeer has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

function SimpleDataPeer(peerName, stunServers, dataChannelCallbacks, mocks) {
  var constraints,
    config,
    i;
  this.peerName = peerName;
Severity: Minor
Found in providers/core/core.peerconnection.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 getContents has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

Resource.prototype.getContents = function (url) {
  return new PromiseCompat(function (resolve, reject) {
    var prop;
    if (!url) {
      this.debug.warn("Asked to get contents of undefined URL.");
Severity: Minor
Found in src/resource.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 onMessage has 39 lines of code (exceeds 25 allowed). Consider refactoring.
Open

Consumer.prototype.onMessage = function (source, message) {
  if (source === 'control' && message.reverse) {
    this.emitChannel = message.channel;
    this.emit(this.emitChannel, {
      type: 'channel announcement',
Severity: Minor
Found in src/consumer.js - About 1 hr to fix

Function IndexedDBStorageProvider has 38 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function IndexedDBStorageProvider() {
  this.dbName = 'freedomjs';
  this.storeName = 'freedomjs';
  if (typeof freedom.storage !== 'undefined') {
    this.ERRCODE = freedom.storage().ERRCODE;
Severity: Minor
Found in providers/storage/indexeddb/storage.indexeddb.js - About 1 hr to fix

Function getInterface has 38 lines of code (exceeds 25 allowed). Consider refactoring.
Open

Provider.prototype.getInterface = function () {
  if (this.iface) {
    return this.iface;
  } else {
    var sanityCheck = function (provider) {
Severity: Minor
Found in src/provider.js - About 1 hr to fix

Function start has 36 lines of code (exceeds 25 allowed). Consider refactoring.
Open

Module.prototype.start = function () {
  var Port;
  if (this.started || this.port) {
    return false;
  }
Severity: Minor
Found in src/module.js - About 1 hr to fix

Function aiMove has 36 lines of code (exceeds 25 allowed). Consider refactoring.
Open

Board.prototype.aiMove = function () {
  'use strict';
  if (this.playerMove) {
    return;
  }
Severity: Minor
Found in demo/tictak/main.js - About 1 hr to fix

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

var WS = function (cap, dispatchEvent, url, protocols, socket) {
  var WSImplementation = null,
    error;
  this.isNode = nodeStyle;
  if (typeof socket !== 'undefined') {
Severity: Minor
Found in providers/core/core.websocket.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 updateUsers has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

var updateUsers = function (users) {
  var user, node;
  
  if (!stage || typeof stage === 'function') {
    stage = updateUsers.bind({}, users);
Severity: Minor
Found in demo/connections/view.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 launchAuthFlow has 35 lines of code (exceeds 25 allowed). Consider refactoring.
Open

RemotePageAuth.prototype.launchAuthFlow = function(authUrl, stateObj, interactive, continuation) {
  "use strict";
  var frame = global.document.createElement('iframe');
  frame.src = stateObj.redirect;
  frame.style.display = 'none';
Severity: Minor
Found in providers/oauth/oauth.remotepageauth.js - About 1 hr to fix

Function print has 34 lines of code (exceeds 25 allowed). Consider refactoring.
Open

Logger_console.prototype.print = function (severity, source, msg) {
  var arr = msg;
  if (typeof this.console === 'undefined' ||
      this.console.freedom === true) {
    return;
Severity: Minor
Found in providers/core/core.console.js - About 1 hr to fix

Function fillClients has 34 lines of code (exceeds 25 allowed). Consider refactoring.
Open

LoopbackSocialProvider.prototype.fillClients = function() {
  var STATUSES = ['ONLINE', 'OFFLINE', 'ONLINE_WITH_OTHER_APP'],
      userId, nClients, clientId, i;
  this.clients = {
    "Test User.0": {
Severity: Minor
Found in providers/social/loopback/social.loopback.js - About 1 hr to fix

Function send has 34 lines of code (exceeds 25 allowed). Consider refactoring.
Open

WS.prototype.send = function (data, continuation) {
  var toSend = data.text || data.binary || data.buffer,
    errcode,
    message;

Severity: Minor
Found in providers/core/core.websocket.js - About 1 hr to fix

Consider simplifying this complex logical expression.
Open

      if (badBuffer[i - 2] === badBuffer[i + 2] &&
          badBuffer[i + 2] === badBuffer[i - 1] &&
          badBuffer[i - 1] === badBuffer[i + 1] &&
          badBuffer[i - 1] * 3 === badBuffer[i] &&
          // Background around the foreground pattern? Not part of the specs.
Severity: Critical
Found in demo/connections/third-party/qr/qr.js - About 1 hr to fix

Consider simplifying this complex logical expression.
Open

        if ((frameBuffer[x + width * y] &&
             frameBuffer[(x + 1) + width * y] &&
             frameBuffer[x + width * (y + 1)] &&
             frameBuffer[(x + 1) + width * (y + 1)]) ||
            // All background colour.
Severity: Critical
Found in demo/connections/third-party/qr/qr.js - About 1 hr to fix

Function set has 33 lines of code (exceeds 25 allowed). Consider refactoring.
Open

IndexedDBStorageProvider.prototype.set = function (key, value, continuation) {
  //this.store.set(key, value).then(continuation);
  if (this.handle.initializing) {
    this.pushQueue("set", key, value, continuation);
    return;
Severity: Minor
Found in providers/storage/indexeddb/storage.indexeddb.js - About 1 hr to fix

Function loadLinks has 33 lines of code (exceeds 25 allowed). Consider refactoring.
Open

Module.prototype.loadLinks = function () {
  var i, channels = ['default'], name, dep;

  if (this.manifest.permissions) {
    for (i = 0; i < this.manifest.permissions.length; i += 1) {
Severity: Minor
Found in src/module.js - About 1 hr to fix

Function onMessage has 33 lines of code (exceeds 25 allowed). Consider refactoring.
Open

FileServer.prototype.onMessage = function (val) {
  // Try parsing message
  try {
    val.msgStr = this.social.ab2str(val.data);
    val.msg = JSON.parse(val.msgStr);
Severity: Minor
Found in demo/filedrop/freedom-modules/fileserver.js - About 1 hr to fix

Function _waitSend has 32 lines of code (exceeds 25 allowed). Consider refactoring.
Open

WebRTCTransportProvider.prototype._waitSend = function(tag, buffers) {
  var bufferBound = 0, // upper bound on the # of bytes buffered
      sendBuffers, checkBufferedAmount;

  sendBuffers = function() {
Severity: Minor
Found in providers/transport/webrtc/transport.webrtc.js - About 1 hr to fix
Severity
Category
Status
Source
Language