Skip to content

Commit

Permalink
review
Browse files Browse the repository at this point in the history
  • Loading branch information
ldez committed Jan 31, 2025
1 parent e8dd5e5 commit 701b797
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 29 deletions.
8 changes: 4 additions & 4 deletions pkg/commands/fmt.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ func (c *fmtCommand) preRunE(_ *cobra.Command, _ []string) error {
}

func (c *fmtCommand) execute(_ *cobra.Command, args []string) error {
if !logutils.HaveDebugTag(logutils.DebugKeyLintersOutput) {
if !logutils.HaveDebugTag(logutils.DebugKeyFormattersOutput) {
// Don't allow linters and loader to print anything
log.SetOutput(io.Discard)
savedStdout, savedStderr := c.setOutputToDevNull()
Expand Down Expand Up @@ -145,15 +145,15 @@ func cleanArgs(args []string) ([]string, error) {
return []string{abs}, nil
}

var expended []string
var expanded []string
for _, arg := range args {
abs, err := filepath.Abs(strings.ReplaceAll(arg, "...", ""))
if err != nil {
return nil, err
}

expended = append(expended, abs)
expanded = append(expanded, abs)
}

return expended, nil
return expanded, nil
}
11 changes: 3 additions & 8 deletions pkg/goformat/runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,11 @@ func (c *Runner) walk(root string) error {
return fs.SkipDir
}

// Ignore non-Go files.
if !isGoFile(f) {
return nil
}

match, err := c.opts.MatchPatterns(path)
match, err := c.opts.MatchAnyPattern(path)
if err != nil || match {
return err
}
Expand Down Expand Up @@ -125,7 +124,7 @@ func NewRunnerOptions(cfg *config.Config) (RunnerOptions, error) {
return opts, nil
}

func (o RunnerOptions) MatchPatterns(path string) (bool, error) {
func (o RunnerOptions) MatchAnyPattern(path string) (bool, error) {
if len(o.patterns) == 0 {
return false, nil
}
Expand Down Expand Up @@ -153,11 +152,7 @@ func skipDir(name string) bool {
return true

default:
if strings.HasPrefix(name, ".") {
return true
}

return false
return strings.HasPrefix(name, ".")
}
}

Expand Down
35 changes: 18 additions & 17 deletions pkg/logutils/logutils.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,22 +16,22 @@ const EnvTestRun = "GL_TEST_RUN"
const envDebug = "GL_DEBUG"

const (
DebugKeyBinSalt = "bin_salt"
DebugKeyConfigReader = "config_reader"
DebugKeyEmpty = ""
DebugKeyEnabledLinters = "enabled_linters"
DebugKeyExec = "exec"
DebugKeyFormatter = "formatter"
DebugKeyGoEnv = "goenv"
DebugKeyLinter = "linter"
DebugKeyLintersContext = "linters_context"
DebugKeyLintersDB = "lintersdb"
DebugKeyLintersOutput = "linters_output"
DebugKeyLoader = "loader" // Debugs packages loading (including `go/packages` internal debugging).
DebugKeyPkgCache = "pkgcache"
DebugKeyRunner = "runner"
DebugKeyStopwatch = "stopwatch"
DebugKeyTest = "test"
DebugKeyBinSalt = "bin_salt"
DebugKeyConfigReader = "config_reader"
DebugKeyEmpty = ""
DebugKeyEnabledLinters = "enabled_linters"
DebugKeyExec = "exec"
DebugKeyFormatter = "formatter"
DebugKeyFormattersOutput = "formatters_output"
DebugKeyGoEnv = "goenv"
DebugKeyLintersContext = "linters_context"
DebugKeyLintersDB = "lintersdb"
DebugKeyLintersOutput = "linters_output"
DebugKeyLoader = "loader" // Debugs packages loading (including `go/packages` internal debugging).
DebugKeyPkgCache = "pkgcache"
DebugKeyRunner = "runner"
DebugKeyStopwatch = "stopwatch"
DebugKeyTest = "test"
)

// Printers.
Expand Down Expand Up @@ -81,7 +81,8 @@ const (
DebugKeyForbidigo = "forbidigo" // Debugs `forbidigo` linter.
DebugKeyGoCritic = "gocritic" // Debugs `gocritic` linter.
DebugKeyGovet = "govet" // Debugs `govet` linter.
DebugKeyRevive = "revive" // Debugs `revive` linter.
DebugKeyLinter = "linter"
DebugKeyRevive = "revive" // Debugs `revive` linter.
)

func getEnabledDebugs() map[string]bool {
Expand Down

0 comments on commit 701b797

Please sign in to comment.