pupilfirst/pupilfirst

View on GitHub

Showing 122 of 226 total issues

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

    def sign_in_at_oauth_origin
      if user.present?
        user.regenerate_login_token

        encrypted_token =
Severity: Minor
Found in app/controllers/users/omniauth_callbacks_controller.rb - About 1 hr to fix

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

        def courses
          if current_user.blank?
            current_school
              .courses
              .live
    Severity: Minor
    Found in app/presenters/layouts/course_nav_presenter.rb - About 1 hr to fix

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

          def average_grades
            @average_grades ||=
              begin
                averaged =
                  TimelineEventGrade
      Severity: Minor
      Found in app/presenters/organisations/student_presenter.rb - About 1 hr to fix

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

          def applicable_submissions
            stage_1 = course.timeline_events.not_auto_verified.live
        
            # Filter by target
            stage_2 =
        Severity: Minor
        Found in app/queries/submissions_resolver.rb - About 1 hr to fix

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

            def targets(role: nil)
              @targets ||=
                begin
                  scope =
                    course.targets.live.includes(
          Severity: Minor
          Found in app/services/concerns/course_exportable.rb - About 1 hr to fix

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

                def validate(_object, context, value)
                  target = Target.find_by(id: value[:target_id])
                  assignment = target.assignments.not_archived.first
                  course = target.course
                  student =
            Severity: Minor
            Found in app/graphql/concerns/validate_student_submission.rb - About 1 hr to fix

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

                  def create_quiz(assignments)
                    assignments.each do |old_assignment, new_assignment|
                      next unless old_assignment.quiz?
              
                      # create quiz
              Severity: Minor
              Found in app/services/levels/clone_service.rb - About 1 hr to fix

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

                    def courses
                      @courses ||=
                        begin
                          if current_school_admin.present?
                            current_school
                Severity: Minor
                Found in app/presenters/users/dashboard_presenter.rb - About 1 hr to fix

                  Method save_report has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      def save_report
                        SubmissionReport.transaction do
                          report =
                            SubmissionReport.find_by(
                              submission_id: @params[:submission_id],
                  Severity: Minor
                  Found in app/graphql/mutations/queue_submission_report.rb - About 1 hr to fix

                    Method save_report has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        def save_report
                          SubmissionReport.transaction do
                            report =
                              SubmissionReport.find_by(
                                submission_id: @params[:submission_id],
                    Severity: Minor
                    Found in app/graphql/mutations/conclude_submission_report.rb - About 1 hr to fix

                      Function captureUnhandledRejections has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                            captureUnhandledRejections: function (r, e, o) {
                              if (r) {
                                "function" == typeof r._rollbarURH &&
                                  r._rollbarURH.belongsToShim &&
                                  r.removeEventListener("unhandledrejection", r._rollbarURH);
                      Severity: Minor
                      Found in app/frontend/shared/utils/rollbar.js - About 1 hr to fix

                        Method prepare_courses has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                          def prepare_courses
                            cohorts = @organisation.cohorts.includes(:course).uniq
                        
                            courses =
                              cohorts.each_with_object({}) do |cohort, courses|
                        Severity: Minor
                        Found in app/controllers/organisations_controller.rb - About 1 hr to fix

                          Method save_report has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                              def save_report
                                SubmissionReport.transaction do
                                  report =
                                    SubmissionReport.find_by(
                                      submission_id: @params[:submission_id],
                          Severity: Minor
                          Found in app/graphql/mutations/begin_processing_submission_report.rb - About 1 hr to fix

                            Function onreadystatechange has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                                      a(function () {
                                        if (
                                          !(
                                            l ||
                                            (this.readyState &&
                            Severity: Minor
                            Found in app/frontend/shared/utils/rollbar.js - About 1 hr to fix

                              Method create_video_resource has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                                  def create_video_resource(size, name, description)
                                    data = {
                                      upload: {
                                        approach: 'tus',
                                        size: size
                              Severity: Minor
                              Found in app/services/vimeo/api_service.rb - About 1 hr to fix

                                Method compute_grading_for_submissions has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                                Open

                                    def compute_grading_for_submissions(target, team_ids)
                                      submissions(target)
                                        .order(:created_at)
                                        .distinct
                                        .each_with_object(Array.new(team_ids.length)) do |submission, grading|
                                Severity: Minor
                                Found in app/services/course_exports/prepare_teams_export_service.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 sanitize_students has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                                Open

                                    def sanitize_students(students)
                                      team_sizes = {}
                                
                                      students.select do |student|
                                        if student.team_name.present?
                                Severity: Minor
                                Found in app/services/cohorts/add_students_service.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 toggle_standing has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                                Open

                                  def toggle_standing
                                    authorize current_school
                                
                                    standing_enabled = params[:enable_standing] == "true"
                                
                                
                                Severity: Minor
                                Found in app/controllers/schools_controller.rb - About 1 hr to fix

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

                                      def update_student_details
                                        if student&.name != @params[:name].strip
                                          Users::LogUsernameUpdateService.new(
                                            current_user,
                                            @params[:name],
                                  Severity: Minor
                                  Found in app/graphql/mutations/update_student_details.rb - About 1 hr to fix

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

                                      def create_submission
                                        submission =
                                          TimelineEvent.transaction do
                                            target
                                              .timeline_events
                                    Severity: Minor
                                    Found in app/queries/create_quiz_submission_mutator.rb - About 1 hr to fix
                                      Severity
                                      Category
                                      Status
                                      Source
                                      Language