app/structs/audience.rb
Method expand
has a Cognitive Complexity of 42 (exceeds 5 allowed). Consider refactoring. Open
Open
def self.expand(audience)
audience.keys.map(&:to_sym).collect do |target|
if target == :user_reach
user = User.find(audience[target])
- 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
Class Audience
has 21 methods (exceeds 20 allowed). Consider refactoring. Open
Open
class Audience
def self.all
{ all: nil }
end
Method expand
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
def self.expand(audience)
audience.keys.map(&:to_sym).collect do |target|
if target == :user_reach
user = User.find(audience[target])
Avoid deeply nested control flow statements. Open
Open
expand_followers(user) unless user.nil?
Method expand_reach
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
Open
def self.expand_reach(user_or_team)
audiences = []
audiences.concat(expand_followers(user_or_team))
if user_or_team.is_a?(Team)
- 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
Open
elsif target == :team_followers
team = Team.find(audience[target])
expand_followers(team) unless team.nil?
elsif target == :all
expand_all_users