Showing 57 of 83 total issues
Function request
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
request: function(messages) {
var href = this.endpoint.href,
xhr = Faye.ENV.ActiveXObject ? new ActiveXObject('Microsoft.XMLHTTP') : new XMLHttpRequest(),
self = this;
Consider simplifying this complex logical expression. Open
if ((element && element !== register._element) ||
(eventName && eventName !== register._type) ||
(callback && callback !== register._callback) ||
(context && context !== register._context))
continue;
Method advize
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def advize(response, connection_type)
return unless [Channel::HANDSHAKE, Channel::CONNECT].include?(response['channel'])
if connection_type == 'eventsource'
interval = (@engine.timeout * 1000).floor
- 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 subscribe
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
subscribe: function(channel, callback, context) {
if (channel instanceof Array)
return Faye.map(channel, function(c) {
return this.subscribe(c, callback, context);
}, this);
Method process
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
def process(messages, env, &callback)
local = env.nil?
messages = [messages].flatten
info('Processing messages: ? (local: ?)', messages, local)
Method subscribe
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
def subscribe(channel, force = false, &block)
if Array === channel
return channel.map { |c| subscribe(c, force, &block) }
end
Method handle_websocket
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def handle_websocket(request)
options = {:extensions => @extensions, :ping => @options[:ping]}
ws = Faye::WebSocket.new(request.env, [], options)
client_id = nil
- 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
Method call
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def call(env)
Faye.ensure_reactor_running!
request = Rack::Request.new(env)
unless request.path_info =~ @endpoint_re
- 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
Method disconnect
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def disconnect(message, local = false, &callback)
response = make_response(message)
client_id = message['clientId']
@engine.client_exists(client_id) do |exists|
- 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
Method create
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
def create
respond_to do |format|
@message = @conversation.messages.new(message_params)
@messages = @conversation.messages
if @messages.length==0
Method call
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
def call(env)
filename = File.basename(env['PATH_INFO'])
filename = @path_map[filename] || filename
cache = @index[filename] ||= {}
Method async_each
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
def self.async_each(list, iterator, callback)
n = list.size
i = -1
calls = 0
looping = false
Method process
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def process(messages, env, &callback)
local = env.nil?
messages = [messages].flatten
info('Processing messages: ? (local: ?)', messages, local)
- 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
Method receive_message
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def receive_message(message)
id = message['id']
if message.has_key?('successful')
callback = @response_callbacks.delete(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
Method unsubscribe
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def unsubscribe(channel, &block)
if Array === channel
return channel.map { |c| unsubscribe(c, &block) }
end
- 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
Method handshake
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def handshake(&block)
return if @advice['reconnect'] == NONE
return if @state != UNCONNECTED
@state = CONNECTING
- 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
Method handle_error
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def handle_error(message, immediate = false)
return unless envelope = @envelopes[message['id']]
return unless request = envelope.request
request.callback do |req|
- 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
Method remove_extension
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def remove_extension(extension)
return unless @extensions
@extensions.delete_if do |ext|
next false unless ext == extension
extension.removed(self) if extension.respond_to?(:removed)
- 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
Method unsubscribe
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def unsubscribe(client_id, channel, &callback)
if @clients.has_key?(client_id)
should_trigger = @clients[client_id].delete?(channel)
@clients.delete(client_id) if @clients[client_id].empty?
end
- 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 deeply nested control flow statements. Open
if (v) {
partial.push(quote(k) + (gap ? ': ' : ':') + v);
}