diff options
| author | Mike McQuaid | 2016-10-01 21:20:18 +0100 |
|---|---|---|
| committer | GitHub | 2016-10-01 21:20:18 +0100 |
| commit | fa14c262454c2678ca9c8a1caa2f0080833ac67a (patch) | |
| tree | b58d6d7b308bfc2fa57f2ea544c6e4da6fcdf95b /Library/Homebrew/cmd/style.rb | |
| parent | 19e633f1900ea910c2a9db85dc7c7bea0825676d (diff) | |
| parent | 84c29fcf1ff29df31ab98b03ed4cedf9222ce161 (diff) | |
| download | brew-fa14c262454c2678ca9c8a1caa2f0080833ac67a.tar.bz2 | |
Merge pull request #1169 from reitermarkus/rubocop-separate-configs
Use separate RuboCop configs for formulae and core code.
Diffstat (limited to 'Library/Homebrew/cmd/style.rb')
| -rw-r--r-- | Library/Homebrew/cmd/style.rb | 45 |
1 files changed, 25 insertions, 20 deletions
diff --git a/Library/Homebrew/cmd/style.rb b/Library/Homebrew/cmd/style.rb index db61116be..e666eb200 100644 --- a/Library/Homebrew/cmd/style.rb +++ b/Library/Homebrew/cmd/style.rb @@ -19,7 +19,7 @@ require "utils/json" module Homebrew def style target = if ARGV.named.empty? - [HOMEBREW_LIBRARY_PATH] + nil elsif ARGV.named.any? { |file| File.exist? file } ARGV.named elsif ARGV.named.any? { |tap| tap.count("/") == 1 } @@ -49,27 +49,32 @@ module Homebrew args = %W[ --force-exclusion - --config #{HOMEBREW_LIBRARY}/.rubocop.yml ] args << "--auto-correct" if fix - args += files - - HOMEBREW_LIBRARY.cd do - case output_type - when :print - args << "--display-cop-names" if ARGV.include? "--display-cop-names" - system "rubocop", "--format", "simple", *args - !$?.success? - when :json - json = Utils.popen_read_text("rubocop", "--format", "json", *args) - # exit status of 1 just means violations were found; other numbers mean execution errors - # exitstatus can also be nil if RuboCop process crashes, e.g. due to - # native extension problems - raise "Error while running RuboCop" if $?.exitstatus.nil? || $?.exitstatus > 1 - RubocopResults.new(Utils::JSON.load(json)) - else - raise "Invalid output_type for check_style_impl: #{output_type}" - end + + if files.nil? + args << "--config" << HOMEBREW_LIBRARY_PATH/".rubocop.yml" + args += [HOMEBREW_LIBRARY_PATH] + else + args << "--config" << HOMEBREW_LIBRARY/".rubocop.yml" + args += files + end + + case output_type + when :print + args << "--display-cop-names" if ARGV.include? "--display-cop-names" + args << "--format" << "simple" if files + system "rubocop", *args + !$?.success? + when :json + json = Utils.popen_read_text("rubocop", "--format", "json", *args) + # exit status of 1 just means violations were found; other numbers mean execution errors + # exitstatus can also be nil if RuboCop process crashes, e.g. due to + # native extension problems + raise "Error while running RuboCop" if $?.exitstatus.nil? || $?.exitstatus > 1 + RubocopResults.new(Utils::JSON.load(json)) + else + raise "Invalid output_type for check_style_impl: #{output_type}" end end |
