Showing 30 of 53 total issues
Class Student
has 86 methods (exceeds 20 allowed). Consider refactoring. Open
class Student < User
scope :with_activated_accounts, -> { where('sign_in_count > ?', 0 ) }
validate :primary_payment_method_belongs_to_student
File student.rb
has 475 lines of code (exceeds 250 allowed). Consider refactoring. Open
class Student < User
scope :with_activated_accounts, -> { where('sign_in_count > ?', 0 ) }
validate :primary_payment_method_belongs_to_student
Class Course
has 48 methods (exceeds 20 allowed). Consider refactoring. Open
class Course < ApplicationRecord
default_scope { order(:start_date) }
scope :fulltime_courses, -> { where(parttime: false) }
scope :parttime_intro_courses, -> { joins(:track).where("tracks.description IN (?)", ['Part-Time Intro to Programming', 'Part-Time Evening Intro to Programming']) }
Method update_student_as_admin
has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring. Open
def update_student_as_admin
@student = Student.find(params[:id])
if @student.update(student_params)
if student_params[:cohort_id]
redirect_to student_courses_path(@student), notice: "Current cohort for #{@student.name} has been set to #{@student.cohort.try(:description) || 'blank'}."
- 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
Class CrmLead
has 30 methods (exceeds 20 allowed). Consider refactoring. Open
class CrmLead
def initialize(email)
@email = email
end
Method create
has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring. Open
def create
@cohort = Cohort.find_by_id(params[:enrollment][:cohort_id])
@course = Course.find_by_id(params[:enrollment][:course_id])
@student = Student.find(params[:enrollment][:student_id])
@previous_current_cohort = @student.cohort
- 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 index
has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring. Open
def index
if params[:student_id]
@student = Student.find_by_id(params[:student_id])
if @student
@courses = @student.courses
- 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 after_sign_in_path_for
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
def after_sign_in_path_for(user)
if user.is_a? Admin
user.otp_required_for_login ? course_path(user.current_course) : new_otp_path
elsif user.is_a? Company
company_path(user)
- 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 build_code_reviews
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
def build_code_reviews
code_review_params = Github.get_layout_params(layout_file_path)['code_reviews']
if code_review_params.try(:any?)
order_number = 0
visible_day_of_week, visible_time, due_days_later, due_time, submissions_not_required, always_visible = code_review_params['settings'].values_at 'visible_day_of_week', 'visible_time', 'due_days_later', 'due_time', 'submissions_not_required', 'always_visible'
- 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 destroy
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
def destroy
if params['really_destroy'] == 'true'
enrollment = Enrollment.only_deleted.find(params[:id])
enrollment.really_destroy!
redirect_to student_courses_path(enrollment.student), notice: "Enrollment permanently removed: #{enrollment.course.description}"
- 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 update_student_as_admin
has 45 lines of code (exceeds 25 allowed). Consider refactoring. Open
def update_student_as_admin
@student = Student.find(params[:id])
if @student.update(student_params)
if student_params[:cohort_id]
redirect_to student_courses_path(@student), notice: "Current cohort for #{@student.name} has been set to #{@student.cohort.try(:description) || 'blank'}."
Method index
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
def index
if current_admin
@journals = CodeReview.where(journal: true)
if params[:cohort_id]
@cohort = Cohort.find(params[:cohort_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 get_status
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
def get_status
if deleted?
"Archived"
elsif courses_with_withdrawn.empty?
"Not enrolled"
- 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 update
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def update
if params[:source_course_id]
move_submissions
elsif submission_params['times_submitted']
@submission = Submission.find(params[: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 update
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
def update
if params[:source_course_id]
move_submissions
elsif submission_params['times_submitted']
@submission = Submission.find(params[:id])
Method create
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
def create
@cohort = Cohort.find_by_id(params[:enrollment][:cohort_id])
@course = Course.find_by_id(params[:enrollment][:course_id])
@student = Student.find(params[:enrollment][:student_id])
@previous_current_cohort = @student.cohort
Method set_class_days
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def set_class_days(number_of_weeks:, days_of_week:)
number_of_days = number_of_weeks * days_of_week.count
class_days = []
day = start_date
number_of_days.times 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 update_payment_status
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def update_payment_status(event, status)
payment = Payment.find_by(stripe_transaction: stripe_transaction(event))
if payment && payment.status == "pending"
Rails.logger.info "Stripe Callback: updating #{stripe_transaction(event)} to #{status}"
if payment.try(:update, status: status)
- 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
Function stripeResponseHandler
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
var stripeResponseHandler = function(status, response) {
if (status === 200) {
$("input#card_number").val('****************');
$("input#cvc_code").val('***');
$("input#expiration_month").val('**');
Method attendance_records_for
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def attendance_records_for(status, start_course=nil, end_course=nil)
attributes = { tardy: { tardy: true },
left_early: { left_early: true },
on_time: { tardy: false, left_early: false },
all: {}
- 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"