pupilfirst/pupilfirst

View on GitHub

Showing 124 of 226 total issues

Method create_vimeo_video has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

  def create_vimeo_video
    vimeo_api = Vimeo::ApiService.new(current_school)
    video_title = sanitize_title(title.presence || target.title).truncate(120)
    response = vimeo_api.create_video(size, video_title, description)

Severity: Minor
Found in app/queries/create_vimeo_video_mutator.rb - About 45 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 checklist_data_should_not_be_mutated has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

      def checklist_data_should_not_be_mutated
        old_checklist =
          @submission.checklist.map do |c|
            [
              c["title"],
Severity: Minor
Found in app/graphql/mutations/create_grading.rb - About 45 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 applicable_submissions has a Cognitive Complexity of 8 (exceeds 5 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 45 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

Consider simplifying this complex logical expression.
Open

      if checklist.respond_to?(:all?) &&
           checklist.all? { |item|
             item["title"].is_a?(String) &&
               item["kind"].in?(Assignment.valid_checklist_kind_types) &&
               item["status"] == TimelineEvent::CHECKLIST_STATUS_NO_ANSWER &&
Severity: Major
Found in app/graphql/concerns/validate_student_submission.rb - About 40 mins to fix

    Consider simplifying this complex logical expression.
    Open

        if review_checklist.respond_to?(:all?) &&
             review_checklist.all? { |item|
               valid_title?(item["title"]) && item["result"].respond_to?(:all?) &&
                 item["result"].all? do |result|
                   valid_title?(result["title"]) &&
    Severity: Major
    Found in app/queries/update_review_checklist_mutator.rb - About 40 mins to fix

      Consider simplifying this complex logical expression.
      Open

              if @checklist.respond_to?(:all?) &&
                   @checklist.all? { |item|
                     item["title"].is_a?(String) &&
                       item["kind"].in?(Assignment.valid_checklist_kind_types) &&
                       item["status"].in?(
      Severity: Major
      Found in app/graphql/mutations/create_grading.rb - About 40 mins to fix

        Consider simplifying this complex logical expression.
        Open

              if (e.hasOwnProperty && e.hasOwnProperty("addEventListener")) {
                for (var n = e.addEventListener; n._rollbarOldAdd && n.belongsToShim; )
                  n = n._rollbarOldAdd;
                var t = function (e, o, t) {
                  n.call(this, e, r.wrap(o), t);
        Severity: Major
        Found in app/frontend/shared/utils/rollbar.js - About 40 mins to fix

          Function loadFull has 5 arguments (exceeds 4 allowed). Consider refactoring.
          Open

              (i.prototype.loadFull = function (r, e, o, n, t) {
          Severity: Minor
          Found in app/frontend/shared/utils/rollbar.js - About 35 mins to fix

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

                def oauth_callback
                  @email = email_from_auth_hash
            
                  if oauth_origin.present? && oauth_origin[:session_id]
                    if oauth_origin[:link_data].present?
            Severity: Minor
            Found in app/controllers/users/omniauth_callbacks_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 assign has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
            Open

                def assign(faculty)
                  if faculty.school != @course.school
                    raise 'Faculty must in same school as course'
                  end
            
            
            Severity: Minor
            Found in app/services/cohorts/manage_reviewer_service.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 first_five_topics_from_cache has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
            Open

              def first_five_topics_from_cache(update_type, community_ids)
                topics = []
            
                @topic_details_cache[update_type].each do |topic|
                  next unless topic[:community_id].in?(community_ids)
            Severity: Minor
            Found in app/services/daily_digest_service.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 target_type has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
            Open

              def target_type(target)
                assignment = target.assignments.not_archived.first
                if assignment
                  if assignment.evaluation_criteria.present?
                    "Graded"
            Severity: Minor
            Found in app/services/concerns/course_exportable.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 execute has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
            Open

                def execute
                  return unless @user.discord_user_id.present? && configuration.configured?
            
                  role_ids = [
                    @user.cohorts.pluck(:discord_role_ids),
            Severity: Minor
            Found in app/services/discord/sync_profile_service.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 issue has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
            Open

                def issue(certificate: nil, issuer: nil)
                  certificate_to_issue = certificate || active_certificate
            
                  return if certificate_to_issue.blank? || issued_certificate_exists?
            
            
            Severity: Minor
            Found in app/services/students/issue_certificate_service.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
                  @form =
                    if params[:password_sign_in]
                      Users::Sessions::SignInWithPasswordForm.new(Reform::OpenForm.new)
                    elsif params[:email_link]
            Severity: Minor
            Found in app/controllers/users/sessions_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 links_to_adjacent_targets has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
            Open

                def links_to_adjacent_targets
                  links = {}
            
                  sorted_target_ids =
                    @target
            Severity: Minor
            Found in app/services/targets/details_service.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 validate has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
            Open

                def validate(_object, _context, value)
                  assignment =
                    Target.find_by(id: value[:target_id]).assignments.not_archived.last
                  checklist = value[:checklist]
                  assignment
            Severity: Minor
            Found in app/graphql/concerns/validate_student_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 prepare_courses has a Cognitive Complexity of 7 (exceeds 5 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 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 execute has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
            Open

                def execute(assignment_params)
                  Assignment.transaction do
                    @assignment.role = assignment_params[:role]
                    @assignment.completion_instructions =
                      assignment_params[:completion_instructions]
            Severity: Minor
            Found in app/services/assignments/update_service.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

            Avoid too many return statements within this method.
            Open

                return true if current_school_admin.present?
            Severity: Major
            Found in app/queries/student_submissions_resolver.rb - About 30 mins to fix
              Severity
              Category
              Status
              Source
              Language