Skip to content

Commit 5259c3a

Browse files
Sergio Castilloscastlara
authored andcommitted
ci: add golangci-lint
1 parent 18fd13d commit 5259c3a

File tree

7 files changed

+22
-14
lines changed

7 files changed

+22
-14
lines changed

.github/workflows/tests.yml

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name: Test
2-
on:
2+
on:
33
push:
4-
branches: [ main ]
4+
branches: [main]
55
pull_request:
66

77
jobs:
@@ -13,8 +13,12 @@ jobs:
1313
- name: Setup Go
1414
uses: actions/setup-go@v5
1515
with:
16-
go-version: '1.21.3'
16+
go-version: "1.21.3"
1717
- name: Install dependencies
1818
run: go get .
19-
- name: Test with the Go CLI
19+
- name: Lint
20+
uses: golangci/golangci-lint-action@v6
21+
with:
22+
version: v1.60
23+
- name: Test
2024
run: go test ./...

internal/cli/utils_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ func TestCombineBeforeFuncs(t *testing.T) {
1717

1818
before_func := CombineBeforeFuncs(mockBeforeFuncs.Func1, mockBeforeFuncs.Func2)
1919

20-
before_func(nil)
20+
_ = before_func(nil)
2121

2222
mockBeforeFuncs.AssertExpectations(t)
2323
}
@@ -47,7 +47,7 @@ func TestConfigureLogs(t *testing.T) {
4747
flag.Bool("verbose", input, "")
4848
context := cli.NewContext(nil, flag, nil)
4949

50-
ConfigureLogs(context)
50+
_ = ConfigureLogs(context)
5151

5252
assert.Equal(t, zerolog.GlobalLevel(), want)
5353
}
@@ -69,10 +69,10 @@ func TestConfigFileLoaderNoFile(t *testing.T) {
6969
func TestLogArguments(t *testing.T) {
7070
flag := flag.NewFlagSet("flag", flag.ContinueOnError)
7171
flag.String("some-flag", "", "")
72-
flag.Set("some-flag", "value")
72+
_ = flag.Set("some-flag", "value")
7373
context := cli.NewContext(nil, flag, nil)
7474

75-
LogArguments(context)
75+
_ = LogArguments(context)
7676

7777
// How to assert that the log message was correct?
7878
}

internal/gitlab/gitlab_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ func (c *mockClient) ListProjectIssues(projectId interface{}, opt *gitlab.ListPr
230230
args := c.Called(projectId, opt, options)
231231
var r *gitlab.Response
232232
if resp := args.Get(1); resp != nil {
233-
resp = args.Get(1).(*gitlab.Response)
233+
r = args.Get(1).(*gitlab.Response)
234234
}
235235
return args.Get(0).([]*gitlab.Issue), r, args.Error(2)
236236
}

internal/publish/to_gitlab_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ func TestPublishAsGitlabIssues(t *testing.T) {
176176
},
177177
}
178178

179-
PublishAsGitlabIssues(reports, mockGitlabService)
179+
_ = PublishAsGitlabIssues(reports, mockGitlabService)
180180
mockGitlabService.AssertExpectations(t)
181181

182182
t.Run("FillsTheIssueUrl", func(t *testing.T) {

internal/publish/to_slack_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ func TestPublishAsSpecificChannelSlackMessage(t *testing.T) {
4343
ProjectConfig: scanner.ProjectConfig{SlackChannel: "channel"},
4444
}
4545

46-
PublishAsSpecificChannelSlackMessage([]scanner.Report{report}, mockSlackService)
46+
_ = PublishAsSpecificChannelSlackMessage([]scanner.Report{report}, mockSlackService)
4747

4848
mockSlackService.AssertExpectations(t)
4949
mockSlackService.AssertNumberOfCalls(t, "PostMessage", 1)

internal/shell/shell.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,8 @@ func (c *shellCommandRunner) Run(in CommandInput) (CommandOutput, error) {
3939
if in.Timeout == 0 {
4040
in.Timeout = defaultTimeout
4141
}
42-
ctx, _ := context.WithTimeout(context.Background(), in.Timeout)
42+
ctx, cancel := context.WithTimeout(context.Background(), in.Timeout)
43+
defer cancel()
4344
cmd := exec.CommandContext(ctx, in.Name, in.Args...)
4445
out, err := cmd.Output()
4546

justfile

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,8 @@ run *ARGS:
55
GITLAB_TOKEN=$GITLAB_TOKEN go run . {{ARGS}}
66

77
alias t := test
8-
test:
9-
go test ./...
8+
test *ARGS="./...":
9+
go test {{ARGS}}
10+
11+
lint:
12+
golangci-lint run ./...

0 commit comments

Comments
 (0)