Skip to content

Commit 1fe1894

Browse files
ldezbombsimon
andcommitted
Apply suggestions from code review
Co-authored-by: Simon Sawert <simon@sawert.se>
1 parent 1d822ca commit 1fe1894

File tree

3 files changed

+9
-5
lines changed

3 files changed

+9
-5
lines changed

pkg/config/config.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ func detectGoVersion() string {
9090

9191
// Trims the Go version to keep only M.m.
9292
// Since Go 1.21 the version inside the go.mod can be a patched version (ex: 1.21.0).
93+
// The version can also include information which we want to remove (ex: 1.21alpha1)
9394
// https://go.dev/doc/toolchain#versions
9495
// This a problem with staticcheck and gocritic.
9596
func trimGoVersion(v string) string {

pkg/config/loader.go

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,20 +73,22 @@ func (l *Loader) handleGoVersion() {
7373

7474
l.cfg.LintersSettings.ParallelTest.Go = l.cfg.Run.Go
7575

76-
l.cfg.LintersSettings.Gocritic.Go = trimGoVersion(l.cfg.Run.Go)
76+
trimmedGoVersion := trimGoVersion(l.cfg.Run.Go)
77+
78+
l.cfg.LintersSettings.Gocritic.Go = trimmedGoVersion
7779
if l.cfg.LintersSettings.Gofumpt.LangVersion == "" {
7880
l.cfg.LintersSettings.Gofumpt.LangVersion = l.cfg.Run.Go
7981
}
8082

8183
// staticcheck related linters.
8284
if l.cfg.LintersSettings.Staticcheck.GoVersion == "" {
83-
l.cfg.LintersSettings.Staticcheck.GoVersion = trimGoVersion(l.cfg.Run.Go)
85+
l.cfg.LintersSettings.Staticcheck.GoVersion = trimmedGoVersion
8486
}
8587
if l.cfg.LintersSettings.Gosimple.GoVersion == "" {
86-
l.cfg.LintersSettings.Gosimple.GoVersion = trimGoVersion(l.cfg.Run.Go)
88+
l.cfg.LintersSettings.Gosimple.GoVersion = trimmedGoVersion
8789
}
8890
if l.cfg.LintersSettings.Stylecheck.GoVersion != "" {
89-
l.cfg.LintersSettings.Stylecheck.GoVersion = trimGoVersion(l.cfg.Run.Go)
91+
l.cfg.LintersSettings.Stylecheck.GoVersion = trimmedGoVersion
9092
}
9193
}
9294

pkg/lint/lintersdb/validator.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ func NewValidator(m *Manager) *Validator {
1717
return &Validator{m: m}
1818
}
1919

20-
// Validate validates the configuration.
20+
// Validate validates the configuration by calling all other validators for different
21+
// sections in the configuration and then some additional linter validation functions.
2122
func (v Validator) Validate(cfg *config.Config) error {
2223
err := cfg.Validate()
2324
if err != nil {

0 commit comments

Comments
 (0)