Skip to content

Commit

Permalink
address nogo complaints about variable shadowing (#1808)
Browse files Browse the repository at this point in the history
  • Loading branch information
pmenglund authored May 20, 2024
1 parent 61b277b commit f43d5d0
Showing 1 changed file with 10 additions and 8 deletions.
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

0 comments on commit f43d5d0

Please sign in to comment.