anilmaurya/bidder

View on GitHub

Showing 23 of 42 total issues

File pusher.js has 2600 lines of code (exceeds 250 allowed). Consider refactoring.
Open

/*!
 * Pusher JavaScript Library v2.1.6
 * http://pusherapp.com/
 *
 * Copyright 2013, Pusher
Severity: Major
Found in app/assets/javascripts/pusher.js - About 1 wk to fix

    Function Pusher has 71 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      function Pusher(app_key, options) {
        checkAppKey(app_key);
        options = options || {};
    
        var self = this;
    Severity: Major
    Found in app/assets/javascripts/pusher.js - About 2 hrs to fix

      Function connect has 66 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        prototype.connect = function(minPriority, callback) {
          if (!this.isSupported()) {
            return failAttempt(new Pusher.Errors.UnsupportedStrategy(), callback);
          } else if (this.priority < minPriority) {
            return failAttempt(new Pusher.Errors.TransportPriorityTooLow(), callback);
      Severity: Major
      Found in app/assets/javascripts/pusher.js - About 2 hrs to fix

        Function connect has 48 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          prototype.connect = function(minPriority, callback) {
            var self = this;
        
            var strategies = this.strategies;
            var current = 0;
        Severity: Minor
        Found in app/assets/javascripts/pusher.js - About 1 hr to fix

          Function bindListeners has 47 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            prototype.bindListeners = function() {
              var self = this;
          
              var onMessage = function(m) {
                var message;
          Severity: Minor
          Found in app/assets/javascripts/pusher.js - About 1 hr to fix

            Function connect has 46 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              prototype.connect = function(minPriority, callback) {
                var encrypted = this.encrypted;
                var info = fetchTransportCache(encrypted);
            
                var strategies = [this.strategy];
            Severity: Minor
            Found in app/assets/javascripts/pusher.js - About 1 hr to fix

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

                prototype.send = function(id, data, callback) {
                  if (this.script) {
                    return false;
                  }
              
              
              Severity: Minor
              Found in app/assets/javascripts/pusher.js - About 1 hr to fix

                Function getDefaultStrategy has 40 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                  Pusher.getDefaultStrategy = function(config) {
                    return [
                      [":def", "ws_options", {
                        hostUnencrypted: config.wsHost + ":" + config.wsPort,
                        hostEncrypted: config.wsHost + ":" + config.wssPort
                Severity: Minor
                Found in app/assets/javascripts/pusher.js - About 1 hr to fix

                  Method next_move has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                  Open

                    def next_move(opponent_amount, level)
                      if self.current_amount == 0
                        return 0
                      elsif opponent_amount == 0
                        return 1
                  Severity: Minor
                  Found in app/models/player.rb - 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 ajax has 32 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      ajax: function(socketId, callback){
                        var self = this, xhr;
                  
                        if (Pusher.XHR) {
                          xhr = new Pusher.XHR();
                  Severity: Minor
                  Found in app/assets/javascripts/pusher.js - About 1 hr to fix

                    Function def_transport has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        def_transport: function(context, name, type, priority, options, manager) {
                          var transportClass = transports[type];
                          if (!transportClass) {
                            throw new Pusher.Errors.UnsupportedTransport(type);
                          }
                    Severity: Minor
                    Found in app/assets/javascripts/pusher.js - About 1 hr to fix

                      Function tryStrategy has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                        prototype.tryStrategy = function(strategy, minPriority, options, callback) {
                          var timer = null;
                          var runner = null;
                      
                          if (options.timeout > 0) {
                      Severity: Minor
                      Found in app/assets/javascripts/pusher.js - About 1 hr to fix

                        Function bindListeners has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                          prototype.bindListeners = function() {
                            var self = this;
                        
                            self.onMessage = function(m) {
                              self.unbindListeners();
                        Severity: Minor
                        Found in app/assets/javascripts/pusher.js - About 1 hr to fix

                          Function createConnection has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                            prototype.createConnection = function(name, priority, key, options) {
                              var self = this;
                          
                              var options = Pusher.Util.extend({}, options, {
                                activityTimeout: self.pingDelay
                          Severity: Minor
                          Found in app/assets/javascripts/pusher.js - About 1 hr to fix

                            Method create has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                            Open

                              def create
                                if request.xhr?
                                  game_invite_params = params[:game_invite] || {}
                                  @game_invite = GameInvite.new(game_invite_params.merge!(sender_user_id: current_user.id))
                                  if @game_invite.save
                            Severity: Minor
                            Found in app/controllers/game_invites_controller.rb - 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 def_transport has 6 arguments (exceeds 4 allowed). Consider refactoring.
                            Open

                                def_transport: function(context, name, type, priority, options, manager) {
                            Severity: Minor
                            Found in app/assets/javascripts/pusher.js - About 45 mins to fix

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

                                def game_result
                                  @game_move.update_attributes(player_1_bid: @game.player_1.next_move(@game.player_2.current_amount, @game.level)) if @game.practise
                                  if @game_move.player_1_bid && @game_move.player_2_bid
                                    process_game
                                    @new_game_move = GameMove.create(game_id: @game.id)
                              Severity: Minor
                              Found in app/controllers/game_moves_controller.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

                              Avoid too many return statements within this function.
                              Open

                                    return "backoff";
                              Severity: Major
                              Found in app/assets/javascripts/pusher.js - About 30 mins to fix

                                Avoid too many return statements within this function.
                                Open

                                      return "refused";
                                Severity: Major
                                Found in app/assets/javascripts/pusher.js - About 30 mins to fix

                                  Avoid too many return statements within this function.
                                  Open

                                        return "retry";
                                  Severity: Major
                                  Found in app/assets/javascripts/pusher.js - About 30 mins to fix
                                    Severity
                                    Category
                                    Status
                                    Source
                                    Language