testmycode/tmc-server

View on GitHub

Showing 278 of 278 total issues

Class Exercise has 66 methods (exceeds 20 allowed). Consider refactoring.
Open

class Exercise < ApplicationRecord
self.include_root_in_json = false
include Swagger::Blocks
 
swagger_schema :ExerciseWithPoints do
Severity: Major
Found in app/models/exercise.rb - About 1 day to fix

    Method initialize has 223 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    def initialize(user)
    if user.administrator?
    can :manage, :all
    can :create, Course
    can :create, :custom_course
    Severity: Major
    Found in app/models/ability.rb - About 1 day to fix

      Consider simplifying this complex logical expression.
      Open

      if user.administrator?
      can :manage, :all
      can :create, Course
      can :create, :custom_course
      cannot :refresh, Course
      Severity: Critical
      Found in app/models/ability.rb - About 1 day to fix

        File course.rb has 471 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        require 'gdocs_export'
        require 'system_commands'
        require 'date_and_time_utils'
         
        class Course < ApplicationRecord
        Severity: Minor
        Found in app/models/course.rb - About 7 hrs to fix

          Class Course has 51 methods (exceeds 20 allowed). Consider refactoring.
          Open

          class Course < ApplicationRecord
          include SystemCommands
          include Swagger::Blocks
           
          swagger_schema :Course do
          Severity: Major
          Found in app/models/course.rb - About 7 hrs to fix

            Class Submission has 43 methods (exceeds 20 allowed). Consider refactoring.
            Open

            class Submission < ApplicationRecord
            include Swagger::Blocks
             
            swagger_schema :Submission do
            key :required, %i[id user_id pretest_error created_at exercise_name course_id processed
            Severity: Minor
            Found in app/models/submission.rb - About 5 hrs to fix

              File exercise.rb has 404 lines of code (exceeds 250 allowed). Consider refactoring.
              Open

              require 'shellwords'
               
              require 'date_and_time_utils'
               
              class Exercise < ApplicationRecord
              Severity: Minor
              Found in app/models/exercise.rb - About 5 hrs to fix

                Class User has 42 methods (exceeds 20 allowed). Consider refactoring.
                Open

                class User < ApplicationRecord
                include Comparable
                include Gravtastic
                include Swagger::Blocks
                gravtastic
                Severity: Minor
                Found in app/models/user.rb - About 5 hrs to fix

                  Method create has a Cognitive Complexity of 37 (exceeds 5 allowed). Consider refactoring.
                  Open

                  def create
                  if !params[:submission] || !params[:submission][:file]
                  return respond_not_found('No ZIP file selected or failed to receive it')
                  end
                   
                   
                  Severity: Minor
                  Found in app/controllers/submissions_controller.rb - About 5 hrs to fix

                  Method send_submission has a Cognitive Complexity of 36 (exceeds 5 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?
                  Severity: Minor
                  Found in app/models/remote_sandbox.rb - About 5 hrs to fix

                  Method email_confirmation has a Cognitive Complexity of 33 (exceeds 5 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)
                  Severity: Minor
                  Found in app/mailers/user_mailer.rb - About 4 hrs to fix

                  Method check_access! has a Cognitive Complexity of 30 (exceeds 5 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 4 hrs to fix

                  Method show has a Cognitive Complexity of 30 (exceeds 5 allowed). Consider refactoring.
                  Open

                  def show
                  @course ||= @submission.course
                  @exercise ||= @submission.exercise
                  @organization = @course.organization
                   
                   
                  Severity: Minor
                  Found in app/controllers/submissions_controller.rb - About 4 hrs to fix

                  Method create has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring.
                  Open

                  def create
                  unauthorize_guest!
                   
                  @exercise = Exercise.find(params[:exercise_id])
                  authorize! :read, @exercise
                  Severity: Minor
                  Found in app/controllers/api/v8/core/exercises/submissions_controller.rb - About 4 hrs to fix

                  File submission.rb has 338 lines of code (exceeds 250 allowed). Consider refactoring.
                  Open

                  require 'zlib'
                  require 'securerandom'
                  require 'submission_packager'
                   
                  class Submission < ApplicationRecord
                  Severity: Minor
                  Found in app/models/submission.rb - About 4 hrs to fix

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

                    def update
                    authorize! :teach, @organization
                     
                    print_setup_phases(3)
                     
                     
                    Severity: Minor
                    Found in app/controllers/setup/course_timings_controller.rb - About 4 hrs to fix

                    Similar blocks of code found in 2 locations. 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
                    app/controllers/api/v8/users/basic_info_by_ids_controller.rb on lines 9..43

                    Similar blocks of code found in 2 locations. 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: Major
                    Found in app/controllers/api/v8/users/basic_info_by_ids_controller.rb and 1 other location - About 4 hrs to fix
                    app/controllers/api/v8/users/basic_info_by_usernames_controller.rb on lines 61..95

                    Method initialize has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
                    Open

                    def initialize(user)
                    if user.administrator?
                    can :manage, :all
                    can :create, Course
                    can :create, :custom_course
                    Severity: Minor
                    Found in app/models/ability.rb - About 3 hrs to fix

                    Method show has a Cognitive Complexity of 24 (exceeds 5 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
                    Severity: Minor
                    Found in app/controllers/exercises_controller.rb - About 3 hrs to fix
                    Severity
                    Category
                    Status
                    Source
                    Language