mirror of
https://github.com/hanzoai/visor.git
synced 2026-09-24 17:04:14 +00:00
Fix QF1003 violations and drop suppression
This commit is contained in:
@@ -239,10 +239,6 @@ analyzers:
|
||||
# See above.
|
||||
- "symbol \"runtime_pollWaitCanceled\".*"
|
||||
- "symbol \"runtime_procPin\".*"
|
||||
QF1003: # Convert if/else-if chain to tagged switch
|
||||
# disabled for now due to existing violations.
|
||||
internal:
|
||||
exclude: [".*"]
|
||||
QF1004: # Use strings.ReplaceAll instead of Replace(..., -1)
|
||||
# disabled for now due to existing violations.
|
||||
internal:
|
||||
|
||||
+3
-2
@@ -233,9 +233,10 @@ func readHWCap(auxvFilepath string) (hwCap, error) {
|
||||
for i := 0; i < l; i++ {
|
||||
tag := binary.LittleEndian.Uint64(auxv[i*16:])
|
||||
val := binary.LittleEndian.Uint64(auxv[i*16+8:])
|
||||
if tag == _AT_HWCAP {
|
||||
switch tag {
|
||||
case _AT_HWCAP:
|
||||
c.hwCap1 = val
|
||||
} else if tag == _AT_HWCAP2 {
|
||||
case _AT_HWCAP2:
|
||||
c.hwCap2 = val
|
||||
}
|
||||
|
||||
|
||||
@@ -84,11 +84,12 @@ func Prctl(t *kernel.Task, sysno uintptr, args arch.SyscallArguments) (uintptr,
|
||||
val := args[1].Int()
|
||||
// prctl(2): arg2 must be either 0 (permitted capabilities are cleared)
|
||||
// or 1 (permitted capabilities are kept).
|
||||
if val == 0 {
|
||||
switch val {
|
||||
case 0:
|
||||
t.SetKeepCaps(false)
|
||||
} else if val == 1 {
|
||||
case 1:
|
||||
t.SetKeepCaps(true)
|
||||
} else {
|
||||
default:
|
||||
return 0, nil, linuxerr.EINVAL
|
||||
}
|
||||
|
||||
|
||||
@@ -321,11 +321,12 @@ func NewReader(r io.ReadCloser, key []byte) (io.ReadCloser, map[string]string, e
|
||||
// Pick correct reader
|
||||
var cr io.ReadCloser
|
||||
|
||||
if compression == CompressionLevelFlateBestSpeed {
|
||||
switch compression {
|
||||
case CompressionLevelFlateBestSpeed:
|
||||
cr, err = compressio.NewReader(r, key)
|
||||
} else if compression == CompressionLevelNone {
|
||||
case CompressionLevelNone:
|
||||
cr = compressio.NewSimpleReader(r, key)
|
||||
} else {
|
||||
default:
|
||||
// Should never occur, as it has the default path.
|
||||
return nil, nil, fmt.Errorf("metadata contains invalid compression flag value: %v", compression)
|
||||
}
|
||||
|
||||
@@ -258,9 +258,10 @@ func (d *Device) Write(data *buffer.View) (int64, error) {
|
||||
// TUN interface with IFF_NO_PI enabled, thus
|
||||
// we need to determine protocol from version field
|
||||
version := data.AsSlice()[0] >> 4
|
||||
if version == 4 {
|
||||
switch version {
|
||||
case 4:
|
||||
protocol = header.IPv4ProtocolNumber
|
||||
} else if version == 6 {
|
||||
case 6:
|
||||
protocol = header.IPv6ProtocolNumber
|
||||
}
|
||||
}
|
||||
|
||||
@@ -299,10 +299,11 @@ func TestNonBlockingSend(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
if blockCount == 1000 {
|
||||
switch blockCount {
|
||||
case 1000:
|
||||
// Shouldn't have _always_ blocked.
|
||||
t.Fatalf("Socket always blocked!")
|
||||
} else if blockCount == 0 {
|
||||
case 0:
|
||||
// Should have started blocking eventually.
|
||||
t.Fatalf("Socket never blocked!")
|
||||
}
|
||||
|
||||
@@ -604,16 +604,17 @@ func findReasons(pass *analysis.Pass, fdecl *ast.FuncDecl) ([]EscapeReason, bool
|
||||
types := strings.Split(c.Text[len(magicParams):], ",")
|
||||
found = true // For below.
|
||||
for i := 0; i < len(types); i++ {
|
||||
if types[i] == "local" {
|
||||
switch types[i] {
|
||||
case "local":
|
||||
// Limit search to local escapes.
|
||||
local = true
|
||||
} else if types[i] == "all" {
|
||||
case "all":
|
||||
// Append all reasons.
|
||||
reasons = append(reasons, allReasons...)
|
||||
} else if types[i] == "hard" {
|
||||
case "hard":
|
||||
// Append all hard reasons.
|
||||
reasons = append(reasons, hardReasons...)
|
||||
} else {
|
||||
default:
|
||||
r, ok := escapeTypes[types[i]]
|
||||
if !ok {
|
||||
// This is not a valid escape reason.
|
||||
|
||||
Reference in New Issue
Block a user