Remove dead code identified by deadcode tool#37271
Merged
silverwind merged 8 commits intogo-gitea:mainfrom Apr 20, 2026
Merged
Conversation
Ran `deadcode -test ./...` and removed functions, methods and error
types that are unreachable from any call path, including tests. Where
an error type was never constructed, the corresponding IsErr* helper
and its always-false caller branches are removed as well.
Dropped:
- Unused list/load helpers on RunList, ScheduleList, BranchList
- Never-called CRUD/query helpers: CountUserFeeds, HasDeployKey,
WebAuthnCredentials, GetPinnedIssueIDs, UpdateTeamUnits,
UpdateColumnSorting, RemoveAllWithNotice, DumpQueryResult,
RemoveAllUserBadges, GetBadgeByID, UpdateEmailAddress,
CommitsCountBetween, GitConfigGet, dbfs.Create
- Unused error types never constructed: ErrGPGKeyAccessDenied,
ErrNewIssueInsert, ErrUserInactive, ErrInvalidConfiguration
(and the always-false caller branches that checked them)
- Unused IsErr* helpers: IsErrUnknownDependencyType, IsErrIssueIsOpen,
IsErrTopicNotExist, IsErrExternalLoginUser{AlreadyExist,NotExist},
IsErrUserSettingIsNotExist, IsErrSHANotFound
- Unused helpers and option funcs: WithJobResults, SearchMembersOptions.ToConds,
RunList.GetRepoIDs, HostMatchList.AppendPattern, Event.String,
ContentType.String, GlodmarkRender.Renderer, Manager.GetLogRecorder,
DeleteLocaleCookie, Manager.{Err,Value,Deadline,TerminateContext},
ParseCreateHook, ParsePushHook, NotFound (routers/web), MustEnableProjects,
RedirectToDefaultSetting, UserIDAssignmentAPI, ToSecret,
DeadlineForm.Validate
No behaviour change — all removed code paths were unreachable.
Co-Authored-By: Claude (Opus 4.7) <noreply@anthropic.com>
silverwind
commented
Apr 18, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
This PR removes unreachable (“dead”) code identified by the deadcode -test ./... tool across the codebase to reduce maintenance surface and simplify control flow.
Changes:
- Removed unused exported helpers/types (list/load helpers, CRUD/query helpers, option funcs, and route handlers).
- Deleted never-constructed error types and corresponding now-always-false branches in callers.
- Cleaned up related imports and small wrappers/accessors that are no longer referenced.
Reviewed changes
Copilot reviewed 47 out of 47 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| services/repository/files/tree.go | Removed unused IsErrSHANotFound helper. |
| services/repository/files/content.go | Removed unused ContentType.String method. |
| services/forms/repo_form.go | Removed unused DeadlineForm and validation method. |
| services/convert/secret.go | Deleted unused Secret-to-API conversion helper. |
| services/context/user.go | Removed unused API user assignment middleware (UserIDAssignmentAPI). |
| routers/web/shared/actions/runners.go | Removed unused redirect helper. |
| routers/web/org/projects.go | Removed unused “projects enabled” guard helper. |
| routers/web/home.go | Removed unused NotFound helper wrapper. |
| routers/web/auth/linkaccount.go | Removed unreachable inactive-user error branch. |
| routers/web/auth/auth.go | Removed unreachable inactive-user error branch. |
| routers/api/v1/user/gpg_key.go | Removed unreachable GPG access-denied branches and simplified error handling. |
| modules/web/middleware/locale.go | Removed unused locale-cookie deletion helper. |
| modules/tailmsg/talimsg.go | Removed unused log recorder accessor. |
| modules/structs/hook.go | Removed unused webhook payload parsing helpers. |
| modules/storage/storage.go | Removed unused invalid-configuration error type and checker. |
| modules/markup/markdown/markdown.go | Removed unused renderer accessor. |
| modules/hostmatcher/hostmatcher.go | Removed unused pattern append helper. |
| modules/graceful/manager.go | Removed unused context-like methods on Manager; clarified Done comment. |
| modules/graceful/context.go | Removed unused TerminateContext accessor. |
| modules/gitrepo/config.go | Removed unused GitConfigGet helper and related import. |
| modules/gitrepo/commit.go | Removed unused CommitsCountBetween helper. |
| modules/eventsource/event.go | Removed unused Event.String method and related import. |
| modules/actions/jobparser/jobparser.go | Removed unused parse option (WithJobResults). |
| models/user/setting.go | Removed unused error type-check helper. |
| models/user/external_login_user.go | Removed unused error type-check helpers. |
| models/user/error.go | Removed never-constructed inactive-user error type and helper. |
| models/user/email_address.go | Removed unused UpdateEmailAddress helper. |
| models/user/badge.go | Removed unused badge helpers (RemoveAllUserBadges, GetBadgeByID). |
| models/unittest/unit_tests.go | Removed unused query dump debugging helper and imports. |
| models/system/notice.go | Removed unused filesystem removal helper and import. |
| models/repo/topic.go | Removed unused error type-check helper. |
| models/project/column.go | Removed unused column sorting updater. |
| models/organization/team_user.go | Removed unused condition-builder helper. |
| models/organization/team_unit.go | Removed unused team-units update helper. |
| models/issues/pull.go | Removed unreachable ErrNewIssueInsert branch from error handling. |
| models/issues/issue_update.go | Removed unused error type-check helper and unreachable ErrNewIssueInsert branch. |
| models/issues/issue_pin.go | Removed unused pinned-IDs helper. |
| models/issues/issue.go | Removed never-constructed ErrNewIssueInsert type and helper. |
| models/issues/dependency.go | Removed unused error type-check helper. |
| models/git/branch_list.go | Removed unused repo-loading helper and import. |
| models/dbfs/dbfs.go | Removed unused Create helper. |
| models/auth/webauthn.go | Removed unused WebAuthnCredentials helper. |
| models/asymkey/ssh_key_deploy.go | Removed unused deploy-key existence helper. |
| models/asymkey/error.go | Removed never-constructed GPG access-denied error type and helper. |
| models/activities/action_list.go | Removed unused feed-count helper. |
| models/actions/schedule_list.go | Removed unused list/load helpers and imports. |
| models/actions/run_list.go | Removed unused repo-IDs/load-repos helpers and import. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
wxiaoguang
reviewed
Apr 18, 2026
wxiaoguang
reviewed
Apr 18, 2026
wxiaoguang
reviewed
Apr 18, 2026
wxiaoguang
reviewed
Apr 18, 2026
- `DumpQueryResult`: debug helper (silverwind, wxiaoguang) - `ParseCreateHook`/`ParsePushHook`: keep public API surface (Copilot) - `Manager.Err`/`Value`/`Deadline`: preserve `context.Context` interface (Copilot) - `Manager.TerminateContext`: referenced by shutdown docs (Copilot, wxiaoguang) - `dbfs.Create`: consistency with `os.Create` (wxiaoguang) - `Manager.GetLogRecorder`: reserved for future use (wxiaoguang) Co-Authored-By: Claude (Opus 4.7) <noreply@anthropic.com>
Member
Author
|
All mentioned code restored. |
Contributor
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 41 out of 41 changed files in this pull request and generated 1 comment.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
lunny
reviewed
Apr 20, 2026
lunny
reviewed
Apr 20, 2026
lunny
reviewed
Apr 20, 2026
wxiaoguang
approved these changes
Apr 20, 2026
After removing the dead IsErrGPGKeyAccessDenied branch in the previous commit, the DeleteGPGKey handler no longer returns 403, so drop it from the documented responses. Caught by Copilot review. Co-Authored-By: Claude (Opus 4.7) <noreply@anthropic.com>
This reverts commit 66c40fe.
lunny
approved these changes
Apr 20, 2026
silverwind
added a commit
to silverwind/gitea
that referenced
this pull request
Apr 20, 2026
…-lang * origin/main: Update go js dependencies (go-gitea#37312) Update GitHub Actions to latest major versions (go-gitea#37313) Revert "Add WebKit to e2e test matrix (go-gitea#37298)" (go-gitea#37315) Add `form-fetch-action` to some forms, fix "fetch action" resp bug (go-gitea#37305) Move heatmap to first-party code (go-gitea#37262) Use updated yaml fields for snapcraft (go-gitea#37318) Remove dead code identified by `deadcode` tool (go-gitea#37271) Enable strict TypeScript, add `errorMessage` helper (go-gitea#37292) Fix vite manifest update masking build errors (go-gitea#37279) bump snapcraft base (go-gitea#37301) # Conflicts: # web_src/js/modules/errors.ts
silverwind
added a commit
to 6543-forks/gitea
that referenced
this pull request
Apr 21, 2026
…n-better * origin/main: (645 commits) When the requested arch rpm is missing fall back to noarch (go-gitea#37236) Fix `relative-time` error and improve global error handler (go-gitea#37241) Enhance styling in actions page (go-gitea#37323) fix(oauth): Error on auth sources with spaces (go-gitea#37327) Fix actions concurrency groups cross-branch leak (go-gitea#37311) Fix bug when accessing user badges (go-gitea#37321) Fix AppFullLink (go-gitea#37325) Update go js dependencies (go-gitea#37312) Update GitHub Actions to latest major versions (go-gitea#37313) Revert "Add WebKit to e2e test matrix (go-gitea#37298)" (go-gitea#37315) Add `form-fetch-action` to some forms, fix "fetch action" resp bug (go-gitea#37305) Move heatmap to first-party code (go-gitea#37262) Use updated yaml fields for snapcraft (go-gitea#37318) Remove dead code identified by `deadcode` tool (go-gitea#37271) Enable strict TypeScript, add `errorMessage` helper (go-gitea#37292) Fix vite manifest update masking build errors (go-gitea#37279) bump snapcraft base (go-gitea#37301) Add WebKit to e2e test matrix (go-gitea#37298) Don't add useless labels which will bother changelog generation (go-gitea#37267) Fix Repository transferring page (go-gitea#37277) ... # Conflicts: # options/locale/locale_en-US.ini # templates/package/content/debian.tmpl
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Ran
deadcode(-test ./...) to find functions, methods and error types unreachable from any call path (including tests), and removed the truly-dead ones.Unused list/load helpers on
RunList,ScheduleList,BranchList.Never-called CRUD/query helpers:
CountUserFeeds,HasDeployKey,WebAuthnCredentials,GetPinnedIssueIDs,UpdateTeamUnits,UpdateColumnSorting,RemoveAllWithNotice,DumpQueryResult,RemoveAllUserBadges,GetBadgeByID,UpdateEmailAddress,CommitsCountBetween,GitConfigGet,dbfs.CreateError types never constructed — struct +
Error/Unwrap+IsErr*helper + now-always-false caller branches:ErrGPGKeyAccessDenied(+ 2 caller branches inrouters/api/v1/user/gpg_key.go)ErrNewIssueInsert(+|| IsErrNewIssueInsert(err)inmodels/issues/{pull,issue_update}.go)ErrUserInactive(+ 2 caller branches inrouters/web/auth/{auth,linkaccount}.go)ErrInvalidConfiguration(no callers)Unused
IsErr*helpers (error struct is still constructed, just never type-checked):IsErrUnknownDependencyType,IsErrIssueIsOpen,IsErrTopicNotExist,IsErrExternalLoginUserAlreadyExist,IsErrExternalLoginUserNotExist,IsErrUserSettingIsNotExist,IsErrSHANotFoundUnused helpers / option funcs / route handlers:
WithJobResults,SearchMembersOptions.ToConds,RunList.GetRepoIDs,HostMatchList.AppendPattern,Event.String,ContentType.String,GlodmarkRender.Renderer,Manager.GetLogRecorder,DeleteLocaleCookie,Manager.{Err,Value,Deadline,TerminateContext},ParseCreateHook,ParsePushHook,routers/web.NotFound,MustEnableProjects,RedirectToDefaultSetting,UserIDAssignmentAPI,ToSecret,DeadlineForm.ValidateThis PR was written with the help of Claude Opus 4.7