1
1
module CC
2
2
module Engine
3
3
class FileListResolver
4
- def initialize ( root :, config_store :, engine_config : { } )
4
+ def initialize ( root :, builds_config :, engine_config : { } )
5
5
@root = root
6
6
@include_paths = engine_config [ "include_paths" ] || [ "./" ]
7
- @config_store = config_store
7
+ @builds_config = builds_config
8
8
end
9
9
10
10
def expanded_list
11
11
absolute_include_paths . flat_map { |path |
12
- if Dir . exist? ( path )
13
- rubocop_runner . send ( :find_target_files , [ path ] )
14
- elsif rubocop_file_to_include? ( path )
15
- path
16
- end
12
+ find_target_files ( path )
17
13
} . compact
18
14
end
19
15
20
16
private
21
17
22
- attr_reader :config_store
23
-
24
18
def absolute_include_paths
25
19
@include_paths . map { |path | to_absolute_path ( path ) } . compact
26
20
end
@@ -31,17 +25,13 @@ def to_absolute_path(path)
31
25
nil
32
26
end
33
27
34
- def rubocop_file_to_include? ( file )
35
- root , basename = File . split ( file )
36
- store = config_store . for ( root )
37
-
38
- return false if store . file_to_exclude? ( basename )
39
-
40
- file =~ /\. rb$/ || store . file_to_include? ( basename )
28
+ def find_target_files ( path )
29
+ target_files = target_finder . find ( [ path ] , :all_file_types )
30
+ target_files . each ( &:freeze ) . freeze
41
31
end
42
32
43
- def rubocop_runner
44
- @rubocop_runner ||= RuboCop ::Runner . new ( { } , @config_store )
33
+ def target_finder
34
+ @target_finder ||= RuboCop ::TargetFinder . new ( @builds_config . rubocop_config_store )
45
35
end
46
36
end
47
37
end
0 commit comments