style(project): silence remaining lint findings (stutter, max shadow, gosec)

This commit is contained in:
2026-05-01 10:33:16 +08:00
parent 76a1461f4b
commit 1567f21a82
4 changed files with 23 additions and 20 deletions
+3 -3
View File
@@ -45,7 +45,7 @@ func assertReadable(p *Project, c Caller) error {
// assertWritable 是 write 类操作的鉴权门面:仅 owner+admin。已归档项目额外
// 拒绝;调用方应在执行写入前调用此函数。
func assertWritable(p *Project, c Caller) error {
if !(c.IsAdmin || p.OwnerID == c.UserID) {
if !c.IsAdmin && p.OwnerID != c.UserID {
// stranger 对 private 看不见;对 internal 也不能写。统一 not_found 防探测。
if p.Visibility == VisibilityPrivate {
return errs.New(errs.CodeNotFound, "project 不存在")
@@ -148,7 +148,7 @@ func (s *projectService) Archive(ctx context.Context, c Caller, slug string) err
return err
}
// 归档/取消归档仍要 owner+admin 校验,但已归档不再额外阻塞 archive。
if !(c.IsAdmin || p.OwnerID == c.UserID) {
if !c.IsAdmin && p.OwnerID != c.UserID {
if p.Visibility == VisibilityPrivate {
return errs.New(errs.CodeNotFound, "project 不存在")
}
@@ -169,7 +169,7 @@ func (s *projectService) Unarchive(ctx context.Context, c Caller, slug string) e
if err != nil {
return err
}
if !(c.IsAdmin || p.OwnerID == c.UserID) {
if !c.IsAdmin && p.OwnerID != c.UserID {
if p.Visibility == VisibilityPrivate {
return errs.New(errs.CodeNotFound, "project 不存在")
}