Skip to content

Commit 81ae9a7

Browse files
author
Will Fleming
committed
Resolve all paths to absolute paths
When paths were sent in as relative paths from the CLI, `Exclude` directives within a rubocop config yml were not correctly applied. This is because Rubocop internally turns those excludes into absolute paths, and it seems like it was then trying to match the being-analyzed relative path against the had-been-made-absolute excluded path.
1 parent 8f1dc04 commit 81ae9a7

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

lib/cc/engine/file_list_resolver.rb

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,20 +29,24 @@ def exclude_due_to_config?(path)
2929
end
3030

3131
def include_based_files_to_inspect
32-
@include_paths.map do |path|
33-
if path =~ %r{/$}
32+
@include_paths.map(&method(:abs_path)).flat_map do |path|
33+
if Dir.exist?(path)
3434
rubocop_runner.send(:find_target_files, [path])
3535
elsif rubocop_file_to_include?(path)
3636
path
3737
end
38-
end.flatten.compact
38+
end.compact
3939
end
4040

4141
def local_path(path)
4242
realpath = Pathname.new(@root).realpath.to_s
4343
path.gsub(%r{^#{realpath}/}, '')
4444
end
4545

46+
def abs_path(path)
47+
Pathname.new(path).realpath.to_s
48+
end
49+
4650
def rubocop_file_to_include?(file)
4751
if file =~ /\.rb$/
4852
true

0 commit comments

Comments
 (0)