testmycode/tmc-server

View on GitHub

Showing 202 of 278 total issues

Method broadcast_to_channel has 5 arguments (exceeds 4 allowed). Consider refactoring.
Open

    def broadcast_to_channel(id, msg, percent, time, refresh_id = nil)
Severity: Minor
Found in app/background_tasks/refresh_course_task.rb - About 35 mins to fix

    Method prepare_submission has 5 arguments (exceeds 4 allowed). Consider refactoring.
    Open

      def self.prepare_submission(clone_path, output_path, submission_path, extra_params = {}, config = {})
    Severity: Minor
    Found in lib/rust_langs_cli_executor.rb - About 35 mins to fix

      Method course_stats_show_submission_times has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

          def course_stats_show_submission_times
            return respond_not_found('No submissions yet') if @course.submissions.empty?
      
            respond_to do |format|
              format.html { render template: 'courses/stats/submission_times', layout: 'bare' }
      Severity: Minor
      Found in app/controllers/stats_controller.rb - About 35 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 7 (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/api/v8/core/courses/reviews_controller.rb - About 35 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 7 (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/api/v8/core/submissions/reviews_controller.rb - About 35 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 7 (exceeds 5 allowed). Consider refactoring.
      Open

        def show
          authorize! :read, @course
      
          if (request.params[:generate_report]) && (can? :teach, @course)
            report = CourseTemplateRefresh.find(request.params[:generate_report])
      Severity: Minor
      Found in app/controllers/courses_controller.rb - About 35 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 params= has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

        def params=(value)
          if value.is_a?(Hash)
            value.each { |k, v| raise "Invalid submission param: #{k} = #{v}" unless valid_param?(k, v) }
            self.params_json = value.to_json
          elsif value.nil?
      Severity: Minor
      Found in app/models/submission.rb - About 35 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 courses_with_submissions has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

        def courses_with_submissions
          exercises = Exercise.arel_table
          submissions = Submission.arel_table
          query = submissions_exercises_and_points_for_user
          without_disabled(query)
      Severity: Minor
      Found in app/models/user.rb - About 35 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 set_extra_data has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

              def set_extra_data(eager_save = false)
                return unless params['user']
                extra_fields = params['user']['extra_fields']
                return if extra_fields.nil?
                namespace = extra_fields['namespace']
      Severity: Minor
      Found in app/controllers/api/v8/users_controller.rb - About 35 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 destroy has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

        def destroy
          find_key_and_user
      
          if params[:password] != params[:password_confirmation]
            flash.now[:alert] = 'Passwords did not match'
      Severity: Minor
      Found in app/controllers/password_reset_keys_controller.rb - About 35 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 create has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

        def create
          authorize! :create, User
      
          @user = User.new
      
      
      Severity: Minor
      Found in app/controllers/users_controller.rb - About 35 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 labeled has a Cognitive Complexity of 7 (exceeds 5 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 35 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 exercise_group_completion_by_user has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

        def exercise_group_completion_by_user
          # TODO: clean up exercise group discovery
      
          groups = exercises
                   .where(disabled_status: 0)
      Severity: Minor
      Found in app/models/course.rb - About 35 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 extra_field has a Cognitive Complexity of 7 (exceeds 5 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 35 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 authenticate_user! has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

              def authenticate_user!
                return @current_user if @current_user
                if doorkeeper_token
                  @current_user ||= User.find_by(id: doorkeeper_token.resource_owner_id)
                  raise 'Invalid token' unless @current_user
      Severity: Minor
      Found in app/controllers/api/v8/base_controller.rb - About 35 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 settings_from_files has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

          def self.settings_from_files(files)
            result = {}
            files.each do |path|
              next unless File.exist?(path)
              template = ERB.new File.new(path).read
      Severity: Minor
      Found in app/models/site_setting.rb - About 35 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 has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

        def index
          if @organization.nil?
            authorize! :view, :participants_list
            courses = Course.all
            users = User.all
      Severity: Minor
      Found in app/controllers/participants_controller.rb - About 35 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 to_time has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

        def self.to_time(input, options = {})
          options = {
            prefer_end_of_day: false
          }.merge options
      
      
      Severity: Minor
      Found in lib/date_and_time_utils.rb - About 35 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 prepare_submission has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

        def self.prepare_submission(clone_path, output_path, submission_path, extra_params = {}, config = {})
          command = "#{self.langs_executable_path}/current prepare-submission --clone-path #{clone_path} --output-path #{output_path} --submission-path #{submission_path}"
          command = command + " --top-level-dir-name #{config[:toplevel_dir_name]}" if !!config[:toplevel_dir_name]
          command = command + " --stub-zip-path #{config[:tests_from_stub]}" if !!config[:tests_from_stub]
          command = command + " --output-format #{config[:format]}" if !!config[:format]
      Severity: Minor
      Found in lib/rust_langs_cli_executor.rb - About 35 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 run has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

              def run(command)
                output = nil
                Dir.chdir @session.working_dir do
                  output = `#{command} 2>&1`
                  unless $?.success?
      Severity: Minor
      Found in lib/doc_gen/shell_session.rb - About 35 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