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

                  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

                    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

                    Duplicated Code

                    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                    Tuning

                    This issue has a mass of 137.

                    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                    Refactorings

                    Further Reading

                    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

                    Duplicated Code

                    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                    Tuning

                    This issue has a mass of 137.

                    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                    Refactorings

                    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

                    Severity
                    Category
                    Status
                    Source
                    Language