danger-packwerk 0.7.1 → 0.8.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,336 @@
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(team: T.any(::CodeTeams::Team, ::String)).returns(::String) }
30
+ def for_team(team); end
31
+
32
+ sig { params(files: T::Array[::String], autocorrect: T::Boolean, stage_changes: T::Boolean).void }
33
+ def validate!(files: T.unsafe(nil), autocorrect: T.unsafe(nil), stage_changes: T.unsafe(nil)); end
34
+
35
+ class << self
36
+ sig { void }
37
+ def bust_caches!; end
38
+
39
+ sig { params(filename: ::String).void }
40
+ def remove_file_annotation!(filename); end
41
+ end
42
+ end
43
+
44
+ class CodeOwnership::Cli
45
+ class << self
46
+ def for_file(argv); end
47
+ def for_team(argv); end
48
+ def run!(argv); end
49
+
50
+ private
51
+
52
+ def validate!(argv); end
53
+ end
54
+ end
55
+
56
+ class CodeOwnership::InvalidCodeOwnershipConfigurationError < ::StandardError; end
57
+
58
+ module CodeOwnership::Private
59
+ class << self
60
+ sig { void }
61
+ def bust_caches!; end
62
+
63
+ sig { returns(::CodeOwnership::Private::Configuration) }
64
+ def configuration; end
65
+
66
+ sig { returns(::CodeOwnership::Private::OwnershipMappers::FileAnnotations) }
67
+ def file_annotations_mapper; end
68
+
69
+ sig { params(files: T::Array[::String]).returns(T::Hash[::String, T::Array[::String]]) }
70
+ def files_by_mapper(files); end
71
+
72
+ sig { params(team_name: ::String, location_of_reference: ::String).returns(::CodeTeams::Team) }
73
+ def find_team!(team_name, location_of_reference); end
74
+
75
+ sig { returns(T::Array[::CodeOwnership::Private::OwnershipMappers::Interface]) }
76
+ def mappers; end
77
+
78
+ sig { params(klass: T.nilable(T.any(::Class, ::Module))).returns(T.nilable(::String)) }
79
+ def path_from_klass(klass); end
80
+
81
+ sig { returns(T::Array[::String]) }
82
+ def tracked_files; end
83
+
84
+ sig { params(files: T::Array[::String], autocorrect: T::Boolean, stage_changes: T::Boolean).void }
85
+ def validate!(files:, autocorrect: T.unsafe(nil), stage_changes: T.unsafe(nil)); end
86
+ end
87
+ end
88
+
89
+ class CodeOwnership::Private::Configuration < ::T::Struct
90
+ const :js_package_paths, T::Array[::String]
91
+ const :owned_globs, T::Array[::String]
92
+ const :skip_codeowners_validation, T::Boolean
93
+ const :unowned_globs, T::Array[::String]
94
+
95
+ class << self
96
+ sig { returns(::CodeOwnership::Private::Configuration) }
97
+ def fetch; end
98
+
99
+ def inherited(s); end
100
+
101
+ sig { params(config_hash: T::Hash[T.untyped, T.untyped]).returns(T::Array[::String]) }
102
+ def js_package_paths(config_hash); end
103
+ end
104
+ end
105
+
106
+ CodeOwnership::Private::Configuration::DEFAULT_JS_PACKAGE_PATHS = T.let(T.unsafe(nil), Array)
107
+ module CodeOwnership::Private::OwnershipMappers; end
108
+
109
+ class CodeOwnership::Private::OwnershipMappers::FileAnnotations
110
+ include ::CodeOwnership::Private::OwnershipMappers::Interface
111
+
112
+ sig { override.void }
113
+ def bust_caches!; end
114
+
115
+ sig { override.returns(T::Hash[::String, T.nilable(::CodeTeams::Team)]) }
116
+ def codeowners_lines_to_owners; end
117
+
118
+ sig { override.returns(::String) }
119
+ def description; end
120
+
121
+ sig { params(filename: ::String).returns(T.nilable(::CodeTeams::Team)) }
122
+ def file_annotation_based_owner(filename); end
123
+
124
+ sig { override.params(file: ::String).returns(T.nilable(::CodeTeams::Team)) }
125
+ def map_file_to_owner(file); end
126
+
127
+ sig { override.params(files: T::Array[::String]).returns(T::Hash[::String, T.nilable(::CodeTeams::Team)]) }
128
+ def map_files_to_owners(files); end
129
+
130
+ sig { params(filename: ::String).void }
131
+ def remove_file_annotation!(filename); end
132
+ end
133
+
134
+ CodeOwnership::Private::OwnershipMappers::FileAnnotations::TEAM_PATTERN = T.let(T.unsafe(nil), Regexp)
135
+
136
+ module CodeOwnership::Private::OwnershipMappers::Interface
137
+ interface!
138
+
139
+ sig { abstract.void }
140
+ def bust_caches!; end
141
+
142
+ sig { abstract.returns(T::Hash[::String, T.nilable(::CodeTeams::Team)]) }
143
+ def codeowners_lines_to_owners; end
144
+
145
+ sig { abstract.returns(::String) }
146
+ def description; end
147
+
148
+ sig { abstract.params(file: ::String).returns(T.nilable(::CodeTeams::Team)) }
149
+ def map_file_to_owner(file); end
150
+
151
+ sig { abstract.params(files: T::Array[::String]).returns(T::Hash[::String, T.nilable(::CodeTeams::Team)]) }
152
+ def map_files_to_owners(files); end
153
+ end
154
+
155
+ class CodeOwnership::Private::OwnershipMappers::JsPackageOwnership
156
+ include ::CodeOwnership::Private::OwnershipMappers::Interface
157
+
158
+ sig { override.void }
159
+ def bust_caches!; end
160
+
161
+ sig { override.returns(T::Hash[::String, T.nilable(::CodeTeams::Team)]) }
162
+ def codeowners_lines_to_owners; end
163
+
164
+ sig { override.returns(::String) }
165
+ def description; end
166
+
167
+ sig { override.params(file: ::String).returns(T.nilable(::CodeTeams::Team)) }
168
+ def map_file_to_owner(file); end
169
+
170
+ sig { override.params(files: T::Array[::String]).returns(T::Hash[::String, T.nilable(::CodeTeams::Team)]) }
171
+ def map_files_to_owners(files); end
172
+
173
+ sig { params(package: ::CodeOwnership::Private::ParseJsPackages::Package).returns(T.nilable(::CodeTeams::Team)) }
174
+ def owner_for_package(package); end
175
+
176
+ private
177
+
178
+ sig { params(file: ::String).returns(T.nilable(::CodeOwnership::Private::ParseJsPackages::Package)) }
179
+ def map_file_to_relevant_package(file); end
180
+ end
181
+
182
+ class CodeOwnership::Private::OwnershipMappers::PackageOwnership
183
+ include ::CodeOwnership::Private::OwnershipMappers::Interface
184
+
185
+ sig { override.void }
186
+ def bust_caches!; end
187
+
188
+ sig { override.returns(T::Hash[::String, T.nilable(::CodeTeams::Team)]) }
189
+ def codeowners_lines_to_owners; end
190
+
191
+ sig { override.returns(::String) }
192
+ def description; end
193
+
194
+ sig { override.params(file: ::String).returns(T.nilable(::CodeTeams::Team)) }
195
+ def map_file_to_owner(file); end
196
+
197
+ sig { override.params(files: T::Array[::String]).returns(T::Hash[::String, T.nilable(::CodeTeams::Team)]) }
198
+ def map_files_to_owners(files); end
199
+
200
+ sig { params(package: ::ParsePackwerk::Package).returns(T.nilable(::CodeTeams::Team)) }
201
+ def owner_for_package(package); end
202
+ end
203
+
204
+ class CodeOwnership::Private::OwnershipMappers::TeamGlobs
205
+ include ::CodeOwnership::Private::OwnershipMappers::Interface
206
+
207
+ sig { override.void }
208
+ def bust_caches!; end
209
+
210
+ sig { override.returns(T::Hash[::String, T.nilable(::CodeTeams::Team)]) }
211
+ def codeowners_lines_to_owners; end
212
+
213
+ sig { override.returns(::String) }
214
+ def description; end
215
+
216
+ sig { override.params(file: ::String).returns(T.nilable(::CodeTeams::Team)) }
217
+ def map_file_to_owner(file); end
218
+
219
+ sig { override.params(files: T::Array[::String]).returns(T::Hash[::String, T.nilable(::CodeTeams::Team)]) }
220
+ def map_files_to_owners(files); end
221
+ end
222
+
223
+ module CodeOwnership::Private::ParseJsPackages
224
+ class << self
225
+ sig { returns(T::Array[::CodeOwnership::Private::ParseJsPackages::Package]) }
226
+ def all; end
227
+ end
228
+ end
229
+
230
+ CodeOwnership::Private::ParseJsPackages::METADATA = T.let(T.unsafe(nil), String)
231
+ CodeOwnership::Private::ParseJsPackages::PACKAGE_JSON_NAME = T.let(T.unsafe(nil), String)
232
+
233
+ class CodeOwnership::Private::ParseJsPackages::Package < ::T::Struct
234
+ const :metadata, T::Hash[::String, T.untyped]
235
+ const :name, ::String
236
+
237
+ sig { returns(::Pathname) }
238
+ def directory; end
239
+
240
+ class << self
241
+ sig { params(pathname: ::Pathname).returns(::CodeOwnership::Private::ParseJsPackages::Package) }
242
+ def from(pathname); end
243
+
244
+ def inherited(s); end
245
+ end
246
+ end
247
+
248
+ CodeOwnership::Private::ParseJsPackages::ROOT_PACKAGE_NAME = T.let(T.unsafe(nil), String)
249
+ module CodeOwnership::Private::TeamPlugins; end
250
+
251
+ class CodeOwnership::Private::TeamPlugins::Github < ::CodeTeams::Plugin
252
+ sig { returns(::CodeOwnership::Private::TeamPlugins::Github::GithubStruct) }
253
+ def github; end
254
+ end
255
+
256
+ class CodeOwnership::Private::TeamPlugins::Github::GithubStruct < ::Struct
257
+ def do_not_add_to_codeowners_file; end
258
+ def do_not_add_to_codeowners_file=(_); end
259
+ def team; end
260
+ def team=(_); end
261
+
262
+ class << self
263
+ def [](*_arg0); end
264
+ def inspect; end
265
+ def members; end
266
+ def new(*_arg0); end
267
+ end
268
+ end
269
+
270
+ class CodeOwnership::Private::TeamPlugins::Ownership < ::CodeTeams::Plugin
271
+ sig { returns(T::Array[::String]) }
272
+ def owned_globs; end
273
+ end
274
+
275
+ module CodeOwnership::Private::Validations; end
276
+
277
+ class CodeOwnership::Private::Validations::FilesHaveOwners
278
+ include ::CodeOwnership::Private::Validations::Interface
279
+
280
+ sig do
281
+ override
282
+ .params(
283
+ files: T::Array[::String],
284
+ autocorrect: T::Boolean,
285
+ stage_changes: T::Boolean
286
+ ).returns(T::Array[::String])
287
+ end
288
+ def validation_errors(files:, autocorrect: T.unsafe(nil), stage_changes: T.unsafe(nil)); end
289
+ end
290
+
291
+ class CodeOwnership::Private::Validations::FilesHaveUniqueOwners
292
+ include ::CodeOwnership::Private::Validations::Interface
293
+
294
+ sig do
295
+ override
296
+ .params(
297
+ files: T::Array[::String],
298
+ autocorrect: T::Boolean,
299
+ stage_changes: T::Boolean
300
+ ).returns(T::Array[::String])
301
+ end
302
+ def validation_errors(files:, autocorrect: T.unsafe(nil), stage_changes: T.unsafe(nil)); end
303
+ end
304
+
305
+ class CodeOwnership::Private::Validations::GithubCodeownersUpToDate
306
+ include ::CodeOwnership::Private::Validations::Interface
307
+
308
+ sig do
309
+ override
310
+ .params(
311
+ files: T::Array[::String],
312
+ autocorrect: T::Boolean,
313
+ stage_changes: T::Boolean
314
+ ).returns(T::Array[::String])
315
+ end
316
+ def validation_errors(files:, autocorrect: T.unsafe(nil), stage_changes: T.unsafe(nil)); end
317
+
318
+ private
319
+
320
+ sig { returns(T::Array[::String]) }
321
+ def codeowners_file_lines; end
322
+ end
323
+
324
+ module CodeOwnership::Private::Validations::Interface
325
+ interface!
326
+
327
+ sig do
328
+ abstract
329
+ .params(
330
+ files: T::Array[::String],
331
+ autocorrect: T::Boolean,
332
+ stage_changes: T::Boolean
333
+ ).returns(T::Array[::String])
334
+ end
335
+ def validation_errors(files:, autocorrect: T.unsafe(nil), stage_changes: T.unsafe(nil)); end
336
+ end
@@ -0,0 +1,120 @@
1
+ # typed: true
2
+
3
+ # DO NOT EDIT MANUALLY
4
+ # This is an autogenerated file for types exported from the `code_teams` gem.
5
+ # Please instead update this file by running `bin/tapioca gem code_teams`.
6
+
7
+ module CodeTeams
8
+ class << self
9
+ sig { returns(T::Array[::CodeTeams::Team]) }
10
+ def all; end
11
+
12
+ sig { void }
13
+ def bust_caches!; end
14
+
15
+ sig { params(name: ::String).returns(T.nilable(::CodeTeams::Team)) }
16
+ def find(name); end
17
+
18
+ sig { params(dir: ::String).returns(T::Array[::CodeTeams::Team]) }
19
+ def for_directory(dir); end
20
+
21
+ sig { params(string: ::String).returns(::String) }
22
+ def tag_value_for(string); end
23
+
24
+ sig { params(teams: T::Array[::CodeTeams::Team]).returns(T::Array[::String]) }
25
+ def validation_errors(teams); end
26
+ end
27
+ end
28
+
29
+ class CodeTeams::IncorrectPublicApiUsageError < ::StandardError; end
30
+
31
+ class CodeTeams::Plugin
32
+ abstract!
33
+
34
+ sig { params(team: ::CodeTeams::Team).void }
35
+ def initialize(team); end
36
+
37
+ class << self
38
+ sig { returns(T::Array[T.class_of(CodeTeams::Plugin)]) }
39
+ def all_plugins; end
40
+
41
+ sig { params(team: ::CodeTeams::Team).returns(T.attached_class) }
42
+ def for(team); end
43
+
44
+ sig { params(base: T.untyped).void }
45
+ def inherited(base); end
46
+
47
+ sig { params(team: ::CodeTeams::Team, key: ::String).returns(::String) }
48
+ def missing_key_error_message(team, key); end
49
+
50
+ sig { params(teams: T::Array[::CodeTeams::Team]).returns(T::Array[::String]) }
51
+ def validation_errors(teams); end
52
+
53
+ private
54
+
55
+ sig { params(team: ::CodeTeams::Team).returns(T.attached_class) }
56
+ def register_team(team); end
57
+
58
+ sig { returns(T::Hash[T.nilable(::String), T::Hash[::Class, ::CodeTeams::Plugin]]) }
59
+ def registry; end
60
+ end
61
+ end
62
+
63
+ module CodeTeams::Plugins; end
64
+
65
+ class CodeTeams::Plugins::Identity < ::CodeTeams::Plugin
66
+ sig { returns(::CodeTeams::Plugins::Identity::IdentityStruct) }
67
+ def identity; end
68
+
69
+ class << self
70
+ sig { override.params(teams: T::Array[::CodeTeams::Team]).returns(T::Array[::String]) }
71
+ def validation_errors(teams); end
72
+ end
73
+ end
74
+
75
+ class CodeTeams::Plugins::Identity::IdentityStruct < ::Struct
76
+ def name; end
77
+ def name=(_); end
78
+
79
+ class << self
80
+ def [](*_arg0); end
81
+ def inspect; end
82
+ def members; end
83
+ def new(*_arg0); end
84
+ end
85
+ end
86
+
87
+ class CodeTeams::Team
88
+ sig { params(config_yml: T.nilable(::String), raw_hash: T::Hash[T.untyped, T.untyped]).void }
89
+ def initialize(config_yml:, raw_hash:); end
90
+
91
+ sig { params(other: ::Object).returns(T::Boolean) }
92
+ def ==(other); end
93
+
94
+ sig { returns(T.nilable(::String)) }
95
+ def config_yml; end
96
+
97
+ def eql?(*args, &blk); end
98
+
99
+ sig { returns(::Integer) }
100
+ def hash; end
101
+
102
+ sig { returns(::String) }
103
+ def name; end
104
+
105
+ sig { returns(T::Hash[T.untyped, T.untyped]) }
106
+ def raw_hash; end
107
+
108
+ sig { returns(::String) }
109
+ def to_tag; end
110
+
111
+ class << self
112
+ sig { params(raw_hash: T::Hash[T.untyped, T.untyped]).returns(::CodeTeams::Team) }
113
+ def from_hash(raw_hash); end
114
+
115
+ sig { params(config_yml: ::String).returns(::CodeTeams::Team) }
116
+ def from_yml(config_yml); end
117
+ end
118
+ end
119
+
120
+ CodeTeams::UNKNOWN_TEAM_STRING = T.let(T.unsafe(nil), String)
metadata CHANGED
@@ -1,15 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: danger-packwerk
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.1
4
+ version: 0.8.0
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-10-20 00:00:00.000000000 Z
11
+ date: 2022-12-13 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: code_ownership
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
13
27
  - !ruby/object:Gem::Dependency
14
28
  name: danger-plugin-api
15
29
  requirement: !ruby/object:Gem::Requirement
@@ -188,12 +202,16 @@ files:
188
202
  - README.md
189
203
  - lib/danger-packwerk.rb
190
204
  - lib/danger-packwerk/basic_reference_offense.rb
205
+ - lib/danger-packwerk/check/default_formatter.rb
206
+ - lib/danger-packwerk/check/offenses_formatter.rb
191
207
  - lib/danger-packwerk/danger_deprecated_references_yml_changes.rb
192
208
  - lib/danger-packwerk/danger_packwerk.rb
193
209
  - lib/danger-packwerk/packwerk_wrapper.rb
194
210
  - lib/danger-packwerk/private.rb
195
- - lib/danger-packwerk/private/default_offenses_formatter.rb
196
211
  - lib/danger-packwerk/private/deprecated_references.rb
212
+ - lib/danger-packwerk/private/ownership_information.rb
213
+ - lib/danger-packwerk/update/default_formatter.rb
214
+ - lib/danger-packwerk/update/offenses_formatter.rb
197
215
  - lib/danger-packwerk/version.rb
198
216
  - lib/danger-packwerk/violation_diff.rb
199
217
  - lib/danger_plugin.rb
@@ -206,6 +224,8 @@ files:
206
224
  - sorbet/rbi/gems/builder@3.2.4.rbi
207
225
  - sorbet/rbi/gems/claide-plugins@0.9.2.rbi
208
226
  - sorbet/rbi/gems/claide@1.1.0.rbi
227
+ - sorbet/rbi/gems/code_ownership@1.29.1.rbi
228
+ - sorbet/rbi/gems/code_teams@1.0.0.rbi
209
229
  - sorbet/rbi/gems/coderay@1.1.3.rbi
210
230
  - sorbet/rbi/gems/colored2@3.1.2.rbi
211
231
  - sorbet/rbi/gems/concurrent-ruby@1.1.10.rbi
@@ -230,7 +250,6 @@ files:
230
250
  - sorbet/rbi/gems/faraday@1.10.2.rbi
231
251
  - sorbet/rbi/gems/git@1.12.0.rbi
232
252
  - sorbet/rbi/gems/i18n@1.12.0.rbi
233
- - sorbet/rbi/gems/json@2.6.2.rbi
234
253
  - sorbet/rbi/gems/kramdown-parser-gfm@1.1.0.rbi
235
254
  - sorbet/rbi/gems/kramdown@2.4.0.rbi
236
255
  - sorbet/rbi/gems/loofah@2.19.0.rbi
@@ -1,37 +0,0 @@
1
- # typed: strict
2
-
3
- module DangerPackwerk
4
- module Private
5
- class DefaultAddedOffensesFormatter
6
- extend T::Sig
7
-
8
- sig { params(violations: T::Array[BasicReferenceOffense]).returns(String) }
9
- def self.format(violations)
10
- violation = T.must(violations.first)
11
- # We remove leading double colons as they feel like an implementation detail of packwerk.
12
- constant_name = violation.class_name.gsub(/\A::/, '')
13
- link_to_docs = '[the docs](https://github.com/Shopify/packwerk/blob/b647594f93c8922c038255a7aaca125d391a1fbf/docs/new_violation_flow_chart.pdf)'
14
- disclaimer = "We noticed you ran `bin/packwerk update-deprecations`. Make sure to read through #{link_to_docs} for other ways to resolve. "
15
- pluralized_violation = violations.count > 1 ? 'these violations' : 'this violation'
16
- request_to_add_context = "Could you add some context as a reply here about why we needed to add #{pluralized_violation}?"
17
-
18
- if violations.any?(&:dependency?) && violations.any?(&:privacy?)
19
- <<~MESSAGE
20
- Hi! It looks like the pack defining `#{constant_name}` considers this private API, and it's also not in the referencing pack's list of dependencies.
21
- #{disclaimer}#{request_to_add_context}
22
- MESSAGE
23
- elsif violations.any?(&:dependency?)
24
- <<~MESSAGE
25
- Hi! It looks like the pack defining `#{constant_name}` is not in the referencing pack's list of dependencies.
26
- #{disclaimer}#{request_to_add_context}
27
- MESSAGE
28
- else # violations.any?(&:privacy?)
29
- <<~MESSAGE
30
- Hi! It looks like the pack defining `#{constant_name}` considers this private API.
31
- #{disclaimer}#{request_to_add_context}
32
- MESSAGE
33
- end
34
- end
35
- end
36
- end
37
- end