Skip to content

Commit 36a3868

Browse files
alexandearsagikazarmark
authored andcommitted
Review changes
1 parent f0c4ccd commit 36a3868

File tree

6 files changed

+19
-20
lines changed

6 files changed

+19
-20
lines changed

.golangci.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@ linters-settings:
1313
- diagnostic
1414
- experimental
1515
- opinionated
16-
- performance
1716
- style
1817
disabled-checks:
1918
- importShadow
19+
- unnamedResult
2020
golint:
2121
min-confidence: 0
2222
goimports:

internal/encoding/ini/codec.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ type Codec struct {
1919
LoadOptions LoadOptions
2020
}
2121

22-
func (c *Codec) Encode(v map[string]any) ([]byte, error) {
22+
func (c Codec) Encode(v map[string]any) ([]byte, error) {
2323
cfg := ini.Empty()
2424
ini.PrettyFormat = false
2525

@@ -62,7 +62,7 @@ func (c *Codec) Encode(v map[string]any) ([]byte, error) {
6262
return buf.Bytes(), nil
6363
}
6464

65-
func (c *Codec) Decode(b []byte, v map[string]any) error {
65+
func (c Codec) Decode(b []byte, v map[string]any) error {
6666
cfg := ini.Empty(c.LoadOptions)
6767

6868
err := cfg.Append(b)
@@ -90,7 +90,7 @@ func (c *Codec) Decode(b []byte, v map[string]any) error {
9090
return nil
9191
}
9292

93-
func (c *Codec) keyDelimiter() string {
93+
func (c Codec) keyDelimiter() string {
9494
if c.KeyDelimiter == "" {
9595
return "."
9696
}

logger.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@ func (n *discardHandler) Enabled(_ context.Context, _ slog.Level) bool {
5555
return false
5656
}
5757

58-
//nolint:gocritic // hugeParam: _ is heavy (288 bytes); consider passing it by pointer
5958
func (n *discardHandler) Handle(_ context.Context, _ slog.Record) error {
6059
return nil
6160
}

remote/remote.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ func (rc remoteConfigProvider) Watch(rp viper.RemoteProvider) (io.Reader, error)
4444
return bytes.NewReader(resp), nil
4545
}
4646

47-
func (rc remoteConfigProvider) WatchChannel(rp viper.RemoteProvider) (responseCh <-chan *viper.RemoteResponse, quitCh chan bool) {
47+
func (rc remoteConfigProvider) WatchChannel(rp viper.RemoteProvider) (<-chan *viper.RemoteResponse, chan bool) {
4848
cm, err := getConfigManager(rp)
4949
if err != nil {
5050
return nil, nil

viper.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -345,7 +345,7 @@ func (v *Viper) resetEncoding() {
345345
}
346346

347347
{
348-
codec := &ini.Codec{
348+
codec := ini.Codec{
349349
KeyDelimiter: v.keyDelim,
350350
LoadOptions: v.iniLoadOptions,
351351
}
@@ -2182,8 +2182,6 @@ func (v *Viper) SetConfigPermissions(perm os.FileMode) {
21822182
}
21832183

21842184
// IniLoadOptions sets the load options for ini parsing.
2185-
//
2186-
//nolint:gocritic // hugeParam: in is heavy (114 bytes); consider passing it by pointer
21872185
func IniLoadOptions(in ini.LoadOptions) Option {
21882186
return optionFunc(func(v *Viper) {
21892187
v.iniLoadOptions = in

viper_test.go

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -234,15 +234,17 @@ func initIni() {
234234
}
235235

236236
// initDirs makes directories for testing.
237-
func initDirs(t *testing.T) (root, config string) {
238-
testDirs := []string{`a a`, `b`, `C_`}
239-
config = `improbable`
237+
func initDirs(t *testing.T) (string, string) {
238+
var (
239+
testDirs = []string{`a a`, `b`, `C_`}
240+
config = `improbable`
241+
)
240242

241243
if runtime.GOOS != "windows" {
242244
testDirs = append(testDirs, `d\d`)
243245
}
244246

245-
root = t.TempDir()
247+
root := t.TempDir()
246248

247249
for _, dir := range testDirs {
248250
innerDir := filepath.Join(root, dir)
@@ -2342,21 +2344,21 @@ func doTestCaseInsensitive(t *testing.T, typ, config string) {
23422344
assert.Equal(t, 5, cast.ToInt(Get("ef.lm.p.q")))
23432345
}
23442346

2345-
func newViperWithConfigFile(t *testing.T) (v *Viper, configFile string) {
2347+
func newViperWithConfigFile(t *testing.T) (*Viper, string) {
23462348
watchDir := t.TempDir()
2347-
configFile = path.Join(watchDir, "config.yaml")
2349+
configFile := path.Join(watchDir, "config.yaml")
23482350
err := os.WriteFile(configFile, []byte("foo: bar\n"), 0o640)
23492351
require.NoError(t, err)
2350-
v = New()
2352+
v := New()
23512353
v.SetConfigFile(configFile)
23522354
err = v.ReadInConfig()
23532355
require.NoError(t, err)
23542356
require.Equal(t, "bar", v.Get("foo"))
23552357
return v, configFile
23562358
}
23572359

2358-
func newViperWithSymlinkedConfigFile(t *testing.T) (v *Viper, watchDir, configFile string) {
2359-
watchDir = t.TempDir()
2360+
func newViperWithSymlinkedConfigFile(t *testing.T) (*Viper, string, string) {
2361+
watchDir := t.TempDir()
23602362
dataDir1 := path.Join(watchDir, "data1")
23612363
err := os.Mkdir(dataDir1, 0o777)
23622364
require.NoError(t, err)
@@ -2367,11 +2369,11 @@ func newViperWithSymlinkedConfigFile(t *testing.T) (v *Viper, watchDir, configFi
23672369
// now, symlink the tm `data1` dir to `data` in the baseDir
23682370
os.Symlink(dataDir1, path.Join(watchDir, "data"))
23692371
// and link the `<watchdir>/datadir1/config.yaml` to `<watchdir>/config.yaml`
2370-
configFile = path.Join(watchDir, "config.yaml")
2372+
configFile := path.Join(watchDir, "config.yaml")
23712373
os.Symlink(path.Join(watchDir, "data", "config.yaml"), configFile)
23722374
t.Logf("Config file location: %s\n", path.Join(watchDir, "config.yaml"))
23732375
// init Viper
2374-
v = New()
2376+
v := New()
23752377
v.SetConfigFile(configFile)
23762378
err = v.ReadInConfig()
23772379
require.NoError(t, err)

0 commit comments

Comments
 (0)