自定义Swiftlint规则,使折旧等Xcode警告成为错误

时间:2018-08-29 13:34:03

标签: swift regex xcode realm swiftlint

我的项目确实有大约3000条警告,我的动机是使我们的Xcode项目警告免费。我刚刚开始使用swiftLint,因为string.characters.count已贬值,所以我想使每个折旧都出错,但要逐步进行。我想使其递增,因此首先我要关注“ .characters”。整个应用中的使用删除。甚至我都可以在项目中搜索并删除它,但是与此同时,我想设置一个规则,即以后没有其他开发人员使用它。我在yml文件中尝试了以下代码,但Xcode在编译时未对.characters用法给出任何错误。我认为我使用了不正确的正则表达式。有人知道自定义规则或正则表达式有什么问题吗?

custom_rules:
  string_character_usage: # rule identifier
included: ".*\\.swift" # regex that defines paths to include during linting. optional.
excluded: ".*Test\\.swift" # regex that defines paths to exclude during linting. optional
regex: ".*?!\\.characters.\\.*" # matching pattern // I think issue is here
match_kinds: # SyntaxKinds to match. optional.
 - keyword
message: "Please don't use .characters on string as it is already deprecated, take warnings seriously now." # violation message. optional.
severity: error # violation severity. optional.

0 个答案:

没有答案