如何修复线路长度违规?
由于线路长度违规而不允许的警报消息的相关部分: 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)
Rob*_*ier 14
缩短线条:
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()
)
Run Code Online (Sandbox Code Playgroud)
或者更好,使用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.
"""
Run Code Online (Sandbox Code Playgroud)
这是一个通用的解决方案,但并不适合,NSLocalizedString因为它打破了扫描本地化字符串的工具genstrings.
您的另一个解决方案是通过在紧接之前的行上添加禁用来关闭该行的警告:
// swiftlint:disable:next line_length
Run Code Online (Sandbox Code Playgroud)
有关禁用 swiftlint规则的完整详细信息,请参阅禁用代码中的规则.
在这种情况下,只需使用以下命令更新您的line_length规则ignores_interpolated_strings:
line_length:
warning: 120
ignores_function_declarations: true
ignores_comments: true
ignores_interpolated_strings: true
ignores_urls: true
Run Code Online (Sandbox Code Playgroud)
并确保您使用的是最新版本swiftlint(仅在几周前添加)
| 归档时间: |
|
| 查看次数: |
9700 次 |
| 最近记录: |