Repository: go-gitea/gitea
File: models/issues/comment.go (Go)

Code before:
	err := c.LoadIssue(ctx)
	if err != nil { // Silently dropping errors :unamused:
		log.Error("LoadIssue(%d): %v", c.IssueID, err)
		return ""
	}
	err = c.Issue.LoadRepo(ctx)
	if err != nil { // Silently dropping errors :unamused:
		log.Error("loadRepo(%d): %v", c.Issue.RepoID, err)
		return ""
	}
	return fmt.Sprintf("%s/files#%s", c.Issue.Link(), c.HashTag())
}

func (c *Comment) MetaSpecialDoerTr(locale translation.Locale) template.HTML {
	if c.CommentMetaData == nil {
		return ""
	}
	if c.CommentMetaData.SpecialDoerName == SpecialDoerNameCodeOwners {
		return locale.Tr("repo.issues.review.codeowners_rules")
	}
	return htmlutil.HTMLFormat("%s", c.CommentMetaData.SpecialDoerName)
}

func (c *Comment) TimelineRequestedReviewTr(locale translation.Locale, createdStr template.HTML) template.HTML {
	if c.AssigneeID > 0 {
		// it guarantees LoadAssigneeUserAndTeam has been called, and c.Assignee is Ghost user but not nil
		if c.RemovedAssignee {
			if c.PosterID == c.AssigneeID {
				return locale.Tr("repo.issues.review.remove_review_request_self", createdStr)
			}
			return locale.Tr("repo.issues.review.remove_review_request", c.Assignee.GetDisplayName(), createdStr)
		}
		return locale.Tr("repo.issues.review.add_review_request", c.Assignee.GetDisplayName(), createdStr)
	}
	teamName := "Ghost Team"
	if c.AssigneeTeam != nil {
		teamName = c.AssigneeTeam.Name
	}
	if c.RemovedAssignee {
		return locale.Tr("repo.issues.review.remove_review_request", teamName, createdStr)
	}
	return locale.Tr("repo.issues.review.add_review_request", teamName, createdStr)
}

// CreateComment creates comment with context
func CreateComment(ctx context.Context, opts *CreateCommentOptions) (_ *Comment, err error) {
	return db.WithTx2(ctx, func(ctx context.Context) (*Comment, error) {
		var LabelID int64
		if opts.Label != nil {
			LabelID = opts.Label.ID
		}

Review comment (suggestion):
```suggestion
		// it guarantees LoadAssigneeUserAndTeam has been called, and c.Assignee is Ghost user but not nil if the user doesn't exist
```

Code after:
	err := c.LoadIssue(ctx)
	if err != nil { // Silently dropping errors :unamused:
		log.Error("LoadIssue(%d): %v", c.IssueID, err)
		return ""
	}
	err = c.Issue.LoadRepo(ctx)
	if err != nil { // Silently dropping errors :unamused:
		log.Error("loadRepo(%d): %v", c.Issue.RepoID, err)
		return ""
	}
	return fmt.Sprintf("%s/files#%s", c.Issue.Link(), c.HashTag())
}

func (c *Comment) MetaSpecialDoerTr(locale translation.Locale) template.HTML {
	if c.CommentMetaData == nil {
		return ""
	}
	if c.CommentMetaData.SpecialDoerName == SpecialDoerNameCodeOwners {
		return locale.Tr("repo.issues.review.codeowners_rules")
	}
	return htmlutil.HTMLFormat("%s", c.CommentMetaData.SpecialDoerName)
}

func (c *Comment) TimelineRequestedReviewTr(locale translation.Locale, createdStr template.HTML) template.HTML {
	if c.AssigneeID > 0 {
		// it guarantees LoadAssigneeUserAndTeam has been called, and c.Assignee is Ghost user but not nil if the user doesn't exist
		if c.RemovedAssignee {
			if c.PosterID == c.AssigneeID {
				return locale.Tr("repo.issues.review.remove_review_request_self", createdStr)
			}
			return locale.Tr("repo.issues.review.remove_review_request", c.Assignee.GetDisplayName(), createdStr)
		}
		return locale.Tr("repo.issues.review.add_review_request", c.Assignee.GetDisplayName(), createdStr)
	}
	teamName := "Ghost Team"
	if c.AssigneeTeam != nil {
		teamName = c.AssigneeTeam.Name
	}
	if c.RemovedAssignee {
		return locale.Tr("repo.issues.review.remove_review_request", teamName, createdStr)
	}
	return locale.Tr("repo.issues.review.add_review_request", teamName, createdStr)
}

// CreateComment creates comment with context
func CreateComment(ctx context.Context, opts *CreateCommentOptions) (_ *Comment, err error) {
	return db.WithTx2(ctx, func(ctx context.Context) (*Comment, error) {
		var LabelID int64
		if opts.Label != nil {
			LabelID = opts.Label.ID
		}