testmycode/tmc-server

View on GitHub

Showing 278 of 278 total issues

Method run has a Cognitive Complexity of 11 (exceeds 5 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: false).each do |task|
      finished_successfully = false
Severity: Minor
Found in app/background_tasks/kafka_batch_update_points_task.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 award_points has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

    def self.award_points(submission, results, review_points)
      user = submission.user
      exercise = submission.exercise
      course = exercise.course
      available_points = exercise.available_points.to_a.map(&:name)
Severity: Minor
Found in lib/test_run_grader.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 clean_up has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

    def clean_up(root_dir_abs, file)
      if File.symlink?(file)
        dest = File.absolute_path(File.readlink(file), File.dirname(file))
        unless dest.start_with?(root_dir_abs)
          ::Rails.logger.warn("Cleaning up external symlink to: #{dest}")
Severity: Minor
Found in lib/safe_unzipper.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 31 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def show
    @sheetname = params[:id]
    @course = Course.find(params[:course_id])
    authorize! :see_points, @course
    return respond_unauthorized('Authentication required') if current_user.guest?
Severity: Minor
Found in app/controllers/points_controller.rb - About 1 hr to fix

    Method update_exercises has 31 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      def update_exercises(task)
        finished_successfully = false
        course = Course.find(task.course_id)
        Rails.logger.info("Batch publishing exercises for course #{course.name} with moocfi id: #{course.moocfi_id}.")
        if !course.moocfi_id
    Severity: Minor
    Found in lib/kafka_updater.rb - About 1 hr to fix

      Method course_data_core_api has 31 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def course_data_core_api(course)
          # UncomputedUnlock.resolve(course, @user)
          @unlocked_exercises = course.unlocks
                                      .where(user_id: @user.id)
                                      .where(['valid_after IS NULL OR valid_after < ?', Time.now])
      Severity: Minor
      Found in lib/course_info.rb - About 1 hr to fix

        Method refresh has 31 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          def self.refresh(course_template_refresh_task)
            course_template = course_template_refresh_task.course_template
            command = "#{self.langs_executable_path}/current refresh-course"\
            " --cache-path #{course_template.cache_path}"\
            " --cache-root #{Course.cache_root}"\
        Severity: Minor
        Found in lib/rust_langs_cli_executor.rb - About 1 hr to fix

          Identical blocks of code found in 3 locations. Consider refactoring.
          Open

                  def set_user_fields
                    return if params[:user_field].nil?
                    changes = {}
                    UserField.all.select { |f| f.visible_to?(current_user) }.each do |field|
                      value_record = @user.field_value_record(field)
          Severity: Major
          Found in app/controllers/api/v8/users_controller.rb and 2 other locations - About 1 hr to fix
          app/controllers/settings_controller.rb on lines 107..117
          app/controllers/users_controller.rb on lines 200..210

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

          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 5 locations. Consider refactoring.
          Open

                      swagger_path '/api/v8/org/{organization_slug}/courses/{course_name}/users/current/points' do
                        operation :get do
                          key :description, "Returns the current user's points from the course in a json format. Course is searched by name"
                          key :produces, ['application/json']
                          key :tags, ['point']
          app/controllers/api/v8/courses/users/points_controller.rb on lines 10..25
          app/controllers/api/v8/organizations/courses/points_controller.rb on lines 10..25
          app/controllers/api/v8/organizations/courses/studyright_eligibility_controller.rb on lines 10..25
          app/controllers/api/v8/organizations/courses/users/progress_controller.rb on lines 33..48

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

          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

          Identical blocks of code found in 3 locations. Consider refactoring.
          Open

              def set_user_fields
                return if params[:user_field].nil?
                changes = {}
                UserField.all.select { |f| f.visible_to?(current_user) }.each do |field|
                  value_record = @user.field_value_record(field)
          Severity: Major
          Found in app/controllers/users_controller.rb and 2 other locations - About 1 hr to fix
          app/controllers/api/v8/users_controller.rb on lines 206..216
          app/controllers/settings_controller.rb on lines 107..117

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

          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 5 locations. Consider refactoring.
          Open

                      swagger_path '/api/v8/org/{organization_slug}/courses/{course_name}/users/current/points' do
                        operation :get do
                          key :description, "Returns the current user's points from the course in a json format. Course is searched by name"
                          key :produces, ['application/json']
                          key :tags, ['point']
          app/controllers/api/v8/courses/users/points_controller.rb on lines 10..25
          app/controllers/api/v8/organizations/courses/points_controller.rb on lines 10..25
          app/controllers/api/v8/organizations/courses/studyright_eligibility_controller.rb on lines 10..25
          app/controllers/api/v8/organizations/courses/users/points_controller.rb on lines 33..48

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

          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

          Identical blocks of code found in 3 locations. Consider refactoring.
          Open

              def set_user_fields
                return if params[:user_field].nil?
                changes = {}
                UserField.all.select { |f| f.visible_to?(current_user) }.each do |field|
                  value_record = @user.field_value_record(field)
          Severity: Major
          Found in app/controllers/settings_controller.rb and 2 other locations - About 1 hr to fix
          app/controllers/api/v8/users_controller.rb on lines 206..216
          app/controllers/users_controller.rb on lines 200..210

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

          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 5 locations. Consider refactoring.
          Open

                    swagger_path '/api/v8/org/{organization_slug}/courses/{course_name}/points' do
                      operation :get do
                        key :description, "Returns the course's points in a json format. Course is searched by name"
                        key :produces, ['application/json']
                        key :tags, ['point']
          app/controllers/api/v8/courses/users/points_controller.rb on lines 10..25
          app/controllers/api/v8/organizations/courses/studyright_eligibility_controller.rb on lines 10..25
          app/controllers/api/v8/organizations/courses/users/points_controller.rb on lines 33..48
          app/controllers/api/v8/organizations/courses/users/progress_controller.rb on lines 33..48

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

          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 5 locations. Consider refactoring.
          Open

                    swagger_path '/api/v8/org/{organization_slug}/courses/{course_name}/eligible_students' do
                      operation :get do
                        key :description, "Returns all users from the course who have at least 90% of every part's points and are applying for study right, in a json format. Course is searched by name, only 2019 programming mooc course is valid"
                        key :produces, ['application/json']
                        key :tags, ['point']
          app/controllers/api/v8/courses/users/points_controller.rb on lines 10..25
          app/controllers/api/v8/organizations/courses/points_controller.rb on lines 10..25
          app/controllers/api/v8/organizations/courses/users/points_controller.rb on lines 33..48
          app/controllers/api/v8/organizations/courses/users/progress_controller.rb on lines 33..48

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

          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 5 locations. Consider refactoring.
          Open

                    swagger_path '/api/v8/courses/{course_id}/users/{user_id}/points' do
                      operation :get do
                        key :description, "Returns the given user's points from the course in a json format. Course is searched by id"
                        key :produces, ['application/json']
                        key :tags, ['point']
          Severity: Major
          Found in app/controllers/api/v8/courses/users/points_controller.rb and 4 other locations - About 1 hr to fix
          app/controllers/api/v8/organizations/courses/points_controller.rb on lines 10..25
          app/controllers/api/v8/organizations/courses/studyright_eligibility_controller.rb on lines 10..25
          app/controllers/api/v8/organizations/courses/users/points_controller.rb on lines 33..48
          app/controllers/api/v8/organizations/courses/users/progress_controller.rb on lines 33..48

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

          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 generate has 30 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            def generate
              visible_exercises, available_points = visible_exercises_and_points_for
          
              data = File.read(File.join(path, 'certificate.html'))
              awarded_points = AwardedPoint.course_user_points(course, user).reject do |p|
          Severity: Minor
          Found in app/models/certificate.rb - About 1 hr to fix

            Method labeled has 30 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              def labeled(label, tags = nil, options = {}, &block)
                if tags.is_a?(Hash) && options.empty?
                  options = tags
                  tags = nil
                end
            Severity: Minor
            Found in app/helpers/application_helper.rb - About 1 hr to fix

              Method create has 30 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                      def create
                        return respond_forbidden unless current_user.administrator?
                        users = params[:emails].map do |email|
                          User.find_by('lower(email) = ?', email.downcase)
                        end.compact
              Severity: Minor
              Found in app/controllers/api/v8/users/basic_info_by_emails_controller.rb - About 1 hr to fix

                Method show has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                  def show
                    @exercise = Exercise.find(params[:exercise_id])
                    @course = @exercise.course
                    @organization = @course.organization
                
                
                Severity: Minor
                Found in app/controllers/solutions_controller.rb - About 1 hr to fix

                  Method create has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                            def create
                              submission = Submission.find(params[:submission_id])
                              authorize! :read, submission
                  
                              answer_params = params[:answers]
                  Severity: Minor
                  Found in app/controllers/api/v8/core/submissions/feedback_controller.rb - About 1 hr to fix
                    Severity
                    Category
                    Status
                    Source
                    Language