pack_stats 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: da5c8a0753cdd0e4b878fc2fb2c2732fc5ca3664b1e53dc55f9c16e3b7f43fef
4
- data.tar.gz: a57f443a4572e99c7bd8c187d5b963ff9fdecebf71cf5d1339518ea3f89d5852
3
+ metadata.gz: 3f84f807ac7cd49095073c3da4a5f99fd2a4ba84a56b9740eb6d039ab310f720
4
+ data.tar.gz: 538a48f38b02506d4841c5f1c2be9d117c9623cc137315d353bb82547762cfe6
5
5
  SHA512:
6
- metadata.gz: 5c1bed7cbd4c71fe9937b9ea9ceb47a9784b7852f3a788f0f69c240848dd1d106e5be56a0005a2f6785f5e948c3419b2c9d7094bca559112e3289fe4334ea3ed
7
- data.tar.gz: 06c0b6fd7a7af65934ad6c6f346bb0fafa61874742c12f4d752b8437e5f6024c34153a079c0666004d68eac8c693fbd5354a62d2fc7d45e8bdb6615ded6d0569
6
+ metadata.gz: 9396f5f105aaadadcc5260d8eaf5beaa3bcc35bf053261b3c73c2c07bfe7e95d0a92e524e110ae842ed8507d87fa1581a76db95c097cae7d1e4da9a7b46b7c9c
7
+ data.tar.gz: bf1650ae0da82fcfdb29d25b09359c9f112aeb2a395b339f7a162d0963491b2fc0ccec54aa1e52ba178669c505023c301d456cf468372d9233fa2c3bdc93e42c
data/README.md CHANGED
@@ -38,13 +38,6 @@ PackStats.report_to_datadog!(
38
38
  # Example: [Pathname.new("./gems")]
39
39
  #
40
40
  componentized_source_code_locations: componentized_source_code_locations,
41
- #
42
- # A file is determined to be packaged if it exists in any of these directories.
43
- # This is an array of `Pathname`. `Pathname` can be relative or absolute paths.
44
- #
45
- # Example: [Pathname.new("./packs")]
46
- #
47
- packaged_source_code_locations: packaged_source_code_locations,
48
41
  )
49
42
  ```
50
43
 
@@ -63,7 +63,7 @@ module PackStats
63
63
  raise StandardError, "Could not find matching package #{to_package_name}"
64
64
  end
65
65
 
66
- tags = package_tags + [Tag.for('to_package', Metrics.humanized_package_name(to_package_name))] + Metrics.tags_for_to_team(CodeOwnership.for_package(to_package)&.name)
66
+ tags = package_tags + [Tag.for('to_package', Metrics.humanized_package_name(to_package_name))] + Metrics.tags_for_to_team(Private.package_owner(to_package))
67
67
  all_metrics << GaugeMetric.for('by_package.outbound_dependency_violations.per_package.count', Metrics.file_count(violations.select(&:dependency?)), tags)
68
68
  all_metrics << GaugeMetric.for('by_package.outbound_privacy_violations.per_package.count', Metrics.file_count(violations.select(&:privacy?)), tags)
69
69
  end
@@ -89,7 +89,8 @@ module PackStats
89
89
  raise StandardError, "Could not find matching package #{explicit_dependency}"
90
90
  end
91
91
 
92
- tags = package_tags + [Tag.for('to_package', Metrics.humanized_package_name(explicit_dependency))] + Metrics.tags_for_to_team(CodeOwnership.for_package(to_package)&.name)
92
+ owner = Private.package_owner(to_package)
93
+ tags = package_tags + [Tag.for('to_package', Metrics.humanized_package_name(explicit_dependency))] + Metrics.tags_for_to_team(owner)
93
94
  all_metrics << GaugeMetric.for('by_package.outbound_explicit_dependencies.per_package.count', 1, tags)
94
95
  end
95
96
 
@@ -17,7 +17,8 @@ module PackStats
17
17
  all_metrics = T.let([], T::Array[GaugeMetric])
18
18
  app_level_tag = Tag.for('app', app_name)
19
19
 
20
- all_packages.group_by { |package| CodeOwnership.for_package(package)&.name }.each do |team_name, packages_by_team|
20
+
21
+ all_packages.group_by { |package| Private.package_owner(package) }.each do |team_name, packages_by_team|
21
22
  # We look at `all_packages` because we care about ALL inbound violations across all teams
22
23
  inbound_violations_by_package = all_packages.flat_map(&:violations).group_by(&:to_package_name)
23
24
 
@@ -51,7 +52,7 @@ module PackStats
51
52
  raise StandardError, "Could not find matching package #{violation.to_package_name}"
52
53
  end
53
54
 
54
- CodeOwnership.for_package(to_package)&.name
55
+ Private.package_owner(to_package)
55
56
  end
56
57
 
57
58
  grouped_outbound_violations.each do |to_team_name, violations|
@@ -17,7 +17,7 @@ module PackStats
17
17
  [
18
18
  Tag.new(key: 'package', value: humanized_package_name(package.name)),
19
19
  Tag.new(key: 'app', value: app_name),
20
- *Metrics.tags_for_team(CodeOwnership.for_package(package)&.name),
20
+ *Metrics.tags_for_team(Private.package_owner(package)),
21
21
  ]
22
22
  end
23
23
 
@@ -48,6 +48,13 @@ module PackStats
48
48
  new_metric
49
49
  end
50
50
  end
51
+
52
+ sig { params(package: ParsePackwerk::Package).returns(T.nilable(String) )}
53
+ def self.package_owner(package)
54
+ pack = Packs.find(package.name)
55
+ return nil if pack.nil?
56
+ CodeOwnership.for_package(pack)&.name
57
+ end
51
58
  end
52
59
 
53
60
  private_constant :Private
data/lib/pack_stats.rb CHANGED
@@ -7,6 +7,7 @@ require 'benchmark'
7
7
  require 'code_teams'
8
8
  require 'code_ownership'
9
9
  require 'pathname'
10
+ require 'packs'
10
11
  require 'pack_stats/private'
11
12
  require 'pack_stats/private/source_code_file'
12
13
  require 'pack_stats/private/datadog_reporter'
@@ -27,23 +28,17 @@ module PackStats
27
28
  ].freeze, T::Array[Pathname]
28
29
  )
29
30
 
30
- DEFAULT_PACKAGED_SOURCE_CODE_LOCATIONS = T.let(
31
- [
32
- Pathname.new('packs'),
33
- Pathname.new('packages'),
34
- ].freeze, T::Array[Pathname]
35
- )
36
-
37
31
  sig do
38
32
  params(
39
33
  datadog_client: Dogapi::Client,
40
34
  app_name: String,
41
35
  source_code_pathnames: T::Array[Pathname],
42
36
  componentized_source_code_locations: T::Array[Pathname],
43
- packaged_source_code_locations: T::Array[Pathname],
44
37
  report_time: Time,
45
38
  verbose: T::Boolean,
46
39
  # See note on get_metrics
40
+ packaged_source_code_locations: T.nilable(T::Array[Pathname]),
41
+ # See note on get_metrics
47
42
  use_gusto_legacy_names: T::Boolean
48
43
  ).void
49
44
  end
@@ -52,16 +47,15 @@ module PackStats
52
47
  app_name:,
53
48
  source_code_pathnames:,
54
49
  componentized_source_code_locations: DEFAULT_COMPONENTIZED_SOURCE_CODE_LOCATIONS,
55
- packaged_source_code_locations: DEFAULT_PACKAGED_SOURCE_CODE_LOCATIONS,
56
50
  report_time: Time.now, # rubocop:disable Rails/TimeZone
57
51
  verbose: false,
52
+ packaged_source_code_locations: [],
58
53
  use_gusto_legacy_names: false
59
54
  )
60
55
 
61
56
  all_metrics = self.get_metrics(
62
57
  source_code_pathnames: source_code_pathnames,
63
58
  componentized_source_code_locations: componentized_source_code_locations,
64
- packaged_source_code_locations: packaged_source_code_locations,
65
59
  app_name: app_name,
66
60
  use_gusto_legacy_names: use_gusto_legacy_names,
67
61
  )
@@ -88,8 +82,9 @@ module PackStats
88
82
  params(
89
83
  source_code_pathnames: T::Array[Pathname],
90
84
  componentized_source_code_locations: T::Array[Pathname],
91
- packaged_source_code_locations: T::Array[Pathname],
92
85
  app_name: String,
86
+ # This field is deprecated
87
+ packaged_source_code_locations: T.nilable(T::Array[Pathname]),
93
88
  # It is not recommended to set this to true.
94
89
  # Gusto uses this to preserve historical trends in Dashboards as the names of
95
90
  # things changed, but new dashboards can use names that better match current tooling conventions.
@@ -100,15 +95,14 @@ module PackStats
100
95
  def self.get_metrics(
101
96
  source_code_pathnames:,
102
97
  componentized_source_code_locations:,
103
- packaged_source_code_locations:,
104
98
  app_name:,
99
+ packaged_source_code_locations: [],
105
100
  use_gusto_legacy_names: false
106
101
  )
107
102
  all_metrics = Private::DatadogReporter.get_metrics(
108
103
  source_code_files: source_code_files(
109
104
  source_code_pathnames: source_code_pathnames,
110
105
  componentized_source_code_locations: componentized_source_code_locations,
111
- packaged_source_code_locations: packaged_source_code_locations
112
106
  ),
113
107
  app_name: app_name
114
108
  )
@@ -124,18 +118,21 @@ module PackStats
124
118
  params(
125
119
  source_code_pathnames: T::Array[Pathname],
126
120
  componentized_source_code_locations: T::Array[Pathname],
127
- packaged_source_code_locations: T::Array[Pathname]
128
121
  ).returns(T::Array[Private::SourceCodeFile])
129
122
  end
130
123
  def self.source_code_files(
131
124
  source_code_pathnames:,
132
- componentized_source_code_locations:,
133
- packaged_source_code_locations:
125
+ componentized_source_code_locations:
134
126
  )
135
127
 
136
128
  # Sorbet has the wrong signatures for `Pathname#find`, whoops!
137
129
  componentized_file_set = Set.new(componentized_source_code_locations.select(&:exist?).flat_map { |pathname| T.unsafe(pathname).find.to_a })
138
- packaged_file_set = Set.new(packaged_source_code_locations.select(&:exist?).flat_map { |pathname| T.unsafe(pathname).find.to_a })
130
+
131
+ packaged_file_set = Packs.all.flat_map do |pack|
132
+ pack.relative_path.find.to_a
133
+ end
134
+
135
+ packaged_file_set = Set.new(packaged_file_set)
139
136
 
140
137
  source_code_pathnames.map do |pathname|
141
138
  componentized_file = componentized_file_set.include?(pathname)
@@ -0,0 +1,525 @@
1
+ # typed: true
2
+
3
+ # DO NOT EDIT MANUALLY
4
+ # This is an autogenerated file for types exported from the `code_ownership` gem.
5
+ # Please instead update this file by running `bin/tapioca gem code_ownership`.
6
+
7
+ # source://code_ownership//lib/code_ownership/cli.rb#7
8
+ module CodeOwnership
9
+ extend ::CodeOwnership
10
+
11
+ requires_ancestor { Kernel }
12
+
13
+ # Given a backtrace from either `Exception#backtrace` or `caller`, find the
14
+ # first line that corresponds to a file with assigned ownership
15
+ #
16
+ # source://code_ownership//lib/code_ownership.rb#95
17
+ sig do
18
+ params(
19
+ backtrace: T.nilable(T::Array[::String]),
20
+ excluded_teams: T::Array[::CodeTeams::Team]
21
+ ).returns(T.nilable(::CodeTeams::Team))
22
+ end
23
+ def for_backtrace(backtrace, excluded_teams: T.unsafe(nil)); end
24
+
25
+ # source://code_ownership//lib/code_ownership.rb#127
26
+ sig { params(klass: T.nilable(T.any(::Class, ::Module))).returns(T.nilable(::CodeTeams::Team)) }
27
+ def for_class(klass); end
28
+
29
+ # source://code_ownership//lib/code_ownership.rb#21
30
+ sig { params(file: ::String).returns(T.nilable(::CodeTeams::Team)) }
31
+ def for_file(file); end
32
+
33
+ # source://code_ownership//lib/code_ownership.rb#144
34
+ sig { params(package: ::Packs::Pack).returns(T.nilable(::CodeTeams::Team)) }
35
+ def for_package(package); end
36
+
37
+ # source://code_ownership//lib/code_ownership.rb#39
38
+ sig { params(team: T.any(::CodeTeams::Team, ::String)).returns(::String) }
39
+ def for_team(team); end
40
+
41
+ # source://code_ownership//lib/code_ownership.rb#83
42
+ sig { params(files: T::Array[::String], autocorrect: T::Boolean, stage_changes: T::Boolean).void }
43
+ def validate!(files: T.unsafe(nil), autocorrect: T.unsafe(nil), stage_changes: T.unsafe(nil)); end
44
+
45
+ class << self
46
+ # Generally, you should not ever need to do this, because once your ruby process loads, cached content should not change.
47
+ # Namely, the set of files, packages, and directories which are tracked for ownership should not change.
48
+ # The primary reason this is helpful is for clients of CodeOwnership who want to test their code, and each test context
49
+ # has different ownership and tracked files.
50
+ #
51
+ # source://code_ownership//lib/code_ownership.rb#153
52
+ sig { void }
53
+ def bust_caches!; end
54
+
55
+ # source://code_ownership//lib/code_ownership.rb#72
56
+ sig { params(filename: ::String).void }
57
+ def remove_file_annotation!(filename); end
58
+ end
59
+ end
60
+
61
+ # source://code_ownership//lib/code_ownership/cli.rb#8
62
+ class CodeOwnership::Cli
63
+ class << self
64
+ # For now, this just returns team ownership
65
+ # Later, this could also return code ownership errors about that file.
66
+ #
67
+ # source://code_ownership//lib/code_ownership/cli.rb#76
68
+ def for_file(argv); end
69
+
70
+ # source://code_ownership//lib/code_ownership/cli.rb#123
71
+ def for_team(argv); end
72
+
73
+ # source://code_ownership//lib/code_ownership/cli.rb#9
74
+ def run!(argv); end
75
+
76
+ private
77
+
78
+ # source://code_ownership//lib/code_ownership/cli.rb#33
79
+ def validate!(argv); end
80
+ end
81
+ end
82
+
83
+ # source://code_ownership//lib/code_ownership.rb#68
84
+ class CodeOwnership::InvalidCodeOwnershipConfigurationError < ::StandardError; end
85
+
86
+ # source://code_ownership//lib/code_ownership/private/configuration.rb#4
87
+ module CodeOwnership::Private
88
+ class << self
89
+ # source://code_ownership//lib/code_ownership/private.rb#30
90
+ sig { void }
91
+ def bust_caches!; end
92
+
93
+ # source://code_ownership//lib/code_ownership/private.rb#24
94
+ sig { returns(::CodeOwnership::Private::Configuration) }
95
+ def configuration; end
96
+
97
+ # source://code_ownership//lib/code_ownership/private.rb#69
98
+ sig { returns(::CodeOwnership::Private::OwnershipMappers::FileAnnotations) }
99
+ def file_annotations_mapper; end
100
+
101
+ # source://code_ownership//lib/code_ownership/private.rb#106
102
+ sig { params(files: T::Array[::String]).returns(T::Hash[::String, T::Array[::String]]) }
103
+ def files_by_mapper(files); end
104
+
105
+ # source://code_ownership//lib/code_ownership/private.rb#96
106
+ sig { params(team_name: ::String, location_of_reference: ::String).returns(::CodeTeams::Team) }
107
+ def find_team!(team_name, location_of_reference); end
108
+
109
+ # source://code_ownership//lib/code_ownership/private.rb#59
110
+ sig { returns(T::Array[::CodeOwnership::Private::OwnershipMappers::Interface]) }
111
+ def mappers; end
112
+
113
+ # Returns a string version of the relative path to a Rails constant,
114
+ # or nil if it can't find something
115
+ #
116
+ # source://code_ownership//lib/code_ownership/private.rb#77
117
+ sig { params(klass: T.nilable(T.any(::Class, ::Module))).returns(T.nilable(::String)) }
118
+ def path_from_klass(klass); end
119
+
120
+ # The output of this function is string pathnames relative to the root.
121
+ #
122
+ # source://code_ownership//lib/code_ownership/private.rb#90
123
+ sig { returns(T::Array[::String]) }
124
+ def tracked_files; end
125
+
126
+ # source://code_ownership//lib/code_ownership/private.rb#37
127
+ sig { params(files: T::Array[::String], autocorrect: T::Boolean, stage_changes: T::Boolean).void }
128
+ def validate!(files:, autocorrect: T.unsafe(nil), stage_changes: T.unsafe(nil)); end
129
+ end
130
+ end
131
+
132
+ # source://code_ownership//lib/code_ownership/private/configuration.rb#5
133
+ class CodeOwnership::Private::Configuration < ::T::Struct
134
+ const :js_package_paths, T::Array[::String]
135
+ const :owned_globs, T::Array[::String]
136
+ const :skip_codeowners_validation, T::Boolean
137
+ const :unowned_globs, T::Array[::String]
138
+
139
+ class << self
140
+ # source://code_ownership//lib/code_ownership/private/configuration.rb#15
141
+ sig { returns(::CodeOwnership::Private::Configuration) }
142
+ def fetch; end
143
+
144
+ # source://sorbet-runtime/0.5.9924/lib/types/struct.rb#13
145
+ def inherited(s); end
146
+
147
+ # source://code_ownership//lib/code_ownership/private/configuration.rb#27
148
+ sig { params(config_hash: T::Hash[T.untyped, T.untyped]).returns(T::Array[::String]) }
149
+ def js_package_paths(config_hash); end
150
+ end
151
+ end
152
+
153
+ # source://code_ownership//lib/code_ownership/private/configuration.rb#7
154
+ CodeOwnership::Private::Configuration::DEFAULT_JS_PACKAGE_PATHS = T.let(T.unsafe(nil), Array)
155
+
156
+ # source://code_ownership//lib/code_ownership/private/ownership_mappers/interface.rb#7
157
+ module CodeOwnership::Private::OwnershipMappers; end
158
+
159
+ # Calculate, cache, and return a mapping of file names (relative to the root
160
+ # of the repository) to team name.
161
+ #
162
+ # Example:
163
+ #
164
+ # {
165
+ # 'app/models/company.rb' => Team.find('Setup & Onboarding'),
166
+ # ...
167
+ # }
168
+ #
169
+ # source://code_ownership//lib/code_ownership/private/ownership_mappers/file_annotations.rb#17
170
+ class CodeOwnership::Private::OwnershipMappers::FileAnnotations
171
+ include ::CodeOwnership::Private::OwnershipMappers::Interface
172
+
173
+ # source://code_ownership//lib/code_ownership/private/ownership_mappers/file_annotations.rb#113
174
+ sig { override.void }
175
+ def bust_caches!; end
176
+
177
+ # source://code_ownership//lib/code_ownership/private/ownership_mappers/file_annotations.rb#102
178
+ sig { override.returns(T::Hash[::String, T.nilable(::CodeTeams::Team)]) }
179
+ def codeowners_lines_to_owners; end
180
+
181
+ # source://code_ownership//lib/code_ownership/private/ownership_mappers/file_annotations.rb#108
182
+ sig { override.returns(::String) }
183
+ def description; end
184
+
185
+ # source://code_ownership//lib/code_ownership/private/ownership_mappers/file_annotations.rb#50
186
+ sig { params(filename: ::String).returns(T.nilable(::CodeTeams::Team)) }
187
+ def file_annotation_based_owner(filename); end
188
+
189
+ # source://code_ownership//lib/code_ownership/private/ownership_mappers/file_annotations.rb#29
190
+ sig { override.params(file: ::String).returns(T.nilable(::CodeTeams::Team)) }
191
+ def map_file_to_owner(file); end
192
+
193
+ # source://code_ownership//lib/code_ownership/private/ownership_mappers/file_annotations.rb#38
194
+ sig { override.params(files: T::Array[::String]).returns(T::Hash[::String, T.nilable(::CodeTeams::Team)]) }
195
+ def map_files_to_owners(files); end
196
+
197
+ # source://code_ownership//lib/code_ownership/private/ownership_mappers/file_annotations.rb#86
198
+ sig { params(filename: ::String).void }
199
+ def remove_file_annotation!(filename); end
200
+ end
201
+
202
+ # source://code_ownership//lib/code_ownership/private/ownership_mappers/file_annotations.rb#23
203
+ CodeOwnership::Private::OwnershipMappers::FileAnnotations::TEAM_PATTERN = T.let(T.unsafe(nil), Regexp)
204
+
205
+ # @abstract Subclasses must implement the `abstract` methods below.
206
+ #
207
+ # source://code_ownership//lib/code_ownership/private/ownership_mappers/interface.rb#8
208
+ module CodeOwnership::Private::OwnershipMappers::Interface
209
+ interface!
210
+
211
+ # @abstract
212
+ #
213
+ # source://code_ownership//lib/code_ownership/private/ownership_mappers/interface.rb#45
214
+ sig { abstract.void }
215
+ def bust_caches!; end
216
+
217
+ # @abstract
218
+ #
219
+ # source://code_ownership//lib/code_ownership/private/ownership_mappers/interface.rb#37
220
+ sig { abstract.returns(T::Hash[::String, T.nilable(::CodeTeams::Team)]) }
221
+ def codeowners_lines_to_owners; end
222
+
223
+ # @abstract
224
+ #
225
+ # source://code_ownership//lib/code_ownership/private/ownership_mappers/interface.rb#41
226
+ sig { abstract.returns(::String) }
227
+ def description; end
228
+
229
+ # This should be fast when run with ONE file
230
+ #
231
+ # @abstract
232
+ #
233
+ # source://code_ownership//lib/code_ownership/private/ownership_mappers/interface.rb#21
234
+ sig { abstract.params(file: ::String).returns(T.nilable(::CodeTeams::Team)) }
235
+ def map_file_to_owner(file); end
236
+
237
+ # This should be fast when run with MANY files
238
+ #
239
+ # @abstract
240
+ #
241
+ # source://code_ownership//lib/code_ownership/private/ownership_mappers/interface.rb#31
242
+ sig { abstract.params(files: T::Array[::String]).returns(T::Hash[::String, T.nilable(::CodeTeams::Team)]) }
243
+ def map_files_to_owners(files); end
244
+ end
245
+
246
+ # source://code_ownership//lib/code_ownership/private/ownership_mappers/js_package_ownership.rb#8
247
+ class CodeOwnership::Private::OwnershipMappers::JsPackageOwnership
248
+ include ::CodeOwnership::Private::OwnershipMappers::Interface
249
+
250
+ # source://code_ownership//lib/code_ownership/private/ownership_mappers/js_package_ownership.rb#80
251
+ sig { override.void }
252
+ def bust_caches!; end
253
+
254
+ # Package ownership ignores the passed in files when generating code owners lines.
255
+ # This is because Package ownership knows that the fastest way to find code owners for package based ownership
256
+ # is to simply iterate over the packages and grab the owner, rather than iterating over each file just to get what package it is in
257
+ # In theory this means that we may generate code owners lines that cover files that are not in the passed in argument,
258
+ # but in practice this is not of consequence because in reality we never really want to generate code owners for only a
259
+ # subset of files, but rather we want code ownership for all files.
260
+ #
261
+ # source://code_ownership//lib/code_ownership/private/ownership_mappers/js_package_ownership.rb#54
262
+ sig { override.returns(T::Hash[::String, T.nilable(::CodeTeams::Team)]) }
263
+ def codeowners_lines_to_owners; end
264
+
265
+ # source://code_ownership//lib/code_ownership/private/ownership_mappers/js_package_ownership.rb#64
266
+ sig { override.returns(::String) }
267
+ def description; end
268
+
269
+ # source://code_ownership//lib/code_ownership/private/ownership_mappers/js_package_ownership.rb#18
270
+ sig { override.params(file: ::String).returns(T.nilable(::CodeTeams::Team)) }
271
+ def map_file_to_owner(file); end
272
+
273
+ # source://code_ownership//lib/code_ownership/private/ownership_mappers/js_package_ownership.rb#31
274
+ sig { override.params(files: T::Array[::String]).returns(T::Hash[::String, T.nilable(::CodeTeams::Team)]) }
275
+ def map_files_to_owners(files); end
276
+
277
+ # source://code_ownership//lib/code_ownership/private/ownership_mappers/js_package_ownership.rb#69
278
+ sig { params(package: ::CodeOwnership::Private::ParseJsPackages::Package).returns(T.nilable(::CodeTeams::Team)) }
279
+ def owner_for_package(package); end
280
+
281
+ private
282
+
283
+ # takes a file and finds the relevant `package.json` file by walking up the directory
284
+ # structure. Example, given `packages/a/b/c.rb`, this looks for `packages/a/b/package.json`, `packages/a/package.json`,
285
+ # `packages/package.json`, and `package.json` in that order, stopping at the first file to actually exist.
286
+ # We do additional caching so that we don't have to check for file existence every time
287
+ #
288
+ # source://code_ownership//lib/code_ownership/private/ownership_mappers/js_package_ownership.rb#91
289
+ sig { params(file: ::String).returns(T.nilable(::CodeOwnership::Private::ParseJsPackages::Package)) }
290
+ def map_file_to_relevant_package(file); end
291
+ end
292
+
293
+ # source://code_ownership//lib/code_ownership/private/ownership_mappers/package_ownership.rb#8
294
+ class CodeOwnership::Private::OwnershipMappers::PackageOwnership
295
+ include ::CodeOwnership::Private::OwnershipMappers::Interface
296
+
297
+ # source://code_ownership//lib/code_ownership/private/ownership_mappers/package_ownership.rb#80
298
+ sig { override.void }
299
+ def bust_caches!; end
300
+
301
+ # Package ownership ignores the passed in files when generating code owners lines.
302
+ # This is because Package ownership knows that the fastest way to find code owners for package based ownership
303
+ # is to simply iterate over the packages and grab the owner, rather than iterating over each file just to get what package it is in
304
+ # In theory this means that we may generate code owners lines that cover files that are not in the passed in argument,
305
+ # but in practice this is not of consequence because in reality we never really want to generate code owners for only a
306
+ # subset of files, but rather we want code ownership for all files.
307
+ #
308
+ # source://code_ownership//lib/code_ownership/private/ownership_mappers/package_ownership.rb#54
309
+ sig { override.returns(T::Hash[::String, T.nilable(::CodeTeams::Team)]) }
310
+ def codeowners_lines_to_owners; end
311
+
312
+ # source://code_ownership//lib/code_ownership/private/ownership_mappers/package_ownership.rb#64
313
+ sig { override.returns(::String) }
314
+ def description; end
315
+
316
+ # source://code_ownership//lib/code_ownership/private/ownership_mappers/package_ownership.rb#18
317
+ sig { override.params(file: ::String).returns(T.nilable(::CodeTeams::Team)) }
318
+ def map_file_to_owner(file); end
319
+
320
+ # source://code_ownership//lib/code_ownership/private/ownership_mappers/package_ownership.rb#31
321
+ sig { override.params(files: T::Array[::String]).returns(T::Hash[::String, T.nilable(::CodeTeams::Team)]) }
322
+ def map_files_to_owners(files); end
323
+
324
+ # source://code_ownership//lib/code_ownership/private/ownership_mappers/package_ownership.rb#69
325
+ sig { params(package: ::Packs::Pack).returns(T.nilable(::CodeTeams::Team)) }
326
+ def owner_for_package(package); end
327
+ end
328
+
329
+ # source://code_ownership//lib/code_ownership/private/ownership_mappers/team_globs.rb#8
330
+ class CodeOwnership::Private::OwnershipMappers::TeamGlobs
331
+ include ::CodeOwnership::Private::OwnershipMappers::Interface
332
+
333
+ # source://code_ownership//lib/code_ownership/private/ownership_mappers/team_globs.rb#56
334
+ sig { override.void }
335
+ def bust_caches!; end
336
+
337
+ # source://code_ownership//lib/code_ownership/private/ownership_mappers/team_globs.rb#45
338
+ sig { override.returns(T::Hash[::String, T.nilable(::CodeTeams::Team)]) }
339
+ def codeowners_lines_to_owners; end
340
+
341
+ # source://code_ownership//lib/code_ownership/private/ownership_mappers/team_globs.rb#62
342
+ sig { override.returns(::String) }
343
+ def description; end
344
+
345
+ # source://code_ownership//lib/code_ownership/private/ownership_mappers/team_globs.rb#38
346
+ sig { override.params(file: ::String).returns(T.nilable(::CodeTeams::Team)) }
347
+ def map_file_to_owner(file); end
348
+
349
+ # source://code_ownership//lib/code_ownership/private/ownership_mappers/team_globs.rb#22
350
+ sig { override.params(files: T::Array[::String]).returns(T::Hash[::String, T.nilable(::CodeTeams::Team)]) }
351
+ def map_files_to_owners(files); end
352
+ end
353
+
354
+ # Modeled off of ParsePackwerk
355
+ #
356
+ # source://code_ownership//lib/code_ownership/private/parse_js_packages.rb#8
357
+ module CodeOwnership::Private::ParseJsPackages
358
+ class << self
359
+ # source://code_ownership//lib/code_ownership/private/parse_js_packages.rb#57
360
+ sig { returns(T::Array[::CodeOwnership::Private::ParseJsPackages::Package]) }
361
+ def all; end
362
+ end
363
+ end
364
+
365
+ # source://code_ownership//lib/code_ownership/private/parse_js_packages.rb#13
366
+ CodeOwnership::Private::ParseJsPackages::METADATA = T.let(T.unsafe(nil), String)
367
+
368
+ # source://code_ownership//lib/code_ownership/private/parse_js_packages.rb#12
369
+ CodeOwnership::Private::ParseJsPackages::PACKAGE_JSON_NAME = T.let(T.unsafe(nil), String)
370
+
371
+ # source://code_ownership//lib/code_ownership/private/parse_js_packages.rb#15
372
+ class CodeOwnership::Private::ParseJsPackages::Package < ::T::Struct
373
+ const :metadata, T::Hash[::String, T.untyped]
374
+ const :name, ::String
375
+
376
+ # source://code_ownership//lib/code_ownership/private/parse_js_packages.rb#48
377
+ sig { returns(::Pathname) }
378
+ def directory; end
379
+
380
+ class << self
381
+ # source://code_ownership//lib/code_ownership/private/parse_js_packages.rb#22
382
+ sig { params(pathname: ::Pathname).returns(::CodeOwnership::Private::ParseJsPackages::Package) }
383
+ def from(pathname); end
384
+
385
+ # source://sorbet-runtime/0.5.9924/lib/types/struct.rb#13
386
+ def inherited(s); end
387
+ end
388
+ end
389
+
390
+ # source://code_ownership//lib/code_ownership/private/parse_js_packages.rb#11
391
+ CodeOwnership::Private::ParseJsPackages::ROOT_PACKAGE_NAME = T.let(T.unsafe(nil), String)
392
+
393
+ # source://code_ownership//lib/code_ownership/private/team_plugins/ownership.rb#5
394
+ module CodeOwnership::Private::TeamPlugins; end
395
+
396
+ # source://code_ownership//lib/code_ownership/private/team_plugins/github.rb#6
397
+ class CodeOwnership::Private::TeamPlugins::Github < ::CodeTeams::Plugin
398
+ # source://code_ownership//lib/code_ownership/private/team_plugins/github.rb#13
399
+ sig { returns(::CodeOwnership::Private::TeamPlugins::Github::GithubStruct) }
400
+ def github; end
401
+ end
402
+
403
+ # source://code_ownership//lib/code_ownership/private/team_plugins/github.rb#10
404
+ class CodeOwnership::Private::TeamPlugins::Github::GithubStruct < ::Struct
405
+ # Returns the value of attribute do_not_add_to_codeowners_file
406
+ #
407
+ # @return [Object] the current value of do_not_add_to_codeowners_file
408
+ def do_not_add_to_codeowners_file; end
409
+
410
+ # Sets the attribute do_not_add_to_codeowners_file
411
+ #
412
+ # @param value [Object] the value to set the attribute do_not_add_to_codeowners_file to.
413
+ # @return [Object] the newly set value
414
+ #
415
+ # source://code_ownership//lib/code_ownership/private/team_plugins/github.rb#10
416
+ def do_not_add_to_codeowners_file=(_); end
417
+
418
+ # Returns the value of attribute team
419
+ #
420
+ # @return [Object] the current value of team
421
+ def team; end
422
+
423
+ # Sets the attribute team
424
+ #
425
+ # @param value [Object] the value to set the attribute team to.
426
+ # @return [Object] the newly set value
427
+ #
428
+ # source://code_ownership//lib/code_ownership/private/team_plugins/github.rb#10
429
+ def team=(_); end
430
+
431
+ class << self
432
+ def [](*_arg0); end
433
+ def inspect; end
434
+ def members; end
435
+ def new(*_arg0); end
436
+ end
437
+ end
438
+
439
+ # source://code_ownership//lib/code_ownership/private/team_plugins/ownership.rb#6
440
+ class CodeOwnership::Private::TeamPlugins::Ownership < ::CodeTeams::Plugin
441
+ # source://code_ownership//lib/code_ownership/private/team_plugins/ownership.rb#11
442
+ sig { returns(T::Array[::String]) }
443
+ def owned_globs; end
444
+ end
445
+
446
+ # source://code_ownership//lib/code_ownership/private/validations/interface.rb#5
447
+ module CodeOwnership::Private::Validations; end
448
+
449
+ # source://code_ownership//lib/code_ownership/private/validations/files_have_owners.rb#6
450
+ class CodeOwnership::Private::Validations::FilesHaveOwners
451
+ include ::CodeOwnership::Private::Validations::Interface
452
+
453
+ # source://code_ownership//lib/code_ownership/private/validations/files_have_owners.rb#12
454
+ sig do
455
+ override
456
+ .params(
457
+ files: T::Array[::String],
458
+ autocorrect: T::Boolean,
459
+ stage_changes: T::Boolean
460
+ ).returns(T::Array[::String])
461
+ end
462
+ def validation_errors(files:, autocorrect: T.unsafe(nil), stage_changes: T.unsafe(nil)); end
463
+ end
464
+
465
+ # source://code_ownership//lib/code_ownership/private/validations/files_have_unique_owners.rb#6
466
+ class CodeOwnership::Private::Validations::FilesHaveUniqueOwners
467
+ include ::CodeOwnership::Private::Validations::Interface
468
+
469
+ # source://code_ownership//lib/code_ownership/private/validations/files_have_unique_owners.rb#12
470
+ sig do
471
+ override
472
+ .params(
473
+ files: T::Array[::String],
474
+ autocorrect: T::Boolean,
475
+ stage_changes: T::Boolean
476
+ ).returns(T::Array[::String])
477
+ end
478
+ def validation_errors(files:, autocorrect: T.unsafe(nil), stage_changes: T.unsafe(nil)); end
479
+ end
480
+
481
+ # source://code_ownership//lib/code_ownership/private/validations/github_codeowners_up_to_date.rb#6
482
+ class CodeOwnership::Private::Validations::GithubCodeownersUpToDate
483
+ include ::CodeOwnership::Private::Validations::Interface
484
+
485
+ # source://code_ownership//lib/code_ownership/private/validations/github_codeowners_up_to_date.rb#12
486
+ sig do
487
+ override
488
+ .params(
489
+ files: T::Array[::String],
490
+ autocorrect: T::Boolean,
491
+ stage_changes: T::Boolean
492
+ ).returns(T::Array[::String])
493
+ end
494
+ def validation_errors(files:, autocorrect: T.unsafe(nil), stage_changes: T.unsafe(nil)); end
495
+
496
+ private
497
+
498
+ # Generate the contents of a CODEOWNERS file that GitHub can use to
499
+ # automatically assign reviewers
500
+ # https://help.github.com/articles/about-codeowners/
501
+ #
502
+ # source://code_ownership//lib/code_ownership/private/validations/github_codeowners_up_to_date.rb#100
503
+ sig { returns(T::Array[::String]) }
504
+ def codeowners_file_lines; end
505
+ end
506
+
507
+ # @abstract Subclasses must implement the `abstract` methods below.
508
+ #
509
+ # source://code_ownership//lib/code_ownership/private/validations/interface.rb#6
510
+ module CodeOwnership::Private::Validations::Interface
511
+ interface!
512
+
513
+ # @abstract
514
+ #
515
+ # source://code_ownership//lib/code_ownership/private/validations/interface.rb#13
516
+ sig do
517
+ abstract
518
+ .params(
519
+ files: T::Array[::String],
520
+ autocorrect: T::Boolean,
521
+ stage_changes: T::Boolean
522
+ ).returns(T::Array[::String])
523
+ end
524
+ def validation_errors(files:, autocorrect: T.unsafe(nil), stage_changes: T.unsafe(nil)); end
525
+ end
@@ -0,0 +1,111 @@
1
+ # typed: true
2
+
3
+ # DO NOT EDIT MANUALLY
4
+ # This is an autogenerated file for types exported from the `packs` gem.
5
+ # Please instead update this file by running `bin/tapioca gem packs`.
6
+
7
+ # source://packs//lib/packs/pack.rb#3
8
+ module Packs
9
+ class << self
10
+ # source://packs//lib/packs.rb#16
11
+ sig { returns(T::Array[::Packs::Pack]) }
12
+ def all; end
13
+
14
+ # source://packs//lib/packs.rb#34
15
+ sig { void }
16
+ def bust_cache!; end
17
+
18
+ # source://packs//lib/packs.rb#41
19
+ sig { returns(::Packs::Private::Configuration) }
20
+ def config; end
21
+
22
+ # @yield [config]
23
+ #
24
+ # source://packs//lib/packs.rb#47
25
+ sig { params(blk: T.proc.params(arg0: ::Packs::Private::Configuration).void).void }
26
+ def configure(&blk); end
27
+
28
+ # source://packs//lib/packs.rb#21
29
+ sig { params(name: ::String).returns(T.nilable(::Packs::Pack)) }
30
+ def find(name); end
31
+
32
+ # source://packs//lib/packs.rb#26
33
+ sig { params(file_path: T.any(::Pathname, ::String)).returns(T.nilable(::Packs::Pack)) }
34
+ def for_file(file_path); end
35
+
36
+ private
37
+
38
+ # source://packs//lib/packs.rb#73
39
+ sig { returns(T::Array[::Pathname]) }
40
+ def package_glob_patterns; end
41
+
42
+ # source://packs//lib/packs.rb#59
43
+ sig { returns(T::Hash[::String, ::Packs::Pack]) }
44
+ def packs_by_name; end
45
+ end
46
+ end
47
+
48
+ # source://packs//lib/packs.rb#10
49
+ Packs::PACKAGE_FILE = T.let(T.unsafe(nil), String)
50
+
51
+ # source://packs//lib/packs/pack.rb#4
52
+ class Packs::Pack < ::T::Struct
53
+ const :name, ::String
54
+ const :path, ::Pathname
55
+ const :raw_hash, T::Hash[T.untyped, T.untyped]
56
+ const :relative_path, ::Pathname
57
+
58
+ # source://packs//lib/packs/pack.rb#34
59
+ sig { returns(::String) }
60
+ def last_name; end
61
+
62
+ # source://packs//lib/packs/pack.rb#39
63
+ sig { returns(T::Hash[T.untyped, T.untyped]) }
64
+ def metadata; end
65
+
66
+ # source://packs//lib/packs/pack.rb#28
67
+ sig { params(relative: T::Boolean).returns(::Pathname) }
68
+ def yml(relative: T.unsafe(nil)); end
69
+
70
+ class << self
71
+ # source://packs//lib/packs/pack.rb#13
72
+ sig { params(package_yml_absolute_path: ::Pathname).returns(::Packs::Pack) }
73
+ def from(package_yml_absolute_path); end
74
+
75
+ # source://sorbet-runtime/0.5.9924/lib/types/struct.rb#13
76
+ def inherited(s); end
77
+ end
78
+ end
79
+
80
+ # source://packs//lib/packs/private/configuration.rb#4
81
+ module Packs::Private
82
+ class << self
83
+ # source://packs//lib/packs/private.rb#10
84
+ sig { returns(::Pathname) }
85
+ def root; end
86
+ end
87
+ end
88
+
89
+ # source://packs//lib/packs/private/configuration.rb#5
90
+ class Packs::Private::Configuration < ::T::Struct
91
+ prop :pack_paths, T::Array[::String]
92
+
93
+ class << self
94
+ # source://packs//lib/packs/private/configuration.rb#17
95
+ sig { returns(::Packs::Private::Configuration) }
96
+ def fetch; end
97
+
98
+ # source://sorbet-runtime/0.5.9924/lib/types/struct.rb#13
99
+ def inherited(s); end
100
+
101
+ # source://packs//lib/packs/private/configuration.rb#26
102
+ sig { params(config_hash: T::Hash[T.untyped, T.untyped]).returns(T::Array[::String]) }
103
+ def pack_paths(config_hash); end
104
+ end
105
+ end
106
+
107
+ # source://packs//lib/packs/private/configuration.rb#7
108
+ Packs::Private::Configuration::CONFIGURATION_PATHNAME = T.let(T.unsafe(nil), Pathname)
109
+
110
+ # source://packs//lib/packs/private/configuration.rb#9
111
+ Packs::Private::Configuration::DEFAULT_PACK_PATHS = T.let(T.unsafe(nil), Array)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pack_stats
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gusto Engineers
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-12-14 00:00:00.000000000 Z
11
+ date: 2022-12-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: code_teams
@@ -52,6 +52,20 @@ dependencies:
52
52
  - - ">="
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: packs
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
55
69
  - !ruby/object:Gem::Dependency
56
70
  name: parse_packwerk
57
71
  requirement: !ruby/object:Gem::Requirement
@@ -190,10 +204,11 @@ files:
190
204
  - lib/pack_stats/tags.rb
191
205
  - sorbet/config
192
206
  - sorbet/rbi/gems/ast@2.4.2.rbi
193
- - sorbet/rbi/gems/code_ownership@1.28.0.rbi
207
+ - sorbet/rbi/gems/code_ownership@1.29.2.rbi
194
208
  - sorbet/rbi/gems/code_teams@1.0.0.rbi
195
209
  - sorbet/rbi/gems/dogapi@1.45.0.rbi
196
210
  - sorbet/rbi/gems/manual.rbi
211
+ - sorbet/rbi/gems/packs@0.0.5.rbi
197
212
  - sorbet/rbi/gems/parse_packwerk@0.16.0.rbi
198
213
  - sorbet/rbi/gems/rspec@3.10.0.rbi
199
214
  - sorbet/rbi/gems/rubocop-packs@0.0.30.rbi
@@ -1,337 +0,0 @@
1
- # typed: true
2
-
3
- # DO NOT EDIT MANUALLY
4
- # This is an autogenerated file for types exported from the `code_ownership` gem.
5
- # Please instead update this file by running `bin/tapioca gem code_ownership`.
6
-
7
- module CodeOwnership
8
- extend ::CodeOwnership
9
-
10
- requires_ancestor { Kernel }
11
-
12
- sig do
13
- params(
14
- backtrace: T.nilable(T::Array[::String]),
15
- excluded_teams: T::Array[::CodeTeams::Team]
16
- ).returns(T.nilable(::CodeTeams::Team))
17
- end
18
- def for_backtrace(backtrace, excluded_teams: T.unsafe(nil)); end
19
-
20
- sig { params(klass: T.nilable(T.any(::Class, ::Module))).returns(T.nilable(::CodeTeams::Team)) }
21
- def for_class(klass); end
22
-
23
- sig { params(file: ::String).returns(T.nilable(::CodeTeams::Team)) }
24
- def for_file(file); end
25
-
26
- sig { params(package: ::ParsePackwerk::Package).returns(T.nilable(::CodeTeams::Team)) }
27
- def for_package(package); end
28
-
29
- sig { params(files: T::Array[::String], autocorrect: T::Boolean, stage_changes: T::Boolean).void }
30
- def validate!(files: T.unsafe(nil), autocorrect: T.unsafe(nil), stage_changes: T.unsafe(nil)); end
31
-
32
- class << self
33
- sig { void }
34
- def bust_caches!; end
35
-
36
- sig { params(filename: ::String).void }
37
- def remove_file_annotation!(filename); end
38
- end
39
- end
40
-
41
- class CodeOwnership::Cli
42
- class << self
43
- def for_file(argv); end
44
- def run!(argv); end
45
-
46
- private
47
-
48
- def validate!(argv); end
49
- end
50
- end
51
-
52
- class CodeOwnership::InvalidCodeOwnershipConfigurationError < ::StandardError; end
53
-
54
- module CodeOwnership::Private
55
- class << self
56
- sig { void }
57
- def bust_caches!; end
58
-
59
- sig { returns(::CodeOwnership::Private::Configuration) }
60
- def configuration; end
61
-
62
- sig { returns(::CodeOwnership::Private::OwnershipMappers::FileAnnotations) }
63
- def file_annotations_mapper; end
64
-
65
- sig { params(files: T::Array[::String]).returns(T::Hash[::String, T::Array[::String]]) }
66
- def files_by_mapper(files); end
67
-
68
- sig { params(team_name: ::String, location_of_reference: ::String).returns(::CodeTeams::Team) }
69
- def find_team!(team_name, location_of_reference); end
70
-
71
- sig { returns(T::Array[::CodeOwnership::Private::OwnershipMappers::Interface]) }
72
- def mappers; end
73
-
74
- sig { params(klass: T.nilable(T.any(::Class, ::Module))).returns(T.nilable(::String)) }
75
- def path_from_klass(klass); end
76
-
77
- sig { returns(T::Array[::String]) }
78
- def tracked_files; end
79
-
80
- sig { params(files: T::Array[::String], autocorrect: T::Boolean, stage_changes: T::Boolean).void }
81
- def validate!(files:, autocorrect: T.unsafe(nil), stage_changes: T.unsafe(nil)); end
82
- end
83
- end
84
-
85
- class CodeOwnership::Private::Configuration < ::T::Struct
86
- const :js_package_paths, T::Array[::String]
87
- const :owned_globs, T::Array[::String]
88
- const :skip_codeowners_validation, T::Boolean
89
- const :unowned_globs, T::Array[::String]
90
-
91
- class << self
92
- sig { returns(::CodeOwnership::Private::Configuration) }
93
- def fetch; end
94
-
95
- def inherited(s); end
96
-
97
- sig { params(config_hash: T::Hash[T.untyped, T.untyped]).returns(T::Array[::String]) }
98
- def js_package_paths(config_hash); end
99
- end
100
- end
101
-
102
- CodeOwnership::Private::Configuration::DEFAULT_JS_PACKAGE_PATHS = T.let(T.unsafe(nil), Array)
103
- module CodeOwnership::Private::OwnershipMappers; end
104
-
105
- class CodeOwnership::Private::OwnershipMappers::FileAnnotations
106
- include ::CodeOwnership::Private::OwnershipMappers::Interface
107
-
108
- sig { override.void }
109
- def bust_caches!; end
110
-
111
- sig { override.returns(T::Hash[::String, T.nilable(::CodeTeams::Team)]) }
112
- def codeowners_lines_to_owners; end
113
-
114
- sig { override.returns(::String) }
115
- def description; end
116
-
117
- sig { params(filename: ::String).returns(T.nilable(::CodeTeams::Team)) }
118
- def file_annotation_based_owner(filename); end
119
-
120
- sig { override.params(file: ::String).returns(T.nilable(::CodeTeams::Team)) }
121
- def map_file_to_owner(file); end
122
-
123
- sig { override.params(files: T::Array[::String]).returns(T::Hash[::String, T.nilable(::CodeTeams::Team)]) }
124
- def map_files_to_owners(files); end
125
-
126
- sig { params(filename: ::String).void }
127
- def remove_file_annotation!(filename); end
128
- end
129
-
130
- CodeOwnership::Private::OwnershipMappers::FileAnnotations::TEAM_PATTERN = T.let(T.unsafe(nil), Regexp)
131
-
132
- module CodeOwnership::Private::OwnershipMappers::Interface
133
- interface!
134
-
135
- sig { abstract.void }
136
- def bust_caches!; end
137
-
138
- sig { abstract.returns(T::Hash[::String, T.nilable(::CodeTeams::Team)]) }
139
- def codeowners_lines_to_owners; end
140
-
141
- sig { abstract.returns(::String) }
142
- def description; end
143
-
144
- sig { abstract.params(file: ::String).returns(T.nilable(::CodeTeams::Team)) }
145
- def map_file_to_owner(file); end
146
-
147
- sig { abstract.params(files: T::Array[::String]).returns(T::Hash[::String, T.nilable(::CodeTeams::Team)]) }
148
- def map_files_to_owners(files); end
149
- end
150
-
151
- class CodeOwnership::Private::OwnershipMappers::JsPackageOwnership
152
- include ::CodeOwnership::Private::OwnershipMappers::Interface
153
-
154
- sig { override.void }
155
- def bust_caches!; end
156
-
157
- sig { override.returns(T::Hash[::String, T.nilable(::CodeTeams::Team)]) }
158
- def codeowners_lines_to_owners; end
159
-
160
- sig { override.returns(::String) }
161
- def description; end
162
-
163
- sig { override.params(file: ::String).returns(T.nilable(::CodeTeams::Team)) }
164
- def map_file_to_owner(file); end
165
-
166
- sig { override.params(files: T::Array[::String]).returns(T::Hash[::String, T.nilable(::CodeTeams::Team)]) }
167
- def map_files_to_owners(files); end
168
-
169
- sig { params(package: ::CodeOwnership::Private::ParseJsPackages::Package).returns(T.nilable(::CodeTeams::Team)) }
170
- def owner_for_package(package); end
171
-
172
- private
173
-
174
- sig { params(file: ::String).returns(T.nilable(::CodeOwnership::Private::ParseJsPackages::Package)) }
175
- def map_file_to_relevant_package(file); end
176
- end
177
-
178
- class CodeOwnership::Private::OwnershipMappers::PackageOwnership
179
- include ::CodeOwnership::Private::OwnershipMappers::Interface
180
-
181
- sig { override.void }
182
- def bust_caches!; end
183
-
184
- sig { override.returns(T::Hash[::String, T.nilable(::CodeTeams::Team)]) }
185
- def codeowners_lines_to_owners; end
186
-
187
- sig { override.returns(::String) }
188
- def description; end
189
-
190
- sig { override.params(file: ::String).returns(T.nilable(::CodeTeams::Team)) }
191
- def map_file_to_owner(file); end
192
-
193
- sig { override.params(files: T::Array[::String]).returns(T::Hash[::String, T.nilable(::CodeTeams::Team)]) }
194
- def map_files_to_owners(files); end
195
-
196
- sig { params(package: ::ParsePackwerk::Package).returns(T.nilable(::CodeTeams::Team)) }
197
- def owner_for_package(package); end
198
-
199
- private
200
-
201
- sig { params(file: ::String).returns(T.nilable(::ParsePackwerk::Package)) }
202
- def map_file_to_relevant_package(file); end
203
- end
204
-
205
- class CodeOwnership::Private::OwnershipMappers::TeamGlobs
206
- include ::CodeOwnership::Private::OwnershipMappers::Interface
207
-
208
- sig { override.void }
209
- def bust_caches!; end
210
-
211
- sig { override.returns(T::Hash[::String, T.nilable(::CodeTeams::Team)]) }
212
- def codeowners_lines_to_owners; end
213
-
214
- sig { override.returns(::String) }
215
- def description; end
216
-
217
- sig { override.params(file: ::String).returns(T.nilable(::CodeTeams::Team)) }
218
- def map_file_to_owner(file); end
219
-
220
- sig { override.params(files: T::Array[::String]).returns(T::Hash[::String, T.nilable(::CodeTeams::Team)]) }
221
- def map_files_to_owners(files); end
222
- end
223
-
224
- module CodeOwnership::Private::ParseJsPackages
225
- class << self
226
- sig { returns(T::Array[::CodeOwnership::Private::ParseJsPackages::Package]) }
227
- def all; end
228
- end
229
- end
230
-
231
- CodeOwnership::Private::ParseJsPackages::METADATA = T.let(T.unsafe(nil), String)
232
- CodeOwnership::Private::ParseJsPackages::PACKAGE_JSON_NAME = T.let(T.unsafe(nil), String)
233
-
234
- class CodeOwnership::Private::ParseJsPackages::Package < ::T::Struct
235
- const :metadata, T::Hash[::String, T.untyped]
236
- const :name, ::String
237
-
238
- sig { returns(::Pathname) }
239
- def directory; end
240
-
241
- class << self
242
- sig { params(pathname: ::Pathname).returns(::CodeOwnership::Private::ParseJsPackages::Package) }
243
- def from(pathname); end
244
-
245
- def inherited(s); end
246
- end
247
- end
248
-
249
- CodeOwnership::Private::ParseJsPackages::ROOT_PACKAGE_NAME = T.let(T.unsafe(nil), String)
250
- module CodeOwnership::Private::TeamPlugins; end
251
-
252
- class CodeOwnership::Private::TeamPlugins::Github < ::CodeTeams::Plugin
253
- sig { returns(::CodeOwnership::Private::TeamPlugins::Github::GithubStruct) }
254
- def github; end
255
- end
256
-
257
- class CodeOwnership::Private::TeamPlugins::Github::GithubStruct < ::Struct
258
- def do_not_add_to_codeowners_file; end
259
- def do_not_add_to_codeowners_file=(_); end
260
- def team; end
261
- def team=(_); end
262
-
263
- class << self
264
- def [](*_arg0); end
265
- def inspect; end
266
- def members; end
267
- def new(*_arg0); end
268
- end
269
- end
270
-
271
- class CodeOwnership::Private::TeamPlugins::Ownership < ::CodeTeams::Plugin
272
- sig { returns(T::Array[::String]) }
273
- def owned_globs; end
274
- end
275
-
276
- module CodeOwnership::Private::Validations; end
277
-
278
- class CodeOwnership::Private::Validations::FilesHaveOwners
279
- include ::CodeOwnership::Private::Validations::Interface
280
-
281
- sig do
282
- override
283
- .params(
284
- files: T::Array[::String],
285
- autocorrect: T::Boolean,
286
- stage_changes: T::Boolean
287
- ).returns(T::Array[::String])
288
- end
289
- def validation_errors(files:, autocorrect: T.unsafe(nil), stage_changes: T.unsafe(nil)); end
290
- end
291
-
292
- class CodeOwnership::Private::Validations::FilesHaveUniqueOwners
293
- include ::CodeOwnership::Private::Validations::Interface
294
-
295
- sig do
296
- override
297
- .params(
298
- files: T::Array[::String],
299
- autocorrect: T::Boolean,
300
- stage_changes: T::Boolean
301
- ).returns(T::Array[::String])
302
- end
303
- def validation_errors(files:, autocorrect: T.unsafe(nil), stage_changes: T.unsafe(nil)); end
304
- end
305
-
306
- class CodeOwnership::Private::Validations::GithubCodeownersUpToDate
307
- include ::CodeOwnership::Private::Validations::Interface
308
-
309
- sig do
310
- override
311
- .params(
312
- files: T::Array[::String],
313
- autocorrect: T::Boolean,
314
- stage_changes: T::Boolean
315
- ).returns(T::Array[::String])
316
- end
317
- def validation_errors(files:, autocorrect: T.unsafe(nil), stage_changes: T.unsafe(nil)); end
318
-
319
- private
320
-
321
- sig { returns(T::Array[::String]) }
322
- def codeowners_file_lines; end
323
- end
324
-
325
- module CodeOwnership::Private::Validations::Interface
326
- interface!
327
-
328
- sig do
329
- abstract
330
- .params(
331
- files: T::Array[::String],
332
- autocorrect: T::Boolean,
333
- stage_changes: T::Boolean
334
- ).returns(T::Array[::String])
335
- end
336
- def validation_errors(files:, autocorrect: T.unsafe(nil), stage_changes: T.unsafe(nil)); end
337
- end