Skip to content
This repository was archived by the owner on Dec 19, 2025. It is now read-only.

Commit 8574025

Browse files
committed
Address golangci-lint feedback
1 parent 478021f commit 8574025

File tree

4 files changed

+22
-26
lines changed

4 files changed

+22
-26
lines changed

graph.go

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,7 @@ func WalkGraph(root *GraphNode) (string, error) {
5555
var currSeq int
5656

5757
// First, loop through the graph nodes to assign proper ids
58-
for {
59-
if len(toProcess) == 0 {
60-
break
61-
}
62-
58+
for len(toProcess) != 0 {
6359
currNode := toProcess[0]
6460

6561
if currNode.level > currLevel {

main.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ func processFile(shortener *Shortener, path string) ([]byte, []byte, error) {
212212
return nil, nil, nil
213213
}
214214

215-
log.Debugf("Processing file %s", path)
215+
log.Debugf("processing file %s", path)
216216

217217
contents, err := os.ReadFile(path)
218218
if err != nil {
@@ -239,7 +239,7 @@ func handleOutput(path string, contents []byte, result []byte) error {
239239
return nil
240240
} else if *writeOutput {
241241
if path == "" {
242-
return errors.New("No path to write out to")
242+
return errors.New("no path to write out to")
243243
}
244244

245245
info, err := os.Stat(path)
@@ -248,11 +248,11 @@ func handleOutput(path string, contents []byte, result []byte) error {
248248
}
249249

250250
if bytes.Equal(contents, result) {
251-
log.Debugf("Contents unchanged, skipping write")
251+
log.Debugf("contents unchanged, skipping write")
252252
return nil
253253
}
254254

255-
log.Debugf("Contents changed, writing output to %s", path)
255+
log.Debugf("contents changed, writing output to %s", path)
256256
return os.WriteFile(path, result, info.Mode())
257257
}
258258

shortener.go

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -101,11 +101,11 @@ func (s *Shortener) Shorten(contents []byte) ([]byte, error) {
101101
// Do initial, non-line-length-aware formatting
102102
contents, err = s.formatSrc(contents)
103103
if err != nil {
104-
return nil, fmt.Errorf("Error formatting source: %+v", err)
104+
return nil, fmt.Errorf("error formatting source: %+v", err)
105105
}
106106

107107
for {
108-
log.Debugf("Starting round %d", round)
108+
log.Debugf("starting round %d", round)
109109

110110
// Annotate all long lines
111111
lines := strings.Split(string(contents), "\n")
@@ -125,7 +125,7 @@ func (s *Shortener) Shorten(contents []byte) ([]byte, error) {
125125
}
126126

127127
if stop {
128-
log.Debug("Nothing more to shorten or reformat, stopping")
128+
log.Debug("nothing more to shorten or reformat, stopping")
129129
break
130130
}
131131

@@ -144,7 +144,7 @@ func (s *Shortener) Shorten(contents []byte) ([]byte, error) {
144144
}
145145
defer dotFile.Close()
146146

147-
log.Debugf("Writing dot file output to %s", s.config.DotFile)
147+
log.Debugf("writing dot file output to %s", s.config.DotFile)
148148
err = CreateDot(result, dotFile)
149149
if err != nil {
150150
return nil, err
@@ -160,14 +160,14 @@ func (s *Shortener) Shorten(contents []byte) ([]byte, error) {
160160
output := bytes.NewBuffer([]byte{})
161161
err = decorator.Fprint(output, result)
162162
if err != nil {
163-
return nil, fmt.Errorf("Error parsing source: %+v", err)
163+
return nil, fmt.Errorf("error parsing source: %+v", err)
164164
}
165165
contents = output.Bytes()
166166

167167
round++
168168

169169
if round > maxRounds {
170-
log.Debugf("Hit max rounds, stopping")
170+
log.Debugf("hit max rounds, stopping")
171171
break
172172
}
173173
}
@@ -182,7 +182,7 @@ func (s *Shortener) Shorten(contents []byte) ([]byte, error) {
182182
// Do final round of non-line-length-aware formatting after we've fixed up the comments
183183
contents, err = s.formatSrc(contents)
184184
if err != nil {
185-
return nil, fmt.Errorf("Error formatting source: %+v", err)
185+
return nil, fmt.Errorf("error formatting source: %+v", err)
186186
}
187187

188188
return contents, nil
@@ -357,20 +357,20 @@ func (s *Shortener) isGoDirective(line string) bool {
357357
func (s *Shortener) formatNode(node dst.Node) {
358358
switch n := node.(type) {
359359
case dst.Decl:
360-
log.Debugf("Processing declaration: %+v", n)
360+
log.Debugf("processing declaration: %+v", n)
361361
s.formatDecl(n)
362362
case dst.Expr:
363-
log.Debugf("Processing expression: %+v", n)
363+
log.Debugf("processing expression: %+v", n)
364364
s.formatExpr(n, false, false)
365365
case dst.Stmt:
366-
log.Debugf("Processing statement: %+v", n)
366+
log.Debugf("processing statement: %+v", n)
367367
s.formatStmt(n)
368368
case dst.Spec:
369-
log.Debugf("Processing spec: %+v", n)
369+
log.Debugf("processing spec: %+v", n)
370370
s.formatSpec(n, false)
371371
default:
372372
log.Debugf(
373-
"Got a node type that can't be shortened: %+v",
373+
"got a node type that can't be shortened: %+v",
374374
reflect.TypeOf(n),
375375
)
376376
}
@@ -393,7 +393,7 @@ func (s *Shortener) formatDecl(decl dst.Decl) {
393393
}
394394
default:
395395
log.Debugf(
396-
"Got a declaration type that can't be shortened: %+v",
396+
"got a declaration type that can't be shortened: %+v",
397397
reflect.TypeOf(d),
398398
)
399399
}
@@ -473,7 +473,7 @@ func (s *Shortener) formatStmt(stmt dst.Stmt) {
473473
default:
474474
if shouldShorten {
475475
log.Debugf(
476-
"Got a statement type that can't be shortened: %+v",
476+
"got a statement type that can't be shortened: %+v",
477477
reflect.TypeOf(st),
478478
)
479479
}
@@ -565,7 +565,7 @@ func (s *Shortener) formatExpr(expr dst.Expr, force bool, isChain bool) {
565565
default:
566566
if shouldShorten {
567567
log.Debugf(
568-
"Got an expression type that can't be shortened: %+v",
568+
"got an expression type that can't be shortened: %+v",
569569
reflect.TypeOf(e),
570570
)
571571
}
@@ -585,7 +585,7 @@ func (s *Shortener) formatSpec(spec dst.Spec, force bool) {
585585
default:
586586
if shouldShorten {
587587
log.Debugf(
588-
"Got a spec type that can't be shortened: %+v",
588+
"got a spec type that can't be shortened: %+v",
589589
reflect.TypeOf(sp),
590590
)
591591
}

tags.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,5 +213,5 @@ func getWidth(node dst.Node) (int, error) {
213213
return 1 + xWidth, nil
214214
}
215215

216-
return 0, fmt.Errorf("Could not get width of node %+v", node)
216+
return 0, fmt.Errorf("could not get width of node %+v", node)
217217
}

0 commit comments

Comments
 (0)