Showing 202 of 278 total issues
Method run
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
def run
Rails.logger.info('Creating directory vendor/tmc-langs-rust') unless File.directory?('vendor/tmc-langs-rust')
Dir.mkdir('vendor/tmc-langs-rust') unless File.directory?('vendor/tmc-langs-rust')
executable = "vendor/tmc-langs-rust/tmc-langs-cli-x86_64-unknown-linux-gnu-#{@@rust_langs_version}"
Method filter_fields!
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
def self.filter_fields!(submissions)
submissions.map! do |sub|
{
id: sub.id,
user_id: sub.user_id,
Method show
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
def show
unauthorize_guest! if current_user.guest?
user = current_user
user = User.find_by!(id: params[:id]) unless params[:id] == 'current'
authorize! :read, user
Method update_user_points
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
def update_user_points(task)
finished_successfully = false
course = Course.find(task.course_id)
user = User.find(task.user_id)
Rails.logger.info("Publishing points for user #{user.id} with moocfi id: #{course.moocfi_id}.")
Method exercise_data_core_api
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
def exercise_data_core_api(exercise)
# optimization: use @unlocked_exercises to avoid querying unlocks repeatedly
locked = exercise.requires_unlock? && !@unlocked_exercises.include?(exercise.name)
show_points = !exercise.hide_submission_results? && !exercise.course.hide_submission_results?
attempted = exercise.attempted_by?(@user)
Method update
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def update
unauthorize_guest! if current_user.guest?
User.transaction do
@user = current_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 find_all_files_under
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def self.find_all_files_under(root_dir)
files = []
total_size = 0
Pathname(root_dir).realpath.find do |file|
next unless file.size <= MAX_INDIVIDUAL_FILE_SIZE
- 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 10 (exceeds 5 allowed). Consider refactoring. Open
def index
if params[:course_id]
fetch :course
@organization = @course.organization
@my_reviews = @course.submissions
- 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 confirm_email
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def confirm_email
language = params[:language]
VerificationToken.unscoped.email.find_by!(user_id: params[:user_id], token: params[:id])
redirect_path = root_url
redirect_path = "https://course.elementsofai.com/#{language && language != "en" ? "#{language}/" : ''}email-verification" if params[:origin] && params[:origin].start_with?('elements_of_ai')
- 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 10 (exceeds 5 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
- 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 10 (exceeds 5 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
- 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 10 (exceeds 5 allowed). Consider refactoring. Open
def create
authorize! :modify_assistants, @course
if params[:commit] == 'Add new assistant'
new_assistant = User.find_by('lower(email) = ?', assistant_params[:email].downcase)
- 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 10 (exceeds 5 allowed). Consider refactoring. Open
def show
authorization_skip!
organization = Organization.find_by!(slug: params[:organization_slug])
course = organization.courses.find_by(name: "#{params[:organization_slug]}-#{params[:course_name]}")
course = organization.courses.find_by!(name: params[:course_name]) unless course
- 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_data
has a Cognitive Complexity of 10 (exceeds 5 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)
- 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_exercise_checksums
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def update_exercise_checksums
@rust_data['exercises'].each do |exercise|
ex = @course.exercises.find { |e| e.name == exercise['name'] }
next unless ex
if ex.checksum != exercise['checksum']
- 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_results
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def self.save_results(submission, results)
ActiveRecord::Base.transaction do
raise InvalidTokenError, 'Invalid or expired token' if results['token'] != submission.secret_token
submission.all_tests_passed = 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 <=>
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def <=>(other)
if other.is_a?(Version)
p1 = parts.clone
p2 = other.parts.clone
p1 << 0 while p1.length < p2.length
- 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 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
def create
authorize! :create, User
@user = User.new
Method visible_to?
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
def visible_to?(user, ignore_email_verification = false)
if user.administrator?
true
elsif !ignore_email_verification && !user.email_verified?
false
Method run
has 27 lines of code (exceeds 25 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