mirror of
https://gitea.com/gitea/gitea-mcp.git
synced 2026-02-27 09:05:12 +00:00
chore: add golangci-lint, bump Go to 1.26, fix all lint issues (#133)
## Summary
- Add `.golangci.yml` with linter configuration matching the main gitea repo
- Add `lint`, `lint-fix`, `lint-go`, `lint-go-fix`, and `security-check` Makefile targets
- Add `tidy` Makefile target (extracts min Go version from `go.mod` for `-compat` flag)
- Bump minimum Go version to 1.26
- Update golangci-lint to v2.10.1
- Replace `golang/govulncheck-action` with `make security-check` in CI
- Add `make lint` step to CI
- Fix all lint issues across the codebase (formatting, `errors.New` vs `fmt.Errorf`, `any` vs `interface{}`, unused returns, stuttering names, Go 1.26 `new(expr)`, etc.)
- Remove unused `pkg/ptr` package (inlined by Go 1.26 `new(expr)`)
- Remove dead linter exclusions (staticcheck, gocritic, testifylint, dupl)
## Test plan
- [x] `make lint` passes
- [x] `go test ./...` passes
- [x] `make build` succeeds
Reviewed-on: https://gitea.com/gitea/gitea-mcp/pulls/133
Reviewed-by: techknowlogick <techknowlogick@noreply.gitea.com>
Co-authored-by: silverwind <me@silverwind.io>
Co-committed-by: silverwind <me@silverwind.io>
This commit is contained in:
committed by
techknowlogick
parent
4d5fa3ab2c
commit
8728c04748
@@ -2,11 +2,11 @@ package search
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
|
||||
"gitea.com/gitea/gitea-mcp/pkg/gitea"
|
||||
"gitea.com/gitea/gitea-mcp/pkg/log"
|
||||
"gitea.com/gitea/gitea-mcp/pkg/ptr"
|
||||
"gitea.com/gitea/gitea-mcp/pkg/to"
|
||||
"gitea.com/gitea/gitea-mcp/pkg/tool"
|
||||
|
||||
@@ -61,23 +61,23 @@ var (
|
||||
func init() {
|
||||
Tool.RegisterRead(server.ServerTool{
|
||||
Tool: SearchUsersTool,
|
||||
Handler: SearchUsersFn,
|
||||
Handler: UsersFn,
|
||||
})
|
||||
Tool.RegisterRead(server.ServerTool{
|
||||
Tool: SearOrgTeamsTool,
|
||||
Handler: SearchOrgTeamsFn,
|
||||
Handler: OrgTeamsFn,
|
||||
})
|
||||
Tool.RegisterRead(server.ServerTool{
|
||||
Tool: SearchReposTool,
|
||||
Handler: SearchReposFn,
|
||||
Handler: ReposFn,
|
||||
})
|
||||
}
|
||||
|
||||
func SearchUsersFn(ctx context.Context, req mcp.CallToolRequest) (*mcp.CallToolResult, error) {
|
||||
log.Debugf("Called SearchUsersFn")
|
||||
func UsersFn(ctx context.Context, req mcp.CallToolRequest) (*mcp.CallToolResult, error) {
|
||||
log.Debugf("Called UsersFn")
|
||||
keyword, ok := req.GetArguments()["keyword"].(string)
|
||||
if !ok {
|
||||
return to.ErrorResult(fmt.Errorf("keyword is required"))
|
||||
return to.ErrorResult(errors.New("keyword is required"))
|
||||
}
|
||||
page, ok := req.GetArguments()["page"].(float64)
|
||||
if !ok {
|
||||
@@ -105,15 +105,15 @@ func SearchUsersFn(ctx context.Context, req mcp.CallToolRequest) (*mcp.CallToolR
|
||||
return to.TextResult(users)
|
||||
}
|
||||
|
||||
func SearchOrgTeamsFn(ctx context.Context, req mcp.CallToolRequest) (*mcp.CallToolResult, error) {
|
||||
log.Debugf("Called SearchOrgTeamsFn")
|
||||
func OrgTeamsFn(ctx context.Context, req mcp.CallToolRequest) (*mcp.CallToolResult, error) {
|
||||
log.Debugf("Called OrgTeamsFn")
|
||||
org, ok := req.GetArguments()["org"].(string)
|
||||
if !ok {
|
||||
return to.ErrorResult(fmt.Errorf("organization is required"))
|
||||
return to.ErrorResult(errors.New("organization is required"))
|
||||
}
|
||||
query, ok := req.GetArguments()["query"].(string)
|
||||
if !ok {
|
||||
return to.ErrorResult(fmt.Errorf("query is required"))
|
||||
return to.ErrorResult(errors.New("query is required"))
|
||||
}
|
||||
includeDescription, _ := req.GetArguments()["includeDescription"].(bool)
|
||||
page, ok := req.GetArguments()["page"].(float64)
|
||||
@@ -143,11 +143,11 @@ func SearchOrgTeamsFn(ctx context.Context, req mcp.CallToolRequest) (*mcp.CallTo
|
||||
return to.TextResult(teams)
|
||||
}
|
||||
|
||||
func SearchReposFn(ctx context.Context, req mcp.CallToolRequest) (*mcp.CallToolResult, error) {
|
||||
log.Debugf("Called SearchReposFn")
|
||||
func ReposFn(ctx context.Context, req mcp.CallToolRequest) (*mcp.CallToolResult, error) {
|
||||
log.Debugf("Called ReposFn")
|
||||
keyword, ok := req.GetArguments()["keyword"].(string)
|
||||
if !ok {
|
||||
return to.ErrorResult(fmt.Errorf("keyword is required"))
|
||||
return to.ErrorResult(errors.New("keyword is required"))
|
||||
}
|
||||
keywordIsTopic, _ := req.GetArguments()["keywordIsTopic"].(bool)
|
||||
keywordInDescription, _ := req.GetArguments()["keywordInDescription"].(bool)
|
||||
@@ -155,12 +155,12 @@ func SearchReposFn(ctx context.Context, req mcp.CallToolRequest) (*mcp.CallToolR
|
||||
var pIsPrivate *bool
|
||||
isPrivate, ok := req.GetArguments()["isPrivate"].(bool)
|
||||
if ok {
|
||||
pIsPrivate = ptr.To(isPrivate)
|
||||
pIsPrivate = new(isPrivate)
|
||||
}
|
||||
var pIsArchived *bool
|
||||
isArchived, ok := req.GetArguments()["isArchived"].(bool)
|
||||
if ok {
|
||||
pIsArchived = ptr.To(isArchived)
|
||||
pIsArchived = new(isArchived)
|
||||
}
|
||||
sort, _ := req.GetArguments()["sort"].(string)
|
||||
order, _ := req.GetArguments()["order"].(string)
|
||||
|
||||
Reference in New Issue
Block a user