Fix or disable new linters

This commit is contained in:
Daniel 2022-02-01 13:40:50 +01:00
parent fcb5ca2473
commit 3e4e0c361d
12 changed files with 23 additions and 15 deletions

View file

@ -4,6 +4,8 @@
linters: linters:
enable-all: true enable-all: true
disable: disable:
- containedctx
- contextcheck
- cyclop - cyclop
- exhaustivestruct - exhaustivestruct
- forbidigo - forbidigo
@ -16,12 +18,16 @@ linters:
- gomnd - gomnd
- ifshort - ifshort
- interfacer - interfacer
- ireturn
- lll - lll
- nestif - nestif
- nilnil
- nlreturn - nlreturn
- noctx - noctx
- revive - revive
- tagliatelle
- testpackage - testpackage
- varnamelen
- whitespace - whitespace
- wrapcheck - wrapcheck
- wsl - wsl

View file

@ -13,8 +13,6 @@ type Accessor interface {
GetFloat(key string) (value float64, ok bool) GetFloat(key string) (value float64, ok bool)
GetBool(key string) (value bool, ok bool) GetBool(key string) (value bool, ok bool)
Exists(key string) bool Exists(key string) bool
Set(key string, value interface{}) error Set(key string, value interface{}) error
Type() string Type() string
} }

View file

@ -44,7 +44,7 @@ var (
F64: 42.42, F64: 42.42,
B: true, B: true,
} }
testJSONBytes, _ = json.Marshal(testStruct) testJSONBytes, _ = json.Marshal(testStruct) //nolint:errchkjson
testJSON = string(testJSONBytes) testJSON = string(testJSONBytes)
) )

View file

@ -45,7 +45,7 @@ func makeKey(dbName, key string) string {
return fmt.Sprintf("%s:%s", dbName, key) return fmt.Sprintf("%s:%s", dbName, key)
} }
func testDatabase(t *testing.T, storageType string, shadowDelete bool) { //nolint:gocognit,gocyclo,thelper func testDatabase(t *testing.T, storageType string, shadowDelete bool) { //nolint:maintidx,thelper
t.Run(fmt.Sprintf("TestStorage_%s_%v", storageType, shadowDelete), func(t *testing.T) { t.Run(fmt.Sprintf("TestStorage_%s_%v", storageType, shadowDelete), func(t *testing.T) {
dbName := fmt.Sprintf("testing-%s-%v", storageType, shadowDelete) dbName := fmt.Sprintf("testing-%s-%v", storageType, shadowDelete)
fmt.Println(dbName) fmt.Println(dbName)

View file

@ -12,17 +12,21 @@ type Record interface {
DatabaseName() string // test DatabaseName() string // test
DatabaseKey() string // config DatabaseKey() string // config
// Metadata.
Meta() *Meta Meta() *Meta
SetMeta(meta *Meta) SetMeta(meta *Meta)
CreateMeta() CreateMeta()
UpdateMeta() UpdateMeta()
// Serialization.
Marshal(self Record, format uint8) ([]byte, error) Marshal(self Record, format uint8) ([]byte, error)
MarshalRecord(self Record) ([]byte, error) MarshalRecord(self Record) ([]byte, error)
GetAccessor(self Record) accessor.Accessor GetAccessor(self Record) accessor.Accessor
// Locking.
Lock() Lock()
Unlock() Unlock()
// Wrapping.
IsWrapped() bool IsWrapped() bool
} }

View file

@ -117,7 +117,7 @@ var (
} }
) )
func TestConversion(t *testing.T) { func TestConversion(t *testing.T) { //nolint:maintidx
t.Parallel() t.Parallel()
compressionFormats := []uint8{AUTO, GZIP} compressionFormats := []uint8{AUTO, GZIP}

View file

@ -259,7 +259,7 @@ func (d *GenCodeTestStruct) Size() (s uint64) {
return return
} }
func (d *GenCodeTestStruct) GenCodeMarshal(buf []byte) ([]byte, error) { func (d *GenCodeTestStruct) GenCodeMarshal(buf []byte) ([]byte, error) { //nolint:maintidx
size := d.Size() size := d.Size()
{ {
if uint64(cap(buf)) >= size { if uint64(cap(buf)) >= size {
@ -555,7 +555,7 @@ func (d *GenCodeTestStruct) GenCodeMarshal(buf []byte) ([]byte, error) {
return buf[:i+35], nil return buf[:i+35], nil
} }
func (d *GenCodeTestStruct) GenCodeUnmarshal(buf []byte) (uint64, error) { func (d *GenCodeTestStruct) GenCodeUnmarshal(buf []byte) (uint64, error) { //nolint:maintidx
i := uint64(0) i := uint64(0)
{ {

View file

@ -96,7 +96,7 @@ func TriggerWriterChannel() chan struct{} {
} }
func defaultColorFormater(line Message, duplicates uint64) string { func defaultColorFormater(line Message, duplicates uint64) string {
return formatLine(line.(*logLine), duplicates, true) return formatLine(line.(*logLine), duplicates, true) //nolint:forcetypeassert // TODO: improve
} }
func startWriter() { func startWriter() {

View file

@ -269,6 +269,6 @@ func (mng *Manager) findParentSubsystem(m *modules.Module) (*Subsystem, *ModuleS
// Otherwise Less() will panic. // Otherwise Less() will panic.
type bySubsystemID []record.Record type bySubsystemID []record.Record
func (sl bySubsystemID) Less(i, j int) bool { return sl[i].(*Subsystem).ID < sl[j].(*Subsystem).ID } func (sl bySubsystemID) Less(i, j int) bool { return sl[i].(*Subsystem).ID < sl[j].(*Subsystem).ID } //nolint:forcetypeassert // Can only be *Subsystem.
func (sl bySubsystemID) Swap(i, j int) { sl[i], sl[j] = sl[j], sl[i] } func (sl bySubsystemID) Swap(i, j int) { sl[i], sl[j] = sl[j], sl[i] }
func (sl bySubsystemID) Len() int { return len(sl) } func (sl bySubsystemID) Len() int { return len(sl) }

View file

@ -427,7 +427,7 @@ func waitUntilNextScheduledTask() <-chan time.Time {
defer scheduleLock.Unlock() defer scheduleLock.Unlock()
if taskSchedule.Len() > 0 { if taskSchedule.Len() > 0 {
return time.After(time.Until(taskSchedule.Front().Value.(*Task).executeAt)) return time.After(time.Until(taskSchedule.Front().Value.(*Task).executeAt)) //nolint:forcetypeassert // Can only be *Task.
} }
return waitForever return waitForever
} }

View file

@ -278,7 +278,7 @@ func (r *Registry) getMatchingProvider(key string) *keyedValueProvider {
return nil return nil
} }
return provider.(*keyedValueProvider) return provider.(*keyedValueProvider) //nolint:forcetypeassert
} }
func (r *Registry) collectProviderByPrefix(prefix string) []*keyedValueProvider { func (r *Registry) collectProviderByPrefix(prefix string) []*keyedValueProvider {
@ -288,12 +288,12 @@ func (r *Registry) collectProviderByPrefix(prefix string) []*keyedValueProvider
// if there's a LongestPrefix provider that's the only one // if there's a LongestPrefix provider that's the only one
// we need to ask // we need to ask
if _, p, ok := r.providers.LongestPrefix(prefix); ok { if _, p, ok := r.providers.LongestPrefix(prefix); ok {
return []*keyedValueProvider{p.(*keyedValueProvider)} return []*keyedValueProvider{p.(*keyedValueProvider)} //nolint:forcetypeassert
} }
var providers []*keyedValueProvider var providers []*keyedValueProvider
r.providers.WalkPrefix(prefix, func(key string, p interface{}) bool { r.providers.WalkPrefix(prefix, func(key string, p interface{}) bool {
providers = append(providers, p.(*keyedValueProvider)) providers = append(providers, p.(*keyedValueProvider)) //nolint:forcetypeassert
return false return false
}) })

View file

@ -84,12 +84,12 @@ func TestRegistryGet(t *testing.T) {
r, err = reg.Get("p1/f1/v1") r, err = reg.Get("p1/f1/v1")
require.NoError(t, err) require.NoError(t, err)
require.NotNil(t, r) require.NotNil(t, r)
assert.Equal(t, "p1.1", r.(*testRecord).Value) assert.Equal(t, "p1.1", r.(*testRecord).Value) //nolint:forcetypeassert
r, err = reg.Get("p1/v3") r, err = reg.Get("p1/v3")
require.NoError(t, err) require.NoError(t, err)
require.NotNil(t, r) require.NotNil(t, r)
assert.Equal(t, "p1.3", r.(*testRecord).Value) assert.Equal(t, "p1.3", r.(*testRecord).Value) //nolint:forcetypeassert
r, err = reg.Get("p1/v4") r, err = reg.Get("p1/v4")
require.Error(t, err) require.Error(t, err)