|
1 | 1 | package testpkg
|
2 | 2 |
|
3 | 3 | func fn1() {
|
| 4 | + // want +2 `missing whitespace above this line \(never cuddle decl\)` |
4 | 5 | var a = 1
|
5 |
| - var b = 2 // want `missing whitespace above this line \(never cuddle decl\)` |
| 6 | + var b = 2 |
6 | 7 |
|
| 8 | + // want +2 `missing whitespace above this line \(never cuddle decl\)` |
7 | 9 | const c = 3
|
8 |
| - const d = 4 // want `missing whitespace above this line \(never cuddle decl\)` |
| 10 | + const d = 4 |
9 | 11 |
|
| 12 | + // want +3 `missing whitespace above this line \(never cuddle decl\)` |
| 13 | + // want +3 `missing whitespace above this line \(invalid statement above assign\)` |
10 | 14 | e := 5
|
11 |
| - var f = 6 // want `missing whitespace above this line \(never cuddle decl\)` |
12 |
| - g := 7 // want `missing whitespace above this line \(invalid statement above assign\)` |
| 15 | + var f = 6 |
| 16 | + g := 7 |
| 17 | + |
| 18 | + // want +2 `missing whitespace above this line \(never cuddle decl\)` |
| 19 | + var a = 1 |
| 20 | + var b = a |
13 | 21 | }
|
14 | 22 |
|
15 | 23 | func fn2() {
|
16 |
| - var a = 1 |
17 |
| - var b = a // want `missing whitespace above this line \(never cuddle decl\)` |
| 24 | + var x = func() { // want +1 `unnecessary whitespace \(leading-whitespace\)` |
| 25 | + |
| 26 | + return 1 |
| 27 | + }() |
18 | 28 | }
|
19 | 29 |
|
20 | 30 | func fn3() {
|
21 |
| - a := 1 |
22 |
| - var b = a // want `missing whitespace above this line \(never cuddle decl\)` |
| 31 | + // want +4 `missing whitespace above this line \(never cuddle decl\)` |
| 32 | + // want +4 `missing whitespace above this line \(never cuddle decl\)` |
| 33 | + // want +4 `missing whitespace above this line \(never cuddle decl\)` |
| 34 | + var a = 1 |
| 35 | + var b = 2 |
| 36 | + var c = 3 |
| 37 | + var d = 4 |
23 | 38 | }
|
24 | 39 |
|
25 | 40 | func fn4() {
|
26 |
| - var x = func() { // want +1 `unnecessary whitespace \(leading-whitespace\)` |
| 41 | + // want +5 `missing whitespace above this line \(never cuddle decl\)` |
| 42 | + var ( |
| 43 | + a = 1 |
| 44 | + b = 2 |
| 45 | + ) |
| 46 | + var ( |
| 47 | + c = 3 |
| 48 | + d = 4 |
| 49 | + ) |
| 50 | +} |
27 | 51 |
|
| 52 | +func fn5() { |
| 53 | + // want +7 `missing whitespace above this line \(never cuddle decl\)` |
| 54 | + // want +7 `missing whitespace above this line \(never cuddle decl\)` |
| 55 | + // want +9 `missing whitespace above this line \(never cuddle decl\)` |
| 56 | + var ( |
| 57 | + a = 1 |
| 58 | + b = 2 |
| 59 | + ) |
| 60 | + var x int |
| 61 | + var z = func() int { |
28 | 62 | return 1
|
29 |
| - }() |
| 63 | + } |
| 64 | + var ( |
| 65 | + c = 3 |
| 66 | + d = 4 |
| 67 | + ) |
| 68 | +} |
| 69 | + |
| 70 | +func fn6() { |
| 71 | + // want +5 `missing whitespace above this line \(never cuddle decl\)` |
| 72 | + // want +5 `missing whitespace above this line \(never cuddle decl\)` |
| 73 | + // want +5 `missing whitespace above this line \(never cuddle decl\)` |
| 74 | + // want +5 `missing whitespace above this line \(never cuddle decl\)` |
| 75 | + var a = 1 |
| 76 | + var b = 2 |
| 77 | + var c = 3 // test |
| 78 | + var d = 4 |
| 79 | + var e = 5 |
| 80 | +} |
| 81 | + |
| 82 | +func fn7() { |
| 83 | + // want +2 `missing whitespace above this line \(never cuddle decl\)` |
| 84 | + var a = 1 |
| 85 | + var b = 2 |
| 86 | + |
| 87 | + var c = 3 |
| 88 | + |
| 89 | + // want +2 `missing whitespace above this line \(never cuddle decl\)` |
| 90 | + var d = 4 |
| 91 | + var e = 5 |
| 92 | +} |
| 93 | + |
| 94 | +func fn8() { |
| 95 | + // want +3 `missing whitespace above this line \(never cuddle decl\)` |
| 96 | + // Comment above |
| 97 | + var g = 7 |
| 98 | + var h = 8 |
| 99 | + // Comment after |
| 100 | +} |
| 101 | + |
| 102 | +func fn9() { |
| 103 | + type S1 struct { |
| 104 | + N int |
| 105 | + } |
| 106 | + type S2 struct { // want `missing whitespace above this line \(never cuddle decl\)` |
| 107 | + N int |
| 108 | + } |
| 109 | +} |
| 110 | + |
| 111 | +func fn10() { |
| 112 | + // want +5 `missing whitespace above this line \(never cuddle decl\)` |
| 113 | + // want +5 `missing whitespace above this line \(never cuddle decl\)` |
| 114 | + // want +5 `missing whitespace above this line \(never cuddle decl\)` |
| 115 | + a := 1 |
| 116 | + b := 2 |
| 117 | + var c int |
| 118 | + var d = "string" |
| 119 | + var e string = "string" |
| 120 | + f := 3 // want `missing whitespace above this line \(invalid statement above assign\)` |
| 121 | +} |
| 122 | + |
| 123 | +func fn11() { |
| 124 | + // want +2 `missing whitespace above this line \(never cuddle decl\)` |
| 125 | + var a int |
| 126 | + var b int |
| 127 | + if b > 0 { // want `missing whitespace above this line \(too many statements above if\)` |
| 128 | + _ = 1 |
| 129 | + } |
| 130 | +} |
| 131 | + |
| 132 | +func fn12() { |
| 133 | + // want +2 `missing whitespace above this line \(never cuddle decl\)` |
| 134 | + var a int |
| 135 | + var b int // Not grouped due to this comment |
| 136 | + if b > 0 { |
| 137 | + _ = 1 |
| 138 | + } |
30 | 139 | }
|
0 commit comments