Skip to content

Commit 3de9ff1

Browse files
committed
Fix lint: add missing G115 nolint in tree.go, remove unused nolints in port.go
- cli/command/image/tree.go:392: add missing nolint:gosec for G115 (uint -> int conversion for terminal width, fits within int range) - opts/swarmopts/port.go:83,94,180: remove nolint:gosec directives that gosec does not trigger on (caught by nolintlint as unused directives); these uint64->uint32 conversions from ParseUint with bitSize=16 are inherently safe without annotation Signed-off-by: abhay1999 <abhaychaurasiya19@gmail.com>
1 parent 05542cc commit 3de9ff1

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

cli/command/image/tree.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -389,7 +389,7 @@ func generateLegend(out tui.Output, width uint) string {
389389
}
390390
legend += legendSb371.String()
391391

392-
r := max(int(width)-tui.Width(legend), 0)
392+
r := max(int(width)-tui.Width(legend), 0) //nolint:gosec // G115: terminal width fits within int range
393393
legend = strings.Repeat(" ", r) + legend
394394
return legend
395395
}

opts/swarmopts/port.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ func (p *PortOpt) Set(value string) error {
8080
return fmt.Errorf("invalid target port (%s): value must be an integer: %w", val, err)
8181
}
8282

83-
pConfig.TargetPort = uint32(tPort) //nolint:gosec // G115: port numbers are in range [0, 65535], within uint32 bounds
83+
pConfig.TargetPort = uint32(tPort)
8484
case portOptPublishedPort:
8585
pPort, err := strconv.ParseUint(val, 10, 16)
8686
if err != nil {
@@ -91,7 +91,7 @@ func (p *PortOpt) Set(value string) error {
9191
return fmt.Errorf("invalid published port (%s): value must be an integer: %w", val, err)
9292
}
9393

94-
pConfig.PublishedPort = uint32(pPort) //nolint:gosec // G115: port numbers are in range [0, 65535], within uint32 bounds
94+
pConfig.PublishedPort = uint32(pPort)
9595
default:
9696
return fmt.Errorf("invalid field key: %s", key)
9797
}
@@ -176,8 +176,8 @@ func ConvertPortToPortConfig(
176176
ports = append(ports, swarm.PortConfig{
177177
// TODO Name: ?
178178
Protocol: portProto.Proto(),
179-
TargetPort: uint32(portProto.Num()), //nolint:gosec // G115: port numbers are in range [0, 65535], within uint32 bounds
180-
PublishedPort: uint32(p.Num()), //nolint:gosec // G115: port numbers are in range [0, 65535], within uint32 bounds
179+
TargetPort: uint32(portProto.Num()),
180+
PublishedPort: uint32(p.Num()),
181181
PublishMode: swarm.PortConfigPublishModeIngress,
182182
})
183183
}

0 commit comments

Comments
 (0)