我们正在使用 RuboCop 对整个代码库进行 linting。
这是我们开始时.rubocop_todo.yml
中所有规则的列表。 复选标记的意思是“这已修复并合并到母版”。
如果您创建 PR 来修复其中一种,请使用 RuboCop 中的--only
选项,将精力集中在一种修复上。 在审查这样的代码时很容易不知所措。 (如果你修复的稍微多一点,没什么大不了的。这就是保持更改可审查性。)
# edit .rubocop.yml, commenting out the first line -
# this removes the "ignore the TODOs" setting
# Auto-correct with only 1 rule
rubocop -a --only Name/OfTheRuleYouAreFixing --auto-correct
# Re-generate the config file
rubocop --auto-gen-config
# Revert line 3 in .rubocop_todo.yml
# This will avoid PR conflicts
# Inspect to see if it looks OK
git diff
# Re-set the TODO list
git checkout .rubocop.yml
# Add and commit the change
git add .
git commit -m"chore: RuboCop lint Name/OfTheRuleYouAreFixing"
删除此评论。 我之前的说法是错误的。 未来的开发人员在检查违规时应该注意 .rubocop_todo.yml 文件。
当前的主引用有一些 rubocop 违规行为没有被 CI 捕获。 这些问题已在https://github.com/lostisland/faraday/pull/870和https://github.com/lostisland/faraday/pull/871中修复
此外,如果 PR 的名称类似于[RuboCop] fix Layout/TrailingBlankLines
,那么将它们添加到上述清单中会容易得多。
我检查了Style/GlobalVars
因为唯一的冒犯者是script/generate_certs
。 一旦旧的集成测试被完全移植,集成套件的旧脚本就可以使用了,这种攻击将被神奇地修复。 在别处添加的任何其他全局变量应继续被标记为 rubocop 犯罪。
在修复Style/Globalvars
之前,我还没有看过这篇文章:man_shrugging:
谢谢大家! 🚀
最有用的评论
谢谢大家! 🚀