Showing 42 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();
Identical blocks of code found in 2 locations. Consider refactoring. Open
return {
abort: function() {
runner.abort();
},
forceMinPriority: function(p) {
- Read upRead up
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Identical blocks of code found in 2 locations. Consider refactoring. Open
return {
abort: function() {
runner.abort();
},
forceMinPriority: function(p) {
- Read upRead up
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
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) {
Similar blocks of code found in 2 locations. Consider refactoring. Open
if (this.errorScript && this.errorScript.parentNode) {
this.errorScript.parentNode.removeChild(this.errorScript);
this.errorScript = null;
}
- Read upRead up
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 57.
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 2 locations. Consider refactoring. Open
if (this.script && this.script.parentNode) {
this.script.parentNode.removeChild(this.script);
this.script = null;
}
- Read upRead up
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 57.
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
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
Similar blocks of code found in 2 locations. Consider refactoring. Open
prototype.clearRetryTimer = function() {
if (this.retryTimer) {
this.retryTimer.ensureAborted();
this.retryTimer = null;
}
- Read upRead up
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 56.
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 2 locations. Consider refactoring. Open
prototype.abortConnecting = function() {
if (this.runner) {
this.runner.abort();
this.runner = null;
}
- Read upRead up
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 56.
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76