Skip to content

Commit 497da8e

Browse files
committed
Fix lint
1 parent 8d3df3c commit 497da8e

File tree

2 files changed

+11
-6
lines changed

2 files changed

+11
-6
lines changed

models/index.go

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ type ResourceIndex struct {
2121
// IssueIndex represents the issue index table
2222
type IssueIndex ResourceIndex
2323

24-
// the function will not return until it acquires the lock or receives an error.
24+
// upsertResourceIndex the function will not return until it acquires the lock or receives an error.
2525
func upsertResourceIndex(e Engine, tableName string, groupID int64) (err error) {
2626
// An atomic UPSERT operation (INSERT/UPDATE) is the only operation
2727
// that ensures that the key is actually locked.
@@ -50,13 +50,19 @@ func upsertResourceIndex(e Engine, tableName string, groupID int64) (err error)
5050
}
5151

5252
var (
53-
ErrResouceOutdated = errors.New("resource outdated")
53+
// ErrResouceOutdated represents an error when request resource outdated
54+
ErrResouceOutdated = errors.New("resource outdated")
55+
// ErrGetResourceIndexFailed represents an error when resource index retries 3 times
5456
ErrGetResourceIndexFailed = errors.New("get resource index failed")
5557
)
5658

59+
const (
60+
maxDupIndexAttempts = 3
61+
)
62+
5763
// GetNextResourceIndex retried 3 times to generate a resource index
5864
func GetNextResourceIndex(tableName string, groupID int64) (int64, error) {
59-
for i := 0; i < 3; i++ {
65+
for i := 0; i < maxDupIndexAttempts; i++ {
6066
idx, err := getNextResourceIndex(tableName, groupID)
6167
if err == ErrResouceOutdated {
6268
continue

models/issue.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,9 +78,8 @@ var (
7878
)
7979

8080
const (
81-
issueTasksRegexpStr = `(^\s*[-*]\s\[[\sxX]\]\s.)|(\n\s*[-*]\s\[[\sxX]\]\s.)`
82-
issueTasksDoneRegexpStr = `(^\s*[-*]\s\[[xX]\]\s.)|(\n\s*[-*]\s\[[xX]\]\s.)`
83-
issueMaxDupIndexAttempts = 3
81+
issueTasksRegexpStr = `(^\s*[-*]\s\[[\sxX]\]\s.)|(\n\s*[-*]\s\[[\sxX]\]\s.)`
82+
issueTasksDoneRegexpStr = `(^\s*[-*]\s\[[xX]\]\s.)|(\n\s*[-*]\s\[[xX]\]\s.)`
8483
)
8584

8685
func init() {

0 commit comments

Comments
 (0)