Skip to content

all: deduplicate same-package imports (staticcheck ST1019)#3695

Open
Deln0r wants to merge 1 commit into
element-hq:mainfrom
Deln0r:lint/st1019-duplicate-imports
Open

all: deduplicate same-package imports (staticcheck ST1019)#3695
Deln0r wants to merge 1 commit into
element-hq:mainfrom
Deln0r:lint/st1019-duplicate-imports

Conversation

@Deln0r
Copy link
Copy Markdown

@Deln0r Deln0r commented May 14, 2026

Summary

A handful of files imported the same package twice, once plain and once aliased. staticcheck ST1019 flags this because the two names refer to the same package and add no information; one of them is redundant.

For each file the dominant name in the body wins and the other import is removed, with the affected references renamed to match.

File Duplicate Kept
clientapi/routing/admin.go api + userapi for userapi/api userapi (matches repo-wide convention, ~73 files vs ~10)
cmd/dendrite-demo-yggdrasil/yggconn/node.go yggdrasilcore + plain core; yggdrasilmulticast + plain multicast plain names
federationapi/consumers/roomserver.go logrus + log log (12 uses vs 2)
federationapi/routing/routing.go api + roomserverAPI for roomserver/api roomserverAPI (17 vs 3)
roomserver/internal/perform/perform_join.go api + rsAPI for roomserver/api rsAPI (23 vs 1)
roomserver/internal/perform/perform_leave.go api + rsAPI for roomserver/api api (18 vs 2)
syncapi/consumers/clientapi.go logrus + log logrus (7 vs 6, matches repo majority)
syncapi/consumers/roomserver.go logrus + log log (32 vs 4)

The kept name was chosen per-file to minimize the number of touched call sites; happy to flip any of them if there's a project-wide convention I missed.

No behavior change; only import aliases and the corresponding qualifier on call sites move.

Test plan

  • go build ./... clean
  • CI lint/test on this PR

A handful of files imported the same package twice, once plain and once
aliased. staticcheck ST1019 flags this because the two names refer to
the same package and add no information; one of them is redundant.

For each file the dominant name in the body wins and the other import
is removed, with the affected references renamed to match:

- clientapi/routing/admin.go: collapse `api`/`userapi` for
  userapi/api → `userapi` (matches the repo-wide convention).
- cmd/dendrite-demo-yggdrasil/yggconn/node.go: collapse
  `yggdrasilcore`/`core` and `yggdrasilmulticast`/`multicast` → the
  plain names. No collisions with other imports in the file.
- federationapi/consumers/roomserver.go: collapse `logrus`/`log` → `log`.
- federationapi/routing/routing.go: collapse `api`/`roomserverAPI`
  for roomserver/api → `roomserverAPI`.
- roomserver/internal/perform/perform_join.go: collapse `api`/`rsAPI`
  for roomserver/api → `rsAPI`.
- roomserver/internal/perform/perform_leave.go: collapse `api`/`rsAPI`
  for roomserver/api → `api` (the dominant name in this file).
- syncapi/consumers/clientapi.go: collapse `logrus`/`log` → `logrus`.
- syncapi/consumers/roomserver.go: collapse `logrus`/`log` → `log`.

No behavior change; only import aliases and the corresponding
qualifier on call sites move.

Signed-off-by: Ian Chechin <ian00chechin@gmail.com>
@Deln0r Deln0r requested a review from a team as a code owner May 14, 2026 15:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant