-
Notifications
You must be signed in to change notification settings - Fork 3.6k
refactor: modernize code with modernize and intrange linters
#1988
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Modernizes the Go codebase based on modernize and intrange golangci-lint suggestions, and updates lint tooling to support these linters.
Changes:
- Enabled
modernizeandintrangein.golangci.ymland updated golangci-lint versions in CI andscript/lint. - Refactored code to use newer Go stdlib helpers (
slices,maps,strings.CutSuffix,min/max,any) andfor range <int>loops. - Updated tests and supporting utilities to align with the modernized patterns (primarily
interface{}→anyand slice/map helpers).
Reviewed changes
Copilot reviewed 39 out of 39 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| script/lint | Bumps locally-installed golangci-lint version to v2.8.0. |
| .github/workflows/lint.yml | Updates CI golangci-lint version configuration to v2.8. |
| .golangci.yml | Enables modernize + intrange and adds an exclusion rule for revive’s stdlib-name conflict warning. |
| pkg/tooldiscovery/search.go | Uses max() for simpler max-length calculation in similarity scoring. |
| pkg/scopes/scopes.go | Uses slices.Sort for deterministic scope ordering. |
| pkg/raw/raw.go | Switches request body type to any. |
| pkg/lockdown/lockdown.go | Switches GraphQL variables map type to map[string]any. |
| pkg/inventory/filters.go | Uses slices.Sort for enabled toolset ID ordering. |
| pkg/inventory/builder.go | Uses maps.Copy and slices.Sort for simpler map copy and deterministic ordering. |
| pkg/http/oauth/oauth.go | Uses strings.CutSuffix for cleaner route joining. |
| pkg/github/tools.go | Replaces manual loop with slices.Contains. |
| pkg/github/repositories.go | Updates request parsing maps/slices to any-based types. |
| pkg/github/pullrequests.go | Switches GraphQL variables map type to map[string]any. |
| pkg/github/issues.go | Switches GraphQL variables/response maps to map[string]any. |
| pkg/github/discussions.go | Switches GraphQL variables/response maps to map[string]any. |
| pkg/github/context_tools.go | Switches GraphQL variables map type to map[string]any. |
| pkg/github/actions.go | Switches inputs map type to map[string]any and simplifies buffer sizing with min(). |
| pkg/buffer/buffer.go | Simplifies buffer-size math with min() and uses for range <int> iteration. |
| cmd/mcpcurl/main.go | Uses any-typed argument maps and updates JSON parsing containers accordingly. |
| cmd/github-mcp-server/generate_docs.go | Uses slices.Contains and strings.Cut to simplify doc generation logic. |
| internal/toolsnaps/toolsnaps_test.go | Updates test structs/maps to any and uses for range <int> loops. |
| pkg/github/actions_test.go | Updates slices/maps to any and uses for range <int> loops. |
| pkg/github/code_scanning_test.go | Updates request args maps to map[string]any. |
| pkg/github/context_tools_test.go | Updates GraphQL vars/request args maps to map[string]any. |
| pkg/github/dependabot_test.go | Updates request args maps to map[string]any. |
| pkg/github/discussions_test.go | Updates GraphQL vars/request/expected maps to any-based types. |
| pkg/github/gists_test.go | Updates request args maps to map[string]any. |
| pkg/github/git_test.go | Updates request args/response parsing to any-based types. |
| pkg/github/helper_test.go | Updates helper APIs to any and uses for range <int> in path matching. |
| pkg/github/issues_test.go | Updates GraphQL vars/request args maps and arrays to any-based types. |
| pkg/github/notifications_test.go | Updates request args maps to map[string]any. |
| pkg/github/params_test.go | Updates params maps to map[string]any. |
| pkg/github/projects_test.go | Updates request args/response parsing to any-based types. |
| pkg/github/pullrequests_test.go | Updates request args/expected-body maps and arrays to any-based types. |
| pkg/github/repositories_test.go | Updates request args/expected-body maps and arrays to any-based types and uses for range <int>. |
| pkg/github/repository_resource_completions_test.go | Uses for range <int> for deterministic test data generation. |
| pkg/github/search_test.go | Updates request args maps to map[string]any. |
| pkg/github/secret_scanning_test.go | Updates request args maps to map[string]any. |
| pkg/github/security_advisories_test.go | Updates request args maps to map[string]any. |
|
I know it's a lot of changes. But they are trivial and can be easily applied via |
Summary
Refactor the codebase to utilize the latest practices and Go language features. This was found with the help of
modernizeandintrangelinters.Why
Improves code quality and maintainability by modernizing Go code patterns to use current best practices and language features.
What changed
modernizeandintrangelinters to.golangci.yml..github/workflows/lint.ymlandscript/lint. This is required because themodernizelinter was added in v2.6.modernizeandintrangelinter suggestions (viagolangci-lint run --fix) with some manual editing.context,errors, andhttppackages.MCP impact
Prompts tested (tool changes only)
Security / limits
Tool renaming
deprecated_tool_aliases.goLint & tests
./script/lint./script/testDocs