Merge pull request #11105 from hashicorp/f-add-staticcheck-ci
ci: add staticcheck with ST1020 and update golangci-lint
This commit is contained in:
commit
04a15b5c16
|
@ -64,6 +64,10 @@ linters-settings:
|
|||
disabled-checks:
|
||||
- commentFormatting
|
||||
- deprecatedComment
|
||||
staticcheck:
|
||||
# Only enable a single check to start.
|
||||
# I(jrasell) will work on enabling additional checks when possible.
|
||||
checks: ["ST1020"]
|
||||
|
||||
issues:
|
||||
exclude:
|
||||
|
@ -87,6 +91,7 @@ linters:
|
|||
- gofmt
|
||||
- gosimple
|
||||
- depguard
|
||||
- staticcheck
|
||||
# Stretch Goal
|
||||
#- maligned
|
||||
fast: false
|
||||
|
|
|
@ -123,7 +123,7 @@ deps: ## Install build and development dependencies
|
|||
lint-deps: ## Install linter dependencies
|
||||
## Keep versions in sync with tools/go.mod (see https://github.com/golang/go/issues/30515)
|
||||
@echo "==> Updating linter dependencies..."
|
||||
go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.39.0
|
||||
go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.42.0
|
||||
go install github.com/client9/misspell/cmd/misspell@v0.3.4
|
||||
go install github.com/hashicorp/go-hclog/hclogvet@v0.1.3
|
||||
|
||||
|
|
|
@ -174,7 +174,10 @@ func expandNamespacePolicy(policy string) []string {
|
|||
NamespaceCapabilityReadScalingPolicy,
|
||||
}
|
||||
|
||||
write := append(read, []string{
|
||||
write := make([]string, len(read))
|
||||
copy(write, read)
|
||||
|
||||
write = append(write, []string{
|
||||
NamespaceCapabilityScaleJob,
|
||||
NamespaceCapabilitySubmitJob,
|
||||
NamespaceCapabilityDispatchJob,
|
||||
|
|
|
@ -2833,8 +2833,12 @@ func (c *Client) setGaugeForMemoryStats(nodeID string, hStats *stats.HostStats,
|
|||
|
||||
// setGaugeForCPUStats proxies metrics for CPU specific statistics
|
||||
func (c *Client) setGaugeForCPUStats(nodeID string, hStats *stats.HostStats, baseLabels []metrics.Label) {
|
||||
|
||||
labels := make([]metrics.Label, len(baseLabels))
|
||||
copy(labels, baseLabels)
|
||||
|
||||
for _, cpu := range hStats.CPU {
|
||||
labels := append(baseLabels, metrics.Label{
|
||||
labels := append(labels, metrics.Label{
|
||||
Name: "cpu",
|
||||
Value: cpu.CPU,
|
||||
})
|
||||
|
@ -2848,8 +2852,12 @@ func (c *Client) setGaugeForCPUStats(nodeID string, hStats *stats.HostStats, bas
|
|||
|
||||
// setGaugeForDiskStats proxies metrics for disk specific statistics
|
||||
func (c *Client) setGaugeForDiskStats(nodeID string, hStats *stats.HostStats, baseLabels []metrics.Label) {
|
||||
|
||||
labels := make([]metrics.Label, len(baseLabels))
|
||||
copy(labels, baseLabels)
|
||||
|
||||
for _, disk := range hStats.DiskStats {
|
||||
labels := append(baseLabels, metrics.Label{
|
||||
labels := append(labels, metrics.Label{
|
||||
Name: "disk",
|
||||
Value: disk.Device,
|
||||
})
|
||||
|
@ -2877,7 +2885,7 @@ func (c *Client) setGaugeForAllocationStats(nodeID string, baseLabels []metrics.
|
|||
metrics.SetGaugeWithLabels([]string{"client", "allocated", "cpu"}, float32(allocated.Flattened.Cpu.CpuShares), baseLabels)
|
||||
|
||||
for _, n := range allocated.Flattened.Networks {
|
||||
labels := append(baseLabels, metrics.Label{
|
||||
labels := append(baseLabels, metrics.Label{ //nolint:gocritic
|
||||
Name: "device",
|
||||
Value: n.Device,
|
||||
})
|
||||
|
@ -2903,7 +2911,7 @@ func (c *Client) setGaugeForAllocationStats(nodeID string, baseLabels []metrics.
|
|||
}
|
||||
|
||||
unallocatedMbits := n.MBits - usedMbits
|
||||
labels := append(baseLabels, metrics.Label{
|
||||
labels := append(baseLabels, metrics.Label{ //nolint:gocritic
|
||||
Name: "device",
|
||||
Value: n.Device,
|
||||
})
|
||||
|
|
|
@ -258,7 +258,7 @@ func (m *manager) waitForFirstFingerprint(ctx context.Context, cancel context.Ca
|
|||
mu.Lock()
|
||||
defer mu.Unlock()
|
||||
|
||||
updated := append(driversByStatus[lastHeath], name)
|
||||
updated := append(driversByStatus[lastHeath], name) //nolint:gocritic
|
||||
driversByStatus[lastHeath] = updated
|
||||
}
|
||||
|
||||
|
|
|
@ -556,7 +556,7 @@ func (c *AllocStatusCommand) outputTaskResources(alloc *api.Allocation, task str
|
|||
c.Ui.Output("Task Resources")
|
||||
var addr []string
|
||||
for _, nw := range resource.Networks {
|
||||
ports := append(nw.DynamicPorts, nw.ReservedPorts...)
|
||||
ports := append(nw.DynamicPorts, nw.ReservedPorts...) //nolint:gocritic
|
||||
for _, port := range ports {
|
||||
addr = append(addr, fmt.Sprintf("%v: %v:%v\n", port.Label, nw.IP, port.Value))
|
||||
}
|
||||
|
|
|
@ -131,7 +131,7 @@ func (w *NoXSSResponseWriter) Write(p []byte) (int, error) {
|
|||
}
|
||||
|
||||
// >= 512 bytes available, set the Content-Type and flush.
|
||||
all := append(w.buf, p...)
|
||||
all := append(w.buf, p...) //nolint:gocritic
|
||||
contentType := http.DetectContentType(all)
|
||||
|
||||
// Prefix match to exclude the character set which may be user
|
||||
|
|
|
@ -238,7 +238,7 @@ func diffSystemAllocs(
|
|||
// Build a mapping of nodes to all their allocs.
|
||||
nodeAllocs := make(map[string][]*structs.Allocation, len(allocs))
|
||||
for _, alloc := range allocs {
|
||||
nallocs := append(nodeAllocs[alloc.NodeID], alloc)
|
||||
nallocs := append(nodeAllocs[alloc.NodeID], alloc) //nolint:gocritic
|
||||
nodeAllocs[alloc.NodeID] = nallocs
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue