Method user_activity
has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring. Open
def user_activity(user, from, to, limit, publish=false)
activity_feed_keys = user.nil? ? Audience.to_key(Audience.all).to_a : user.subscribed_channels.map { |channel| Audience.channel_to_key(channel) }
count = 0
from = from.nil? ? "-inf" : from.to_f
- 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 user_activity
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def user_activity(user, from, to, limit, publish=false)
Method extra_information
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def extra_information(data)
extra_info = {}
u = User.find_by_username(data['user']['username']) unless data['user'].nil?
extra_info.merge!(user_info(u)) unless u.nil?
extra_info.merge!(team_info(u.team)) unless u.nil? or u.team.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 generate_event
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def generate_event(event_type, audience, data={}, drip_rate=:immediately)
data.merge!({ event_type: event_type }.with_indifferent_access)
data = { version: VERSION, event_id: Time.now.utc.to_i }.with_indifferent_access.merge(data)
data.deep_merge!(extra_information(data))
drip_rate = :immediately if drip_rate.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"