Method show
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
def show
respond_to do |format|
format.html do
# see notes in application.rb on how this works
update_last_seen_at
- 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 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
def create
topic_saved, post_saved = false, false
# this is icky - move the topic/first post workings into the topic model?
Topic.transaction do
@topic = @forum.topics.build(:title => params[:topic][:title])
Method create
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def create
topic_saved, post_saved = false, false
# this is icky - move the topic/first post workings into the topic model?
Topic.transaction do
@topic = @forum.topics.build(:title => params[:topic][:title])
- 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 assign_protected
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def assign_protected
@topic.user = current_user if @topic.new_record?
# admins and moderators can sticky and lock topics
return unless admin? or current_user.moderator_of?(@topic.forum)
@topic.sticky, @topic.locked = params[:topic][:sticky], params[:topic][:locked]
- 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"