Skip to content

Commit fd3f166

Browse files
authored
Merge pull request #289 from lunny/lunny/golint_models_issue_comment
Golint fixed for models/issue_comment.go
2 parents 7b6cc92 + 9fc609c commit fd3f166

File tree

1 file changed

+17
-7
lines changed

1 file changed

+17
-7
lines changed

models/issue_comment.go

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import (
2121
// CommentType defines whether a comment is just a simple comment, an action (like close) or a reference.
2222
type CommentType int
2323

24+
// Enumerate all the comment types
2425
const (
2526
// Plain comment, can be associated with a commit (CommitID > 0) and a line (LineNum > 0)
2627
CommentTypeComment CommentType = iota
@@ -37,8 +38,10 @@ const (
3738
CommentTypePullRef
3839
)
3940

41+
// CommentTag defines comment tag type
4042
type CommentTag int
4143

44+
// Enumerate all the comment tag types
4245
const (
4346
CommentTagNone CommentTag = iota
4447
CommentTagPoster
@@ -72,15 +75,19 @@ type Comment struct {
7275
ShowTag CommentTag `xorm:"-"`
7376
}
7477

78+
// BeforeInsert will be invoked by XORM before inserting a record
79+
// representing this object.
7580
func (c *Comment) BeforeInsert() {
7681
c.CreatedUnix = time.Now().Unix()
7782
c.UpdatedUnix = c.CreatedUnix
7883
}
7984

85+
// BeforeUpdate is invoked from XORM before updating this object.
8086
func (c *Comment) BeforeUpdate() {
8187
c.UpdatedUnix = time.Now().Unix()
8288
}
8389

90+
// AfterSet is invoked from XORM after setting the value of a field of this object.
8491
func (c *Comment) AfterSet(colName string, _ xorm.Cell) {
8592
var err error
8693
switch colName {
@@ -107,6 +114,7 @@ func (c *Comment) AfterSet(colName string, _ xorm.Cell) {
107114
}
108115
}
109116

117+
// AfterDelete is invoked from XORM after the object is deleted.
110118
func (c *Comment) AfterDelete() {
111119
_, err := DeleteAttachmentsByComment(c.ID, true)
112120

@@ -115,6 +123,7 @@ func (c *Comment) AfterDelete() {
115123
}
116124
}
117125

126+
// APIFormat converts a Comment to the api.Comment format
118127
func (c *Comment) APIFormat() *api.Comment {
119128
return &api.Comment{
120129
ID: c.ID,
@@ -137,21 +146,21 @@ func (c *Comment) EventTag() string {
137146

138147
// MailParticipants sends new comment emails to repository watchers
139148
// and mentioned people.
140-
func (cmt *Comment) MailParticipants(opType ActionType, issue *Issue) (err error) {
141-
mentions := markdown.FindAllMentions(cmt.Content)
142-
if err = UpdateIssueMentions(cmt.IssueID, mentions); err != nil {
143-
return fmt.Errorf("UpdateIssueMentions [%d]: %v", cmt.IssueID, err)
149+
func (c *Comment) MailParticipants(opType ActionType, issue *Issue) (err error) {
150+
mentions := markdown.FindAllMentions(c.Content)
151+
if err = UpdateIssueMentions(c.IssueID, mentions); err != nil {
152+
return fmt.Errorf("UpdateIssueMentions [%d]: %v", c.IssueID, err)
144153
}
145154

146155
switch opType {
147156
case ActionCommentIssue:
148-
issue.Content = cmt.Content
157+
issue.Content = c.Content
149158
case ActionCloseIssue:
150159
issue.Content = fmt.Sprintf("Closed #%d", issue.Index)
151160
case ActionReopenIssue:
152161
issue.Content = fmt.Sprintf("Reopened #%d", issue.Index)
153162
}
154-
if err = mailIssueCommentToParticipants(issue, cmt.Poster, mentions); err != nil {
163+
if err = mailIssueCommentToParticipants(issue, c.Poster, mentions); err != nil {
155164
log.Error(4, "mailIssueCommentToParticipants: %v", err)
156165
}
157166

@@ -272,6 +281,7 @@ func createStatusComment(e *xorm.Session, doer *User, repo *Repository, issue *I
272281
})
273282
}
274283

284+
// CreateCommentOptions defines options for creating comment
275285
type CreateCommentOptions struct {
276286
Type CommentType
277287
Doer *User
@@ -374,7 +384,7 @@ func GetCommentsByIssueID(issueID int64) ([]*Comment, error) {
374384
return getCommentsByIssueID(x, issueID)
375385
}
376386

377-
// GetCommentsByIssueID returns a list of comments of an issue since a given time point.
387+
// GetCommentsByIssueIDSince returns a list of comments of an issue since a given time point.
378388
func GetCommentsByIssueIDSince(issueID, since int64) ([]*Comment, error) {
379389
return getCommentsByIssueIDSince(x, issueID, since)
380390
}

0 commit comments

Comments
 (0)