pupilfirst/pupilfirst

View on GitHub

Showing 122 of 224 total issues

Avoid too many return statements within this method.
Open

    return true if current_school_admin.present?
Severity: Major
Found in app/policies/timeline_event_file_policy.rb - About 30 mins to fix

    Avoid too many return statements within this method.
    Open

        return false if organisation.blank?
    Severity: Major
    Found in app/policies/timeline_event_policy.rb - About 30 mins to fix

      Avoid too many return statements within this method.
      Open

            return true if course.faculty.exists?(user: current_user)
      Severity: Major
      Found in app/graphql/mutations/create_submission_comment.rb - About 30 mins to fix

        Avoid too many return statements within this method.
        Open

              return true if course.faculty.exists?(user: current_user)
        Severity: Major
        Found in app/graphql/mutations/create_moderation_report.rb - About 30 mins to fix

          Avoid too many return statements within this method.
          Open

                return true if course.faculty.exists?(user: current_user)
          Severity: Major
          Found in app/graphql/mutations/create_reaction.rb - About 30 mins to fix

            Avoid too many return statements within this method.
            Open

                return false if organisation.blank?
            Severity: Major
            Found in app/policies/timeline_event_file_policy.rb - About 30 mins to fix

              Method token has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

                  def token
                    user =
                      Users::AuthenticationService.new(
                        current_school,
                        params[:token]
              Severity: Minor
              Found in app/controllers/users/sessions_controller.rb - About 25 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 download? has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

                def download?
                  return false if user.blank?
              
                  timeline_event = record.timeline_event
              
              
              Severity: Minor
              Found in app/policies/timeline_event_file_policy.rb - About 25 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 connect? has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

                def connect?
                  # Cannot connect if connect link is blank.
                  return false if record.connect_link.blank?
              
                  if user&.students.present?
              Severity: Minor
              Found in app/policies/faculty_policy.rb - About 25 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_team has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

                  def update_team
                    Team.transaction do
                      team.update!(name: @params[:name]) if @params[:name] != team.name
              
                      # Remove old team members
              Severity: Minor
              Found in app/graphql/mutations/update_team.rb - About 25 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 merge_student_profiles has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

                  def merge_student_profiles
                    return if @old_user.students.blank?
              
                    Rails.logger.info("Merging student profiles...")
              
              
              Severity: Minor
              Found in app/services/users/merge_accounts_service.rb - About 25 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 6 (exceeds 5 allowed). Consider refactoring.
              Open

                def execute
                  variables = ensure_hash(params[:variables])
                  query = params[:query]
                  operation_name = params[:operationName]
              
              
              Severity: Minor
              Found in app/controllers/graphql_controller.rb - About 25 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 school_icon has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

                def school_icon(background)
                  icon = background == :dark ? :icon_on_dark_bg : :icon_on_light_bg
              
                  if current_school.present? && current_school.public_send(icon).attached?
                    icon_url =
              Severity: Minor
              Found in app/presenters/error_presenter.rb - About 25 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 mark_as_read? has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

                def mark_as_read?
                  return false if user.blank?
              
                  # Has access to school
                  return false unless course&.school == @current_school && student.present?
              Severity: Minor
              Found in app/policies/target_policy.rb - About 25 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 curriculum? has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

                def curriculum?
                  return true if record.public_preview?
              
                  if current_school_admin.present? ||
                       user.course_authors.where(course: record).present?
              Severity: Minor
              Found in app/policies/course_policy.rb - About 25 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 stringify_ids_in_array has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

                def stringify_ids_in_array(key, array)
                  if key.ends_with?('_ids')
                    array.map(&:to_s)
                  else
                    array.map do |element|
              Severity: Minor
              Found in lib/stringify_ids.rb - About 25 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 status has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

                def status
                  if passed_at.blank?
                    evaluated_at.present? ? :failed : :pending
                  else
                    evaluated_at.present? ? :passed : :marked_as_complete
              Severity: Minor
              Found in app/models/timeline_event.rb - About 25 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 recaptcha_success? has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

                def recaptcha_success?(form, action:)
                  if Rails.env.test?
                    true
                  else
                    hostname = current_school.domains.primary.fqdn
              Severity: Minor
              Found in app/controllers/concerns/recaptcha_verifiable.rb - About 25 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 merge_coach_profiles has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

                  def merge_coach_profiles
                    old_user_coach = @old_user.faculty
              
                    return if @old_user.faculty.blank?
              
              
              Severity: Minor
              Found in app/services/users/merge_accounts_service.rb - About 25 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 perform has a Cognitive Complexity of 6 (exceeds 5 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 25 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