chore: Enable additional gocritic (#13713)

This commit is contained in:
Joshua Powers 2023-08-03 08:11:26 -06:00 committed by GitHub
parent 2ae65d1a94
commit 564f24a0a4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 11 additions and 2 deletions

View File

@ -84,6 +84,7 @@ linters-settings:
- caseOrder - caseOrder
- codegenComment - codegenComment
- deferInLoop - deferInLoop
- dupArg
- dupBranchBody - dupBranchBody
- dupCase - dupCase
- dupSubExpr - dupSubExpr
@ -92,7 +93,10 @@ linters-settings:
- evalOrder - evalOrder
- exitAfterDefer - exitAfterDefer
- externalErrorReassign - externalErrorReassign
- flagName
- mapKey
- nilValReturn - nilValReturn
- offBy1
- regexpPattern - regexpPattern
- sloppyTypeAssert - sloppyTypeAssert
- sortSlice - sortSlice

View File

@ -248,7 +248,12 @@ func snmpTranslateCall(oid string) (mibName string, oidNum string, oidText strin
} }
if i := strings.Index(obj, "("); i != -1 { if i := strings.Index(obj, "("); i != -1 {
obj = obj[i+1:] obj = obj[i+1:]
oidNum += "." + obj[:strings.Index(obj, ")")] if j := strings.Index(obj, ")"); j != -1 {
oidNum += "." + obj[:j]
} else {
return "", "", "", "", fmt.Errorf("getting OID number from: %s", obj)
}
} else { } else {
oidNum += "." + obj oidNum += "." + obj
} }

View File

@ -35,7 +35,7 @@ func newM2() telegraf.Metric {
map[string]interface{}{ map[string]interface{}{
"Request": "/mixed/CASE/paTH/?from=-1D&to=now", "Request": "/mixed/CASE/paTH/?from=-1D&to=now",
"req/sec": 5, "req/sec": 5,
" whitespace ": " whitespace\t", " whitespace ": " whitespace\t", //nolint:gocritic // additional whitespace on purpose for testing
}, },
time.Now(), time.Now(),
) )