File response_controller.rb
has 316 lines of code (exceeds 250 allowed). Consider refactoring. Open
class ResponseController < ApplicationController
include AuthorizationHelper
include ResponseHelper
helper :submitted_content
Class ResponseController
has 24 methods (exceeds 20 allowed). Consider refactoring. Open
class ResponseController < ApplicationController
include AuthorizationHelper
include ResponseHelper
helper :submitted_content
Method edit
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
def edit
assign_action_parameters
@prev = Response.where(map_id: @map.id)
@review_scores = @prev.to_a
if @prev.present?
Method create
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
def create
map_id = params[:id]
unless params[:map_id].nil?
map_id = params[:map_id]
end # pass map_id as a hidden field in the review form
Method edit
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def edit
assign_action_parameters
@prev = Response.where(map_id: @map.id)
@review_scores = @prev.to_a
if @prev.present?
- 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 redirect
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
def redirect
error_id = params[:error_msg]
message_id = params[:msg]
flash[:error] = error_id unless error_id&.empty?
flash[:note] = message_id unless message_id&.empty?
Method update
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def update
render nothing: true unless action_allowed?
msg = ''
begin
# the response to be updated
- 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 8 (exceeds 5 allowed). Consider refactoring. Open
def create
map_id = params[:id]
unless params[:map_id].nil?
map_id = params[:map_id]
end # pass map_id as a hidden field in the review form
- 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 new_feedback
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def new_feedback
review = Response.find(params[:id]) unless params[:id].nil?
if review
reviewer = AssignmentParticipant.where(user_id: session[:user].id, parent_id: review.map.assignment.id).first
map = FeedbackResponseMap.where(reviewed_object_id: review.id, reviewer_id: reviewer.id).first
- 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 action_allowed?
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def action_allowed?
response = user_id = nil
action = params[:action]
# Initialize response and user id if action is edit or delete or update or view.
if %w[edit delete update view].include?(action)
- 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
unexpected token error
(Using Ruby 2.1 parser; configure using TargetRubyVersion
parameter, under AllCops
) Open
flash[:error] = error_id unless error_id&.empty?
- Exclude checks
unexpected token error
(Using Ruby 2.1 parser; configure using TargetRubyVersion
parameter, under AllCops
) Open
flash[:note] = message_id unless message_id&.empty?
- Exclude checks