Showing 202 of 278 total issues
Avoid deeply nested control flow statements. Open
elsif submission.requires_review?
if can? :create_review, submission.course
link_to 'Required', new_submission_review_path(submission)
else
'Pending'
Method show
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def show
course_id = params[:course_id]
user_id = params[:id]
course = Course.where(id: course_id).first || Course.where(name: course_id).first
- 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 maybe_update_password
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def maybe_update_password
if params[:old_password].present? && params[:password].present?
if !@user.has_password?(params[:old_password])
@user.errors.add(:old_password, 'incorrect')
elsif params[:password] != params[:password_repeat]
- 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 validate
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def validate(record)
kind = record.feedback_question.kind
ans = record.answer.strip
if kind =~ FeedbackQuestion.send(:intrange_regex)
- 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 filter_by
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def self.filter_by(filter_params)
users = includes(:user_field_values)
users = users.where(administrator: false) unless filter_params['include_administrators']
- 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 raise_pretest_error_if_any
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def raise_pretest_error_if_any
unless pretest_error.nil?
error = "Submission failed: #{pretest_error}."
error << if stdout.blank?
"\n\n(no stdout)"
- 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 difference_with_solution
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def difference_with_solution
@course ||= @submission.course
authorize! :teach, @course
@exercise ||= @submission.exercise
@organization = @course.organization
- 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_points
has a Cognitive Complexity of 8 (exceeds 5 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
- 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
Avoid deeply nested control flow statements. Open
if can? :create_review, submission.course
link_to 'Requested', new_submission_review_path(submission)
else
'Requested'
end
Method index
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def index
respond_to do |format|
format.json do
if params[:row_format] == 'datatables'
index_json_datatables
- 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
Avoid deeply nested control flow statements. Open
if remaining > 0
"get #{remaining} more #{plural(remaining, 'point')} from #{group}"
end
Method create
has a Cognitive Complexity of 8 (exceeds 5 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
- 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_dir_containing
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def find_dir_containing(root, to_find)
Pathname(root).find do |path|
next unless path.directory?
next unless (path + to_find).directory?
return path
- 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_user_course_points
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def update_user_course_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}.")
- 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 set_memory_limit
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def set_memory_limit
@rust_data['exercises'].each do |exercise|
ex = @course.exercises.find { |e| e.name == exercise['name'] }
next unless ex
if (exercise['tmcproject-yml'] || {}).include? 'memory_gb'
- 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 set_docker_image
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def set_docker_image
default_image = Exercise.new.docker_image
@rust_data['exercises'].each do |exercise|
ex = @course.exercises.find { |e| e.name == exercise['name'] }
next unless ex
- 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 set_cpu_limit
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def set_cpu_limit
@rust_data['exercises'].each do |exercise|
ex = @course.exercises.find { |e| e.name == exercise['name'] }
next unless ex
if (exercise['tmcproject-yml'] || {}).include? 'cpus'
- 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 check_options
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def check_options
raise ':name required' unless @options[:name]
raise ':erb_path required' unless @options[:erb_path]
raise ':working_dir required' unless @options[:working_dir]
raise ':executable_path required' unless @options[:executable_path]
- 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_course_points
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def update_course_points(task)
finished_successfully = false
course = Course.find(task.course_id)
Rails.logger.info("Batch publishing points for course #{course.name} with moocfi id: #{course.moocfi_id}")
if !course.moocfi_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
Consider simplifying this complex logical expression. Open
elsif !@exercise.visible_to?(user)
false
else
show_when_completed = SiteSetting.value('show_model_solutions_when_exercise_completed')
show_when_expired = SiteSetting.value('show_model_solutions_when_exercise_expired')