Method local_submit
has a Cognitive Complexity of 46 (exceeds 5 allowed). Consider refactoring. Open
def local_submit
@user = User.find_by(email: params[:user])
@cud = @user ? @course.course_user_data.find_by(user_id: @user.id) : nil
unless @cud
err = "ERROR: invalid username (#{params[:user]}) for class #{@course.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 local_submit
has 108 lines of code (exceeds 25 allowed). Consider refactoring. Open
def local_submit
@user = User.find_by(email: params[:user])
@cud = @user ? @course.course_user_data.find_by(user_id: @user.id) : nil
unless @cud
err = "ERROR: invalid username (#{params[:user]}) for class #{@course.id}"
File handin.rb
has 301 lines of code (exceeds 250 allowed). Consider refactoring. Open
require "pathname"
##
# Handles different handin methods, including web form, local_submit and log_submit
#
Method handin
has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring. Open
def handin
if @assessment.disable_handins?
flash[:error] = "Sorry, handins are disabled for this assessment."
redirect_to(action: :show)
return false
- 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 handin
has 62 lines of code (exceeds 25 allowed). Consider refactoring. Open
def handin
if @assessment.disable_handins?
flash[:error] = "Sorry, handins are disabled for this assessment."
redirect_to(action: :show)
return false
Method log_submit
has 57 lines of code (exceeds 25 allowed). Consider refactoring. Open
def log_submit
@user = User.find_by(email: params[:user])
@cud = @user ? @course.course_user_data.find_by(user_id: @user.id) : nil
unless @cud
err = "ERROR: invalid username (#{params[:user]}) for class #{@course.id}"
Method log_submit
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
def log_submit
@user = User.find_by(email: params[:user])
@cud = @user ? @course.course_user_data.find_by(user_id: @user.id) : nil
unless @cud
err = "ERROR: invalid username (#{params[:user]}) for class #{@course.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
Avoid too many return
statements within this method. Open
redirect_to([:history, @course, @assessment]) && return
Avoid too many return
statements within this method. Open
render(plain: flash[:error], status: :bad_request) && return
Avoid too many return
statements within this method. Open
render(plain: "Successfully submitted\n") && return
Avoid too many return
statements within this method. Open
render(plain: "Invalid path to file", status: :bad_request) && return
Avoid too many return
statements within this method. Open
redirect_to(action: :show) && return
Avoid too many return
statements within this method. Open
render(plain: remote_handin_dir) && return
Avoid too many return
statements within this method. Open
render(plain: "OK", status: 200) && return
Avoid too many return
statements within this method. Open
render(plain: err, status: :bad_request) && return
Avoid too many return
statements within this method. Open
render(plain: " - You have #{remaining} submissions left\n") && return
Avoid too many return
statements within this method. Open
render(plain: "OK", status: 200) && return if scores.keys.length == 0
Avoid too many return
statements within this method. Open
status: :bad_request) && return
Avoid too many return
statements within this method. Open
render(plain: "WARNING: could not clear previous handin directory, please") && return
Avoid too many return
statements within this method. Open
render(plain: flash[:error], status: :bad_request) && return unless validateHandinForGroups_forHTML