fix: 修复 golangci-lint 报告的 5 个问题
- gofmt: 修复 admin_service/antigravity_oauth_service/token_refresh_service 格式 - staticcheck S1009: 移除 SetUserSettingsResponse.IsSuccess 中冗余的 nil 检查 - unused: 将仅测试使用的 applyAntigravitySubscriptionResult 移至测试文件 Made-with: Cursor
This commit is contained in:
@@ -767,7 +767,7 @@ func (r *SetUserSettingsResponse) IsSuccess() bool {
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
// userSettings 为 nil 或空 map 均视为成功
|
// userSettings 为 nil 或空 map 均视为成功
|
||||||
if r.UserSettings == nil || len(r.UserSettings) == 0 {
|
if len(r.UserSettings) == 0 {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
// 如果包含 telemetryEnabled 字段,说明未成功清除
|
// 如果包含 telemetryEnabled 字段,说明未成功清除
|
||||||
|
|||||||
@@ -2740,4 +2740,3 @@ func (s *adminServiceImpl) ForceAntigravityPrivacy(ctx context.Context, account
|
|||||||
applyAntigravityPrivacyMode(account, mode)
|
applyAntigravityPrivacyMode(account, mode)
|
||||||
return mode
|
return mode
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,33 @@
|
|||||||
|
|
||||||
package service
|
package service
|
||||||
|
|
||||||
import "testing"
|
import (
|
||||||
|
"testing"
|
||||||
|
)
|
||||||
|
|
||||||
|
func applyAntigravitySubscriptionResult(account *Account, result AntigravitySubscriptionResult) (map[string]any, map[string]any) {
|
||||||
|
credentials := make(map[string]any)
|
||||||
|
for k, v := range account.Credentials {
|
||||||
|
credentials[k] = v
|
||||||
|
}
|
||||||
|
credentials["plan_type"] = result.PlanType
|
||||||
|
|
||||||
|
extra := make(map[string]any)
|
||||||
|
for k, v := range account.Extra {
|
||||||
|
extra[k] = v
|
||||||
|
}
|
||||||
|
if result.SubscriptionStatus != "" {
|
||||||
|
extra["subscription_status"] = result.SubscriptionStatus
|
||||||
|
} else {
|
||||||
|
delete(extra, "subscription_status")
|
||||||
|
}
|
||||||
|
if result.SubscriptionError != "" {
|
||||||
|
extra["subscription_error"] = result.SubscriptionError
|
||||||
|
} else {
|
||||||
|
delete(extra, "subscription_error")
|
||||||
|
}
|
||||||
|
return credentials, extra
|
||||||
|
}
|
||||||
|
|
||||||
func TestApplyAntigravityPrivacyMode_SetsInMemoryExtra(t *testing.T) {
|
func TestApplyAntigravityPrivacyMode_SetsInMemoryExtra(t *testing.T) {
|
||||||
account := &Account{}
|
account := &Account{}
|
||||||
|
|||||||
@@ -36,27 +36,3 @@ func NormalizeAntigravitySubscription(resp *antigravity.LoadCodeAssistResponse)
|
|||||||
PlanType: antigravity.TierIDToPlanType(tierID),
|
PlanType: antigravity.TierIDToPlanType(tierID),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func applyAntigravitySubscriptionResult(account *Account, result AntigravitySubscriptionResult) (map[string]any, map[string]any) {
|
|
||||||
credentials := make(map[string]any)
|
|
||||||
for k, v := range account.Credentials {
|
|
||||||
credentials[k] = v
|
|
||||||
}
|
|
||||||
credentials["plan_type"] = result.PlanType
|
|
||||||
|
|
||||||
extra := make(map[string]any)
|
|
||||||
for k, v := range account.Extra {
|
|
||||||
extra[k] = v
|
|
||||||
}
|
|
||||||
if result.SubscriptionStatus != "" {
|
|
||||||
extra["subscription_status"] = result.SubscriptionStatus
|
|
||||||
} else {
|
|
||||||
delete(extra, "subscription_status")
|
|
||||||
}
|
|
||||||
if result.SubscriptionError != "" {
|
|
||||||
extra["subscription_error"] = result.SubscriptionError
|
|
||||||
} else {
|
|
||||||
delete(extra, "subscription_error")
|
|
||||||
}
|
|
||||||
return credentials, extra
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -526,4 +526,3 @@ func (s *TokenRefreshService) ensureAntigravityPrivacy(ctx context.Context, acco
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user