testmycode/tmc-server

View on GitHub

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

  def show
    if params[:username].present? && params[:session_id].present?
      user = User.find_by(login: params[:username])
      user ||= User.find_by('lower(email) = ?', params[:username].downcase)
      # Allows using oauth2 tokens of the new api for authenticating
Severity: Minor
Found in app/controllers/auths_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 print_setup_phases has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

  def print_setup_phases(phase = 0)
    update_setup_phase(phase) unless phase == 2
    maxphase = setup_in_progress? ? session[:ongoing_course_setup][:phase] : phase
    STEPS.each_with_index do |st, i|
      path = nil
Severity: Minor
Found in app/controllers/setup/setup_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 create has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

  def create
    authorize! :teach, @organization

    custom = params[:course][:course_template_id].blank?

Severity: Minor
Found in app/controllers/setup/course_details_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 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

          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

                    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/feedback_answers_controller.rb - About 1 hr to fix

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

                        def self.course_points(course, include_admins = false, hidden = false, only_for_user = nil)
                          awarded_points = AwardedPoint.arel_table
                          users = User.arel_table
                          exercises = Exercise.arel_table
                          submissions = Submission.arel_table
                      Severity: Minor
                      Found in app/models/awarded_point.rb - About 1 hr to fix

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

                          def difference_with_solution
                            @course ||= @submission.course
                            authorize! :teach, @course
                            @exercise ||= @submission.exercise
                            @organization = @course.organization
                        Severity: Minor
                        Found in app/controllers/submissions_controller.rb - About 1 hr to fix

                          Method index_csv has 29 lines of code (exceeds 25 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 1 hr to fix
                            Severity
                            Category
                            Status
                            Source
                            Language