From 70fc82578795a3c99fb149615e2efbf4596ea4a4 Mon Sep 17 00:00:00 2001 From: Markus Reiter Date: Tue, 27 Sep 2016 18:48:06 +0200 Subject: Use separate RuboCop configs for formulae and core code. --- Library/Homebrew/cmd/style.rb | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'Library/Homebrew/cmd') diff --git a/Library/Homebrew/cmd/style.rb b/Library/Homebrew/cmd/style.rb index db61116be..1a4b02277 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,10 +49,16 @@ module Homebrew args = %W[ --force-exclusion - --config #{HOMEBREW_LIBRARY}/.rubocop.yml ] args << "--auto-correct" if fix - args += files + + if files.nil? + args << "--config" << HOMEBREW_LIBRARY/".rubocop_core.yml" + args += [HOMEBREW_LIBRARY_PATH] + else + args << "--config" << HOMEBREW_LIBRARY/".rubocop_formula.yml" + args += files + end HOMEBREW_LIBRARY.cd do case output_type -- cgit v1.2.3 From 5800f2f084fa59d073a4793b0fb77630f12b2bab Mon Sep 17 00:00:00 2001 From: Markus Reiter Date: Wed, 28 Sep 2016 22:34:09 +0200 Subject: Use separate `.rubocop.yml` in `Library/Taps` and `Library/Homebrew`. --- Library/Homebrew/cmd/style.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'Library/Homebrew/cmd') diff --git a/Library/Homebrew/cmd/style.rb b/Library/Homebrew/cmd/style.rb index 1a4b02277..d396f81ee 100644 --- a/Library/Homebrew/cmd/style.rb +++ b/Library/Homebrew/cmd/style.rb @@ -53,10 +53,10 @@ module Homebrew args << "--auto-correct" if fix if files.nil? - args << "--config" << HOMEBREW_LIBRARY/".rubocop_core.yml" + args << "--config" << HOMEBREW_LIBRARY_PATH/".rubocop.yml" args += [HOMEBREW_LIBRARY_PATH] else - args << "--config" << HOMEBREW_LIBRARY/".rubocop_formula.yml" + args << "--config" << HOMEBREW_LIBRARY/"Taps/.rubocop.yml" args += files end -- cgit v1.2.3 From 18a9945ad8aa3bbe71512d1422e562ef3eee3ee5 Mon Sep 17 00:00:00 2001 From: Markus Reiter Date: Wed, 28 Sep 2016 22:47:14 +0200 Subject: `cd` to `HOMEBREW_LIBRARY` is not needed anymore for RuboCop. --- Library/Homebrew/cmd/style.rb | 33 ++++++++++++++++----------------- 1 file changed, 16 insertions(+), 17 deletions(-) (limited to 'Library/Homebrew/cmd') diff --git a/Library/Homebrew/cmd/style.rb b/Library/Homebrew/cmd/style.rb index d396f81ee..e44641f70 100644 --- a/Library/Homebrew/cmd/style.rb +++ b/Library/Homebrew/cmd/style.rb @@ -56,26 +56,25 @@ module Homebrew args << "--config" << HOMEBREW_LIBRARY_PATH/".rubocop.yml" args += [HOMEBREW_LIBRARY_PATH] else - args << "--config" << HOMEBREW_LIBRARY/"Taps/.rubocop.yml" + args << "--config" << Tap::TAP_DIRECTORY/".rubocop.yml" + args << "--format" << "simple" args += files end - 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 + case output_type + when :print + args << "--display-cop-names" if ARGV.include? "--display-cop-names" + 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 -- cgit v1.2.3 From 5b31507fdac6ae12141b3e84f70115610a7ae00c Mon Sep 17 00:00:00 2001 From: Mike McQuaid Date: Sat, 1 Oct 2016 12:13:09 +0100 Subject: Use Library/.rubocop.yml file. This allows having a shared style that’s use for Homebrew/brew and taps which can be overridden by Homebrew/brew. --- Library/Homebrew/cmd/style.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Library/Homebrew/cmd') diff --git a/Library/Homebrew/cmd/style.rb b/Library/Homebrew/cmd/style.rb index e44641f70..9934c6939 100644 --- a/Library/Homebrew/cmd/style.rb +++ b/Library/Homebrew/cmd/style.rb @@ -56,7 +56,7 @@ module Homebrew args << "--config" << HOMEBREW_LIBRARY_PATH/".rubocop.yml" args += [HOMEBREW_LIBRARY_PATH] else - args << "--config" << Tap::TAP_DIRECTORY/".rubocop.yml" + args << "--config" << HOMEBREW_LIBRARY/".rubocop.yml" args << "--format" << "simple" args += files end -- cgit v1.2.3 From 84c29fcf1ff29df31ab98b03ed4cedf9222ce161 Mon Sep 17 00:00:00 2001 From: Mike McQuaid Date: Sat, 1 Oct 2016 17:04:44 +0100 Subject: Fix JSON output handling. --- Library/Homebrew/cmd/style.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Library/Homebrew/cmd') diff --git a/Library/Homebrew/cmd/style.rb b/Library/Homebrew/cmd/style.rb index 9934c6939..e666eb200 100644 --- a/Library/Homebrew/cmd/style.rb +++ b/Library/Homebrew/cmd/style.rb @@ -57,13 +57,13 @@ module Homebrew args += [HOMEBREW_LIBRARY_PATH] else args << "--config" << HOMEBREW_LIBRARY/".rubocop.yml" - args << "--format" << "simple" 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 -- cgit v1.2.3