testmycode/tmc-server

View on GitHub

Showing 202 of 278 total issues

Method show has 27 lines of code (exceeds 25 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

    Method update_available_points has 27 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

          def update_available_points
            @rust_data['exercises'].each do |exercise|
              added = []
              removed = []
    
    
    Severity: Minor
    Found in lib/course_refresh_database_updater.rb - About 1 hr to fix

      Method run has 27 lines of code (exceeds 25 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

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

          def show
            course_id = params[:course_id]
            user_id = params[:id]
        
            course = Course.where(id: course_id).first || Course.where(name: course_id).first
        Severity: Minor
        Found in app/controllers/exercise_status_controller.rb - About 1 hr to fix

          Method extra_field has 26 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            def extra_field(field_value, method_options)
              field = field_value.field
          
              return '' if field.options[:hidden]
              return raw(field.label) if field.field_type == :html
          Severity: Minor
          Found in app/helpers/extra_field_helper.rb - About 1 hr to fix

            Method sh! has 26 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              def sh!(*args)
                options = {
                  assert_silent: false,
                  escape: true,
                  timeout: nil
            Severity: Minor
            Found in lib/system_commands.rb - About 1 hr to fix

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

                def create
                  course = Course.find(course_notification_params[:course_id])
                  authorize! :send_mail_to_participants, course
              
                  participants = User.course_students(course)
              Severity: Minor
              Found in app/controllers/course_notifications_controller.rb - About 55 mins 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 maybe_update_password has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
              Open

                  def maybe_update_password(user, user_params)
                    if user_params[:old_password].present? || user_params[:password].present?
                      if !user.has_password?(user_params[:old_password])
                        user.errors.add(:old_password, 'incorrect')
                      elsif user_params[:password] != user_params[:password_repeat]
              Severity: Minor
              Found in app/controllers/settings_controller.rb - About 55 mins 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_json_data has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
              Open

                  def index_json_data
                    result = []
                    @participants.each do |user|
                      record = { id: user.id, username: user.login, email: user.email }
                      @extra_fields.each do |field|
              Severity: Minor
              Found in app/controllers/participants_controller.rb - About 55 mins 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 eligible_students has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
              Open

                        def eligible_students
                          unauthorize_guest!
              
                          return respond_with_error("This feature is only for MOOC-organization's 2019 programming MOOC") unless params[:course_name] == '2019-ohjelmointi' && params[:organization_slug] == 'mooc'
              
              

              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_client_version_api_v8 has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
              Open

                      def check_client_version_api_v8
                        if should_check_for_client_version?
                          begin
                            check_client_minimum_version(params[:client], params[:client_version])
                          rescue StandardError
              Severity: Minor
              Found in app/controllers/api/v8/base_controller.rb - About 55 mins 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 find_source_files_under has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
              Open

                  def self.find_source_files_under(root_dir)
                    files = []
                    total_size = 0
                    Pathname(root_dir).realpath.find do |file|
                      Find.prune if file.directory? && should_skip_dir?(file)
              Severity: Minor
              Found in app/models/source_file_list.rb - About 55 mins 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 9 (exceeds 5 allowed). Consider refactoring.
              Open

                  def award_points
                    submission = @review.submission
                    exercise = submission.exercise
                    course = exercise.course
                    raise 'Exercise of submission has been moved or deleted' unless exercise
              Severity: Minor
              Found in app/controllers/reviews_controller.rb - About 55 mins 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 source_file? has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
              Open

                  def self.source_file?(file)
                    return false unless file.file?
                    dir = file.parent.to_s
                    name = file.basename.to_s.downcase
                    name.end_with?('.java', '.jsp') ||
              Severity: Minor
              Found in app/models/source_file_list.rb - About 55 mins 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 9 (exceeds 5 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 55 mins 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 can_handle_hidden_fields has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
              Open

                        def can_handle_hidden_fields(params)
                          return false unless params[:client] == 'netbeans_plugin'
                          splitted = params[:client_version].split('.')
                          min_version = [1, 2, 5]
                          min_version.each_with_index do |version_number, i|
              Severity: Minor
              Found in app/controllers/api/v8/core/submissions_controller.rb - About 55 mins 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_api_version has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
              Open

                  def check_api_version
                    if should_check_api_version?
                      if params[:api_version].blank?
                        return respond_with_error('Please update the TMC client. No API version received from client.', 404, nil, obsolete_client: true)
                      elsif params[:api_version].to_s != ApiVersion::API_VERSION.to_s
              Severity: Minor
              Found in app/controllers/application_controller.rb - About 55 mins 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 maybe_update_password has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
              Open

                  def maybe_update_password(user, user_params)
                    if user_params[:old_password].present? || user_params[:password].present?
                      if !user.has_password?(user_params[:old_password])
                        user.errors.add(:old_password, 'incorrect')
                      elsif user_params[:password] != user_params[:password_repeat]
              Severity: Minor
              Found in app/controllers/users_controller.rb - About 55 mins 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 update_user_progress has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
              Open

                def update_user_progress(task)
                  finished_successfully = false
                  user = User.find(task.user_id)
                  course = Course.find(task.course_id)
                  Rails.logger.info("Publishing progress for user #{user.id} with moocfi id: #{course.moocfi_id}.")
              Severity: Minor
              Found in lib/kafka_updater.rb - About 55 mins 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 hash_file_tree has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
              Open

                def self.hash_file_tree(root_path)
                  paths = []
                  root_path = File.expand_path(root_path)
                  Find.find(root_path) do |path|
                    paths << path unless File.directory?(path)
              Severity: Minor
              Found in lib/file_tree_hasher.rb - About 55 mins 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