testmycode/tmc-server

View on GitHub

Showing 202 of 278 total issues

Method update_user_progress has 38 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def update_user_progress(task)
    finished_successfully = false
    user = User.find(task.user_id)
    course = Course.find(task.course_id)
    Rails.logger.info("Publishing progress for user #{user.id} with moocfi id: #{course.moocfi_id}.")
Severity: Minor
Found in lib/kafka_updater.rb - About 1 hr to fix

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

      Method course_stats_show_submissions has 37 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          def course_stats_show_submissions
            return respond_not_found('No submissions yet') if @course.submissions.empty?
      
            @start_time =
              if params[:start_time]
      Severity: Minor
      Found in app/controllers/stats_controller.rb - About 1 hr to fix

        Method index has 37 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

                def index
                  unauthorize_guest!
                  exercise = Exercise.find(params[:exercise_id])
                  course = exercise.course
                  authorize! :read, exercise
        Severity: Minor
        Found in app/controllers/api/v8/exercises/model_solutions_controller.rb - About 1 hr to fix

          Method update has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
          Open

            def update
              User.transaction do
                @user = current_user
                @email_before = @user.email
          
          
          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 exercise_group_completion_counts_for_user has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
          Open

            def exercise_group_completion_counts_for_user(user)
              # TODO: clean up exercise group discovery
          
              groups = exercises.enabled.map(&:name).map { |name| name =~ /^(.+)-[^-]+$/ ? Regexp.last_match(1) : '' }.uniq.sort
          
          
          Severity: Minor
          Found in app/models/course.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 course_stats_show_submissions has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
          Open

              def course_stats_show_submissions
                return respond_not_found('No submissions yet') if @course.submissions.empty?
          
                @start_time =
                  if params[:start_time]
          Severity: Minor
          Found in app/controllers/stats_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 update has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
          Open

            def update
              authorize! :update, @user
          
              User.transaction do
                @email_before = @user.email
          Severity: Minor
          Found in app/controllers/settings_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 for_submission has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
          Open

            def self.for_submission(submission)
              Dir.mktmpdir do |tmpdir|
                zip_path = "#{tmpdir}/submission.zip"
                File.open(zip_path, 'wb') { |f| f.write(submission.return_file) }
                SafeUnzipper.new.unzip(zip_path, tmpdir)
          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 assign_show_view_vars has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
          Open

              def assign_show_view_vars
                @exercises = @course.exercises.includes(:course)
                @exercises.preload(:unlocks).where(unlocks: { user: current_user })
                @exercises = @exercises.select { |ex| ex.visible_to?(current_user) }
                                       .natsort_by(&:name)
          Severity: Minor
          Found in app/controllers/courses_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 refresh_course has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
          Open

                def refresh_course(course, data)
                  @report = Report.new
                  @rust_data = data['output-data']
                  Course.transaction(requires_new: true) do
                    @course = Course.find(course.id)
          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 load_fields has 34 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              def self.load_fields(kind, config_file_path)
                return [] unless File.exist?(config_file_path)
          
                kind = kind.to_s
          
          
          Severity: Minor
          Found in app/models/extra_field.rb - About 1 hr to fix

            Method check_access! has 33 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                def check_access!
                  if current_user.guest?
                    raise CanCan::AccessDenied
                  end
            
            
            Severity: Minor
            Found in app/controllers/submissions_controller.rb - About 1 hr to fix

              Method index has 33 lines of code (exceeds 25 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

                Method submission_review_column has 33 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                  def submission_review_column(submission)
                    if submission.reviewed?
                      if can? :create_review, submission.course
                        link_to 'Available', new_submission_review_path(submission)
                      else
                Severity: Minor
                Found in app/helpers/submissions_helper.rb - About 1 hr to fix

                  Method index has 33 lines of code (exceeds 25 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
                  Severity: Minor
                  Found in app/controllers/points_controller.rb - About 1 hr to fix

                    Method course_data has 33 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                      def course_data(organization, course, opts = {})
                        @course = course
                        data = {
                          id: course.id,
                          name: course.name,
                    Severity: Minor
                    Found in lib/course_list.rb - About 1 hr to fix

                      Method create has 32 lines of code (exceeds 25 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

                        Method create has 32 lines of code (exceeds 25 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

                          Method exercise_data has 32 lines of code (exceeds 25 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
                            Severity
                            Category
                            Status
                            Source
                            Language