Debian Codegraph @

testdata/script/func-merge-parameters.txtar

raw
1 # By default, this rule isn't enabled.
2 exec gofumpt foo.go
3 cmp stdout foo.go
4
5 # It's run with -extra.
6 exec gofumpt -extra foo.go
7 cmp stdout foo.go.golden
8
9 exec gofumpt -d foo.go.golden
10 ! stdout .
11
12 -- foo.go --
13 package p
14
15 type f func(x int, y int) int
16
17 type i interface {
18 add(x int, y int)
19 }
20
21 type s struct {
22 x int
23 y int
24 }
25
26 func mergeAdjacent(x int, y int) {}
27
28 func mergeThreeAdjacent(x int, y int, z int) {}
29
30 func mergeOneWithTwo(x, y int, z int) {}
31
32 func mergeTwoWithOne(x int, y, z int) {}
33
34 func mergeWithComment(
35 x int, y int, // comment
36 )
37
38 func mergeAllSyntax(x chan []*foo.Bar, y chan []*foo.Bar) {}
39
40 func dontMergeAnonymousParams(int, int) {}
41
42 func dontMergeMultipleLines(
43 x int,
44 y int,
45 ) {
46 }
47
48 func dontMergeMultipleLines2(
49 x,
50 y int,
51 z int,
52 ) {
53 }
54 -- foo.go.golden --
55 package p
56
57 type f func(x, y int) int
58
59 type i interface {
60 add(x, y int)
61 }
62
63 type s struct {
64 x int
65 y int
66 }
67
68 func mergeAdjacent(x, y int) {}
69
70 func mergeThreeAdjacent(x, y, z int) {}
71
72 func mergeOneWithTwo(x, y, z int) {}
73
74 func mergeTwoWithOne(x, y, z int) {}
75
76 func mergeWithComment(
77 x, y int, // comment
78 )
79
80 func mergeAllSyntax(x, y chan []*foo.Bar) {}
81
82 func dontMergeAnonymousParams(int, int) {}
83
84 func dontMergeMultipleLines(
85 x int,
86 y int,
87 ) {
88 }
89
90 func dontMergeMultipleLines2(
91 x,
92 y int,
93 z int,
94 ) {
95 }