Showing 122 of 226 total issues
Method sign_in_at_oauth_origin
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
def sign_in_at_oauth_origin
if user.present?
user.regenerate_login_token
encrypted_token =
Method courses
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
def courses
if current_user.blank?
current_school
.courses
.live
Method average_grades
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
def average_grades
@average_grades ||=
begin
averaged =
TimelineEventGrade
Method applicable_submissions
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
def applicable_submissions
stage_1 = course.timeline_events.not_auto_verified.live
# Filter by target
stage_2 =
Method targets
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
def targets(role: nil)
@targets ||=
begin
scope =
course.targets.live.includes(
Method validate
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
def validate(_object, context, value)
target = Target.find_by(id: value[:target_id])
assignment = target.assignments.not_archived.first
course = target.course
student =
Method create_quiz
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
def create_quiz(assignments)
assignments.each do |old_assignment, new_assignment|
next unless old_assignment.quiz?
# create quiz
Method courses
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
def courses
@courses ||=
begin
if current_school_admin.present?
current_school
Method save_report
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
def save_report
SubmissionReport.transaction do
report =
SubmissionReport.find_by(
submission_id: @params[:submission_id],
Method save_report
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
def save_report
SubmissionReport.transaction do
report =
SubmissionReport.find_by(
submission_id: @params[:submission_id],
Function captureUnhandledRejections
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
captureUnhandledRejections: function (r, e, o) {
if (r) {
"function" == typeof r._rollbarURH &&
r._rollbarURH.belongsToShim &&
r.removeEventListener("unhandledrejection", r._rollbarURH);
Method prepare_courses
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
def prepare_courses
cohorts = @organisation.cohorts.includes(:course).uniq
courses =
cohorts.each_with_object({}) do |cohort, courses|
Method save_report
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
def save_report
SubmissionReport.transaction do
report =
SubmissionReport.find_by(
submission_id: @params[:submission_id],
Function onreadystatechange
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
a(function () {
if (
!(
l ||
(this.readyState &&
Method create_video_resource
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
def create_video_resource(size, name, description)
data = {
upload: {
approach: 'tus',
size: size
Method compute_grading_for_submissions
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
Open
def compute_grading_for_submissions(target, team_ids)
submissions(target)
.order(:created_at)
.distinct
.each_with_object(Array.new(team_ids.length)) do |submission, grading|
- 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 sanitize_students
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
Open
def sanitize_students(students)
team_sizes = {}
students.select do |student|
if student.team_name.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 toggle_standing
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
def toggle_standing
authorize current_school
standing_enabled = params[:enable_standing] == "true"
Method update_student_details
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
def update_student_details
if student&.name != @params[:name].strip
Users::LogUsernameUpdateService.new(
current_user,
@params[:name],
Method create_submission
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
def create_submission
submission =
TimelineEvent.transaction do
target
.timeline_events