test(linters): Enable sloppyLen (#15512)

This commit is contained in:
Joshua Powers 2024-06-17 08:23:32 -06:00 committed by GitHub
parent 7037429e6a
commit f55e02e8fd
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 8 additions and 7 deletions

View File

@ -109,6 +109,7 @@ linters-settings:
- nilValReturn
- offBy1
- regexpPattern
- sloppyLen
- sloppyReassign
- sloppyTypeAssert
- sortSlice

View File

@ -218,7 +218,7 @@ func (a *Aerospike) parseNodeInfo(acc telegraf.Accumulator, stats map[string]str
func (a *Aerospike) getNamespaces(n *as.Node, infoPolicy *as.InfoPolicy) ([]string, error) {
var namespaces []string
if len(a.Namespaces) <= 0 {
if len(a.Namespaces) == 0 {
info, err := n.RequestInfo(infoPolicy, "namespaces")
if err != nil {
return namespaces, err
@ -262,7 +262,7 @@ func (a *Aerospike) parseNamespaceInfo(acc telegraf.Accumulator, stats map[strin
func (a *Aerospike) getSets(n *as.Node, infoPolicy *as.InfoPolicy) ([]string, error) {
var namespaceSets []string
// Gather all sets
if len(a.Sets) <= 0 {
if len(a.Sets) == 0 {
stats, err := n.RequestInfo(infoPolicy, "sets")
if err != nil {
return namespaceSets, err

View File

@ -46,7 +46,7 @@ func (d *Dovecot) Gather(acc telegraf.Accumulator) error {
d.Servers = append(d.Servers, "127.0.0.1:24242")
}
if len(d.Filters) <= 0 {
if len(d.Filters) == 0 {
d.Filters = append(d.Filters, "")
}

View File

@ -83,7 +83,7 @@ func (f *File) refreshFilePaths() error {
return fmt.Errorf("could not compile glob %q: %w", file, err)
}
files := g.Match()
if len(files) <= 0 {
if len(files) == 0 {
return fmt.Errorf("could not find file(s): %v", file)
}
allFiles = append(allFiles, files...)

View File

@ -221,7 +221,7 @@ func TestSubscribeClientIntegration(t *testing.T) {
}
}
if len(newRemaining) <= 0 {
if len(newRemaining) == 0 {
return
}
@ -361,7 +361,7 @@ func TestSubscribeClientIntegrationAdditionalFields(t *testing.T) {
}
}
if len(newRemaining) <= 0 {
if len(newRemaining) == 0 {
return
}
// Test if the received metric matches one of the expected

View File

@ -511,7 +511,7 @@ func (c *X509Cert) collectCertURLs() []*url.URL {
for _, path := range c.globpaths {
files := path.Match()
if len(files) <= 0 {
if len(files) == 0 {
c.Log.Errorf("could not find file: %v", path.GetRoots())
continue
}