danger-packwerk 0.5.0 → 0.6.0

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: ed0f4ec91fc454370224df9823a43b198bbb3172fa996ac426975bf28d5e5cd8
4
- data.tar.gz: '0398f5c8ed12c82a0ed23b32e055463bac58a9797800c5aac1f115afa8bf811a'
3
+ metadata.gz: 3338a7622d64fc169f9ef273873bc11002ff56ba3d66b225189f0dc1bd6b6cf9
4
+ data.tar.gz: 58cb63b3956cf29245575e8be453280c33041b3ce15579c2102d07819c836c26
5
5
  SHA512:
6
- metadata.gz: 1b20096b8a326a153832e24d73ddf4beab32220c65b035d44ca6ac2baa8f0bb043bcacba294e710c1000934d936410f59f61a7547fe304edd094cfb26f32fbc0
7
- data.tar.gz: e1948eab25e12d87c03ef56054c8a981ca6e92ded648f05b0c38b28495d12ac5808cf6c453949f4f3d453ae79862bf5acb740e974f1146fac383144d41d59469
6
+ metadata.gz: 31aab3fcdb5c3bb7837214ac46fae8807fcfa9727d9a3d21a4d371c8c8de4db688c13ff486e7e9660ec552f7aa39cbd1c622338e8b88ae087f226362804e8097
7
+ data.tar.gz: fba5ddd5b2d9ed86b3173b1aca8562ba523dcd74c974d45570edc07853ac5c4819bf3c64956ca10a037b800db056853cb38097ce422fa79eb2983ab297ea9890
@@ -45,7 +45,8 @@ module DangerPackwerk
45
45
  def self.from(deprecated_references_yml)
46
46
  deprecated_references_yml_pathname = Pathname.new(deprecated_references_yml)
47
47
 
48
- from_package_name = T.must(ParsePackwerk.package_from_path(deprecated_references_yml_pathname)).name
48
+ from_package = ParsePackwerk.package_from_path(deprecated_references_yml_pathname)
49
+ from_package_name = from_package.name
49
50
  violations = Private::DeprecatedReferences.from(deprecated_references_yml_pathname).violations
50
51
 
51
52
  # See the larger comment below for more information on why we need this information.
@@ -45,14 +45,7 @@ module DangerPackwerk
45
45
 
46
46
  current_comment_count = 0
47
47
 
48
- # The format for git.renamed_files is a T::Array[{after: "some/path/new", before: "some/path/old"}]
49
- renamed_files = git.renamed_files.map { |before_after_file| before_after_file[:after] }
50
-
51
- violations_to_comment_on = violation_diff.added_violations.reject do |violation|
52
- renamed_files.include?(violation.file)
53
- end
54
-
55
- violations_to_comment_on.group_by(&:class_name).each do |_class_name, violations|
48
+ violation_diff.added_violations.group_by(&:class_name).each do |_class_name, violations|
56
49
  break if current_comment_count >= max_comments
57
50
 
58
51
  location = T.must(violations.first).file_location
@@ -92,8 +85,36 @@ module DangerPackwerk
92
85
  removed_violations += base_commit_violations - head_commit_violations
93
86
  end
94
87
 
88
+ # The format for git.renamed_files is a T::Array[{after: "some/path/new", before: "some/path/old"}]
89
+ renamed_files = git.renamed_files.map { |before_after_file| before_after_file[:after] }
90
+
91
+ #
92
+ # This implementation creates some false negatives:
93
+ # That is – it doesn't capture some cases:
94
+ # 1) A file has been renamed without renaming a constant.
95
+ # That can happen if we change only the autoloaded portion of a filename.
96
+ # For example: `packs/foo/app/services/my_class.rb` (defines: `MyClass`)
97
+ # is changed to `packs/foo/app/public/my_class.rb` (still defines: `MyClass`)
98
+ #
99
+ # This implementation also doesn't cover these false positives:
100
+ # That is – it leaves a comment when it should not.
101
+ # 1) A CONSTANT within a class or module has been renamed.
102
+ # e.g. `class MyClass; MY_CONSTANT = 1; end` becomes `class MyClass; RENAMED_CONSTANT = 1; end`
103
+ # We would not detect based on file renames that `MY_CONSTANT` has been renamed.
104
+ #
105
+ renamed_constants = []
106
+
107
+ added_violations.each do |violation|
108
+ filepath_that_defines_this_constant = Private.constant_resolver.resolve(violation.class_name)&.location
109
+ renamed_constants << violation.class_name if renamed_files.include?(filepath_that_defines_this_constant)
110
+ end
111
+
112
+ relevant_added_violations = added_violations.reject do |violation|
113
+ renamed_files.include?(violation.file) || renamed_constants.include?(violation.class_name)
114
+ end
115
+
95
116
  ViolationDiff.new(
96
- added_violations: added_violations,
117
+ added_violations: relevant_added_violations,
97
118
  removed_violations: removed_violations
98
119
  )
99
120
  end
@@ -84,14 +84,23 @@ module DangerPackwerk
84
84
 
85
85
  packwerk_reference_offenses = PackwerkWrapper.get_offenses_for_files(targeted_files.to_a).compact
86
86
 
87
+ renamed_files = git.renamed_files.map { |before_after_file| before_after_file[:after] }
88
+
89
+ # Ignore references that have been renamed
90
+ packwerk_reference_offenses_to_care_about = packwerk_reference_offenses.reject do |packwerk_reference_offense|
91
+ constant_name = packwerk_reference_offense.reference.constant.name
92
+ filepath_that_defines_this_constant = Private.constant_resolver.resolve(constant_name)&.location
93
+ renamed_files.include?(filepath_that_defines_this_constant)
94
+ end
95
+
87
96
  # We group by the constant name, line number, and reference path. Any offenses with these same values should only differ on what type of violation
88
97
  # they are (privacy or dependency). We put privacy and dependency violation messages in the same comment since they would occur on the same line.
89
- packwerk_reference_offenses.group_by do |packwerk_reference_offense|
98
+ packwerk_reference_offenses_to_care_about.group_by do |packwerk_reference_offense|
90
99
  case grouping_strategy
91
100
  when CommentGroupingStrategy::PerConstantPerLocation
92
101
  [
93
102
  packwerk_reference_offense.reference.constant.name,
94
- packwerk_reference_offense.location.line,
103
+ packwerk_reference_offense.location&.line,
95
104
  packwerk_reference_offense.reference.relative_path
96
105
  ]
97
106
  when CommentGroupingStrategy::PerConstantPerPack
@@ -108,7 +117,7 @@ module DangerPackwerk
108
117
  current_comment_count += 1
109
118
 
110
119
  reference_offense = T.must(unique_packwerk_reference_offenses.first)
111
- line_number = reference_offense.location.line
120
+ line_number = reference_offense.location&.line
112
121
  referencing_file = reference_offense.reference.relative_path
113
122
 
114
123
  message = offenses_formatter.call(unique_packwerk_reference_offenses)
@@ -1,13 +1,27 @@
1
- # typed: strong
1
+ # typed: strict
2
2
 
3
3
  require 'danger-packwerk/private/deprecated_references'
4
4
  require 'danger-packwerk/private/default_offenses_formatter'
5
+ require 'constant_resolver'
5
6
 
6
7
  module DangerPackwerk
7
8
  #
8
9
  # Anything within the Private module is subject to change.
9
10
  #
10
11
  module Private
12
+ extend T::Sig
13
+
14
+ sig { returns(ConstantResolver) }
15
+ def self.constant_resolver
16
+ @constant_resolver = T.let(@constant_resolver, T.nilable(ConstantResolver))
17
+ @constant_resolver ||= begin
18
+ load_paths = Packwerk::ApplicationLoadPaths.extract_relevant_paths(Dir.pwd, 'test')
19
+ ConstantResolver.new(
20
+ root_path: Dir.pwd,
21
+ load_paths: T.unsafe(load_paths).keys
22
+ )
23
+ end
24
+ end
11
25
  end
12
26
 
13
27
  private_constant :Private
@@ -2,5 +2,5 @@
2
2
  # frozen_string_literal: true
3
3
 
4
4
  module DangerPackwerk
5
- VERSION = '0.5.0'
5
+ VERSION = '0.6.0'
6
6
  end
@@ -0,0 +1,30 @@
1
+ # typed: true
2
+
3
+ # DO NOT EDIT MANUALLY
4
+ # This is an autogenerated file for types exported from the `constant_resolver` gem.
5
+ # Please instead update this file by running `bin/tapioca gem constant_resolver`.
6
+
7
+ class ConstantResolver
8
+ def initialize(root_path:, load_paths:, inflector: T.unsafe(nil)); end
9
+
10
+ def config; end
11
+ def file_map; end
12
+ def resolve(const_name, current_namespace_path: T.unsafe(nil)); end
13
+
14
+ private
15
+
16
+ def ambiguous_constant_message(const_name, paths); end
17
+ def coerce_load_paths(load_paths); end
18
+ def glob_path(path); end
19
+ def resolve_constant(const_name, current_namespace_path, original_name: T.unsafe(nil)); end
20
+ def resolve_traversing_namespace_path(const_name, current_namespace_path); end
21
+ end
22
+
23
+ class ConstantResolver::ConstantContext < ::Struct; end
24
+
25
+ class ConstantResolver::DefaultInflector
26
+ def camelize(string); end
27
+ end
28
+
29
+ class ConstantResolver::Error < ::StandardError; end
30
+ ConstantResolver::VERSION = T.let(T.unsafe(nil), String)
@@ -38,60 +38,153 @@ module Packwerk::ApplicationLoadPaths
38
38
  end
39
39
 
40
40
  class Packwerk::ApplicationValidator
41
+ sig { params(config_file_path: ::String, configuration: ::Packwerk::Configuration, environment: ::String).void }
41
42
  def initialize(config_file_path:, configuration:, environment:); end
42
43
 
44
+ sig { returns(::Packwerk::ApplicationValidator::Result) }
43
45
  def check_acyclic_graph; end
46
+
47
+ sig { returns(::Packwerk::ApplicationValidator::Result) }
44
48
  def check_all; end
49
+
50
+ sig { returns(::Packwerk::ApplicationValidator::Result) }
45
51
  def check_application_structure; end
46
- def check_autoload_path_cache; end
47
- def check_inflection_file; end
52
+
53
+ sig { returns(::Packwerk::ApplicationValidator::Result) }
48
54
  def check_package_manifest_paths; end
55
+
56
+ sig { returns(::Packwerk::ApplicationValidator::Result) }
49
57
  def check_package_manifest_syntax; end
58
+
59
+ sig { returns(::Packwerk::ApplicationValidator::Result) }
50
60
  def check_package_manifests_for_privacy; end
61
+
62
+ sig { returns(::Packwerk::ApplicationValidator::Result) }
51
63
  def check_root_package_exists; end
64
+
65
+ sig { returns(::Packwerk::ApplicationValidator::Result) }
52
66
  def check_valid_package_dependencies; end
53
67
 
54
68
  private
55
69
 
56
- def assert_constants_can_be_loaded(constants); end
70
+ sig do
71
+ params(
72
+ constants: T.untyped,
73
+ config_file_path: ::String
74
+ ).returns(T::Array[::Packwerk::ApplicationValidator::Result])
75
+ end
76
+ def assert_constants_can_be_loaded(constants, config_file_path); end
77
+
78
+ sig { params(cycles: T.untyped).returns(T::Array[::String]) }
57
79
  def build_cycle_strings(cycles); end
80
+
81
+ sig do
82
+ params(
83
+ name: T.untyped,
84
+ location: T.untyped,
85
+ config_file_path: T.untyped
86
+ ).returns(::Packwerk::ApplicationValidator::Result)
87
+ end
58
88
  def check_private_constant_location(name, location, config_file_path); end
89
+
90
+ sig { params(list: T.untyped).returns(T.untyped) }
59
91
  def format_yaml_strings(list); end
92
+
93
+ sig { params(path: T.untyped).returns(T::Boolean) }
60
94
  def invalid_package_path?(path); end
95
+
96
+ sig do
97
+ params(
98
+ results: T::Array[::Packwerk::ApplicationValidator::Result],
99
+ separator: ::String,
100
+ errors_headline: ::String
101
+ ).returns(::Packwerk::ApplicationValidator::Result)
102
+ end
61
103
  def merge_results(results, separator: T.unsafe(nil), errors_headline: T.unsafe(nil)); end
104
+
105
+ sig { returns(T.any(::String, T::Array[::String])) }
62
106
  def package_glob; end
107
+
108
+ sig { params(glob_pattern: T.any(::String, T::Array[::String])).returns(T::Array[::String]) }
63
109
  def package_manifests(glob_pattern = T.unsafe(nil)); end
110
+
111
+ sig { params(setting: T.untyped).returns(T.untyped) }
64
112
  def package_manifests_settings_for(setting); end
65
- def package_set; end
113
+
114
+ sig { params(name: T.untyped, config_file_path: T.untyped).returns(::Packwerk::ApplicationValidator::Result) }
66
115
  def private_constant_unresolvable(name, config_file_path); end
116
+
117
+ sig { params(path: ::String).returns(::Pathname) }
67
118
  def relative_path(path); end
119
+
120
+ sig { params(paths: T::Array[::String]).returns(T::Array[::Pathname]) }
68
121
  def relative_paths(paths); end
69
122
  end
70
123
 
71
- class Packwerk::ApplicationValidator::Result < ::Struct
72
- def error_value; end
73
- def error_value=(_); end
124
+ class Packwerk::ApplicationValidator::Result < ::T::Struct
125
+ const :error_value, T.nilable(::String)
126
+ const :ok, T::Boolean
127
+
128
+ sig { returns(T::Boolean) }
74
129
  def ok?; end
75
130
 
76
131
  class << self
77
- def [](*_arg0); end
78
- def inspect; end
79
- def members; end
80
- def new(*_arg0); end
132
+ def inherited(s); end
81
133
  end
82
134
  end
83
135
 
84
136
  Packwerk::AssociationInspector::CustomAssociations = T.type_alias { T.any(T::Array[::Symbol], T::Set[::Symbol]) }
85
137
  Packwerk::AssociationInspector::RAILS_ASSOCIATIONS = T.let(T.unsafe(nil), Set)
86
138
 
87
- module Packwerk::Checker
88
- interface!
139
+ class Packwerk::Cache
140
+ sig { params(enable_cache: T::Boolean, cache_directory: ::Pathname, config_path: T.nilable(::String)).void }
141
+ def initialize(enable_cache:, cache_directory:, config_path:); end
89
142
 
90
- sig { abstract.params(reference: ::Packwerk::Reference).returns(T::Boolean) }
91
- def invalid_reference?(reference); end
143
+ sig { void }
144
+ def bust_cache!; end
92
145
 
93
- sig { abstract.returns(::Packwerk::ViolationType) }
94
- def violation_type; end
146
+ sig { params(contents: ::String, contents_key: ::Symbol).void }
147
+ def bust_cache_if_contents_have_changed(contents, contents_key); end
148
+
149
+ sig { void }
150
+ def bust_cache_if_inflections_have_changed!; end
151
+
152
+ sig { void }
153
+ def bust_cache_if_packwerk_yml_has_changed!; end
154
+
155
+ sig { void }
156
+ def create_cache_directory!; end
157
+
158
+ sig { params(file: ::String).returns(::String) }
159
+ def digest_for_file(file); end
160
+
161
+ sig { params(str: ::String).returns(::String) }
162
+ def digest_for_string(str); end
163
+
164
+ sig do
165
+ params(
166
+ file_path: ::String,
167
+ block: T.proc.returns(T::Array[::Packwerk::UnresolvedReference])
168
+ ).returns(T::Array[::Packwerk::UnresolvedReference])
169
+ end
170
+ def with_cache(file_path, &block); end
171
+ end
172
+
173
+ Packwerk::Cache::CACHE_SHAPE = T.type_alias { T::Hash[::String, ::Packwerk::Cache::CacheContents] }
174
+
175
+ class Packwerk::Cache::CacheContents < ::T::Struct
176
+ const :file_contents_digest, ::String
177
+ const :unresolved_references, T::Array[::Packwerk::UnresolvedReference]
178
+
179
+ sig { returns(::String) }
180
+ def serialize; end
181
+
182
+ class << self
183
+ sig { params(serialized_cache_contents: ::String).returns(::Packwerk::Cache::CacheContents) }
184
+ def deserialize(serialized_cache_contents); end
185
+
186
+ def inherited(s); end
187
+ end
95
188
  end
96
189
 
97
190
  class Packwerk::Cli
@@ -115,24 +208,45 @@ class Packwerk::Cli
115
208
 
116
209
  private
117
210
 
118
- def fetch_files_to_process(paths); end
211
+ sig { returns(::Packwerk::ApplicationValidator) }
212
+ def checker; end
213
+
214
+ sig do
215
+ params(
216
+ relative_file_paths: T::Array[::String],
217
+ ignore_nested_packages: T::Boolean
218
+ ).returns(T::Array[::String])
219
+ end
220
+ def fetch_files_to_process(relative_file_paths, ignore_nested_packages); end
221
+
222
+ sig { returns(T::Boolean) }
119
223
  def generate_configs; end
224
+
225
+ sig { returns(T::Boolean) }
120
226
  def init; end
227
+
228
+ sig { params(result: ::Packwerk::ApplicationValidator::Result).void }
121
229
  def list_validation_errors(result); end
230
+
231
+ sig { params(result: ::Packwerk::Result).returns(T::Boolean) }
122
232
  def output_result(result); end
123
- def parse_run(paths); end
124
- def update(paths); end
233
+
234
+ sig { params(params: T.untyped).returns(::Packwerk::ParseRun) }
235
+ def parse_run(params); end
236
+
237
+ sig { params(_paths: T::Array[::String]).returns(T::Boolean) }
125
238
  def validate(_paths); end
126
239
  end
127
240
 
128
241
  class Packwerk::Configuration
129
242
  def initialize(configs = T.unsafe(nil), config_path: T.unsafe(nil)); end
130
243
 
244
+ def cache_directory; end
245
+ def cache_enabled?; end
131
246
  def config_path; end
132
247
  def custom_associations; end
133
248
  def exclude; end
134
249
  def include; end
135
- def inflections_file; end
136
250
  def load_paths; end
137
251
  def package_paths; end
138
252
  def parallel?; end
@@ -152,9 +266,18 @@ Packwerk::Configuration::DEFAULT_EXCLUDE_GLOBS = T.let(T.unsafe(nil), Array)
152
266
  Packwerk::Configuration::DEFAULT_INCLUDE_GLOBS = T.let(T.unsafe(nil), Array)
153
267
 
154
268
  class Packwerk::ConstantDiscovery
269
+ sig { params(constant_resolver: ::ConstantResolver, packages: Packwerk::PackageSet).void }
155
270
  def initialize(constant_resolver:, packages:); end
156
271
 
272
+ sig do
273
+ params(
274
+ const_name: ::String,
275
+ current_namespace_path: T.nilable(T::Array[::String])
276
+ ).returns(T.nilable(::Packwerk::ConstantDiscovery::ConstantContext))
277
+ end
157
278
  def context_for(const_name, current_namespace_path: T.unsafe(nil)); end
279
+
280
+ sig { params(path: ::String).returns(::Packwerk::Package) }
158
281
  def package_from_path(path); end
159
282
  end
160
283
 
@@ -175,14 +298,11 @@ class Packwerk::ConstantDiscovery::ConstantContext < ::Struct
175
298
  end
176
299
  end
177
300
 
178
- class Packwerk::DependencyChecker
179
- include ::Packwerk::Checker
180
-
181
- sig { override.params(reference: ::Packwerk::Reference).returns(T::Boolean) }
182
- def invalid_reference?(reference); end
183
-
184
- sig { override.returns(::Packwerk::ViolationType) }
185
- def violation_type; end
301
+ class Packwerk::Debug
302
+ class << self
303
+ sig { params(out: ::String).void }
304
+ def out(out); end
305
+ end
186
306
  end
187
307
 
188
308
  class Packwerk::DeprecatedReferences
@@ -203,41 +323,62 @@ class Packwerk::DeprecatedReferences
203
323
 
204
324
  private
205
325
 
206
- sig { returns(T::Hash[T.untyped, T.untyped]) }
326
+ sig { returns(T::Hash[::String, T.untyped]) }
207
327
  def deprecated_references; end
208
328
 
209
- sig { params(filepath: ::String).returns(T::Hash[T.untyped, T.untyped]) }
329
+ sig { params(filepath: ::String).returns(T::Hash[::String, T.untyped]) }
210
330
  def load_yaml(filepath); end
211
331
 
212
- sig { returns(T::Hash[T.untyped, T.untyped]) }
332
+ sig { returns(T::Hash[::String, T.untyped]) }
213
333
  def prepare_entries_for_dump; end
214
334
  end
215
335
 
216
- class Packwerk::FileProcessor
217
- def initialize(node_processor_factory:, parser_factory: T.unsafe(nil)); end
218
-
219
- def call(file_path); end
220
- end
336
+ Packwerk::DeprecatedReferences::ENTRIES_TYPE = T.type_alias { T::Hash[::String, T.untyped] }
221
337
 
222
338
  class Packwerk::FileProcessor::UnknownFileTypeResult < ::Packwerk::Offense
339
+ sig { params(file: ::String).void }
223
340
  def initialize(file:); end
224
341
  end
225
342
 
226
343
  class Packwerk::FilesForProcessing
227
- def initialize(paths, configuration); end
344
+ sig do
345
+ params(
346
+ relative_file_paths: T::Array[::String],
347
+ configuration: ::Packwerk::Configuration,
348
+ ignore_nested_packages: T::Boolean
349
+ ).void
350
+ end
351
+ def initialize(relative_file_paths, configuration, ignore_nested_packages); end
228
352
 
353
+ sig { returns(T::Array[::String]) }
229
354
  def files; end
230
355
 
231
356
  private
232
357
 
358
+ sig { params(relative_globs: T::Array[::String]).returns(T::Array[::String]) }
359
+ def absolute_files_for_globs(relative_globs); end
360
+
361
+ sig { returns(T::Array[::String]) }
233
362
  def configured_excluded_files; end
363
+
364
+ sig { returns(T::Array[::String]) }
234
365
  def configured_included_files; end
366
+
367
+ sig { returns(T::Array[::String]) }
235
368
  def custom_files; end
236
- def custom_included_files(path); end
237
- def files_for_globs(globs); end
369
+
370
+ sig { params(absolute_file_path: ::String).returns(T::Array[::String]) }
371
+ def custom_included_files(absolute_file_path); end
238
372
 
239
373
  class << self
240
- def fetch(paths:, configuration:); end
374
+ sig do
375
+ params(
376
+ relative_file_paths: T::Array[::String],
377
+ configuration: ::Packwerk::Configuration,
378
+ ignore_nested_packages: T::Boolean
379
+ ).returns(T::Array[::String])
380
+ end
381
+ def fetch(relative_file_paths:, configuration:, ignore_nested_packages: T.unsafe(nil)); end
241
382
  end
242
383
  end
243
384
 
@@ -281,8 +422,8 @@ module Packwerk::Generators
281
422
  end
282
423
 
283
424
  class Packwerk::Generators::ConfigurationFile
284
- sig { params(load_paths: T::Array[::String], root: ::String, out: T.any(::IO, ::StringIO)).void }
285
- def initialize(load_paths:, root:, out: T.unsafe(nil)); end
425
+ sig { params(root: ::String, out: T.any(::IO, ::StringIO)).void }
426
+ def initialize(root:, out: T.unsafe(nil)); end
286
427
 
287
428
  sig { returns(T::Boolean) }
288
429
  def generate; end
@@ -290,27 +431,15 @@ class Packwerk::Generators::ConfigurationFile
290
431
  private
291
432
 
292
433
  def render; end
293
- def set_template_variables; end
294
434
  def template; end
295
435
 
296
436
  class << self
297
- def generate(load_paths:, root:, out:); end
437
+ def generate(root:, out:); end
298
438
  end
299
439
  end
300
440
 
301
441
  Packwerk::Generators::ConfigurationFile::CONFIGURATION_TEMPLATE_FILE_PATH = T.let(T.unsafe(nil), String)
302
442
 
303
- class Packwerk::Generators::InflectionsFile
304
- def initialize(root, out: T.unsafe(nil)); end
305
-
306
- sig { returns(T::Boolean) }
307
- def generate; end
308
-
309
- class << self
310
- def generate(root:, out:); end
311
- end
312
- end
313
-
314
443
  class Packwerk::Generators::RootPackage
315
444
  def initialize(root:, out: T.unsafe(nil)); end
316
445
 
@@ -337,77 +466,7 @@ class Packwerk::Graph
337
466
  def visit(node, visited_nodes: T.unsafe(nil), path: T.unsafe(nil)); end
338
467
  end
339
468
 
340
- module Packwerk::Inflections
341
- end
342
-
343
- class Packwerk::Inflections::Custom
344
- def initialize(custom_inflection_file = T.unsafe(nil)); end
345
-
346
- def apply_to(inflections_object); end
347
- def inflections; end
348
- def inflections=(_arg0); end
349
- end
350
-
351
- Packwerk::Inflections::Custom::SUPPORTED_INFLECTION_METHODS = T.let(T.unsafe(nil), Array)
352
-
353
- module Packwerk::Inflections::Default
354
- class << self
355
- def apply_to(inflections_object); end
356
- end
357
- end
358
-
359
- class Packwerk::Inflector
360
- sig { params(custom_inflector: ::Packwerk::Inflections::Custom).void }
361
- def initialize(custom_inflector:); end
362
-
363
- def inflections(_ = T.unsafe(nil)); end
364
- def pluralize(word, count = T.unsafe(nil)); end
365
-
366
- class << self
367
- def default; end
368
-
369
- sig { params(inflections_file: ::String).returns(::Packwerk::Inflector) }
370
- def from_file(inflections_file); end
371
- end
372
- end
373
-
374
469
  module Packwerk::Node
375
- class << self
376
- def class?(node); end
377
- def class_or_module_name(class_or_module_node); end
378
- def constant?(node); end
379
- def constant_assignment?(node); end
380
- def constant_name(constant_node); end
381
- def each_child(node); end
382
- def enclosing_namespace_path(starting_node, ancestors:); end
383
- def hash?(node); end
384
- def literal_value(string_or_symbol_node); end
385
- def location(node); end
386
- def method_arguments(method_call_node); end
387
- def method_call?(node); end
388
- def method_name(method_call_node); end
389
- def module_name_from_definition(node); end
390
- def name_location(node); end
391
- def parent_class(class_node); end
392
-
393
- def parent_module_name(ancestors:); end
394
-
395
- def string?(node); end
396
- def symbol?(node); end
397
- def value_from_hash(hash_node, key); end
398
-
399
- private
400
-
401
- def hash_pair_key(hash_pair_node); end
402
- def hash_pair_value(hash_pair_node); end
403
- def hash_pairs(hash_node); end
404
- def method_call_node(block_node); end
405
- def module_creation?(node); end
406
- def name_from_block_definition(node); end
407
- def name_part_from_definition(node); end
408
- def receiver(method_call_or_block_node); end
409
- def type_of(node); end
410
- end
411
470
  end
412
471
 
413
472
  class Packwerk::Node::Location < ::Struct
@@ -426,7 +485,11 @@ end
426
485
 
427
486
  class Packwerk::Node::TypeError < ::ArgumentError; end
428
487
 
488
+ class Packwerk::NodeProcessor
489
+ end
490
+
429
491
  class Packwerk::NodeVisitor
492
+ sig { params(node_processor: ::Packwerk::NodeProcessor).void }
430
493
  def initialize(node_processor:); end
431
494
 
432
495
  def visit(node, ancestors:, result:); end
@@ -436,8 +499,13 @@ class Packwerk::Offense
436
499
  sig { params(file: ::String, message: ::String, location: T.nilable(::Packwerk::Node::Location)).void }
437
500
  def initialize(file:, message:, location: T.unsafe(nil)); end
438
501
 
502
+ sig { returns(::String) }
439
503
  def file; end
504
+
505
+ sig { returns(T.nilable(::Packwerk::Node::Location)) }
440
506
  def location; end
507
+
508
+ sig { returns(::String) }
441
509
  def message; end
442
510
 
443
511
  sig { params(style: ::Packwerk::OutputStyle).returns(::String) }
@@ -538,61 +606,143 @@ end
538
606
  class Packwerk::Package
539
607
  include ::Comparable
540
608
 
609
+ sig { params(name: ::String, config: T.nilable(T.any(::FalseClass, T::Hash[T.untyped, T.untyped]))).void }
541
610
  def initialize(name:, config:); end
542
611
 
612
+ sig { params(other: T.untyped).returns(T.nilable(::Integer)) }
543
613
  def <=>(other); end
614
+
615
+ sig { returns(T::Array[::String]) }
544
616
  def dependencies; end
617
+
618
+ sig { params(package: ::Packwerk::Package).returns(T::Boolean) }
545
619
  def dependency?(package); end
620
+
621
+ sig { returns(T::Boolean) }
546
622
  def enforce_dependencies?; end
623
+
624
+ sig { returns(T.nilable(T.any(T::Array[::String], T::Boolean))) }
547
625
  def enforce_privacy; end
626
+
627
+ sig { params(other: T.untyped).returns(T::Boolean) }
548
628
  def eql?(other); end
629
+
630
+ sig { returns(::Integer) }
549
631
  def hash; end
632
+
633
+ sig { returns(::String) }
550
634
  def name; end
635
+
636
+ sig { params(path: ::String).returns(T::Boolean) }
551
637
  def package_path?(path); end
638
+
639
+ sig { returns(::String) }
552
640
  def public_path; end
641
+
642
+ sig { params(path: ::String).returns(T::Boolean) }
553
643
  def public_path?(path); end
644
+
645
+ sig { returns(T::Boolean) }
554
646
  def root?; end
647
+
648
+ sig { returns(::String) }
555
649
  def to_s; end
650
+
651
+ sig { returns(T.nilable(::String)) }
556
652
  def user_defined_public_path; end
557
653
  end
558
654
 
559
655
  Packwerk::Package::ROOT_PACKAGE_NAME = T.let(T.unsafe(nil), String)
560
656
 
561
657
  class Packwerk::PackageSet
658
+ extend T::Generic
562
659
  include ::Enumerable
563
660
 
661
+ Elem = type_member(fixed: Packwerk::Package)
662
+
663
+ sig { params(packages: T::Array[::Packwerk::Package]).void }
564
664
  def initialize(packages); end
565
665
 
666
+ sig { override.params(blk: T.proc.params(arg0: ::Packwerk::Package).returns(T.untyped)).returns(T.untyped) }
566
667
  def each(&blk); end
668
+
669
+ sig { params(name: ::String).returns(T.nilable(::Packwerk::Package)) }
567
670
  def fetch(name); end
671
+
672
+ sig { params(file_path: T.any(::Pathname, ::String)).returns(::Packwerk::Package) }
568
673
  def package_from_path(file_path); end
569
674
 
675
+ sig { returns(T::Hash[::String, ::Packwerk::Package]) }
676
+ def packages; end
677
+
570
678
  class << self
679
+ sig do
680
+ params(
681
+ root_path: ::String,
682
+ package_pathspec: T.nilable(T.any(::String, T::Array[::String]))
683
+ ).returns(Packwerk::PackageSet)
684
+ end
571
685
  def load_all_from(root_path, package_pathspec: T.unsafe(nil)); end
572
- def package_paths(root_path, package_pathspec); end
686
+
687
+ sig do
688
+ params(
689
+ root_path: ::String,
690
+ package_pathspec: T.any(::String, T::Array[::String]),
691
+ exclude_pathspec: T.nilable(T.any(::String, T::Array[::String]))
692
+ ).returns(T::Array[::Pathname])
693
+ end
694
+ def package_paths(root_path, package_pathspec, exclude_pathspec = T.unsafe(nil)); end
573
695
 
574
696
  private
575
697
 
698
+ sig { params(packages: T::Array[::Packwerk::Package]).void }
576
699
  def create_root_package_if_none_in(packages); end
700
+
701
+ sig { params(globs: T::Array[::String], path: ::Pathname).returns(T::Boolean) }
702
+ def exclude_path?(globs, path); end
577
703
  end
578
704
  end
579
705
 
580
706
  Packwerk::PackageSet::PACKAGE_CONFIG_FILENAME = T.let(T.unsafe(nil), String)
581
707
 
582
708
  class Packwerk::ParseRun
583
- def initialize(files:, configuration:, progress_formatter: T.unsafe(nil), offenses_formatter: T.unsafe(nil)); end
709
+ sig do
710
+ params(
711
+ absolute_files: T::Array[::String],
712
+ configuration: ::Packwerk::Configuration,
713
+ progress_formatter: ::Packwerk::Formatters::ProgressFormatter,
714
+ offenses_formatter: ::Packwerk::OffensesFormatter
715
+ ).void
716
+ end
717
+ def initialize(absolute_files:, configuration:, progress_formatter: T.unsafe(nil), offenses_formatter: T.unsafe(nil)); end
584
718
 
719
+ sig { returns(::Packwerk::Result) }
585
720
  def check; end
721
+
722
+ sig { returns(::Packwerk::Result) }
586
723
  def detect_stale_violations; end
724
+
725
+ sig { returns(::Packwerk::Result) }
587
726
  def update_deprecations; end
588
727
 
589
728
  private
590
729
 
730
+ sig { params(show_errors: T::Boolean).returns(::Packwerk::OffenseCollection) }
591
731
  def find_offenses(show_errors: T.unsafe(nil)); end
592
- def serial_find_offenses; end
732
+
733
+ sig do
734
+ params(
735
+ block: T.proc.params(path: ::String).returns(T::Array[::Packwerk::Offense])
736
+ ).returns(T::Array[::Packwerk::Offense])
737
+ end
738
+ def serial_find_offenses(&block); end
739
+
740
+ sig { params(failed: T::Boolean).void }
593
741
  def update_progress(failed: T.unsafe(nil)); end
594
742
  end
595
743
 
744
+ Packwerk::ParseRun::ProcessFileProc = T.type_alias { T.proc.params(path: ::String).returns(T::Array[::Packwerk::Offense]) }
745
+
596
746
  class Packwerk::ParsedConstantDefinitions
597
747
  def initialize(root_node:); end
598
748
 
@@ -610,12 +760,28 @@ end
610
760
 
611
761
  module Packwerk::Parsers; end
612
762
 
763
+ class Packwerk::Parsers::Erb
764
+ include ::Packwerk::Parsers::ParserInterface
765
+
766
+ def initialize(parser_class: T.unsafe(nil), ruby_parser: T.unsafe(nil)); end
767
+
768
+ def call(io:, file_path: T.unsafe(nil)); end
769
+ def parse_buffer(buffer, file_path:); end
770
+
771
+ private
772
+
773
+ def code_nodes(node); end
774
+ def to_ruby_ast(erb_ast, file_path); end
775
+ end
776
+
613
777
  class Packwerk::Parsers::Factory
614
778
  include ::Singleton
615
779
  extend ::Singleton::SingletonClassMethods
616
780
 
617
781
  def erb_parser_class; end
618
782
  def erb_parser_class=(klass); end
783
+
784
+ sig { params(path: ::String).returns(T.nilable(::Packwerk::Parsers::ParserInterface)) }
619
785
  def for_path(path); end
620
786
  end
621
787
 
@@ -630,14 +796,69 @@ end
630
796
 
631
797
  class Packwerk::Parsers::ParseResult < ::Packwerk::Offense; end
632
798
 
799
+ module Packwerk::Parsers::ParserInterface
800
+ interface!
801
+
802
+ sig { abstract.params(io: ::File, file_path: ::String).returns(T.untyped) }
803
+ def call(io:, file_path:); end
804
+ end
805
+
633
806
  class Packwerk::Parsers::Ruby
807
+ include ::Packwerk::Parsers::ParserInterface
808
+
634
809
  def initialize(parser_class: T.unsafe(nil)); end
635
810
 
636
811
  def call(io:, file_path: T.unsafe(nil)); end
637
812
  end
638
813
 
639
- class Packwerk::PrivacyChecker
640
- include ::Packwerk::Checker
814
+ Packwerk::PathSpec = T.type_alias { T.any(::String, T::Array[::String]) }
815
+
816
+ class Packwerk::Reference < ::Struct
817
+ def constant; end
818
+ def constant=(_); end
819
+ def relative_path; end
820
+ def relative_path=(_); end
821
+ def source_location; end
822
+ def source_location=(_); end
823
+ def source_package; end
824
+ def source_package=(_); end
825
+
826
+ class << self
827
+ def [](*_arg0); end
828
+ def inspect; end
829
+ def members; end
830
+ def new(*_arg0); end
831
+ end
832
+ end
833
+
834
+ module Packwerk::ReferenceChecking
835
+ end
836
+
837
+ module Packwerk::ReferenceChecking::Checkers
838
+ end
839
+
840
+ module Packwerk::ReferenceChecking::Checkers::Checker
841
+ interface!
842
+
843
+ sig { abstract.params(reference: ::Packwerk::Reference).returns(T::Boolean) }
844
+ def invalid_reference?(reference); end
845
+
846
+ sig { abstract.returns(::Packwerk::ViolationType) }
847
+ def violation_type; end
848
+ end
849
+
850
+ class Packwerk::ReferenceChecking::Checkers::DependencyChecker
851
+ include ::Packwerk::ReferenceChecking::Checkers::Checker
852
+
853
+ sig { override.params(reference: ::Packwerk::Reference).returns(T::Boolean) }
854
+ def invalid_reference?(reference); end
855
+
856
+ sig { override.returns(::Packwerk::ViolationType) }
857
+ def violation_type; end
858
+ end
859
+
860
+ class Packwerk::ReferenceChecking::Checkers::PrivacyChecker
861
+ include ::Packwerk::ReferenceChecking::Checkers::Checker
641
862
 
642
863
  sig { override.params(reference: ::Packwerk::Reference).returns(T::Boolean) }
643
864
  def invalid_reference?(reference); end
@@ -659,20 +880,15 @@ class Packwerk::PrivacyChecker
659
880
  def explicitly_private_constant?(constant, explicitly_private_constants:); end
660
881
  end
661
882
 
662
- class Packwerk::Reference < ::Struct
663
- def constant; end
664
- def constant=(_); end
665
- def relative_path; end
666
- def relative_path=(_); end
667
- def source_package; end
668
- def source_package=(_); end
883
+ class Packwerk::ReferenceChecking::ReferenceChecker
884
+ sig { params(checkers: T::Array[::Packwerk::ReferenceChecking::Checkers::Checker]).void }
885
+ def initialize(checkers); end
669
886
 
670
- class << self
671
- def [](*_arg0); end
672
- def inspect; end
673
- def members; end
674
- def new(*_arg0); end
675
- end
887
+ sig { params(reference: T.any(::Packwerk::Offense, ::Packwerk::Reference)).returns(T::Array[::Packwerk::Offense]) }
888
+ def call(reference); end
889
+ end
890
+
891
+ class Packwerk::ReferenceExtractor
676
892
  end
677
893
 
678
894
  class Packwerk::ReferenceOffense < ::Packwerk::Offense
@@ -685,25 +901,50 @@ class Packwerk::ReferenceOffense < ::Packwerk::Offense
685
901
  end
686
902
  def initialize(reference:, violation_type:, location: T.unsafe(nil)); end
687
903
 
904
+ sig { returns(::Packwerk::Reference) }
688
905
  def reference; end
906
+
907
+ sig { returns(::Packwerk::ViolationType) }
689
908
  def violation_type; end
690
909
 
691
910
  private
692
911
 
912
+ sig { params(reference: ::Packwerk::Reference, violation_type: ::Packwerk::ViolationType).returns(::String) }
693
913
  def build_message(reference, violation_type); end
694
914
  end
695
915
 
696
916
  class Packwerk::Result < ::T::Struct
697
- prop :message, ::String
698
- prop :status, T::Boolean
917
+ const :message, ::String
918
+ const :status, T::Boolean
699
919
 
700
920
  class << self
701
921
  def inherited(s); end
702
922
  end
703
923
  end
704
924
 
925
+ class Packwerk::RunContext
926
+ end
705
927
 
706
928
  Packwerk::RunContext::DEFAULT_CHECKERS = T.let(T.unsafe(nil), Array)
929
+
930
+ class Packwerk::UnresolvedReference < ::Struct
931
+ def constant_name; end
932
+ def constant_name=(_); end
933
+ def namespace_path; end
934
+ def namespace_path=(_); end
935
+ def relative_path; end
936
+ def relative_path=(_); end
937
+ def source_location; end
938
+ def source_location=(_); end
939
+
940
+ class << self
941
+ def [](*_arg0); end
942
+ def inspect; end
943
+ def members; end
944
+ def new(*_arg0); end
945
+ end
946
+ end
947
+
707
948
  Packwerk::VERSION = T.let(T.unsafe(nil), String)
708
949
 
709
950
  class Packwerk::ViolationType < ::T::Enum
@@ -15,7 +15,7 @@ module ParsePackwerk
15
15
  sig { params(name: ::String).returns(T.nilable(::ParsePackwerk::Package)) }
16
16
  def find(name); end
17
17
 
18
- sig { params(file_path: T.any(::Pathname, ::String)).returns(T.nilable(::ParsePackwerk::Package)) }
18
+ sig { params(file_path: T.any(::Pathname, ::String)).returns(::ParsePackwerk::Package) }
19
19
  def package_from_path(file_path); end
20
20
 
21
21
  sig { params(package: ::ParsePackwerk::Package).void }
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: danger-packwerk
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gusto Engineers
@@ -198,9 +198,10 @@ files:
198
198
  - lib/danger-packwerk/violation_diff.rb
199
199
  - lib/danger_plugin.rb
200
200
  - sorbet/config
201
+ - sorbet/rbi/gems/constant_resolver@0.2.0.rbi
201
202
  - sorbet/rbi/gems/danger@8.5.0.rbi
202
- - sorbet/rbi/gems/packwerk@1.3.2.rbi
203
- - sorbet/rbi/gems/parse_packwerk@0.12.0.rbi
203
+ - sorbet/rbi/gems/packwerk@2.1.1.rbi
204
+ - sorbet/rbi/gems/parse_packwerk@0.12.1.rbi
204
205
  - sorbet/rbi/todo.rbi
205
206
  - sorbet/tapioca/require.rb
206
207
  homepage: https://github.com/rubyatscale/danger-packwerk