testmycode/tmc-server

View on GitHub

Showing 202 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

                  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 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

                  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 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

                  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_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

                  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 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

                  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 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

                  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

                  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

                    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 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

                    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 24 (exceeds 5 allowed). Consider refactoring.
                    Open

                            def show
                              @submission = Submission.find_by!(id: params[:id])
                              unless @submission.processed?
                                authorization_skip!
                                sandbox_status = :created
                    Severity: Minor
                    Found in app/controllers/api/v8/core/submissions_controller.rb - About 3 hrs 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_csv has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
                    Open

                        def index_csv
                          CSV.generate(force_quotes: true) do |csv|
                            title_row = (@ordinary_fields + @extra_fields.map(&:name)).select { |f| @visible_columns.include?(f) }.map(&:humanize)
                    
                            if @group_completion
                    Severity: Minor
                    Found in app/controllers/participants_controller.rb - About 3 hrs 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 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

                    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

                    Severity
                    Category
                    Status
                    Source
                    Language