diff --git a/.golangci.yml b/.golangci.yml index dbe138014..f49ec6b80 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -7,7 +7,7 @@ linters: - errcheck - goconst - gofmt - - golint + - revive - gosec - govet - ineffassign diff --git a/pkg/codegen/go/gen_program_expressions.go b/pkg/codegen/go/gen_program_expressions.go index 258e51c47..b40928715 100644 --- a/pkg/codegen/go/gen_program_expressions.go +++ b/pkg/codegen/go/gen_program_expressions.go @@ -349,6 +349,7 @@ func (g *generator) genObjectConsExpression( // first lower all inner expressions and emit temps for i, item := range expr.Items { // don't treat keys as inputs + //nolint: revive k, kTemps := g.lowerExpression(item.Key, item.Key.Type()) temps = append(temps, kTemps...) item.Key = k diff --git a/pkg/codegen/internal/test/program_driver.go b/pkg/codegen/internal/test/program_driver.go index a3b4e6da8..e86f34e7b 100644 --- a/pkg/codegen/internal/test/program_driver.go +++ b/pkg/codegen/internal/test/program_driver.go @@ -101,6 +101,7 @@ type langConfig struct { // // The PCL file is the only piece that must be manually authored. Once the schema has been written, the expected outputs // can be generated by running `PULUMI_ACCEPT=true go test ./..." from the `pkg/codegen` directory. +//nolint: revive func TestProgramCodegen( t *testing.T, language string, diff --git a/pkg/codegen/internal/test/sdk_driver.go b/pkg/codegen/internal/test/sdk_driver.go index f79e1644f..4fdf42cbd 100644 --- a/pkg/codegen/internal/test/sdk_driver.go +++ b/pkg/codegen/internal/test/sdk_driver.go @@ -137,6 +137,7 @@ type checkPackageSignature = func(t *testing.T, pwd string) // // The schema is the only piece that must be manually authored. Once the schema has been written, the expected outputs // can be generated by running `PULUMI_ACCEPT=true go test ./..." from the `pkg/codegen` directory. +//nolint: revive func TestSDKCodegen(t *testing.T, language string, genPackage GenPkgSignature, checkPackage checkPackageSignature) { testDir := filepath.Join("..", "internal", "test", "testdata") diff --git a/pkg/codegen/internal/test/type_driver.go b/pkg/codegen/internal/test/type_driver.go index cc49fbe56..0d93497f9 100644 --- a/pkg/codegen/internal/test/type_driver.go +++ b/pkg/codegen/internal/test/type_driver.go @@ -49,7 +49,7 @@ type NewTypeNameGeneratorFunc func(pkg *schema.Package) TypeNameGeneratorFunc type TypeNameGeneratorFunc func(t schema.Type) string -func TestTypeNameCodegen(t *testing.T, language string, newTypeNameGenerator NewTypeNameGeneratorFunc) { +func TestTypeNameCodegen(t *testing.T, language string, newTypeNameGenerator NewTypeNameGeneratorFunc) { //nolint:revive // Read in, decode, and import the schema. schemaBytes, err := os.ReadFile(filepath.FromSlash("../internal/test/testdata/types.json")) require.NoError(t, err) diff --git a/pkg/codegen/python/gen.go b/pkg/codegen/python/gen.go index 2c72ae491..04c953f3f 100644 --- a/pkg/codegen/python/gen.go +++ b/pkg/codegen/python/gen.go @@ -928,10 +928,7 @@ func (mod *modContext) genTypes(dir string, fs fs) error { if err := genTypes("_inputs.py", true); err != nil { return err } - if err := genTypes("outputs.py", false); err != nil { - return err - } - return nil + return genTypes("outputs.py", false) } func awaitableTypeNames(tok string) (baseName, awaitableName string) { diff --git a/pkg/codegen/schema/schema.go b/pkg/codegen/schema/schema.go index cd98ac307..a0c157f3c 100644 --- a/pkg/codegen/schema/schema.go +++ b/pkg/codegen/schema/schema.go @@ -1,4 +1,4 @@ -// Copyright 2016-2020, Pulumi Corporation. +// Copyright 2016-2021, Pulumi Corporation. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -16,7 +16,7 @@ package schema import ( "bytes" - _ "embed" //nolint: golint + _ "embed" "encoding/json" "fmt" "io" diff --git a/pkg/engine/deployment.go b/pkg/engine/deployment.go index 5bf3b81d0..7fe46ba6a 100644 --- a/pkg/engine/deployment.go +++ b/pkg/engine/deployment.go @@ -1,4 +1,4 @@ -// Copyright 2016-2018, Pulumi Corporation. +// Copyright 2016-2021, Pulumi Corporation. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -16,7 +16,6 @@ package engine import ( "context" - "fmt" "time" "github.com/opentracing/opentracing-go" @@ -177,9 +176,9 @@ func newDeployment(ctx *Context, info *deploymentContext, opts deploymentOptions imp := &opts.imports[i] _, err := tokens.ParseTypeToken(imp.Type.String()) if err != nil { - return nil, errors.New(fmt.Sprintf("import type %q is not a valid resource type token. "+ + return nil, errors.Errorf("import type %q is not a valid resource type token. "+ "Type tokens must be of the format :: - "+ - "refer to the import section of the provider resource documentation.", imp.Type.String())) + "refer to the import section of the provider resource documentation.", imp.Type.String()) } if imp.Provider == "" && imp.Version == nil { imp.Version = defaultProviderVersions[imp.Type.Package()] diff --git a/pkg/engine/lifeycletest/test_plan.go b/pkg/engine/lifeycletest/test_plan.go index 35b4c933e..0ba17f58e 100644 --- a/pkg/engine/lifeycletest/test_plan.go +++ b/pkg/engine/lifeycletest/test_plan.go @@ -1,4 +1,4 @@ -//nolint:golint +//nolint:revive package lifecycletest import ( diff --git a/pkg/testing/integration/program.go b/pkg/testing/integration/program.go index 60f30906c..6b74c27e8 100644 --- a/pkg/testing/integration/program.go +++ b/pkg/testing/integration/program.go @@ -1995,7 +1995,7 @@ func (pt *ProgramTester) prepareDotNetProject(projinfo *engine.Projinfo) error { return errors.Wrap(err, "failed to find a local Pulumi NuGet package") } if len(matches) != 1 { - return errors.New(fmt.Sprintf("attempting to find a local Pulumi NuGet package yielded %v results", matches)) + return errors.Errorf("attempting to find a local Pulumi NuGet package yielded %v results", matches) } file := filepath.Base(matches[0]) r := strings.NewReplacer(dep+".", "", ".nupkg", "") diff --git a/sdk/go/auto/local_workspace.go b/sdk/go/auto/local_workspace.go index d2f10c18f..bca8785da 100644 --- a/sdk/go/auto/local_workspace.go +++ b/sdk/go/auto/local_workspace.go @@ -1,4 +1,4 @@ -// Copyright 2016-2020, Pulumi Corporation. +// Copyright 2016-2021, Pulumi Corporation. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -518,10 +518,10 @@ func validatePulumiVersion(minVersion semver.Version, currentVersion semver.Vers return nil } if minVersion.Major < currentVersion.Major { - return errors.New(fmt.Sprintf("Major version mismatch. You are using Pulumi CLI version %s with Automation SDK v%v. Please update the SDK.", currentVersion, minVersion.Major)) + return errors.Errorf("Major version mismatch. You are using Pulumi CLI version %s with Automation SDK v%v. Please update the SDK.", currentVersion, minVersion.Major) } if minVersion.GT(currentVersion) { - return errors.New(fmt.Sprintf("Minimum version requirement failed. The minimum CLI version requirement is %s, your current CLI version is %s. Please update the Pulumi CLI.", minimumVersion, currentVersion)) + return errors.Errorf("Minimum version requirement failed. The minimum CLI version requirement is %s, your current CLI version is %s. Please update the Pulumi CLI.", minimumVersion, currentVersion) } return nil } diff --git a/sdk/go/common/resource/properties.go b/sdk/go/common/resource/properties.go index 8caf98dd3..355658267 100644 --- a/sdk/go/common/resource/properties.go +++ b/sdk/go/common/resource/properties.go @@ -108,7 +108,7 @@ type Secret struct { // - The ID may be unknown (in which case it will be the unknown property value) // - Otherwise, the ID must be a string. // -//nolint: golint +//nolint: revive type ResourceReference struct { URN URN ID PropertyValue diff --git a/sdk/go/common/workspace/loaders.go b/sdk/go/common/workspace/loaders.go index aba23ae04..5649c4363 100644 --- a/sdk/go/common/workspace/loaders.go +++ b/sdk/go/common/workspace/loaders.go @@ -25,25 +25,25 @@ import ( // projectSingleton is a singleton instance of projectLoader, which controls a global map of instances of Project // configs (one per path). -var projectSingleton *projectLoader = &projectLoader{ +var projectSingleton = &projectLoader{ internal: map[string]*Project{}, } // projectStackSingleton is a singleton instance of projectStackLoader, which controls a global map of instances of // ProjectStack configs (one per path). -var projectStackSingleton *projectStackLoader = &projectStackLoader{ +var projectStackSingleton = &projectStackLoader{ internal: map[string]*ProjectStack{}, } // pluginProjectSingleton is a singleton instance of pluginProjectLoader, which controls a global map of instances of // PluginProject configs (one per path). -var pluginProjectSingleton *pluginProjectLoader = &pluginProjectLoader{ +var pluginProjectSingleton = &pluginProjectLoader{ internal: map[string]*PluginProject{}, } // policyPackProjectSingleton is a singleton instance of policyPackProjectLoader, which controls a global map of // instances of PolicyPackProject configs (one per path). -var policyPackProjectSingleton *policyPackProjectLoader = &policyPackProjectLoader{ +var policyPackProjectSingleton = &policyPackProjectLoader{ internal: map[string]*PolicyPackProject{}, } diff --git a/sdk/go/common/workspace/project.go b/sdk/go/common/workspace/project.go index c78b466ed..c40d51886 100644 --- a/sdk/go/common/workspace/project.go +++ b/sdk/go/common/workspace/project.go @@ -305,7 +305,6 @@ func save(path string, value interface{}, mkDirAll bool) error { } } - // Changing the permissions on these file is ~ a breaking change, so disable golint. //nolint: gosec return ioutil.WriteFile(path, b, 0644) } diff --git a/sdk/go/pulumi/resource.go b/sdk/go/pulumi/resource.go index f5bcbd1cb..a4dc78c11 100644 --- a/sdk/go/pulumi/resource.go +++ b/sdk/go/pulumi/resource.go @@ -497,7 +497,7 @@ func Transformations(o []ResourceTransformation) ResourceOption { } // URN_ is an optional URN of a previously-registered resource of this type to read from the engine. -//nolint: golint +//nolint: revive func URN_(o string) ResourceOption { return resourceOption(func(ro *resourceOptions) { ro.URN = o diff --git a/sdk/go/pulumi/workgroup_test.go b/sdk/go/pulumi/workgroup_test.go index a3c6e5b16..e5d4dcebb 100644 --- a/sdk/go/pulumi/workgroup_test.go +++ b/sdk/go/pulumi/workgroup_test.go @@ -25,7 +25,7 @@ import ( func TestWorkGroupActsAsWaitGroup(t *testing.T) { check := func(j int) func(*testing.T) { return func(*testing.T) { - var n int32 = 0 + var n int32 wg := &workGroup{} wg.Add(j) diff --git a/tests/integration/integration_test.go b/tests/integration/integration_test.go index e7fa6f386..dfbce3ada 100644 --- a/tests/integration/integration_test.go +++ b/tests/integration/integration_test.go @@ -573,7 +573,7 @@ func TestConfigPaths(t *testing.T) { e.RunCommand("pulumi", "stack", "rm", "--yes") } -//nolint:golint,deadcode +//nolint:deadcode func pathEnv(t *testing.T, path ...string) string { pathEnv := []string{os.Getenv("PATH")} for _, p := range path { @@ -591,12 +591,12 @@ func pathEnv(t *testing.T, path ...string) string { return "PATH=" + strings.Join(pathEnv, pathSeparator) } -//nolint:golint,deadcode +//nolint:deadcode func testComponentSlowPathEnv(t *testing.T) string { return pathEnv(t, filepath.Join("construct_component_slow", "testcomponent")) } -//nolint:golint,deadcode +//nolint:deadcode func testComponentPlainPathEnv(t *testing.T) string { return pathEnv(t, filepath.Join("construct_component_plain", "testcomponent")) }