Skip to content

Commit 63fe4e8

Browse files
committed
fix: Linters
1 parent 8b814e8 commit 63fe4e8

File tree

30 files changed

+41
-111
lines changed

30 files changed

+41
-111
lines changed

.golangci.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,8 @@ linters-settings:
9898
# ).
9999
# Run `GL_DEBUG=govet golangci-lint run --enable=govet` to see default, all available analyzers, and enabled analyzers.
100100
# Default: []
101+
disable:
102+
- fieldalignment
101103
enable:
102104
# Check for missing values after append.
103105
- appends
@@ -127,8 +129,6 @@ linters-settings:
127129
- directive
128130
# Report passing non-pointer or non-error values to errors.As.
129131
- errorsas
130-
# Find structs that would use less memory if their fields were sorted.
131-
- fieldalignment
132132
# Find calls to a particular function.
133133
- findcall
134134
# Report assembly that clobbers the frame pointer before saving it.

cmd/aoc-cli/handlers.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import (
2121
)
2222

2323
func onExit(_ context.Context) cli.AfterFunc {
24-
return func(c *cli.Context) error {
24+
return func(_ *cli.Context) error {
2525
fmt.Println("Exit...")
2626

2727
return nil

internal/command/command_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,10 @@ func newMockHTTPClient(p returnParams) *mockHTTPClient {
3434
return &http.Response{
3535
Status: http.StatusText(p.status),
3636
StatusCode: p.status,
37-
Proto: "HTTP/1.0",
38-
ProtoMajor: 1,
39-
ProtoMinor: 0,
40-
Header: nil,
37+
Proto: req.Proto,
38+
ProtoMajor: req.ProtoMajor,
39+
ProtoMinor: req.ProtoMinor,
40+
Header: req.Header,
4141
Body: p.body,
4242
ContentLength: 0,
4343
TransferEncoding: nil,

internal/puzzles/common/intcomputer/intcoumputer_test.go

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,6 @@ func Test_New(t *testing.T) {
4747
}
4848

4949
for _, tt := range tests {
50-
tt := tt
51-
5250
t.Run(tt.name, func(t *testing.T) {
5351
got, err := New(tt.args.input)
5452
if tt.wantErr {
@@ -116,8 +114,6 @@ func Test_computer_add(t *testing.T) {
116114
}
117115

118116
for _, tt := range tests {
119-
tt := tt
120-
121117
t.Run(tt.name, func(t *testing.T) {
122118
err := tt.c.add(tt.args.aPos, tt.args.bPos, tt.args.resPos)
123119
require.NoError(t, err)
@@ -163,8 +159,6 @@ func Test_computer_mult(t *testing.T) {
163159
}
164160

165161
for _, tt := range tests {
166-
tt := tt
167-
168162
t.Run(tt.name, func(t *testing.T) {
169163
err := tt.c.mult(tt.args.aPos, tt.args.bPos, tt.args.resPos)
170164
require.NoError(t, err)
@@ -195,8 +189,6 @@ func Test_computer_Execute(t *testing.T) {
195189
}
196190

197191
for _, tt := range tests {
198-
tt := tt
199-
200192
t.Run(tt.name, func(t *testing.T) {
201193
comp := tt.c
202194
got, err := comp.Execute()
@@ -233,8 +225,6 @@ func Test_computer_Input(t *testing.T) {
233225
}
234226

235227
for _, tt := range tests {
236-
tt := tt
237-
238228
t.Run(tt.name, func(t *testing.T) {
239229
comp := tt.c
240230
comp.Input(tt.args.noun, tt.args.verb)

internal/puzzles/input/content_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,10 @@ func newMockHTTPClient(p returnParams) *mockHTTPClient {
3434
return &http.Response{
3535
Status: http.StatusText(p.status),
3636
StatusCode: p.status,
37-
Proto: "HTTP/1.0",
37+
Proto: req.Proto,
3838
ProtoMajor: 1,
39-
ProtoMinor: 0,
40-
Header: nil,
39+
ProtoMinor: req.ProtoMinor,
40+
Header: req.Header,
4141
Body: p.body,
4242
ContentLength: 0,
4343
TransferEncoding: nil,
@@ -173,7 +173,7 @@ func TestGet(t *testing.T) {
173173
name: "",
174174
client: client{
175175
IHTTPClient: &mockHTTPClient{
176-
MockDo: func(req *http.Request) (*http.Response, error) {
176+
MockDo: func(_ *http.Request) (*http.Response, error) {
177177
return &http.Response{}, errors.New("error in test")
178178
},
179179
},

internal/puzzles/name_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,16 +49,16 @@ func TestMakeName(t *testing.T) {
4949
}
5050

5151
for _, tt := range tests {
52-
tt := tt
53-
5452
t.Run(tt.name, func(t *testing.T) {
5553
got, err := MakeName(tt.args.year, tt.args.puzzle)
5654
if tt.wantErr {
5755
assert.Error(t, err)
5856

5957
return
6058
}
59+
6160
assert.NoError(t, err)
61+
6262
assert.Equal(t, tt.want, got)
6363
})
6464
}

internal/puzzles/solutions/2015/day01/solution_test.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -124,8 +124,6 @@ func Test_solution_Part1(t *testing.T) {
124124
}
125125

126126
for _, tt := range tests {
127-
tt := tt
128-
129127
t.Run(tt.name, func(t *testing.T) {
130128
got, err := s.Part1(tt.args.input)
131129
if tt.wantErr {
@@ -180,8 +178,6 @@ func Test_solution_Part2(t *testing.T) {
180178
}
181179

182180
for _, tt := range tests {
183-
tt := tt
184-
185181
t.Run(tt.name, func(t *testing.T) {
186182
got, err := s.Part2(tt.args.input)
187183
if tt.wantErr {

internal/puzzles/solutions/2015/day02/solution_test.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,6 @@ func Test_solution_Part1(t *testing.T) {
6868
}
6969

7070
for _, tt := range tests {
71-
tt := tt
72-
7371
t.Run(tt.name, func(t *testing.T) {
7472
got, err := s.Part1(tt.args.input)
7573
if tt.wantErr {
@@ -124,8 +122,6 @@ func Test_solution_Part2(t *testing.T) {
124122
}
125123

126124
for _, tt := range tests {
127-
tt := tt
128-
129125
t.Run(tt.name, func(t *testing.T) {
130126
got, err := s.Part2(tt.args.input)
131127
if tt.wantErr {

internal/puzzles/solutions/2016/day01/solution_test.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,6 @@ func Test_solution_Part1(t *testing.T) {
7676
}
7777

7878
for _, tt := range tests {
79-
tt := tt
80-
8179
t.Run(tt.name, func(t *testing.T) {
8280
got, err := s.Part1(tt.args.input)
8381
if tt.wantErr {
@@ -124,8 +122,6 @@ func Test_solution_Part2(t *testing.T) {
124122
}
125123

126124
for _, tt := range tests {
127-
tt := tt
128-
129125
t.Run(tt.name, func(t *testing.T) {
130126
got, err := s.Part2(tt.args.input)
131127
if tt.wantErr {

internal/puzzles/solutions/2016/day02/solution.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ let's predict that this is a 2 dimension matrix and '5' is 0,2m
119119
func loadKeypadPart2() keypad {
120120
start := keypadPos{
121121
x: 0,
122-
y: 2,
122+
y: 2, //nolint:mnd // False positive.
123123
}
124124

125125
g := [][]string{

0 commit comments

Comments
 (0)