Showing 202 of 278 total issues
Method update_user_progress
has 38 lines of code (exceeds 25 allowed). Consider refactoring. Open
def update_user_progress(task)
finished_successfully = false
user = User.find(task.user_id)
course = Course.find(task.course_id)
Rails.logger.info("Publishing progress for user #{user.id} with moocfi id: #{course.moocfi_id}.")
Method run
has 38 lines of code (exceeds 25 allowed). Consider refactoring. Open
def run
CourseTemplateRefresh.where(status: :not_started).each do |task|
channel_id = task.course_template_id
task.status = :in_progress
task.save!
Method course_stats_show_submissions
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
def course_stats_show_submissions
return respond_not_found('No submissions yet') if @course.submissions.empty?
@start_time =
if params[:start_time]
Method index
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
def index
unauthorize_guest!
exercise = Exercise.find(params[:exercise_id])
course = exercise.course
authorize! :read, exercise
Method update
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def update
User.transaction do
@user = current_user
@email_before = @user.email
- 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 exercise_group_completion_counts_for_user
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def exercise_group_completion_counts_for_user(user)
# TODO: clean up exercise group discovery
groups = exercises.enabled.map(&:name).map { |name| name =~ /^(.+)-[^-]+$/ ? Regexp.last_match(1) : '' }.uniq.sort
- 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 course_stats_show_submissions
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def course_stats_show_submissions
return respond_not_found('No submissions yet') if @course.submissions.empty?
@start_time =
if params[:start_time]
- 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
authorize! :update, @user
User.transaction do
@email_before = @user.email
- 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 for_submission
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def self.for_submission(submission)
Dir.mktmpdir do |tmpdir|
zip_path = "#{tmpdir}/submission.zip"
File.open(zip_path, 'wb') { |f| f.write(submission.return_file) }
SafeUnzipper.new.unzip(zip_path, tmpdir)
- 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 assign_show_view_vars
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def assign_show_view_vars
@exercises = @course.exercises.includes(:course)
@exercises.preload(:unlocks).where(unlocks: { user: current_user })
@exercises = @exercises.select { |ex| ex.visible_to?(current_user) }
.natsort_by(&:name)
- 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 refresh_course
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def refresh_course(course, data)
@report = Report.new
@rust_data = data['output-data']
Course.transaction(requires_new: true) do
@course = Course.find(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 load_fields
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
def self.load_fields(kind, config_file_path)
return [] unless File.exist?(config_file_path)
kind = kind.to_s
Method check_access!
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
def check_access!
if current_user.guest?
raise CanCan::AccessDenied
end
Method index
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
def index
if params[:course_id]
fetch :course
@organization = @course.organization
@my_reviews = @course.submissions
Method submission_review_column
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
def submission_review_column(submission)
if submission.reviewed?
if can? :create_review, submission.course
link_to 'Available', new_submission_review_path(submission)
else
Method index
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
def index
@course = Course.find(params[:course_id])
authorize! :see_points, @course
return respond_unauthorized('Authentication required') if current_user.guest?
add_course_breadcrumb
Method course_data
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
def course_data(organization, course, opts = {})
@course = course
data = {
id: course.id,
name: course.name,
Method create
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
def create
return respond_forbidden unless current_user.administrator?
users = if params[:extra_fields]
User.eager_load(:user_field_values).where(login: params[:usernames])
else
Method create
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
def create
return respond_forbidden unless current_user.administrator?
users = if params[:extra_fields]
User.eager_load(:user_field_values).where(id: params[:ids])
else
Method exercise_data
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
def exercise_data(exercise)
return nil unless exercise.visible_to?(@user)
# optimization: use @unlocked_exercises to avoid querying unlocks repeatedly
locked = exercise.requires_unlock? && !@unlocked_exercises.include?(exercise.name)