File grading.rb
has 392 lines of code (exceeds 250 allowed). Consider refactoring. Open
require "csv"
require "utilities"
module AssessmentGrading
# Export all scores for an assessment for all students as CSV
Method save_entries
has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring. Open
def save_entries(entries, data_type)
asmt = @assessment
begin
User.transaction do
- 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 parse_csv_row
has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring. Open
def parse_csv_row(row, kind, problems, emails)
row = row.dup
email = row.shift.to_s
data = row.shift problems.count
- 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 stats_for_grader
has 49 lines of code (exceeds 25 allowed). Consider refactoring. Open
def stats_for_grader(submissions)
result = []
problem_id_to_name = @assessment.problem_id_to_name
stats = Statistics.new
Method quickSetScore
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
def quickSetScore
return unless request.post?
return unless params[:submission_id]
return unless params[:problem_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 quickSetScoreDetails
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
def quickSetScoreDetails
return unless request.post?
return unless params[:submission_id]
return unless params[:problem_id]
# get submission and problem IDs
- 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 bulkGrade
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
def bulkGrade
return unless request.post?
# part 1: submitting a CSV for processing and returning errors in CSV
if params[:upload]
- 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 save_entries
has 44 lines of code (exceeds 25 allowed). Consider refactoring. Open
def save_entries(entries, data_type)
asmt = @assessment
begin
User.transaction do
Method parse_csv_row
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
def parse_csv_row(row, kind, problems, emails)
row = row.dup
email = row.shift.to_s
data = row.shift problems.count
Method stats_for_grader
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def stats_for_grader(submissions)
result = []
problem_id_to_name = @assessment.problem_id_to_name
stats = Statistics.new
- 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 statistics
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
def statistics
load_course_config
latest_submissions = @assessment.submissions.latest_for_statistics.includes(:scores, :course_user_datum)
#latest_submissions = @assessment.submissions.latest.includes(:scores, :course_user_datum)
Method bulkGrade_complete
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def bulkGrade_complete
redirect_to(action: :bulkGrade) && return unless request.post?
# retrieve entries CSV from hidden field in form
csv = params[:confirm][:bulkGrade_csv]
- 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(action: :bulkGrade) && return