Skip to content

Commit add7445

Browse files
committed
refactor: depthは使っていないので消す
1 parent ce376e7 commit add7445

File tree

2 files changed

+13
-13
lines changed

2 files changed

+13
-13
lines changed

report.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ func report(ctx context.Context, call *ssa.Call) {
6464
}
6565
case *ssa.Slice:
6666
w := new(walker)
67-
if r, ok := w.walk(ctx, 0, v); ok && len(r) > 0 {
67+
if r, ok := w.walk(ctx, v); ok && len(r) > 0 {
6868
want = strings.Join(r, ".") + ": %w"
6969
gotWant = true
7070
}

walk.go

+12-12
Original file line numberDiff line numberDiff line change
@@ -28,25 +28,25 @@ func (w *walker) contains(n interface{}) bool {
2828
return false
2929
}
3030

31-
func (w *walker) walkRefs(ctx context.Context, depth int, v ssautil.Referrerer) ([]string, bool) {
32-
for _, v := range *v.Referrers() {
33-
if r, ok := w.walk(ctx, depth, v); ok {
31+
func (w *walker) walkRefs(ctx context.Context, v ssautil.Referrerer) ([]string, bool) {
32+
for _, v := range ssautil.Referrers(v) {
33+
if r, ok := w.walk(ctx, v); ok {
3434
return r, true
3535
}
3636
}
3737
return nil, false
3838
}
3939

40-
func (w *walker) walkOperands(ctx context.Context, depth int, v ssautil.Operander) ([]string, bool) {
40+
func (w *walker) walkOperands(ctx context.Context, v ssautil.Operander) ([]string, bool) {
4141
for _, v := range ssautil.Operands(v) {
42-
if r, ok := w.walk(ctx, depth, v); ok {
42+
if r, ok := w.walk(ctx, v); ok {
4343
return r, true
4444
}
4545
}
4646
return nil, false
4747
}
4848

49-
func (w *walker) walk(ctx context.Context, depth int, v ssautil.Poser) ([]string, bool) {
49+
func (w *walker) walk(ctx context.Context, v ssautil.Poser) ([]string, bool) {
5050
if w.contains(v) {
5151
return nil, false
5252
}
@@ -55,17 +55,17 @@ func (w *walker) walk(ctx context.Context, depth int, v ssautil.Poser) ([]string
5555

5656
switch v := v.(type) {
5757
case *ssa.Slice:
58-
return w.walkOperands(ctx, depth+1, v)
58+
return w.walkOperands(ctx, v)
5959
case *ssa.Alloc:
60-
return w.walkRefs(ctx, depth+1, v)
60+
return w.walkRefs(ctx, v)
6161
case *ssa.IndexAddr:
62-
return w.walkRefs(ctx, depth+1, v)
62+
return w.walkRefs(ctx, v)
6363
case *ssa.Store:
64-
return w.walkOperands(ctx, depth+1, v)
64+
return w.walkOperands(ctx, v)
6565
case *ssa.ChangeInterface:
66-
return w.walkOperands(ctx, depth+1, v)
66+
return w.walkOperands(ctx, v)
6767
case *ssa.Extract:
68-
return w.walkOperands(ctx, depth+1, v)
68+
return w.walkOperands(ctx, v)
6969
case *ssa.Call:
7070
return formatCall(ctx, v)
7171
}

0 commit comments

Comments
 (0)