Skip to content

Commit 1b2eac8

Browse files
committed
review
1 parent 01f0552 commit 1b2eac8

File tree

3 files changed

+25
-29
lines changed

3 files changed

+25
-29
lines changed

pkg/commands/fmt.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ func (c *fmtCommand) preRunE(_ *cobra.Command, _ []string) error {
9999
}
100100

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

148-
var expended []string
148+
var expanded []string
149149
for _, arg := range args {
150150
abs, err := filepath.Abs(strings.ReplaceAll(arg, "...", ""))
151151
if err != nil {
152152
return nil, err
153153
}
154154

155-
expended = append(expended, abs)
155+
expanded = append(expanded, abs)
156156
}
157157

158-
return expended, nil
158+
return expanded, nil
159159
}

pkg/goformat/runner.go

+3-8
Original file line numberDiff line numberDiff line change
@@ -58,12 +58,11 @@ func (c *Runner) walk(root string) error {
5858
return fs.SkipDir
5959
}
6060

61-
// Ignore non-Go files.
6261
if !isGoFile(f) {
6362
return nil
6463
}
6564

66-
match, err := c.opts.MatchPatterns(path)
65+
match, err := c.opts.MatchAnyPattern(path)
6766
if err != nil || match {
6867
return err
6968
}
@@ -125,7 +124,7 @@ func NewRunnerOptions(cfg *config.Config) (RunnerOptions, error) {
125124
return opts, nil
126125
}
127126

128-
func (o RunnerOptions) MatchPatterns(path string) (bool, error) {
127+
func (o RunnerOptions) MatchAnyPattern(path string) (bool, error) {
129128
if len(o.patterns) == 0 {
130129
return false, nil
131130
}
@@ -153,11 +152,7 @@ func skipDir(name string) bool {
153152
return true
154153

155154
default:
156-
if strings.HasPrefix(name, ".") {
157-
return true
158-
}
159-
160-
return false
155+
return strings.HasPrefix(name, ".")
161156
}
162157
}
163158

pkg/logutils/logutils.go

+18-17
Original file line numberDiff line numberDiff line change
@@ -16,22 +16,22 @@ const EnvTestRun = "GL_TEST_RUN"
1616
const envDebug = "GL_DEBUG"
1717

1818
const (
19-
DebugKeyBinSalt = "bin_salt"
20-
DebugKeyConfigReader = "config_reader"
21-
DebugKeyEmpty = ""
22-
DebugKeyEnabledLinters = "enabled_linters"
23-
DebugKeyExec = "exec"
24-
DebugKeyFormatter = "formatter"
25-
DebugKeyGoEnv = "goenv"
26-
DebugKeyLinter = "linter"
27-
DebugKeyLintersContext = "linters_context"
28-
DebugKeyLintersDB = "lintersdb"
29-
DebugKeyLintersOutput = "linters_output"
30-
DebugKeyLoader = "loader" // Debugs packages loading (including `go/packages` internal debugging).
31-
DebugKeyPkgCache = "pkgcache"
32-
DebugKeyRunner = "runner"
33-
DebugKeyStopwatch = "stopwatch"
34-
DebugKeyTest = "test"
19+
DebugKeyBinSalt = "bin_salt"
20+
DebugKeyConfigReader = "config_reader"
21+
DebugKeyEmpty = ""
22+
DebugKeyEnabledLinters = "enabled_linters"
23+
DebugKeyExec = "exec"
24+
DebugKeyFormatter = "formatter"
25+
DebugKeyFormattersOutput = "formatters_output"
26+
DebugKeyGoEnv = "goenv"
27+
DebugKeyLintersContext = "linters_context"
28+
DebugKeyLintersDB = "lintersdb"
29+
DebugKeyLintersOutput = "linters_output"
30+
DebugKeyLoader = "loader" // Debugs packages loading (including `go/packages` internal debugging).
31+
DebugKeyPkgCache = "pkgcache"
32+
DebugKeyRunner = "runner"
33+
DebugKeyStopwatch = "stopwatch"
34+
DebugKeyTest = "test"
3535
)
3636

3737
// Printers.
@@ -77,7 +77,8 @@ const (
7777
DebugKeyForbidigo = "forbidigo" // Debugs `forbidigo` linter.
7878
DebugKeyGoCritic = "gocritic" // Debugs `gocritic` linter.
7979
DebugKeyGovet = "govet" // Debugs `govet` linter.
80-
DebugKeyRevive = "revive" // Debugs `revive` linter.
80+
DebugKeyLinter = "linter"
81+
DebugKeyRevive = "revive" // Debugs `revive` linter.
8182
)
8283

8384
func getEnabledDebugs() map[string]bool {

0 commit comments

Comments
 (0)