freedomjs/freedom

View on GitHub

Showing 262 of 262 total issues

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

IsolatedStorageProvider.prototype._flushQueue = function() {
  var i, elt;
  for (i = 0; i < this.queue.length; i += 1) {
    elt = this.queue[i];
    if (elt.cmd === "keys") {
Severity: Minor
Found in providers/storage/isolated/storage.isolated.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

Avoid deeply nested control flow statements.
Open

          if (this.dependantChannels.indexOf(key) < 0) {
            return true;
          }
Severity: Major
Found in src/module.js - About 45 mins to fix

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

Debug.prototype.onMessage = function (source, message) {
  if (source === 'control' && message.channel && !this.emitChannel) {
    this.emitChannel = message.channel;
    this.config = message.config;
    if (!this.config.global.console) {
Severity: Minor
Found in src/debug.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 bindDefault has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

ProxyBinder.prototype.bindDefault = function (port, api, manifest, internal) {
  'use strict';
  var metadata = {
    name: manifest.name,
    icon: manifest.icon,
Severity: Minor
Found in src/proxybinder.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 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

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

  } else if (val.from.clientId && val.msg.cmd && val.msg.data && val.msg.cmd === 'done') {
    this.updateStats(val.msg.data, -1, 1);
  } else {
    console.log("social.onMessage: Unrecognized message: " + JSON.stringify(val));
  }
Severity: Major
Found in demo/filedrop/freedom-modules/fileserver.js and 2 other locations - About 45 mins to fix
demo/filedrop/freedom-modules/filefetcher.js on lines 63..68
demo/filedrop/freedom-modules/fileserver.js on lines 49..75

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 50.

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

function start(LogClient) {
  var logClient = new LogClient(),
    input = document.getElementById('msg-input');

  input.focus();
Severity: Minor
Found in demo/advancedlogging/page.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

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

  if (val.from.clientId && val.msg.cmd && val.msg.data && val.msg.cmd === 'fetch') {
    var key = val.msg.data,
      targetId = val.from.clientId;
    this.updateStats(key, 1, 0);

Severity: Major
Found in demo/filedrop/freedom-modules/fileserver.js and 2 other locations - About 45 mins to fix
demo/filedrop/freedom-modules/filefetcher.js on lines 63..68
demo/filedrop/freedom-modules/fileserver.js on lines 71..75

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 50.

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

Avoid deeply nested control flow statements.
Open

            if (k) {
              if (y !== 0) {
                y--;
              } else {
                x -= 2;
Severity: Major
Found in demo/connections/third-party/qr/qr.js - About 45 mins to fix

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

var record = function (level, source, message) {
  'use strict';
  var formatted = '<span style="';
  if (level === 'debug') {
    formatted += "color:#888;";
Severity: Minor
Found in demo/advancedlogging/logger.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

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

  if (val.from.clientId && val.msg.cmd && val.msg.data && val.msg.cmd === 'error') {
    this.logger.log('social.onMessage: ' + val.msg.data);
    freedom().emit('download-error', val.msg.data);
  } else {
    this.logger.log("social.onMessage: Unrecognized message: " + JSON.stringify(val));
Severity: Major
Found in demo/filedrop/freedom-modules/filefetcher.js and 2 other locations - About 45 mins to fix
demo/filedrop/freedom-modules/fileserver.js on lines 49..75
demo/filedrop/freedom-modules/fileserver.js on lines 71..75

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 50.

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

    this.resource.get(this.manifestId, message.data).then(function (id, data) {
      this.port.onMessage(this.modInternal, {
        type: 'resolve.response',
        id: id,
        data: data
Severity: Minor
Found in src/module.js and 1 other location - About 40 mins to fix
src/module.js on lines 117..123

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 49.

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

          this.once('modInternal', function (flow, api) {
            this.port.onMessage(this.modInternal, {
              type: 'Connection',
              channel: flow,
              api: api
Severity: Minor
Found in src/module.js and 1 other location - About 40 mins to fix
src/module.js on lines 368..374

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 49.

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 WS has 5 arguments (exceeds 4 allowed). Consider refactoring.
Open

var WS = function (cap, dispatchEvent, url, protocols, socket) {
Severity: Minor
Found in providers/core/core.websocket.js - About 35 mins to fix

Function open has 5 arguments (exceeds 4 allowed). Consider refactoring.
Open

XhrProvider.prototype.open = function(method, url, async, user, password) {
Severity: Minor
Found in providers/core/core.xhr.js - About 35 mins to fix

Function onOpen has 5 arguments (exceeds 4 allowed). Consider refactoring.
Open

  onOpen: function (id, name, page, resources, postMessage) {
Severity: Minor
Found in providers/core/core.view.js - About 35 mins to fix

Function PeerConnection has 5 arguments (exceeds 4 allowed). Consider refactoring.
Open

function PeerConnection(portModule, dispatchEvent,
                        RTCPeerConnection, RTCSessionDescription,
                        RTCIceCandidate) {
Severity: Minor
Found in providers/core/core.peerconnection.js - About 35 mins to fix

Function conform has 5 arguments (exceeds 4 allowed). Consider refactoring.
Open

Consumer.conform = function (template, from, externals, separate, debug) {
Severity: Minor
Found in src/consumer.js - About 35 mins to fix

Function onOpen has 5 arguments (exceeds 4 allowed). Consider refactoring.
Open

  this.onOpen = function (id, name, page, resources, postMessage) {
Severity: Minor
Found in demo/connections/heightCustomViewProvider.js - About 35 mins to fix

Function setup has 5 arguments (exceeds 4 allowed). Consider refactoring.
Open

PeerConnection.prototype.setup = function (signallingChannelId, peerName,
                                           stunServers, initiateConnection,
                                           continuation) {
Severity: Minor
Found in providers/core/core.peerconnection.js - About 35 mins to fix
Severity
Category
Status
Source
Language