dimelo/faye-authentication

View on GitHub

Showing 12 of 12 total issues

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

(function() {
'use strict';

var timeout = setTimeout, defer;

Severity: Major
Found in app/assets/javascripts/faye-authentication.js and 1 other location - About 1 wk to fix
app/assets/javascripts/faye-authentication.js on lines 125..288

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

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

(function() {
'use strict';

var timeout = setTimeout, defer;

Severity: Major
Found in app/assets/javascripts/faye-authentication.js and 1 other location - About 1 wk to fix
app/assets/javascripts/faye-authentication.js on lines 290..453

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

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

File faye-authentication.js has 371 lines of code (exceeds 250 allowed). Consider refactoring.
Open

function FayeAuthentication(client, endpoint, options) {
  this._client = client;
  this._endpoint = endpoint || '/faye/auth';
  this._signatures = {};
  this._outbox = {};
Severity: Minor
Found in app/assets/javascripts/faye-authentication.js - About 4 hrs to fix

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

        this._signatures[clientId][channel].then(function(signature) {
          message.signature = signature;
          if (!message.retried) {
            self._outbox[message.id] = {message: message, clientId: clientId};
          }
    Severity: Major
    Found in app/assets/javascripts/faye-authentication.js and 1 other location - About 1 hr to fix
    app/assets/javascripts/faye-authentication.js on lines 70..76

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

    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

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

        promise.then(function(signature) {
          message.signature = signature;
          if (!message.retried) {
            self._outbox[message.id] = {message: message, clientId: clientId};
          }
    Severity: Major
    Found in app/assets/javascripts/faye-authentication.js and 1 other location - About 1 hr to fix
    app/assets/javascripts/faye-authentication.js on lines 61..67

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

    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 resolveWaitingSignatures has 30 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    FayeAuthentication.prototype.resolveWaitingSignatures = function() {
      if (this._waiting_signatures.length == 0) {
        return ;
      }
      var self = this;
    Severity: Minor
    Found in app/assets/javascripts/faye-authentication.js - About 1 hr to fix

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

      FayeAuthentication.prototype.signMessage = function(message, callback) {
        var channel = message.subscription || message.channel;
        var clientId = message.clientId;
      
        var self = this;
      Severity: Minor
      Found in app/assets/javascripts/faye-authentication.js - About 1 hr to fix

        Method prepare_request has 5 arguments (exceeds 4 allowed). Consider refactoring.
        Open

              def self.prepare_request(uri, channel, data, key, options = {})
        Severity: Minor
        Found in lib/faye/authentication/http_client.rb - About 35 mins to fix

          Method publish has 5 arguments (exceeds 4 allowed). Consider refactoring.
          Open

                def self.publish(url, channel, data, key, options = {})
          Severity: Minor
          Found in lib/faye/authentication/http_client.rb - About 35 mins to fix

            Method authentication_required? has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
            Open

                def self.authentication_required?(message, options = {})
                  subscription_or_channel = message['subscription'] || message['channel']
                  return false if message['channel'].nil?
                  return false unless (message['channel'].start_with?('/meta/subscribe') || (!(message['channel'].start_with?('/meta/'))))
                  whitelist_proc = options[:whitelist]
            Severity: Minor
            Found in lib/faye/authentication.rb - About 35 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

            Method incoming has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
            Open

                  def incoming(message, callback)
                    if Faye::Authentication.authentication_required?(message, @options)
                      begin
                        Faye::Authentication.validate(message['signature'],
                                                      message['subscription'] || message['channel'],
            Severity: Minor
            Found in lib/faye/authentication/server_extension.rb - About 35 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 authentication_required has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

            FayeAuthentication.prototype.authentication_required = function(message) {
              var subscription_or_channel = message.subscription || message.channel;
              if (message.channel.lastIndexOf('/meta/subscribe') === 0 || message.channel.lastIndexOf('/meta/', 0) !== 0) {
                if(this._options.whitelist) {
                  try {
            Severity: Minor
            Found in app/assets/javascripts/faye-authentication.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

            Severity
            Category
            Status
            Source
            Language