Skip to content

Commit ac542b4

Browse files
committed
chore: fix new issue detected by go-critic
1 parent f7cfe24 commit ac542b4

File tree

6 files changed

+12
-9
lines changed

6 files changed

+12
-9
lines changed

.golangci.yml

+3
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,9 @@ linters:
117117
# - wsl
118118

119119
issues:
120+
exclude:
121+
# disable this rule for go1.15 compatibility
122+
- 'ioutilDeprecated:'
120123
# Excluding configuration per-path, per-linter, per-text and per-source
121124
exclude-rules:
122125
- path: _test\.go

pkg/golinters/goanalysis/runner_loadingpackage.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -492,6 +492,6 @@ func sizeOfReflectValueTreeBytes(rv reflect.Value, visitedPtrs map[uintptr]struc
492492
case reflect.Invalid:
493493
return 0
494494
default:
495-
panic("unknown rv of type " + fmt.Sprint(rv))
495+
panic("unknown rv of type " + rv.String())
496496
}
497497
}

pkg/golinters/gocritic.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ func NewGocritic() *goanalysis.Linter {
3434
}
3535
return goanalysis.NewLinter(
3636
gocriticName,
37-
`Provides many diagnostics that check for bugs, performance and style issues.
37+
`Provides diagnostics that check for bugs, performance and style issues.
3838
Extensible without recompilation through dynamic rules.
3939
Dynamic rules are written declaratively with AST patterns, filters, report message and optional suggestion.`,
4040
[]*analysis.Analyzer{analyzer},

pkg/result/issue.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ func (i *Issue) Fingerprint() string {
9292
}
9393

9494
hash := md5.New() //nolint:gosec
95-
_, _ = hash.Write([]byte(fmt.Sprintf("%s%s%s", i.Pos.Filename, i.Text, firstLine)))
95+
_, _ = fmt.Fprintf(hash, "%s%s%s", i.Pos.Filename, i.Text, firstLine)
9696

9797
return fmt.Sprintf("%X", hash.Sum(nil))
9898
}

pkg/timeutils/stopwatch.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@ const noStagesText = "no stages"
1515
type Stopwatch struct {
1616
name string
1717
startedAt time.Time
18-
stages map[string]time.Duration
1918
log logutils.Log
2019

21-
sync.Mutex
20+
stages map[string]time.Duration
21+
mu sync.Mutex
2222
}
2323

2424
func NewStopwatch(name string, log logutils.Log) *Stopwatch {
@@ -110,7 +110,7 @@ func (s *Stopwatch) TrackStage(name string, f func()) {
110110
startedAt := time.Now()
111111
f()
112112

113-
s.Lock()
113+
s.mu.Lock()
114114
s.stages[name] += time.Since(startedAt)
115-
s.Unlock()
115+
s.mu.Unlock()
116116
}

scripts/expand_website_templates/main.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ func getLatestVersion() (string, error) {
136136
req, err := http.NewRequest( // nolint:noctx
137137
http.MethodGet,
138138
"https://api.github.com/repos/golangci/golangci-lint/releases/latest",
139-
nil,
139+
http.NoBody,
140140
)
141141
if err != nil {
142142
return "", fmt.Errorf("failed to prepare a http request: %s", err)
@@ -286,7 +286,7 @@ func check(b bool, title string) string {
286286
}
287287

288288
func span(title, icon string) string {
289-
return fmt.Sprintf(`<span title="%s">%s</span>`, title, icon)
289+
return fmt.Sprintf(`<span title=%q>%s</span>`, title, icon)
290290
}
291291

292292
func getThanksList() string {

0 commit comments

Comments
 (0)