|  | 
| 10 | 10 | PROTOTYPE_INITIALIZE = /\s*(?:public|private)?\s*def\s+initialize:\s*#{PARAMETERS}(?:\s*\??\{\s*#{PARAMETERS}\s*->\s*untyped\s*\})?\s*->\s*void/ | 
| 11 | 11 | PROTOTYPE_METHOD = /\s*(?:public|private)?\s*def\s+(?:self\??\.)?(?:[^\s]+):\s*#{PARAMETERS}(?:\s*\??\{\s*#{PARAMETERS}\s*->\s*untyped\s*\})?\s*->\s*untyped/ | 
| 12 | 12 | 
 | 
| 13 |  | -# TODO: Find untyped/partially typed attributes, instance variables, class variables, constants | 
| 14 |  | - | 
| 15 | 13 | steepfile_path = Pathname(ENV["STEEPFILE_PATH"]) | 
| 16 | 14 | project = Steep::Project.new(steepfile_path: steepfile_path).tap do |project| | 
| 17 | 15 |   Steep::Project::DSL.parse(project, steepfile_path.read, filename: steepfile_path.to_s) | 
| 18 | 16 | end | 
| 19 | 17 | datadog_target = project.targets&.find { |target| target.name == :datadog } | 
| 20 | 18 | loader = ::Steep::Services::FileLoader.new(base_dir: project.base_dir) | 
| 21 | 19 | 
 | 
| 22 |  | -ignored_paths = datadog_target&.source_pattern&.ignores | 
|  | 20 | +ignored_paths_with_folders = datadog_target&.source_pattern&.ignores | 
|  | 21 | + | 
|  | 22 | +ignored_files = ignored_paths_with_folders.each_with_object([]) do |ignored_path, result| | 
|  | 23 | +  # If the ignored path is a folder, add all the .rb files in the folder to the ignored paths | 
|  | 24 | +  if ignored_path.end_with?("/") | 
|  | 25 | +    result.push(*Dir.glob(ignored_path + "**/*.rb")) | 
|  | 26 | +  else | 
|  | 27 | +    result.push(ignored_path) | 
|  | 28 | +  end | 
|  | 29 | +end | 
| 23 | 30 | 
 | 
| 24 | 31 | # List signature files that are not related to ignored files | 
| 25 | 32 | signature_paths_with_ignored_files = loader.each_path_in_patterns(datadog_target.signature_pattern) | 
| 26 | 33 | signature_paths = signature_paths_with_ignored_files.reject do |sig_path| | 
| 27 |  | -  # replace sig/ with lib/ and .rbs with .rb | 
| 28 | 34 |   corresponding_lib_file = sig_path.to_s.sub(/^sig/, "lib").sub(/\.rbs$/, ".rb") | 
| 29 |  | -  ignored_paths.any? do |ignored| | 
|  | 35 | +  ignored_paths_with_folders.any? do |ignored| | 
| 30 | 36 |     if ignored.end_with?("/") | 
| 31 | 37 |       # Directory ignore - check if signature file is inside this directory | 
| 32 | 38 |       corresponding_lib_file.start_with?(ignored) | 
|  | 
| 37 | 43 |   end | 
| 38 | 44 | end | 
| 39 | 45 | 
 | 
| 40 |  | -# Ignored files stats | 
| 41 |  | -ignored_files_size = ignored_paths.inject(0) do |result, path| | 
| 42 |  | -  if path.end_with?("/") | 
| 43 |  | -    result + Dir.glob(path + "**/*.rb").size | 
| 44 |  | -  else | 
| 45 |  | -    result + 1 | 
| 46 |  | -  end | 
| 47 |  | -end | 
| 48 | 46 | total_files_size = Dir.glob("#{project.base_dir}/lib/**/*.rb").size | 
| 49 | 47 | 
 | 
| 50 | 48 | # steep:ignore comments stats | 
|  | 
| 121 | 119 | 
 | 
| 122 | 120 | resulting_stats = { | 
| 123 | 121 |   total_files_size: total_files_size, | 
| 124 |  | -  ignored_files: { | 
| 125 |  | -    size: ignored_files_size, # Required as we don't list all ignored files, but only their paths | 
| 126 |  | -    paths: ignored_paths | 
| 127 |  | -  }, | 
|  | 122 | +  ignored_files: ignored_files, | 
| 128 | 123 | 
 | 
| 129 | 124 |   steep_ignore_comments: ignore_comments, | 
| 130 | 125 | 
 | 
|  | 
0 commit comments