Showing 202 of 278 total issues
Method index
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
def index
unauthorize_guest!
course = Course.find_by!(id: params[:course_id]) if params[:course_id]
can_see_everything = current_user.administrator? || current_user.teacher?(course.organization) || current_user.assistant?(course)
authorize! :read, 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 send_submission
has 47 lines of code (exceeds 25 allowed). Consider refactoring. Open
def send_submission(submission, notify_url)
exercise = submission.exercise
raise 'Submission has no secret token' if submission.secret_token.blank?
raise "Exercise #{submission.exercise_name} for submission gone. Cannot resubmit." if exercise.nil?
Method update
has 47 lines of code (exceeds 25 allowed). Consider refactoring. Open
def update
authorize! :teach, @organization
print_setup_phases(3)
Method show
has 46 lines of code (exceeds 25 allowed). Consider refactoring. Open
def show
@exercise = Exercise.find(params[:id])
@course = Course.lock('FOR SHARE').find(@exercise.course_id)
@organization = @course.organization
authorize! :read, @course
Method show
has 46 lines of code (exceeds 25 allowed). Consider refactoring. Open
def show
@user = User.find(params[:id])
authorize! :view_participant_information, @user
# TODO: bit ugly -- and now it's even worse!
@awarded_points =
Method email_confirmation
has 46 lines of code (exceeds 25 allowed). Consider refactoring. Open
def email_confirmation(user, origin = nil, language = nil)
@origin = origin
@user = user
token = user.verification_tokens.email.create!
@url = confirm_email_url(@user.id, token.token, language: language)
Method index
has 45 lines of code (exceeds 25 allowed). Consider refactoring. Open
def index
unauthorize_guest!
course = Course.find_by!(id: params[:course_id]) if params[:course_id]
can_see_everything = current_user.administrator? || current_user.teacher?(course.organization) || current_user.assistant?(course)
authorize! :read, course
Method index
has 44 lines of code (exceeds 25 allowed). Consider refactoring. Open
def index
if @organization.nil?
authorize! :view, :participants_list
courses = Course.all
users = User.all
Method bootstrap_flash
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
def bootstrap_flash
flash_messages = []
flash.each do |type, message|
# Skip empty messages, e.g. for devise messages set to nothing in a locale file.
next if message.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 index
has a Cognitive Complexity of 14 (exceeds 5 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
- 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 14 (exceeds 5 allowed). Consider refactoring. Open
def show
@user = User.find(params[:id])
authorize! :view_participant_information, @user
# TODO: bit ugly -- and now it's even worse!
@awarded_points =
- 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 43 lines of code (exceeds 25 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
Method update_user_course_points
has 42 lines of code (exceeds 25 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}.")
Function makeToc
has 40 lines of code (exceeds 25 allowed). Consider refactoring. Open
function makeToc($targetElement) {
function makeId(text) {
return text.replace(/[^_a-zA-Z0-9]+/ig, '_').toLowerCase();
}
Method check_client_minimum_version
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
def check_client_minimum_version(client_name, client_version)
begin
client_version = Version.new(client_version) unless client_version.nil?
rescue StandardError
raise "\nInvalid version string: #{client_version}\n"
- 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_client_version
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
def check_client_version(client_name, client_version)
begin
client_version = Version.new(client_version) unless client_version.nil?
rescue StandardError
raise "Invalid version string: #{client_version}"
- 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 sh!
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
def sh!(*args)
options = {
assert_silent: false,
escape: true,
timeout: 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 write_points
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
def self.write_points(ws, course, students, points)
students.each do |student|
row = student_row ws, student.login
raise "student #{student.login} not found" if row < 0
awarded = AwardedPoint.course_user_sheet_points(course, student, ws.title).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 eligible_students
has 38 lines of code (exceeds 25 allowed). Consider refactoring. Open
def eligible_students
unauthorize_guest!
return respond_with_error("This feature is only for MOOC-organization's 2019 programming MOOC") unless params[:course_name] == '2019-ohjelmointi' && params[:organization_slug] == 'mooc'
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!