From 4678d482b8aae2254d9e03d7765cde16062a17bc Mon Sep 17 00:00:00 2001 From: Will Fleming Date: Tue, 16 Feb 2016 17:04:28 -0500 Subject: [PATCH] Drop support for "exclude_paths" in engine config Engine-visible `exclude_paths` have been deprecated for a while, and we've been removing support from a bunch of engines. Engines should now rely on `include_paths`, which the CLI will calculate based on the `exclude_paths` in `.codeclimate.yml`. --- lib/cc/engine/file_list_resolver.rb | 28 ++------------------- spec/cc/engine/rubocop_spec.rb | 39 ----------------------------- 2 files changed, 2 insertions(+), 65 deletions(-) diff --git a/lib/cc/engine/file_list_resolver.rb b/lib/cc/engine/file_list_resolver.rb index 6bf53bc8..0ebd966b 100644 --- a/lib/cc/engine/file_list_resolver.rb +++ b/lib/cc/engine/file_list_resolver.rb @@ -3,32 +3,11 @@ module Engine class FileListResolver def initialize(root:, engine_config: {}, config_store:) @root = root - @exclude_paths = engine_config["exclude_paths"] || [] - @include_paths = engine_config["include_paths"] + @include_paths = engine_config["include_paths"] || ["./"] @config_store = config_store end def expanded_list - if @include_paths - include_based_files_to_inspect - else - exclude_based_files_to_inspect - end - end - - private - - def exclude_based_files_to_inspect - rubocop_runner.send(:find_target_files, []).reject do |path| - exclude_due_to_config?(path) - end - end - - def exclude_due_to_config?(path) - @exclude_paths.include?(local_path(path)) - end - - def include_based_files_to_inspect absolute_include_paths.flat_map do |path| if Dir.exist?(path) rubocop_runner.send(:find_target_files, [path]) @@ -38,10 +17,7 @@ def include_based_files_to_inspect end.compact end - def local_path(path) - realpath = Pathname.new(@root).realpath.to_s - path.gsub(%r{^#{realpath}/}, '') - end + private def absolute_include_paths @include_paths.map { |path| Pathname.new(path).realpath.to_s } diff --git a/spec/cc/engine/rubocop_spec.rb b/spec/cc/engine/rubocop_spec.rb index d07bf023..205cede6 100644 --- a/spec/cc/engine/rubocop_spec.rb +++ b/spec/cc/engine/rubocop_spec.rb @@ -128,45 +128,6 @@ def method expect(includes_check?(output, "Lint/UselessAssignment")).to be false end - it "uses exclusions passed in via the config hash" do - create_source_file("my_script", <<-EORUBY) - #!/usr/bin/env ruby - - def method - unused = "x" - - return false - end - EORUBY - config = { "exclude_paths" => ["my_script"] } - output = run_engine(config) - - expect(includes_check?(output, "Lint/UselessAssignment")).to be false - end - - it "layers config exclusions on top of the YAML config" do - create_source_file("foo.rb", <<-EORUBY) - def method - unused = "x" - return false - end - EORUBY - create_source_file("bar.rb", <<-EORUBY) - def method - unused = "x" - return false - end - EORUBY - create_source_file( - "rubocop.yml", - "AllCops:\n Exclude:\n - \"foo.rb\"\n" - ) - config = { "config" => "rubocop.yml", "exclude_paths" => ["bar.rb"] } - output = run_engine(config) - - expect(includes_check?(output, "Lint/UselessAssignment")).to be false - end - it "handles different locations properly" do allow_any_instance_of(RuboCop::Cop::Team).to receive(:inspect_file).and_return( [