一次性更正一堆文件的 Ruby 缩进

Correct Ruby indentation for a bunch of files in one go

我有很多 ruby 个缩进不正确的文件。

除了手动之外,我如何自动(借助某些工具)修复它?

示例:

feature 'HAPPY/3_step_minimal_foundation_no_prefill_HAPPY' do
    visit('http://staging.everquote/url_reset') # should be 2 spaces not 4
    visit('http://staging.everquote/url_3_step_minimal_foundation')
    with_ajax_wait do
      expect(css_zip_code).to be_visible # should be 4 spaces not 6
  end

ruby beautifier 包含重新缩进代码的逻辑。

您可以按原样 运行 脚本或提取这些部分。

原来我已经在使用它来检查格式并且目前正在维护(截至 2015 年 9 月)的 rubocop 有一个 -a 选项来实际修复文件。甜蜜!

https://github.com/bbatsov/rubocop