Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

address nogo complaints about variable shadowing #1808

Merged
merged 1 commit into from
May 20, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 10 additions & 8 deletions cmd/gazelle/fix-update.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ import (
"strings"
"syscall"

"github.com/bazelbuild/buildtools/build"

"github.com/bazelbuild/bazel-gazelle/config"
gzflag "github.com/bazelbuild/bazel-gazelle/flag"
"github.com/bazelbuild/bazel-gazelle/internal/wspace"
Expand All @@ -38,7 +40,6 @@ import (
"github.com/bazelbuild/bazel-gazelle/resolve"
"github.com/bazelbuild/bazel-gazelle/rule"
"github.com/bazelbuild/bazel-gazelle/walk"
"github.com/bazelbuild/buildtools/build"
)

// updateConfig holds configuration information needed to run the fix and
Expand Down Expand Up @@ -125,7 +126,7 @@ func (ucr *updateConfigurer) CheckFlags(fs *flag.FlagSet, c *config.Config) erro
if !filepath.IsAbs(dir) {
dir = filepath.Join(c.WorkDir, dir)
}
dir, err := filepath.EvalSymlinks(dir)
dir, err = filepath.EvalSymlinks(dir)
if err != nil {
return fmt.Errorf("%s: failed to resolve symlinks: %v", arg, err)
}
Expand Down Expand Up @@ -220,7 +221,7 @@ func (ucr *updateConfigurer) KnownDirectives() []string { return nil }

func (ucr *updateConfigurer) Configure(c *config.Config, rel string, f *rule.File) {}

// visitRecord stores information about about a directory visited with
// visitRecord stores information about a directory visited with
// packages.Walk.
type visitRecord struct {
// pkgRel is the slash-separated path to the visited directory, relative to
Expand Down Expand Up @@ -289,7 +290,7 @@ func runFixUpdate(wd string, cmd command, args []string) (err error) {
}
ruleIndex := resolve.NewRuleIndex(mrslv.Resolver, exts...)

if err := fixRepoFiles(c, loads); err != nil {
if err = fixRepoFiles(c, loads); err != nil {
return err
}

Expand Down Expand Up @@ -372,7 +373,8 @@ func runFixUpdate(wd string, cmd command, args []string) (err error) {
}

maybeRecordReplacement := func(ruleKind string) (*string, error) {
repl, err := lookupMapKindReplacement(c.KindMap, ruleKind)
var repl *config.MappedKind
repl, err = lookupMapKindReplacement(c.KindMap, ruleKind)
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -463,8 +465,8 @@ func runFixUpdate(wd string, cmd command, args []string) (err error) {

if len(errorsFromWalk) > 1 {
var additionalErrors []string
for _, error := range errorsFromWalk[1:] {
additionalErrors = append(additionalErrors, error.Error())
for _, err = range errorsFromWalk[1:] {
additionalErrors = append(additionalErrors, err.Error())
}

return fmt.Errorf("encountered multiple errors: %w, %v", errorsFromWalk[0], strings.Join(additionalErrors, ", "))
Expand All @@ -480,7 +482,7 @@ func runFixUpdate(wd string, cmd command, args []string) (err error) {
err = cerr
}
}()
if err := maybePopulateRemoteCacheFromGoMod(c, rc); err != nil {
if err = maybePopulateRemoteCacheFromGoMod(c, rc); err != nil {
log.Print(err)
}
for _, v := range visits {
Expand Down