app/controllers/rooms_controller.rb
Class RoomsController
has 32 methods (exceeds 20 allowed). Consider refactoring. Open
Open
class RoomsController < ApplicationController
include Premium
before_action :guest_check, only: [:show, :leaflet_view]
Method leaflet_submit
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
Open
def leaflet_submit
head(:bad_request) and return if params[:votes].blank? || @room.closed?
params[:votes].values.each do |vote|
next unless @room.stories.pluck(:uid).include?(vote[:story_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 create
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
Open
def create
@room = repo.new_entity(room_params.merge(created_by: current_user.id))
if @room.async_mode?
premium_check(billing_path, "Only premium user can create async rooms, be our premium member.", !current_user.premium?); return if performed?
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"