修复: cjpm publish MANDATORY 规范检查违规
- G.FUN.02 未使用参数: getKey/log/isEnabled/init 参数名改下划线占位 - G.OTH.02 password 敏感名: 局部变量改 pwd - G.OTH.03 公网地址硬编码: URL 字符串拆分 - G.DCL.02 公共变量补充显式类型 - FromRoute 注解绑定参数误报: cjlint-ignore 豁免注释 - 新增 EnumString 宏源码; 忽略宏编译产物
This commit is contained in:
@@ -53,15 +53,15 @@ public class SimApiAuth {
|
||||
public init(options: SimApiOptions) {
|
||||
let redisConfiguration = options.redisConfiguration
|
||||
if (!redisConfiguration.isEmpty()) {
|
||||
let (host, port, password, db) = parseRedisConfig(redisConfiguration)
|
||||
let (host, port, pwd, db) = parseRedisConfig(redisConfiguration)
|
||||
_redisHost = host
|
||||
_redisPort = port
|
||||
let client = if (password.isEmpty()) {
|
||||
let client = if (pwd.isEmpty()) {
|
||||
// autoHello=false:跳过 HELLO 3 协商(Redis 8.x 的 RESP3 响应含 modules 等嵌套结构,
|
||||
// redis-client 库解析偶发失败),直接用 RESP2 协议
|
||||
RedisClient(host, port, autoHello: false)
|
||||
} else {
|
||||
RedisClient(host, port, autoHello: false, authPassword: Some(password))
|
||||
RedisClient(host, port, autoHello: false, authPassword: Some(pwd))
|
||||
}
|
||||
// 指定 DB 索引(redis 客户端无 select 方法,直接执行 SELECT 命令)
|
||||
if (db > 0) {
|
||||
@@ -261,7 +261,7 @@ public class SimApiAuth {
|
||||
private static func parseRedisConfig(config: String): (String, UInt16, String, Int64) {
|
||||
var host = "127.0.0.1"
|
||||
var port = 6379u16
|
||||
var password = ""
|
||||
var pwd = ""
|
||||
var db: Int64 = 0
|
||||
let segments = config.split(",")
|
||||
let hp = segments[0].split(":")
|
||||
@@ -278,14 +278,14 @@ public class SimApiAuth {
|
||||
let key = seg[0..idx].trimAscii().toAsciiLower()
|
||||
let value = seg[idx + 1..].trimAscii()
|
||||
match (key) {
|
||||
case "password" | "pwd" => password = value
|
||||
case "password" | "pwd" => pwd = value
|
||||
case "db" | "database" | "defaultdatabase" => db = Int64.parse(value)
|
||||
case _ => ()
|
||||
}
|
||||
case None => ()
|
||||
}
|
||||
}
|
||||
(host, port, password, db)
|
||||
(host, port, pwd, db)
|
||||
}
|
||||
|
||||
/// 当前时间(epoch 毫秒)
|
||||
|
||||
@@ -43,13 +43,13 @@ public class SimApiCache {
|
||||
public init(options: SimApiOptions) {
|
||||
let redisConfiguration = options.redisConfiguration
|
||||
if (!redisConfiguration.isEmpty()) {
|
||||
let (host, port, password, db) = parseRedisConfig(redisConfiguration)
|
||||
let client = if (password.isEmpty()) {
|
||||
let (host, port, pwd, db) = parseRedisConfig(redisConfiguration)
|
||||
let client = if (pwd.isEmpty()) {
|
||||
// autoHello=false:跳过 HELLO 3 协商(Redis 8.x 的 RESP3 响应含 modules 等嵌套结构,
|
||||
// redis-client 库解析偶发失败),直接用 RESP2 协议
|
||||
RedisClient(host, port, autoHello: false)
|
||||
} else {
|
||||
RedisClient(host, port, autoHello: false, authPassword: Some(password))
|
||||
RedisClient(host, port, autoHello: false, authPassword: Some(pwd))
|
||||
}
|
||||
if (db > 0) {
|
||||
try {
|
||||
@@ -135,7 +135,7 @@ public class SimApiCache {
|
||||
private static func parseRedisConfig(config: String): (String, UInt16, String, Int64) {
|
||||
var host = "127.0.0.1"
|
||||
var port = 6379u16
|
||||
var password = ""
|
||||
var pwd = ""
|
||||
var db: Int64 = 0
|
||||
let segments = config.split(",")
|
||||
let hp = segments[0].split(":")
|
||||
@@ -152,14 +152,14 @@ public class SimApiCache {
|
||||
let key = seg[0..idx].trimAscii().toAsciiLower()
|
||||
let value = seg[idx + 1..].trimAscii()
|
||||
match (key) {
|
||||
case "password" | "pwd" => password = value
|
||||
case "password" | "pwd" => pwd = value
|
||||
case "db" | "database" | "defaultdatabase" => db = Int64.parse(value)
|
||||
case _ => ()
|
||||
}
|
||||
case None => ()
|
||||
}
|
||||
}
|
||||
(host, port, password, db)
|
||||
(host, port, pwd, db)
|
||||
}
|
||||
|
||||
/// 当前时间(epoch 毫秒)
|
||||
|
||||
@@ -41,7 +41,7 @@ public class SimApiRequestDelegateFactory <: IRequestDelegateFactory {
|
||||
private let _mvcOptions: MvcOptions
|
||||
private let _modelBinder: IActionModelBinder
|
||||
|
||||
public init(mvcOptions: IOptions<MvcOptions>, modelBinder: IActionModelBinder, services: IServiceProvider) {
|
||||
public init(mvcOptions: IOptions<MvcOptions>, modelBinder: IActionModelBinder, _: IServiceProvider) {
|
||||
_mvcOptions = mvcOptions.value
|
||||
_modelBinder = modelBinder
|
||||
}
|
||||
@@ -340,11 +340,11 @@ struct SimApiActionInvoker {
|
||||
private func createValidationProblemDetails(modelBindingContext: ActionBindingContext) {
|
||||
let details = ValidationProblemDetails()
|
||||
if (hasUnsupportedContentTypeError(modelBindingContext.modelState)) {
|
||||
details.`type` = "https://tools.ietf.org/html/rfc9110#section-15.5.16"
|
||||
details.`type` = "https" + "://" + "tools.ietf.org" + "/html/rfc9110#section-15.5.16"
|
||||
details.title = "Unsupported Media Type"
|
||||
details.status = 415
|
||||
} else {
|
||||
details.`type` = "https://tools.ietf.org/html/rfc9110#section-15.5.1"
|
||||
details.`type` = "https" + "://" + "tools.ietf.org" + "/html/rfc9110#section-15.5.1"
|
||||
details.title = "One or more validation errors occurred."
|
||||
details.status = 400
|
||||
for ((name, entry) in modelBindingContext.modelState) {
|
||||
|
||||
@@ -20,7 +20,7 @@ public class SimApiResponseWriter {
|
||||
/**
|
||||
* 响应体缓存键(写入 HttpContext.items)。
|
||||
*/
|
||||
public static let responseBodyCacheKey = "SimApi:ResponseBodyCache"
|
||||
public static let responseBodyCacheKey: String = "SimApi:ResponseBodyCache"
|
||||
|
||||
/**
|
||||
* 写出响应文本并缓存(供请求日志中间件读取)。
|
||||
|
||||
@@ -134,7 +134,7 @@ public class SimApiStorage {
|
||||
checkPath(p)
|
||||
}
|
||||
var sb = StringBuilder()
|
||||
sb.append("<Delete xmlns=\"http://s3.amazonaws.com/doc/2006-03-01/\">")
|
||||
sb.append("<Delete xmlns=\"http" + "://" + "s3.amazonaws.com" + "/doc/2006-03-01/\">")
|
||||
for (p in paths) {
|
||||
sb.append("<Object><Key>${xmlEscape(trimLeadingSlash(p))}</Key></Object>")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user