diff options
| author | Gautham Goli | 2017-01-18 22:37:11 +0530 |
|---|---|---|
| committer | Gautham Goli | 2017-02-06 12:46:26 +0530 |
| commit | 1f5cf4fd40fc3528e700a421afc9a128c159cac9 (patch) | |
| tree | 7384dc153607f2bba38bf046c857c92eaa3e421b /Library | |
| parent | 0b3d9031e26b47d0ebf48276616c1c4da01ce336 (diff) | |
| download | brew-1f5cf4fd40fc3528e700a421afc9a128c159cac9.tar.bz2 | |
Update docs and manpages to include --fix option
Diffstat (limited to 'Library')
| -rw-r--r-- | Library/Homebrew/dev-cmd/audit.rb | 4 | ||||
| -rw-r--r-- | Library/Homebrew/rubocops/bottle_block_cop.rb | 32 |
2 files changed, 10 insertions, 26 deletions
diff --git a/Library/Homebrew/dev-cmd/audit.rb b/Library/Homebrew/dev-cmd/audit.rb index c2d6aeaed..5ad12d4b6 100644 --- a/Library/Homebrew/dev-cmd/audit.rb +++ b/Library/Homebrew/dev-cmd/audit.rb @@ -5,9 +5,9 @@ #: If no <formulae> are provided, all of them are checked. #: #: If `--strict` is passed, additional checks are run, including RuboCop -#: style checks and custom cop checks. +#: style checks. #: -#: If `--fix` is passed, style violations and custom cop violations will be +#: If `--fix` is passed, style violations will be #: automatically fixed using RuboCop's `--auto-correct` feature. #: #: If `--online` is passed, additional slower checks that require a network diff --git a/Library/Homebrew/rubocops/bottle_block_cop.rb b/Library/Homebrew/rubocops/bottle_block_cop.rb index 6b699ab5e..e16672683 100644 --- a/Library/Homebrew/rubocops/bottle_block_cop.rb +++ b/Library/Homebrew/rubocops/bottle_block_cop.rb @@ -9,42 +9,26 @@ module RuboCop method, _args, body = *node _keyword, method_name = *method - return unless method_name.equal?(:bottle) && revision?(body) - add_offense(node, :expression) + return unless method_name == :bottle + check_revision?(body) end private def autocorrect(node) lambda do |corrector| - # Check for revision - _method, _args, body = *node - if revision?(body) - replace_revision(corrector, node) - end + correction = node.source.sub("revision", "rebuild") + corrector.insert_before(node.source_range, correction) + corrector.remove(node.source_range) end end - def revision?(body) + def check_revision?(body) body.children.each do |method_call_node| _receiver, method_name, _args = *method_call_node - if method_name == :revision - return true - end + next unless method_name == :revision + add_offense(method_call_node, :expression) end - false - end - - def replace_revision(corrector, node) - new_source = "" - node.source.each_line do |line| - if line =~ /\A\s*revision/ - line = line.sub("revision", "rebuild") - end - new_source << line - end - corrector.insert_before(node.source_range, new_source) - corrector.remove(node.source_range) end end end |
