Skip to content

Commit

Permalink
chore: fix new issue detected by go-critic
Browse files Browse the repository at this point in the history
  • Loading branch information
ldez committed Oct 20, 2021
1 parent f7cfe24 commit ac542b4
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 9 deletions.
3 changes: 3 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,9 @@ linters:
# - wsl

issues:
exclude:
# disable this rule for go1.15 compatibility
- 'ioutilDeprecated:'
# Excluding configuration per-path, per-linter, per-text and per-source
exclude-rules:
- path: _test\.go
Expand Down
2 changes: 1 addition & 1 deletion pkg/golinters/goanalysis/runner_loadingpackage.go
Original file line number Diff line number Diff line change
Expand Up @@ -492,6 +492,6 @@ func sizeOfReflectValueTreeBytes(rv reflect.Value, visitedPtrs map[uintptr]struc
case reflect.Invalid:
return 0
default:
panic("unknown rv of type " + fmt.Sprint(rv))
panic("unknown rv of type " + rv.String())
}
}
2 changes: 1 addition & 1 deletion pkg/golinters/gocritic.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ func NewGocritic() *goanalysis.Linter {
}
return goanalysis.NewLinter(
gocriticName,
`Provides many diagnostics that check for bugs, performance and style issues.
`Provides diagnostics that check for bugs, performance and style issues.
Extensible without recompilation through dynamic rules.
Dynamic rules are written declaratively with AST patterns, filters, report message and optional suggestion.`,
[]*analysis.Analyzer{analyzer},
Expand Down
2 changes: 1 addition & 1 deletion pkg/result/issue.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ func (i *Issue) Fingerprint() string {
}

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

return fmt.Sprintf("%X", hash.Sum(nil))
}
8 changes: 4 additions & 4 deletions pkg/timeutils/stopwatch.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ const noStagesText = "no stages"
type Stopwatch struct {
name string
startedAt time.Time
stages map[string]time.Duration
log logutils.Log

sync.Mutex
stages map[string]time.Duration
mu sync.Mutex
}

func NewStopwatch(name string, log logutils.Log) *Stopwatch {
Expand Down Expand Up @@ -110,7 +110,7 @@ func (s *Stopwatch) TrackStage(name string, f func()) {
startedAt := time.Now()
f()

s.Lock()
s.mu.Lock()
s.stages[name] += time.Since(startedAt)
s.Unlock()
s.mu.Unlock()
}
4 changes: 2 additions & 2 deletions scripts/expand_website_templates/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ func getLatestVersion() (string, error) {
req, err := http.NewRequest( // nolint:noctx
http.MethodGet,
"https://api.github.com/repos/golangci/golangci-lint/releases/latest",
nil,
http.NoBody,
)
if err != nil {
return "", fmt.Errorf("failed to prepare a http request: %s", err)
Expand Down Expand Up @@ -286,7 +286,7 @@ func check(b bool, title string) string {
}

func span(title, icon string) string {
return fmt.Sprintf(`<span title="%s">%s</span>`, title, icon)
return fmt.Sprintf(`<span title=%q>%s</span>`, title, icon)
}

func getThanksList() string {
Expand Down

0 comments on commit ac542b4

Please sign in to comment.