AlexStocks commented on code in PR #1062:
URL: https://github.com/apache/dubbo-go-pixiu/pull/1062#discussion_r4172898642
##########
admin/controller/auth/auth_test.go:
##########
@@ -31,12 +31,8 @@ import (
)
func TestParseTokenRejectsUnexpectedSigningMethod(t *testing.T) {
- claims := CustomClaims{
- Username: "admin",
- StandardClaims: jwt.StandardClaims{
- ExpiresAt: time.Now().Add(time.Hour).Unix(),
- },
- }
+ claims := CustomClaims{Username: "admin"}
Review Comment:
[P2] 本次转换只覆盖当前 7 处;与 #1061 合入后仍会残留 4 条 SA1019
先说明:本 PR 在它自己的 base 上是正确的,PR 描述里的两个数字我都独立复现到了。
- base `ba018888` 上 `staticcheck ./admin/controller/auth/...` 报 **7** 条
SA1019(exit 1),行号 36/61/96/109/126/147/156;
- head `60658f21` 上同一条命令 **0** 条(exit 0)。
问题是这个“零”不持久。**#1061 修改同一个文件,并在新增测试里又写了 4 处相同的显式弃用写法。** 以 #1061 的 head
`56a849f4` 实测:
- 单独跑 #1061 → **11** 条 SA1019(行 52/185/220/233/250/271/280 是原有的块形式,行
111/136/145/161 是它新增的单行形式 `CustomClaims{Username: "admin", StandardClaims:
jwt.StandardClaims{...}}`);
- 把本 PR 的 7 处块形式转换原样叠加到 #1061 之上(模拟两者都合入,代码可编译、测试通过)→ **仍有 4 条**,正是 #1061
新增的那 4 处。
也就是说两个 PR 都合入后 `Golang Lint` 仍会因 SA1019 失败,本 PR 的目标只被完成了一部分。建议二选一:本 PR 合入后让
#1061 rebase 并同步处理它新增的 4 处;或先在 #1061 里解决这 4 处,再合本 PR。
另外一点可选、不阻塞:转换后本文件 `grep StandardClaims` 已是 0 命中,但这 7 个 fixture 依然依赖
`admin/controller/auth/auth.go:93` 内嵌的弃用结构体。将来把 `CustomClaims` 迁到
`jwt.RegisteredClaims`(`ExpiresAt` 从 `int64` 变为
`*jwt.NumericDate`)时这些位置会编译失败,而文件里已经没有任何指向该结构体的线索。若认为有价值,可在首个 fixture
上方留一行注释说明字段来源;不接受也不影响本次改动。
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]