education/classroom

View on GitHub

Showing 37 of 77 total issues

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

  def perform
    start = Time.zone.now
    invite_status.creating_repo!
    Broadcaster.call(exercise, :create_repo, :text)

Severity: Minor
Found in app/services/create_github_repo_service.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 build_http_request has 5 arguments (exceeds 4 allowed). Consider refactoring.
Open

        def build_http_request(endpoint, method, headers, query, body)
Severity: Minor
Found in lib/github_classroom/lti/mixins/request_signing.rb - About 35 mins to fix

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

      def create_repo
        job_started = false
        if current_invitation_status.accepted? || current_invitation_status.errored?
          assignment_repo = AssignmentRepo.find_by(assignment: current_assignment, user: current_user)
          assignment_repo&.destroy if assignment_repo&.github_repository&.empty?
    Severity: Minor
    Found in app/controllers/assignment_invitations_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 route_based_on_status has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

      def route_based_on_status
        case current_invitation_status.status
        when "unaccepted"
          redirect_to assignment_invitation_path(current_invitation) if action_name != "show"
        when "completed"
    Severity: Minor
    Found in app/controllers/assignment_invitations_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

    Avoid too many return statements within this method.
    Open

              return false unless lti_message.resource_link_id
    Severity: Major
    Found in lib/github_classroom/lti/message_store.rb - About 30 mins to fix

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

        def perform(assignment, collaborator, retries: 0)
          return unless assignment.invitation.status(collaborator).waiting?
          service = CreateGitHubRepoService.new(assignment, collaborator)
          result = service.perform
          raise CreateGitHubRepoService::Result::Error, result.error if result.failed?
      Severity: Minor
      Found in app/jobs/create_github_repository_new_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

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

        def authenticate_user!
          if logged_in?
            return log_out_and_flash unless current_user.authorized_access_token?
            return become_active if adequate_scopes?
          end
      Severity: Minor
      Found in app/controllers/application_controller/authentication_dependency.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 create_repo has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

        def create_repo
          job_started =
            if group_invite_status.accepted? || group_invite_status.errored?
              if repo_ready?
                group_invite_status.completed!
      Severity: Minor
      Found in app/controllers/group_assignment_invitations_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 users_with_admin_org_hook_scope has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

        def users_with_admin_org_hook_scope
          return @users_with_scope if defined?(@users_with_scope)
      
          @users_with_scope = []
      
      
      Severity: Minor
      Found in app/models/organization_webhook.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 transfer has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

        def transfer
          return false unless user_owns_any_assignments?
          organization.all_assignments.each do |assignment|
            next unless assignment.creator_id == old_user.id
            assignment.update(creator_id: new_user.id)
      Severity: Minor
      Found in app/services/transfer_assignments_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 add_students has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          def add_students
            if params[:lms_user_ids].is_a? String
              params[:lms_user_ids] = params[:lms_user_ids].split
            end
            identifiers = params[:identifiers].split("\r\n").reject(&:blank?)
      Severity: Minor
      Found in app/controllers/orgs/rosters_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 redeem_for has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

        def redeem_for(invitee)
          return reason_for_disabled_invitations unless enabled?
      
          if (repo_access = RepoAccess.find_by(user: invitee, organization: organization))
            assignment_repo = AssignmentRepo.find_by(assignment: assignment, repo_access: repo_access)
      Severity: Minor
      Found in app/models/assignment_invitation.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 validate_starter_code_repository_id has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

        def validate_starter_code_repository_id(repo_id)
          valid_integer_or_number_string = repo_id.is_a?(Integer) || (repo_id.is_a?(String) && repo_id.to_s =~ /^[0-9]+$/)
          raise GitHub::Error, INVALID_SELECTION unless valid_integer_or_number_string
      
          possible_github_repository = GitHubRepository.new(current_user.github_client, repo_id.to_i)
      Severity: Minor
      Found in app/controllers/concerns/starter_code.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 descendents has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

            def descendents(scope)
              if parent_scope?(scope)
                return SCOPE_TREE[scope].keys.map do |child|
                  [child, descendents(child)]
                end.flatten
      Severity: Minor
      Found in lib/github/token.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 ensure_webhook_is_active! has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

        def ensure_webhook_is_active!(client: nil)
          client ||= admin_org_hook_scoped_github_client
          retrieve_org_hook_id!(client) if github_id.blank?
          return create_org_hook!(client) if github_id.blank?
          github_org_hook_is_active = github_org_hook(client).active?
      Severity: Minor
      Found in app/models/organization_webhook.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(payload_body)
          return true unless payload_body.dig("action") == "member_removed"
      
          github_user_id = payload_body.dig("membership", "user", "id")
          github_organization_id = payload_body.dig("organization", "id")
      Severity: Minor
      Found in app/jobs/organization_event_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

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

        def perform(payload_body)
          return true unless payload_body["action"] == "removed"
      
          user_id = payload_body.dig("member", "id")
          team_id = payload_body.dig("team", "id")
      Severity: Minor
      Found in app/jobs/membership_event_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