- Java 双重比较
- java - 比较器与 Apache BeanComparator
- Objective-C 完成 block 导致额外的方法调用?
- database - RESTful URI 是否应该公开数据库主键?
在运行swiftlint
0.24.0版本时,报错。运行 autocorrect
表示文件已更正。然而,swiftlint
的后续运行证明没有进行任何修改。
查看对两个文件 Player.swift
和 Prize.swift
进行 lint 和更正的尝试。
MacBook-Pro-5: Developer$ swiftlint
Loading configuration from '.swiftlint.yml'
Linting Swift files in current working directory
Linting 'Prize.swift' (1/2)
Linting 'Player.swift' (2/2)
Player.swift:26:19: warning: Operator Function Whitespace Violation: Operators should be surrounded by a single whitespace when defining them. (operator_whitespace)
Player.swift:27: warning: Line Length Violation: Line should be 120 characters or less: currently 131 characters (line_length)
Player.swift:39: warning: Line Length Violation: Line should be 120 characters or less: currently 147 characters (line_length)
Prize.swift:44:34: warning: Colon Violation: Colons should be next to the identifier when specifying a type and next to the key in dictionary literals. (colon)
Prize.swift:44: error: Line Length Violation: Line should be 120 characters or less: currently 210 characters (line_length)
Done linting! Found 5 violations, 1 serious in 2 files.
MacBook-Pro-5: Developer$ swiftlint autocorrect
Loading configuration from '.swiftlint.yml'
Correcting Swift files in current working directory
Correcting 'Prize.swift' (1/2)
Correcting 'Player.swift' (2/2)
Done correcting 2 files!
MacBook-Pro-5: Developer$ swiftlint
Loading configuration from '.swiftlint.yml'
Linting Swift files in current working directory
Linting 'Prize.swift' (1/2)
Linting 'Player.swift' (2/2)
Prize.swift:44:34: warning: Colon Violation: Colons should be next to the identifier when specifying a type and next to the key in dictionary literals. (colon)
Prize.swift:44: error: Line Length Violation: Line should be 120 characters or less: currently 210 characters (line_length)
Player.swift:26:19: warning: Operator Function Whitespace Violation: Operators should be surrounded by a single whitespace when defining them. (operator_whitespace)
Player.swift:27: warning: Line Length Violation: Line should be 120 characters or less: currently 131 characters (line_length)
Player.swift:39: warning: Line Length Violation: Line should be 120 characters or less: currently 147 characters (line_length)
Done linting! Found 5 violations, 1 serious in 2 files.
MacBook-Pro-5: Developer$
这是另一次运行,但这次使用的文件 Prize.swift
仅包含一个可纠正的违规行为。同样,autocorrect
不会修改:
MacBook-Pro-5:P Developer$ swiftlint
Linting Swift files in current working directory
Linting 'Prize.swift' (1/2)
Linting 'Player.swift' (2/2)
PPrize.swift:44:34: warning: Colon Violation: Colons should be next to the identifier when specifying a type and next to the key in dictionary literals. (colon)
Done linting! Found 1 violation, 0 serious in 2 files.
MacBook-Pro-5:P Developer$ swiftlint autocorrect
Correcting Swift files in current working directory
Correcting 'Prize.swift' (1/2)
Correcting 'Player.swift' (2/2)
Done correcting 2 files!
MacBook-Pro-5:P Developer$ swiftlint
Linting Swift files in current working directory
Linting 'Prize.swift' (1/2)
Linting 'Player.swift' (2/2)
PPrize.swift:44:34: warning: Colon Violation: Colons should be next to the identifier when specifying a type and next to the key in dictionary literals. (colon)
Done linting! Found 1 violation, 0 serious in 2 files.
MacBook-Pro-5:P Developer$
请注意,是否存在 .swiftlint.yml
文件对此影响为零。
缩写 - 即只显示相关规则 - swiftlint rules
的输出如下所示。请注意,在这三个违规行为中,冒号
绝对是可以纠正的。
MacBook-Pro-5: Developer$ swiftlint rules
+------------------------------------------+--------+-------------+------------------------+-------------+---------------------------------------------------------------------------------------------------------------------------+
| identifier | opt-in | correctable | enabled in your config | kind | configuration |
+------------------------------------------+--------+-------------+------------------------+-------------+---------------------------------------------------------------------------------------------------------------------------+
| colon | no | yes | yes | style | warning, flexible_right_spacing: false, apply_to_dictionaries: true |
| line_length | no | no | yes | metrics | warning: 120, error: 200, ignores urls: false, ignores function declarations: false, ignores comments: false |
| operator_whitespace | no | no | yes | style | warning |
+------------------------------------------+--------+-------------+------------------------+-------------+---------------------------------------------------------------------------------------------------------------------------+
关于 swiftlint autocorrect
如何成功运行有什么想法吗?我可能缺少一些明显的配置或参数吗?我咨询过https://github.com/realm/SwiftLint无济于事。
最佳答案
已更新 swiftlint autocorrect --format
swiftlint --fix --format
swiftlint lint --fix --format
对所有人都有效。来源:https://github.com/realm/SwiftLint/issues/3571
旧
如果 swiftlint
版本低于 0.42.0然后你可以使用 swiftlint autocorrect --format
但如果它是 0.43.0 或更高版本,那么您需要使用 swiftlint --fix
它将自动更正空格、尾随空格、初始格式、if else 中的括号。等等,这不会影响你的逻辑或代码。
swiftlint autocorrect --format
//for version < 0.42.0 swiftlint --fix
//最新版本 >= 0.43.0
关于Swiftlint 自动更正不修改文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48189186/
这个问题已经有答案了: How to check whether a string contains a substring in JavaScript? (3 个回答) 已关闭 4 年前。 需要在运
我已经为系统调用 sys_uname 编写了内联汇编代码,但它似乎不正确。 #include #include #include #include #include struct utsna
我想知道是否有一种方法可以轻松安全地纠正 float 。 例如, 输入时:"32 + 32.1 "结果:“64.0999999999999” 我还必须提到,在使用科学记数法时,这种情况经常发生。“(2
我想知道如果我定义一个基本 Activity 对象并将我的所有 Activity 作为其子类会发生什么。然后我在基类中声明一个静态变量,所有的子类都使用相同的静态变量还是每个子类都有一个。 例如。我的
我想知道自定义整数类型(如 time_t、socklen_t 等)的正确 printf 格式说明符是什么。 例如, #include #include #include #include #i
我有 175 个 mp4 视频文件和扩展名为 .ass 的字幕文件。不幸的是,我的智能电视无法阅读这些字幕。我计划将字幕刻录(硬编码)到视频中。 我使用这个命令: ffmpeg -i orgvideo
我希望当我在分号后按 enter 键时,光标能够正确缩进。我如何在 VS Code 中实现这一点? 最佳答案 您可以关闭 wrappingIndent,或将其设置回默认的 same,然后确保 form
我的工作地点是研究购买第三方工具,用于使用地理编码的基于批处理的美国和加拿大地址更正。 您使用了什么产品? 您喜欢他们什么? 您不喜欢他们什么? 请注意,我们是C/C++ Unix商店。 最佳答案 我
StyleCop 规则 SA1642 坚持要求我的构造函数文档头必须以“初始化...的新实例”开头。 虽然我同意规则本身,但我就是无法让自己接受 StyleCop 强制执行我认为丑陋的拼写。它是用“s
我有一个包含观察结果和观察日期的数据框。日期是从 csv 文件读取的,但仅包括月份和日期。 R 假设它们都是 2016 年的。我知道日期是按从最近到最近的顺序排列的,那么我该如何添加正确的年份呢? 输
我有一个像这样的 Controller 操作: List abcd = new List() foreach (var i in images) { abcd.Add("{url:'"+Get
我正在使用以下 Nginx配置以防止在我使用 x-robots tag 时索引某些文件夹中的内容 location ~ .*/(?:archive|filter|topic)/.* { add
我需要在表格中更正时区不匹配问题。 unix 时间戳 1253568477 之前的所有日期和时间都需要在其值中加上 5 小时才能使它们等于 GMT。 我有以下列... date(数据类型date),关
我有以下内容: class Program { static void Main(string[] args) { Process pr; pr = new P
我是 xampp 的初学者。每次启动 XAMPP 控制面板时,我都会在日志框中看到错误列表。这是一个例子: 14:58:16 [main] Initializing Control Panel
我在 onTouchEvent(MotionEvent event) 中响应自定义 View 内的触摸事件。我遇到坐标不一致的问题:event.getRaw(Y) 返回触摸的 Y 坐标,包括状态栏,但
这是我在 UITableViewHeaderFooterView View 中设置内容的方法。 - (id)initWithFrame:(CGRect)frame { self = [super in
我有一个像这样的子查询 Select id, sum(select fran_payment.amount from fran_payment
我需要实现 ContraintValidatorFactory 接口(interface),它是 jsr303 的一部分 public interface ConstraintValidatorFac
我的脚本似乎无法正常工作,我想要得到的内容是不言自明的。我尝试了几种不同的方法来完成这项工作,四处搜索并尝试解决它。 我还尝试通过 console.log() 检查 chrome 日志,但它没有运
我是一名优秀的程序员,十分优秀!