pupilfirst/pupilfirst

View on GitHub

Showing 122 of 226 total issues

Method rank_change_icon has 41 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def rank_change_icon(delta)
      if delta >= 10
        view.image_tag(
          "courses/leaderboard/rank-change-up-double.svg",
          alt:
Severity: Minor
Found in app/presenters/courses/leaderboard_presenter.rb - About 1 hr to fix

    Function wrap has 40 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

          (i.prototype.wrap = function (r, e, o) {
            try {
              var n;
              if (
                ((n =
    Severity: Minor
    Found in app/frontend/shared/utils/rollbar.js - About 1 hr to fix

      Method execute has 40 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          def execute
            submission =
              TimelineEvent.transaction do
                timeline_event_params =
                  (
      Severity: Minor
      Found in app/services/timeline_events/create_service.rb - About 1 hr to fix

        Method auth_callback has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
        Open

            def auth_callback
              begin
                crypt = EncryptorService.new
        
                data =
        Severity: Minor
        Found in app/controllers/users/sessions_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 delete_content has 39 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            def delete_content
              quiz_questions =
                QuizQuestion.joins(quiz: { assignment: :course }).where(
                  courses: {
                    id: @course.id
        Severity: Minor
        Found in app/services/courses/delete_service.rb - About 1 hr to fix

          Function loadFull has 39 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              (i.prototype.loadFull = function (r, e, o, n, t) {
                var l = !1,
                  i = e.createElement("script"),
                  s = e.getElementsByTagName("script")[0],
                  d = s.parentNode;
          Severity: Minor
          Found in app/frontend/shared/utils/rollbar.js - About 1 hr to fix

            Method student_rows has 36 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                def student_rows
                  rows =
                    students.map do |student|
                      user = student.user
            
            
            Severity: Minor
            Found in app/services/course_exports/prepare_students_export_service.rb - About 1 hr to fix

              Method perform has 36 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  def perform(event_type, course, actor, resource)
                    webhook_endpoint = course.webhook_endpoint
              
                    unless event_type.in?(webhook_endpoint.events)
                      raise "#{event_type} was not one of the requested events in WebhookEndpoint##{webhook_endpoint.id}"
              Severity: Minor
              Found in app/jobs/webhook_deliveries/deliver_job.rb - About 1 hr to fix

                Function Home has 36 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                function Home() {
                  const context = useDocusaurusContext();
                  const { siteConfig = {} } = context;
                  return (
                    <Layout description="Description will go into a meta tag in <head />">
                Severity: Minor
                Found in docs/src/pages/index.js - About 1 hr to fix

                  Method add_updates_for_coach has 36 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                    def add_updates_for_coach(user)
                      coach = user.faculty
                  
                      return [] if coach.blank?
                  
                  
                  Severity: Minor
                  Found in app/services/daily_digest_service.rb - About 1 hr to fix

                    Function startRecording has 35 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                      function startRecording() {
                        if (
                          navigator.mediaDevices &&
                          navigator.mediaDevices.getUserMedia &&
                          !state.recording

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

                          def targets
                            attributes = %w[id title target_group_id sort_index]
                      
                            scope =
                              @course
                      Severity: Minor
                      Found in app/presenters/courses/curriculum_presenter.rb - About 1 hr to fix

                        Method update_email has 35 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                          def update_email
                            user =
                              Users::ValidateUpdateEmailTokenService.new(
                                params[:token],
                                current_school
                        Severity: Minor
                        Found in app/controllers/users_controller.rb - About 1 hr to fix

                          Function setupShim has 34 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                                setupShim: function (r, e) {
                                  if (r) {
                                    var o = e.globalAlias || "Rollbar";
                                    if ("object" == typeof r[o]) return r[o];
                                    (r._rollbarShims = {}), (r._rollbarWrappedError = null);
                          Severity: Minor
                          Found in app/frontend/shared/utils/rollbar.js - About 1 hr to fix

                            Consider simplifying this complex logical expression.
                            Open

                                      if (
                                        !r._rollbar_wrapped &&
                                        ((r._rollbar_wrapped = function () {
                                          o && "function" == typeof o && o.apply(this, arguments);
                                          try {
                            Severity: Critical
                            Found in app/frontend/shared/utils/rollbar.js - About 1 hr to fix

                              Consider simplifying this complex logical expression.
                              Open

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

                                Method generate_url has 33 lines of code (exceeds 25 allowed). Consider refactoring.
                                Open

                                    def generate_url
                                      signer =
                                        Aws::CloudFront::UrlSigner.new(
                                          key_pair_id: Rails.application.secrets.cloudfront[:key_pair_id],
                                          private_key:
                                Severity: Minor
                                Found in app/services/cloudfront/generate_signed_url_service.rb - About 1 hr to fix

                                  Method execute has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                                  Open

                                      def execute
                                        unless (
                                                 target.visibility != Target::VISIBILITY_ARCHIVED &&
                                                   @assignment.milestone
                                               )
                                  Severity: Minor
                                  Found in app/services/schools/milestone_sort_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 create_branch has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                                  Open

                                      def create_branch(re_run)
                                        # Create a branch with the name submission-<student_id>
                                        branch_name_suffix = re_run ? "-#{Time.now.to_i}" : ""
                                        branch_name = "submission-#{@submission.id}#{branch_name_suffix}"
                                        repo_name = @submission.students.first.github_repository
                                  Severity: Minor
                                  Found in app/services/github/add_submission_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 execute has 31 lines of code (exceeds 25 allowed). Consider refactoring.
                                  Open

                                      def execute(re_run: false)
                                        unless github_configuration.configured? &&
                                                 @submission.target.action_config.present?
                                          return
                                        end
                                  Severity: Minor
                                  Found in app/services/github/add_submission_service.rb - About 1 hr to fix
                                    Severity
                                    Category
                                    Status
                                    Source
                                    Language