Skip to content

Commit 8181759

Browse files
committed
Merge pull request #53 from codeclimate/will/drop-exclude-paths
Drop support for "exclude_paths" in engine config
2 parents e27bb9f + 4678d48 commit 8181759

File tree

2 files changed

+2
-65
lines changed

2 files changed

+2
-65
lines changed

lib/cc/engine/file_list_resolver.rb

+2-26
Original file line numberDiff line numberDiff line change
@@ -3,32 +3,11 @@ module Engine
33
class FileListResolver
44
def initialize(root:, engine_config: {}, config_store:)
55
@root = root
6-
@exclude_paths = engine_config["exclude_paths"] || []
7-
@include_paths = engine_config["include_paths"]
6+
@include_paths = engine_config["include_paths"] || ["./"]
87
@config_store = config_store
98
end
109

1110
def expanded_list
12-
if @include_paths
13-
include_based_files_to_inspect
14-
else
15-
exclude_based_files_to_inspect
16-
end
17-
end
18-
19-
private
20-
21-
def exclude_based_files_to_inspect
22-
rubocop_runner.send(:find_target_files, []).reject do |path|
23-
exclude_due_to_config?(path)
24-
end
25-
end
26-
27-
def exclude_due_to_config?(path)
28-
@exclude_paths.include?(local_path(path))
29-
end
30-
31-
def include_based_files_to_inspect
3211
absolute_include_paths.flat_map do |path|
3312
if Dir.exist?(path)
3413
rubocop_runner.send(:find_target_files, [path])
@@ -38,10 +17,7 @@ def include_based_files_to_inspect
3817
end.compact
3918
end
4019

41-
def local_path(path)
42-
realpath = Pathname.new(@root).realpath.to_s
43-
path.gsub(%r{^#{realpath}/}, '')
44-
end
20+
private
4521

4622
def absolute_include_paths
4723
@include_paths.map { |path| Pathname.new(path).realpath.to_s }

spec/cc/engine/rubocop_spec.rb

-39
Original file line numberDiff line numberDiff line change
@@ -128,45 +128,6 @@ def method
128128
expect(includes_check?(output, "Lint/UselessAssignment")).to be false
129129
end
130130

131-
it "uses exclusions passed in via the config hash" do
132-
create_source_file("my_script", <<-EORUBY)
133-
#!/usr/bin/env ruby
134-
135-
def method
136-
unused = "x"
137-
138-
return false
139-
end
140-
EORUBY
141-
config = { "exclude_paths" => ["my_script"] }
142-
output = run_engine(config)
143-
144-
expect(includes_check?(output, "Lint/UselessAssignment")).to be false
145-
end
146-
147-
it "layers config exclusions on top of the YAML config" do
148-
create_source_file("foo.rb", <<-EORUBY)
149-
def method
150-
unused = "x"
151-
return false
152-
end
153-
EORUBY
154-
create_source_file("bar.rb", <<-EORUBY)
155-
def method
156-
unused = "x"
157-
return false
158-
end
159-
EORUBY
160-
create_source_file(
161-
"rubocop.yml",
162-
"AllCops:\n Exclude:\n - \"foo.rb\"\n"
163-
)
164-
config = { "config" => "rubocop.yml", "exclude_paths" => ["bar.rb"] }
165-
output = run_engine(config)
166-
167-
expect(includes_check?(output, "Lint/UselessAssignment")).to be false
168-
end
169-
170131
it "handles different locations properly" do
171132
allow_any_instance_of(RuboCop::Cop::Team).to receive(:inspect_file).and_return(
172133
[

0 commit comments

Comments
 (0)