chore: bump golangci-lint from v1.24 to v1.39

Signed-off-by: Yoan Blanc <yoan@dosimple.ch>
This commit is contained in:
Yoan Blanc 2021-04-03 09:50:23 +02:00
parent 5811796eb4
commit ac0d5d8bd3
No known key found for this signature in database
GPG Key ID: 6058CF4574298812
19 changed files with 28 additions and 27 deletions

View File

@ -57,6 +57,10 @@ linters-settings:
list-type: blacklist
packages:
- github.com/hashicorp/consul/command/flags
gocritic:
disabled-checks:
- commentFormatting
- deprecatedComment
issues:
exclude:

View File

@ -107,7 +107,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.24.0
go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.39.0
go install github.com/client9/misspell/cmd/misspell@v0.3.4
go install github.com/hashicorp/go-hclog/hclogvet@v0.1.3

View File

@ -720,7 +720,7 @@ func (c *Client) doRequest(r *request) (time.Duration, *http.Response, error) {
}
start := time.Now()
resp, err := c.httpClient.Do(req)
diff := time.Now().Sub(start)
diff := time.Since(start)
// If the response is compressed, we swap the body's reader.
if resp != nil && resp.Header != nil {

View File

@ -120,7 +120,7 @@ func (v *CSIVolumes) CreateSnapshot(snap *CSISnapshot, w *WriteOptions) ([]*CSIS
Snapshots: []*CSISnapshot{snap},
}
resp := &CSISnapshotCreateResponse{}
meta, err := v.client.write(fmt.Sprintf("/v1/volumes/snapshot"), req, resp, w)
meta, err := v.client.write("/v1/volumes/snapshot", req, resp, w)
return resp.Snapshots, meta, err
}
@ -129,7 +129,7 @@ func (v *CSIVolumes) DeleteSnapshot(snap *CSISnapshot, w *WriteOptions) error {
req := &CSISnapshotDeleteRequest{
Snapshots: []*CSISnapshot{snap},
}
_, err := v.client.delete(fmt.Sprintf("/v1/volumes/snapshot"), req, w)
_, err := v.client.delete("/v1/volumes/snapshot", req, w)
return err
}

View File

@ -691,9 +691,7 @@ func (m *Multiregion) Copy() *Multiregion {
copyRegion := new(MultiregionRegion)
copyRegion.Name = region.Name
copyRegion.Count = intToPtr(*region.Count)
for _, dc := range region.Datacenters {
copyRegion.Datacenters = append(copyRegion.Datacenters, dc)
}
copyRegion.Datacenters = append(copyRegion.Datacenters, region.Datacenters...)
for k, v := range region.Meta {
copyRegion.Meta[k] = v
}

View File

@ -224,8 +224,7 @@ func (n *Nodes) monitorDrainNode(ctx context.Context, nodeID string,
}
if node.DrainStrategy == nil {
var msg *MonitorMessage
msg = Messagef(MonitorMsgLevelInfo, "Drain complete for node %s", nodeID)
msg := Messagef(MonitorMsgLevelInfo, "Drain complete for node %s", nodeID)
select {
case nodeCh <- msg:
case <-ctx.Done():

View File

@ -24,9 +24,9 @@ func (s *Scaling) ListPolicies(q *QueryOptions) ([]*ScalingPolicyListStub, *Quer
return resp, qm, nil
}
func (s *Scaling) GetPolicy(ID string, q *QueryOptions) (*ScalingPolicy, *QueryMeta, error) {
func (s *Scaling) GetPolicy(id string, q *QueryOptions) (*ScalingPolicy, *QueryMeta, error) {
var policy ScalingPolicy
qm, err := s.client.query("/v1/scaling/policy/"+ID, &policy, q)
qm, err := s.client.query("/v1/scaling/policy/"+id, &policy, q)
if err != nil {
return nil, nil, err
}

View File

@ -165,12 +165,12 @@ type Affinity struct {
Weight *int8 `hcl:"weight,optional"` // Weight applied to nodes that match the affinity. Can be negative
}
func NewAffinity(LTarget string, Operand string, RTarget string, Weight int8) *Affinity {
func NewAffinity(lTarget string, operand string, rTarget string, weight int8) *Affinity {
return &Affinity{
LTarget: LTarget,
RTarget: RTarget,
Operand: Operand,
Weight: int8ToPtr(Weight),
LTarget: lTarget,
RTarget: rTarget,
Operand: operand,
Weight: int8ToPtr(weight),
}
}

View File

@ -121,7 +121,7 @@ func (f *EnvAWSFingerprint) Fingerprint(request *FingerprintRequest, response *F
}
// assume we want blank entries
key := "platform.aws." + strings.Replace(k, "/", ".", -1)
key := "platform.aws." + strings.ReplaceAll(k, "/", ".")
if unique {
key = structs.UniqueNamespace(key)
}

View File

@ -162,7 +162,7 @@ func (f *EnvAzureFingerprint) Fingerprint(request *FingerprintRequest, response
}
// assume we want blank entries
key := "platform.azure." + strings.Replace(k, "/", ".", -1)
key := "platform.azure." + strings.ReplaceAll(k, "/", ".")
if attr.unique {
key = structs.UniqueNamespace(key)
}

View File

@ -166,7 +166,7 @@ func (f *EnvGCEFingerprint) Fingerprint(req *FingerprintRequest, resp *Fingerpri
}
// assume we want blank entries
key := "platform.gce." + strings.Replace(k, "/", ".", -1)
key := "platform.gce." + strings.ReplaceAll(k, "/", ".")
if unique {
key = structs.UniqueNamespace(key)
}

View File

@ -117,7 +117,7 @@ func (a *TestAgent) Start() *TestAgent {
if a.Name != "" {
name = a.Name + "-agent"
}
name = strings.Replace(name, "/", "_", -1)
name = strings.ReplaceAll(name, "/", "_")
d, err := ioutil.TempDir(TempDir, name)
if err != nil {
a.T.Fatalf("Error creating data dir %s: %s", filepath.Join(TempDir, name), err)

View File

@ -159,7 +159,7 @@ func getDeployment(client *api.Deployments, dID string) (match *api.Deployment,
return d, nil, nil
}
dID = strings.Replace(dID, "-", "", -1)
dID = strings.ReplaceAll(dID, "-", "")
if len(dID) == 1 {
return nil, nil, fmt.Errorf("Identifier must contain at least two characters.")
}

View File

@ -4,7 +4,7 @@ import (
"fmt"
"strings"
multierror "github.com/hashicorp/go-multierror"
"github.com/hashicorp/go-multierror"
"github.com/hashicorp/nomad/api"
"github.com/hashicorp/nomad/command/agent"
flaghelper "github.com/hashicorp/nomad/helper/flags"

View File

@ -1018,7 +1018,7 @@ func TarCZF(archive string, src, target string) error {
}
// remove leading path to the src, so files are relative to the archive
path := strings.Replace(file, src, "", -1)
path := strings.ReplaceAll(file, src, "")
if target != "" {
path = filepath.Join([]string{target, path}...)
}

View File

@ -1159,7 +1159,7 @@ func (d *Driver) createContainerConfig(task *drivers.TaskConfig, driverConfig *T
config.Env = task.EnvList()
containerName := fmt.Sprintf("%s-%s", strings.Replace(task.Name, "/", "_", -1), task.AllocID)
containerName := fmt.Sprintf("%s-%s", strings.ReplaceAll(task.Name, "/", "_"), task.AllocID)
logger.Debug("setting container name", "container_name", containerName)
var networkingConfig *docker.NetworkingConfig

View File

@ -20,7 +20,7 @@ func checkForMacJVM() (ok bool, err error) {
cmd.Stderr = &out
err = cmd.Run()
if err != nil {
err = fmt.Errorf("failed check for macOS jvm: %v, out: %v", err, strings.Replace(strings.Replace(out.String(), "\n", " ", -1), `"`, `\"`, -1))
err = fmt.Errorf("failed check for macOS jvm: %v, out: %v", err, strings.ReplaceAll(strings.ReplaceAll(out.String(), "\n", " "), `"`, `\"`))
return false, err
}
return true, nil

View File

@ -73,7 +73,7 @@ func NewExecutorWithIsolation(logger hclog.Logger) Executor {
logger.Error("unable to initialize stats", "error", err)
}
return &LibcontainerExecutor{
id: strings.Replace(uuid.Generate(), "-", "_", -1),
id: strings.ReplaceAll(uuid.Generate(), "-", "_"),
logger: logger,
totalCpuStats: stats.NewCpuStats(),
userCpuStats: stats.NewCpuStats(),

View File

@ -218,7 +218,7 @@ func (r *TestReport) Summary() string {
fmt.Fprintf(w, "[%s]\t\t↳\t%s\t (%vs)\n", status, tname, test.Elapsed)
if test.Failed {
for _, line := range test.Output[2:] {
fmt.Fprintf(w, "\t\t\t%s\n", strings.Replace(strings.TrimSpace(line), "\t", " ", -1))
fmt.Fprintf(w, "\t\t\t%s\n", strings.ReplaceAll(strings.TrimSpace(line), "\t", " "))
}
fmt.Fprintln(w, "\t\t\t----------")
}