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
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;
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);
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;
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;
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];
Function send
has 43 lines of code (exceeds 25 allowed). Consider refactoring. Open
prototype.send = function(id, data, callback) {
if (this.script) {
return false;
}
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
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
- Read upRead up
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();
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);
}
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) {
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();
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
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
- Read upRead up
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) {
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)
- Read upRead up
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";
Avoid too many return
statements within this function. Open
return "refused";
Avoid too many return
statements within this function. Open
return "retry";