Skip to content

Commit 33b81f2

Browse files
committed
Show inside ignored folders in comment
1 parent 79f0aad commit 33b81f2

File tree

2 files changed

+16
-21
lines changed

2 files changed

+16
-21
lines changed

.github/scripts/typing_stats_compare.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -111,13 +111,13 @@ def create_summary(
111111

112112
def ignored_files_summary(head_stats, base_stats)
113113
# This will skip the summary if files are added/removed from contrib folders for now.
114-
ignored_files_added = head_stats[:ignored_files][:paths] - base_stats[:ignored_files][:paths]
115-
ignored_files_removed = base_stats[:ignored_files][:paths] - head_stats[:ignored_files][:paths]
114+
ignored_files_added = head_stats[:ignored_files] - base_stats[:ignored_files]
115+
ignored_files_removed = base_stats[:ignored_files] - head_stats[:ignored_files]
116116

117117
return nil if ignored_files_added.empty? && ignored_files_removed.empty?
118118

119-
typed_files_percentage_base = ((base_stats[:total_files_size] - base_stats[:ignored_files][:size]) / base_stats[:total_files_size].to_f * 100).round(2)
120-
typed_files_percentage_head = ((head_stats[:total_files_size] - head_stats[:ignored_files][:size]) / head_stats[:total_files_size].to_f * 100).round(2)
119+
typed_files_percentage_base = ((base_stats[:total_files_size] - base_stats[:ignored_files].size) / base_stats[:total_files_size].to_f * 100).round(2)
120+
typed_files_percentage_head = ((head_stats[:total_files_size] - head_stats[:ignored_files].size) / head_stats[:total_files_size].to_f * 100).round(2)
121121

122122
intro = create_intro(
123123
added: ignored_files_added,

.github/scripts/typing_stats_compute.rb

Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -10,23 +10,29 @@
1010
PROTOTYPE_INITIALIZE = /\s*(?:public|private)?\s*def\s+initialize:\s*#{PARAMETERS}(?:\s*\??\{\s*#{PARAMETERS}\s*->\s*untyped\s*\})?\s*->\s*void/
1111
PROTOTYPE_METHOD = /\s*(?:public|private)?\s*def\s+(?:self\??\.)?(?:[^\s]+):\s*#{PARAMETERS}(?:\s*\??\{\s*#{PARAMETERS}\s*->\s*untyped\s*\})?\s*->\s*untyped/
1212

13-
# TODO: Find untyped/partially typed attributes, instance variables, class variables, constants
14-
1513
steepfile_path = Pathname(ENV["STEEPFILE_PATH"])
1614
project = Steep::Project.new(steepfile_path: steepfile_path).tap do |project|
1715
Steep::Project::DSL.parse(project, steepfile_path.read, filename: steepfile_path.to_s)
1816
end
1917
datadog_target = project.targets&.find { |target| target.name == :datadog }
2018
loader = ::Steep::Services::FileLoader.new(base_dir: project.base_dir)
2119

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
2330

2431
# List signature files that are not related to ignored files
2532
signature_paths_with_ignored_files = loader.each_path_in_patterns(datadog_target.signature_pattern)
2633
signature_paths = signature_paths_with_ignored_files.reject do |sig_path|
27-
# replace sig/ with lib/ and .rbs with .rb
2834
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|
3036
if ignored.end_with?("/")
3137
# Directory ignore - check if signature file is inside this directory
3238
corresponding_lib_file.start_with?(ignored)
@@ -37,14 +43,6 @@
3743
end
3844
end
3945

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
4846
total_files_size = Dir.glob("#{project.base_dir}/lib/**/*.rb").size
4947

5048
# steep:ignore comments stats
@@ -121,10 +119,7 @@
121119

122120
resulting_stats = {
123121
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,
128123

129124
steep_ignore_comments: ignore_comments,
130125

0 commit comments

Comments
 (0)