如何解决线路长度违规问题?
由于线路长度违规而不允许的警报消息的相关部分:message: NSLocalizedString("\nYou will be requested to Use %@ to Sign In. %@ doesn't share any information about you. The permission is required to post your Live Video.",
⚠行应为120个字符或更少:当前208个字符(line_length)
答案 0 :(得分:11)
缩短线条:
message: NSLocalizedString(
["\nYou will be requested to Use %@ to Sign In. ",
"%@ doesn't share any information about you. The ",
"permission is required to post your Live Video."].joined()
)
或更好,使用vacawama的多线解决方案:
let message =
"""
You will be requested to Use %@ to Sign In. \
%@ doesn't share any information about you. \
The permission is required to post your Live Video.
"""
这是一个通用解决方案,但并不适合NSLocalizedString
,因为它会破坏扫描genstrings
等本地化字符串的工具。
您的另一个解决方案是通过在紧接之前的行上添加禁用来关闭该行的警告:
// swiftlint:disable:next line_length
有关禁用swiftlint规则的详细信息,请参阅Disable rules in code。
答案 1 :(得分:5)
在这种情况下,只需使用line_length
更新您的ignores_interpolated_strings
规则:
line_length:
warning: 120
ignores_function_declarations: true
ignores_comments: true
ignores_interpolated_strings: true
ignores_urls: true
并确保您使用的是swiftlint
的最新版本(仅在几周前added)
答案 2 :(得分:1)
.swiftlint.yml规则文件中添加的这一行对我有用
for (i in (0:(N))) {
for(j in (0:(N))){
V <- seq(i+1, i+G)
#V <- (i+1):(i+G)
W <- seq(j+1, j+G)
#W <- (j+1):(j+G)
m[V, W] <- l
}
}