Showing 202 of 278 total issues
Method run
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def run
return unless @kafka_bridge_url && @kafka_bridge_secret && @service_id
return if @kafka_bridge_url.empty? || @kafka_bridge_secret.empty? || @service_id.empty?
KafkaBatchUpdatePoints.where(realtime: true).each do |task|
finished_successfully = 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 show
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def show
if params[:username].present? && params[:session_id].present?
user = User.find_by(login: params[:username])
user ||= User.find_by('lower(email) = ?', params[:username].downcase)
# Allows using oauth2 tokens of the new api for authenticating
- 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 print_setup_phases
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def print_setup_phases(phase = 0)
update_setup_phase(phase) unless phase == 2
maxphase = setup_in_progress? ? session[:ongoing_course_setup][:phase] : phase
STEPS.each_with_index do |st, i|
path = nil
- 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 create
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def create
authorize! :teach, @organization
custom = params[:course][:course_template_id].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
Method run
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def run
return unless @kafka_bridge_url && @kafka_bridge_secret && @service_id
return if @kafka_bridge_url.empty? || @kafka_bridge_secret.empty? || @service_id.empty?
KafkaBatchUpdatePoints.where(realtime: false).each do |task|
finished_successfully = 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 award_points
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def self.award_points(submission, results, review_points)
user = submission.user
exercise = submission.exercise
course = exercise.course
available_points = exercise.available_points.to_a.map(&: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 clean_up
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def clean_up(root_dir_abs, file)
if File.symlink?(file)
dest = File.absolute_path(File.readlink(file), File.dirname(file))
unless dest.start_with?(root_dir_abs)
::Rails.logger.warn("Cleaning up external symlink to: #{dest}")
- 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 show
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
def show
@sheetname = params[:id]
@course = Course.find(params[:course_id])
authorize! :see_points, @course
return respond_unauthorized('Authentication required') if current_user.guest?
Method update_exercises
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
def update_exercises(task)
finished_successfully = false
course = Course.find(task.course_id)
Rails.logger.info("Batch publishing exercises for course #{course.name} with moocfi id: #{course.moocfi_id}.")
if !course.moocfi_id
Method course_data_core_api
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
def course_data_core_api(course)
# UncomputedUnlock.resolve(course, @user)
@unlocked_exercises = course.unlocks
.where(user_id: @user.id)
.where(['valid_after IS NULL OR valid_after < ?', Time.now])
Method refresh
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
def self.refresh(course_template_refresh_task)
course_template = course_template_refresh_task.course_template
command = "#{self.langs_executable_path}/current refresh-course"\
" --cache-path #{course_template.cache_path}"\
" --cache-root #{Course.cache_root}"\
Method generate
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
def generate
visible_exercises, available_points = visible_exercises_and_points_for
data = File.read(File.join(path, 'certificate.html'))
awarded_points = AwardedPoint.course_user_points(course, user).reject do |p|
Method labeled
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
def labeled(label, tags = nil, options = {}, &block)
if tags.is_a?(Hash) && options.empty?
options = tags
tags = nil
end
Method create
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
def create
return respond_forbidden unless current_user.administrator?
users = params[:emails].map do |email|
User.find_by('lower(email) = ?', email.downcase)
end.compact
Method show
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
def show
@exercise = Exercise.find(params[:exercise_id])
@course = @exercise.course
@organization = @course.organization
Method create
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
def create
submission = Submission.find(params[:submission_id])
authorize! :read, submission
answer_params = params[:answers]
Method create
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
def create
submission = Submission.find(params[:submission_id])
authorize! :read, submission
answer_params = params[:answers]
Method course_points
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
def self.course_points(course, include_admins = false, hidden = false, only_for_user = nil)
awarded_points = AwardedPoint.arel_table
users = User.arel_table
exercises = Exercise.arel_table
submissions = Submission.arel_table
Method difference_with_solution
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
def difference_with_solution
@course ||= @submission.course
authorize! :teach, @course
@exercise ||= @submission.exercise
@organization = @course.organization
Method index_csv
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
def index_csv
CSV.generate(force_quotes: true) do |csv|
title_row = (@ordinary_fields + @extra_fields.map(&:name)).select { |f| @visible_columns.include?(f) }.map(&:humanize)
if @group_completion