freedomjs/freedom

View on GitHub

Showing 262 of 262 total issues

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

Similar blocks of code found in 2 locations. Consider refactoring.
Open

      while (i--) {
        t = stringBuffer[i];

        stringBuffer[i + 2] |= 255 & (t << 4);
        stringBuffer[i + 1] = t >> 4;
Severity: Major
Found in demo/connections/third-party/qr/qr.js and 1 other location - About 1 hr to fix
demo/connections/third-party/qr/qr.js on lines 782..787

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 62.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

      while (i--) {
        t = stringBuffer[i];

        stringBuffer[i + 3] |= 255 & (t << 4);
        stringBuffer[i + 2] = t >> 4;
Severity: Major
Found in demo/connections/third-party/qr/qr.js and 1 other location - About 1 hr to fix
demo/connections/third-party/qr/qr.js on lines 796..801

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 62.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

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 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 _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

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

WebRTCTransportProvider.prototype.send = function(tag, data, continuation) {
  // console.log("TransportProvider.send." + this.name);
  if(!this._setup) {
    continuation(undefined, {
      "errcode": "NOTREADY",
Severity: Minor
Found in providers/transport/webrtc/transport.webrtc.js - About 1 hr to fix

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

Debug.prototype.format = function (severity, source, args) {
  var i, alist = [], argarr;
  if (typeof args === "string" && source) {
    try {
      argarr = JSON.parse(args);
Severity: Minor
Found in src/debug.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 register has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

Api.prototype.register = function(name, constructor, style, flags) {
  var i,
    args;

  this.providers[name] = {
Severity: Minor
Found in src/api.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

Similar blocks of code found in 2 locations. Consider refactoring.
Open

    if (this.manager.delegate && this.manager.toDelegate.core) {
      this.manager.emit(this.manager.delegate, {
        type: 'Delegation',
        request: 'handle',
        flow: 'core',
Severity: Major
Found in providers/core/core.unprivileged.js and 1 other location - About 1 hr to fix
providers/core/core.unprivileged.js on lines 39..49

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 60.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

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

Board.prototype.checkWin = function () {
  'use strict';
  var sets = ["012", "345", "678", "036", "147", "258", "048", "246"],
    s,
    set,
Severity: Minor
Found in demo/tictak/main.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

Similar blocks of code found in 2 locations. Consider refactoring.
Open

  if (this.isInModule()) {
    this.manager.emit(this.manager.delegate, {
      type: 'Delegation',
      request: 'handle',
      flow: 'core',
Severity: Major
Found in providers/core/core.unprivileged.js and 1 other location - About 1 hr to fix
providers/core/core.unprivileged.js on lines 128..138

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 60.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

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

Resource.prototype.httpResolver = function (manifest, url, resolve, reject) {
  var protocols = ["http", "https", "chrome", "chrome-extension", "resource",
                   "app", "gopher"],
    dirname,
    protocolIdx,
Severity: Minor
Found in src/resource.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 onNegotiationNeeded has 31 lines of code (exceeds 25 allowed). Consider refactoring.
Open

SimpleDataPeer.prototype.onNegotiationNeeded = function (e) {
  //console.log(this.peerName + ": " + "onNegotiationNeeded",
  //            JSON.stringify(this._pc), e);
  if (this.pcState !== SimpleDataPeerState.DISCONNECTED) {
    // Negotiation messages are falsely requested for new data channels.
Severity: Minor
Found in providers/core/core.peerconnection.js - About 1 hr to fix
Severity
Category
Status
Source
Language