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:
enable-all: true
disable:
- containedctx
- contextcheck
- cyclop
- exhaustivestruct
- forbidigo
@ -16,12 +18,16 @@ linters:
- gomnd
- ifshort
- interfacer
- ireturn
- lll
- nestif
- nilnil
- nlreturn
- noctx
- revive
- tagliatelle
- testpackage
- varnamelen
- whitespace
- wrapcheck
- wsl

View file

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

View file

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

View file

@ -45,7 +45,7 @@ func makeKey(dbName, key string) string {
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) {
dbName := fmt.Sprintf("testing-%s-%v", storageType, shadowDelete)
fmt.Println(dbName)

View file

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

View file

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

View file

@ -259,7 +259,7 @@ func (d *GenCodeTestStruct) Size() (s uint64) {
return
}
func (d *GenCodeTestStruct) GenCodeMarshal(buf []byte) ([]byte, error) {
func (d *GenCodeTestStruct) GenCodeMarshal(buf []byte) ([]byte, error) { //nolint:maintidx
size := d.Size()
{
if uint64(cap(buf)) >= size {
@ -555,7 +555,7 @@ func (d *GenCodeTestStruct) GenCodeMarshal(buf []byte) ([]byte, error) {
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)
{

View file

@ -96,7 +96,7 @@ func TriggerWriterChannel() chan struct{} {
}
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() {

View file

@ -269,6 +269,6 @@ func (mng *Manager) findParentSubsystem(m *modules.Module) (*Subsystem, *ModuleS
// Otherwise Less() will panic.
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) Len() int { return len(sl) }

View file

@ -427,7 +427,7 @@ func waitUntilNextScheduledTask() <-chan time.Time {
defer scheduleLock.Unlock()
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
}

View file

@ -278,7 +278,7 @@ func (r *Registry) getMatchingProvider(key string) *keyedValueProvider {
return nil
}
return provider.(*keyedValueProvider)
return provider.(*keyedValueProvider) //nolint:forcetypeassert
}
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
// we need to ask
if _, p, ok := r.providers.LongestPrefix(prefix); ok {
return []*keyedValueProvider{p.(*keyedValueProvider)}
return []*keyedValueProvider{p.(*keyedValueProvider)} //nolint:forcetypeassert
}
var providers []*keyedValueProvider
r.providers.WalkPrefix(prefix, func(key string, p interface{}) bool {
providers = append(providers, p.(*keyedValueProvider))
providers = append(providers, p.(*keyedValueProvider)) //nolint:forcetypeassert
return false
})

View file

@ -84,12 +84,12 @@ func TestRegistryGet(t *testing.T) {
r, err = reg.Get("p1/f1/v1")
require.NoError(t, err)
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")
require.NoError(t, err)
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")
require.Error(t, err)