testmycode/tmc-server

View on GitHub

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}"
Severity: Minor
Found in app/background_tasks/rust_langs_downloader_task.rb - About 1 hr to fix

    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,
    Severity: Minor
    Found in app/models/submission.rb - About 1 hr to fix

      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
      Severity: Minor
      Found in app/controllers/api/v8/users_controller.rb - About 1 hr to fix

        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}.")
        Severity: Minor
        Found in lib/kafka_updater.rb - About 1 hr to fix

          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)
          Severity: Minor
          Found in lib/course_info.rb - About 1 hr to fix

            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
            Severity: Minor
            Found in app/controllers/api/v8/users_controller.rb - About 1 hr to fix

            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
            Severity: Minor
            Found in app/models/source_file_list.rb - About 1 hr to fix

            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
            Severity: Minor
            Found in app/controllers/reviews_controller.rb - About 1 hr to fix

            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')
            Severity: Minor
            Found in app/controllers/users_controller.rb - About 1 hr to fix

            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
            Severity: Minor
            Found in app/controllers/api/v8/users/basic_info_by_usernames_controller.rb - About 1 hr to fix

            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
            Severity: Minor
            Found in app/controllers/api/v8/users/basic_info_by_ids_controller.rb - About 1 hr to fix

            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)
            Severity: Minor
            Found in app/controllers/setup/course_assistants_controller.rb - About 1 hr to fix

            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

            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)
            Severity: Minor
            Found in lib/course_info.rb - About 1 hr to fix

            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']
            Severity: Minor
            Found in lib/course_refresh_database_updater.rb - About 1 hr to fix

            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
            Severity: Minor
            Found in lib/sandbox_results_saver.rb - About 1 hr to fix

            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
            Severity: Minor
            Found in lib/version.rb - About 1 hr to fix

            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
            
            
            Severity: Minor
            Found in app/controllers/api/v8/users_controller.rb - About 1 hr to fix

              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
              Severity: Minor
              Found in app/models/solution.rb - About 1 hr to fix

                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
                Severity: Minor
                Found in app/background_tasks/kafka_realtime_update_points_task.rb - About 1 hr to fix
                  Severity
                  Category
                  Status
                  Source
                  Language