Skip to content

Commit 5904a03

Browse files
JoannaaKLCopilot
andauthored
Fix linting flow (github#614)
* Add issues type filter * Add e2e test * Update e2e/e2e_test.go Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Add lint script and update golangci config * Add lint script * Install if not installed * Pass lint config * Use action and rename workflow * Back to reparate config * Migrate config to v2 * Update config * Lint code --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
1 parent 05456fb commit 5904a03

File tree

15 files changed

+89
-107
lines changed

15 files changed

+89
-107
lines changed

.github/workflows/go.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Unit Tests
1+
name: Build and Test Go Project
22
on: [push, pull_request]
33

44
permissions:

.github/workflows/lint.yaml

Lines changed: 0 additions & 45 deletions
This file was deleted.

.github/workflows/lint.yml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
name: golangci-lint
2+
on:
3+
push:
4+
branches:
5+
- main
6+
pull_request:
7+
8+
permissions:
9+
contents: read
10+
11+
jobs:
12+
golangci:
13+
name: lint
14+
runs-on: ubuntu-latest
15+
steps:
16+
- uses: actions/checkout@v4
17+
- uses: actions/setup-go@v5
18+
with:
19+
go-version: stable
20+
- name: golangci-lint
21+
uses: golangci/golangci-lint-action@v8
22+
with:
23+
version: v2.1

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,4 @@ __debug_bin*
1111

1212
# Go
1313
vendor
14+
bin/

.golangci.yml

Lines changed: 25 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,37 @@
1-
# https://golangci-lint.run/usage/configuration
21
version: "2"
3-
42
run:
5-
timeout: 5m
6-
tests: true
73
concurrency: 4
8-
4+
tests: true
95
linters:
106
enable:
11-
- govet
12-
- errcheck
13-
- staticcheck
14-
- revive
15-
- ineffassign
16-
- unused
17-
- misspell
18-
- nakedret
197
- bodyclose
208
- gocritic
21-
- makezero
229
- gosec
10+
- makezero
11+
- misspell
12+
- nakedret
13+
- revive
14+
exclusions:
15+
generated: lax
16+
presets:
17+
- comments
18+
- common-false-positives
19+
- legacy
20+
- std-error-handling
21+
paths:
22+
- third_party$
23+
- builtin$
24+
- examples$
2325
settings:
2426
staticcheck:
2527
checks:
26-
- all
27-
- '-QF1008' # Allow embedded structs to be referenced by field
28-
- '-ST1000' # Do not require package comments
29-
revive:
30-
rules:
31-
- name: exported
32-
disabled: true
33-
- name: exported
34-
disabled: true
35-
- name: package-comments
36-
disabled: true
37-
28+
- "all"
29+
- -QF1008
30+
- -ST1000
3831
formatters:
39-
enable:
40-
- gofmt
41-
- goimports
42-
43-
output:
44-
formats:
45-
text:
46-
print-linter-name: true
47-
print-issued-lines: true
32+
exclusions:
33+
generated: lax
34+
paths:
35+
- third_party$
36+
- builtin$
37+
- examples$

cmd/github-mcp-server/generate_docs.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ var generateDocsCmd = &cobra.Command{
2323
Use: "generate-docs",
2424
Short: "Generate documentation for tools and toolsets",
2525
Long: `Generate the automated sections of README.md and docs/remote-server.md with current tool and toolset information.`,
26-
RunE: func(cmd *cobra.Command, args []string) error {
26+
RunE: func(_ *cobra.Command, _ []string) error {
2727
return generateAllDocs()
2828
},
2929
}
@@ -33,17 +33,17 @@ func init() {
3333
}
3434

3535
// mockGetClient returns a mock GitHub client for documentation generation
36-
func mockGetClient(ctx context.Context) (*gogithub.Client, error) {
36+
func mockGetClient(_ context.Context) (*gogithub.Client, error) {
3737
return gogithub.NewClient(nil), nil
3838
}
3939

4040
// mockGetGQLClient returns a mock GraphQL client for documentation generation
41-
func mockGetGQLClient(ctx context.Context) (*githubv4.Client, error) {
41+
func mockGetGQLClient(_ context.Context) (*githubv4.Client, error) {
4242
return githubv4.NewClient(nil), nil
4343
}
4444

4545
// mockGetRawClient returns a mock raw client for documentation generation
46-
func mockGetRawClient(ctx context.Context) (*raw.Client, error) {
46+
func mockGetRawClient(_ context.Context) (*raw.Client, error) {
4747
return nil, nil
4848
}
4949

cmd/github-mcp-server/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ func main() {
103103
}
104104
}
105105

106-
func wordSepNormalizeFunc(f *pflag.FlagSet, name string) pflag.NormalizedName {
106+
func wordSepNormalizeFunc(_ *pflag.FlagSet, name string) pflag.NormalizedName {
107107
from := []string{"_"}
108108
to := "-"
109109
for _, sep := range from {

pkg/errors/error_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ func TestGitHubErrorContext(t *testing.T) {
260260

261261
t.Run("NewGitHubAPIErrorToCtx with nil context does not error", func(t *testing.T) {
262262
// Given a nil context
263-
var ctx context.Context = nil
263+
var ctx context.Context
264264

265265
// Create a mock GitHub response
266266
resp := &github.Response{

pkg/github/actions_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -538,7 +538,7 @@ func Test_DownloadWorkflowRunArtifact(t *testing.T) {
538538
Pattern: "/repos/owner/repo/actions/artifacts/123/zip",
539539
Method: "GET",
540540
},
541-
http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
541+
http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {
542542
// GitHub returns a 302 redirect to the download URL
543543
w.Header().Set("Location", "https://api.github.com/repos/owner/repo/actions/artifacts/123/download")
544544
w.WriteHeader(http.StatusFound)
@@ -1055,7 +1055,7 @@ func Test_GetJobLogs_WithContentReturn(t *testing.T) {
10551055
logContent := "2023-01-01T10:00:00.000Z Starting job...\n2023-01-01T10:00:01.000Z Running tests...\n2023-01-01T10:00:02.000Z Job completed successfully"
10561056

10571057
// Create a test server to serve log content
1058-
testServer := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
1058+
testServer := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {
10591059
w.WriteHeader(http.StatusOK)
10601060
_, _ = w.Write([]byte(logContent))
10611061
}))

pkg/github/issues.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -893,7 +893,7 @@ func AssignCodingAgentPrompt(t translations.TranslationHelperFunc) (tool mcp.Pro
893893
return mcp.NewPrompt("AssignCodingAgent",
894894
mcp.WithPromptDescription(t("PROMPT_ASSIGN_CODING_AGENT_DESCRIPTION", "Assign GitHub Coding Agent to multiple tasks in a GitHub repository.")),
895895
mcp.WithArgument("repo", mcp.ArgumentDescription("The repository to assign tasks in (owner/repo)."), mcp.RequiredArgument()),
896-
), func(ctx context.Context, request mcp.GetPromptRequest) (*mcp.GetPromptResult, error) {
896+
), func(_ context.Context, request mcp.GetPromptRequest) (*mcp.GetPromptResult, error) {
897897
repo := request.Params.Arguments["repo"]
898898

899899
messages := []mcp.PromptMessage{

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy