danger-packwerk 0.7.0 → 0.8.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (98) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +2 -2
  3. data/lib/danger-packwerk/check/default_formatter.rb +110 -0
  4. data/lib/danger-packwerk/check/offenses_formatter.rb +23 -0
  5. data/lib/danger-packwerk/danger_deprecated_references_yml_changes.rb +7 -5
  6. data/lib/danger-packwerk/danger_packwerk.rb +7 -5
  7. data/lib/danger-packwerk/packwerk_wrapper.rb +2 -2
  8. data/lib/danger-packwerk/private/ownership_information.rb +60 -0
  9. data/lib/danger-packwerk/private.rb +1 -1
  10. data/lib/danger-packwerk/update/default_formatter.rb +67 -0
  11. data/lib/danger-packwerk/update/offenses_formatter.rb +23 -0
  12. data/lib/danger-packwerk/version.rb +1 -1
  13. data/lib/danger-packwerk.rb +4 -0
  14. data/sorbet/config +1 -0
  15. data/sorbet/rbi/gems/actionview@7.0.4.rbi +11543 -0
  16. data/sorbet/rbi/gems/activesupport@7.0.4.rbi +12959 -0
  17. data/sorbet/rbi/gems/addressable@2.8.1.rbi +1505 -0
  18. data/sorbet/rbi/gems/ast@2.4.2.rbi +522 -0
  19. data/sorbet/rbi/gems/better_html@2.0.1.rbi +286 -0
  20. data/sorbet/rbi/gems/builder@3.2.4.rbi +8 -0
  21. data/sorbet/rbi/gems/claide-plugins@0.9.2.rbi +791 -0
  22. data/sorbet/rbi/gems/claide@1.1.0.rbi +1132 -0
  23. data/sorbet/rbi/gems/code_ownership@1.29.1.rbi +336 -0
  24. data/sorbet/rbi/gems/code_teams@1.0.0.rbi +120 -0
  25. data/sorbet/rbi/gems/coderay@1.1.3.rbi +2256 -0
  26. data/sorbet/rbi/gems/colored2@3.1.2.rbi +130 -0
  27. data/sorbet/rbi/gems/concurrent-ruby@1.1.10.rbi +8695 -0
  28. data/sorbet/rbi/gems/cork@0.3.0.rbi +248 -0
  29. data/sorbet/rbi/gems/crass@1.0.6.rbi +436 -0
  30. data/sorbet/rbi/gems/danger-plugin-api@1.0.0.rbi +8 -0
  31. data/sorbet/rbi/gems/danger@9.0.0.rbi +4722 -0
  32. data/sorbet/rbi/gems/diff-lcs@1.5.0.rbi +862 -0
  33. data/sorbet/rbi/gems/erubi@1.11.0.rbi +102 -0
  34. data/sorbet/rbi/gems/faraday-em_http@1.0.0.rbi +266 -0
  35. data/sorbet/rbi/gems/faraday-em_synchrony@1.0.0.rbi +209 -0
  36. data/sorbet/rbi/gems/faraday-excon@1.1.0.rbi +212 -0
  37. data/sorbet/rbi/gems/faraday-http-cache@2.4.1.rbi +805 -0
  38. data/sorbet/rbi/gems/faraday-httpclient@1.0.1.rbi +221 -0
  39. data/sorbet/rbi/gems/faraday-multipart@1.0.4.rbi +266 -0
  40. data/sorbet/rbi/gems/faraday-net_http@1.0.1.rbi +216 -0
  41. data/sorbet/rbi/gems/faraday-net_http_persistent@1.2.0.rbi +206 -0
  42. data/sorbet/rbi/gems/faraday-patron@1.0.0.rbi +212 -0
  43. data/sorbet/rbi/gems/faraday-rack@1.0.0.rbi +225 -0
  44. data/sorbet/rbi/gems/faraday-retry@1.0.3.rbi +222 -0
  45. data/sorbet/rbi/gems/faraday@1.10.2.rbi +1862 -0
  46. data/sorbet/rbi/gems/git@1.12.0.rbi +1936 -0
  47. data/sorbet/rbi/gems/i18n@1.12.0.rbi +1643 -0
  48. data/sorbet/rbi/gems/kramdown-parser-gfm@1.1.0.rbi +8 -0
  49. data/sorbet/rbi/gems/kramdown@2.4.0.rbi +2168 -0
  50. data/sorbet/rbi/gems/loofah@2.19.0.rbi +646 -0
  51. data/sorbet/rbi/gems/method_source@1.0.0.rbi +199 -0
  52. data/sorbet/rbi/gems/minitest@5.16.3.rbi +997 -0
  53. data/sorbet/rbi/gems/multipart-post@2.2.3.rbi +165 -0
  54. data/sorbet/rbi/gems/nap@1.1.0.rbi +351 -0
  55. data/sorbet/rbi/gems/no_proxy_fix@0.1.2.rbi +8 -0
  56. data/sorbet/rbi/gems/nokogiri@1.13.8.rbi +4916 -0
  57. data/sorbet/rbi/gems/octokit@5.6.1.rbi +8939 -0
  58. data/sorbet/rbi/gems/open4@1.3.4.rbi +8 -0
  59. data/sorbet/rbi/gems/{packwerk@2.1.1.rbi → packwerk@2.2.1.rbi} +602 -51
  60. data/sorbet/rbi/gems/parallel@1.22.1.rbi +163 -0
  61. data/sorbet/rbi/gems/parser@3.1.2.1.rbi +5988 -0
  62. data/sorbet/rbi/gems/pry@0.14.1.rbi +6969 -0
  63. data/sorbet/rbi/gems/public_suffix@5.0.0.rbi +779 -0
  64. data/sorbet/rbi/gems/racc@1.6.0.rbi +92 -0
  65. data/sorbet/rbi/gems/rails-dom-testing@2.0.3.rbi +8 -0
  66. data/sorbet/rbi/gems/rails-html-sanitizer@1.4.3.rbi +493 -0
  67. data/sorbet/rbi/gems/rainbow@3.1.1.rbi +227 -0
  68. data/sorbet/rbi/gems/rake@13.0.6.rbi +1865 -0
  69. data/sorbet/rbi/gems/rbi@0.0.14.rbi +2337 -0
  70. data/sorbet/rbi/gems/rchardet@1.8.0.rbi +587 -0
  71. data/sorbet/rbi/gems/regexp_parser@2.5.0.rbi +1851 -0
  72. data/sorbet/rbi/gems/rexml@3.2.5.rbi +3852 -0
  73. data/sorbet/rbi/gems/rspec-core@3.11.0.rbi +7725 -0
  74. data/sorbet/rbi/gems/rspec-expectations@3.11.0.rbi +6201 -0
  75. data/sorbet/rbi/gems/rspec-mocks@3.11.1.rbi +3625 -0
  76. data/sorbet/rbi/gems/rspec-support@3.11.0.rbi +1176 -0
  77. data/sorbet/rbi/gems/rspec@3.11.0.rbi +40 -0
  78. data/sorbet/rbi/gems/rubocop-ast@1.21.0.rbi +4193 -0
  79. data/sorbet/rbi/gems/rubocop-sorbet@0.6.8.rbi +677 -0
  80. data/sorbet/rbi/gems/rubocop@1.36.0.rbi +37914 -0
  81. data/sorbet/rbi/gems/ruby-progressbar@1.11.0.rbi +732 -0
  82. data/sorbet/rbi/gems/ruby2_keywords@0.0.5.rbi +8 -0
  83. data/sorbet/rbi/gems/sawyer@0.9.2.rbi +513 -0
  84. data/sorbet/rbi/gems/smart_properties@1.17.0.rbi +326 -0
  85. data/sorbet/rbi/gems/spoom@1.1.11.rbi +1600 -0
  86. data/sorbet/rbi/gems/tapioca@0.8.0.rbi +1959 -0
  87. data/sorbet/rbi/gems/terminal-table@3.0.2.rbi +438 -0
  88. data/sorbet/rbi/gems/thor@1.2.1.rbi +2921 -0
  89. data/sorbet/rbi/gems/tzinfo@2.0.5.rbi +4879 -0
  90. data/sorbet/rbi/gems/unicode-display_width@2.3.0.rbi +27 -0
  91. data/sorbet/rbi/gems/unparser@0.6.5.rbi +2789 -0
  92. data/sorbet/rbi/gems/webrick@1.7.0.rbi +1802 -0
  93. data/sorbet/rbi/gems/yard-sorbet@0.6.1.rbi +288 -0
  94. data/sorbet/rbi/gems/yard@0.9.27.rbi +12668 -0
  95. data/sorbet/rbi/todo.rbi +122 -0
  96. metadata +104 -8
  97. data/lib/danger-packwerk/private/default_offenses_formatter.rb +0 -37
  98. data/sorbet/rbi/gems/danger@8.5.0.rbi +0 -122
@@ -5,31 +5,38 @@
5
5
  # Please instead update this file by running `bin/tapioca gem packwerk`.
6
6
 
7
7
  module Packwerk
8
+ extend ::ActiveSupport::Autoload
8
9
  end
9
10
 
11
+ # Extracts the load paths from the analyzed application so that we can map constant names to paths.
10
12
  module Packwerk::ApplicationLoadPaths
11
13
  class << self
12
- sig { returns(T::Array[::String]) }
14
+ sig { returns(T::Hash[::String, ::Module]) }
13
15
  def extract_application_autoload_paths; end
14
16
 
15
- sig { params(root: ::String, environment: ::String).returns(T::Array[::String]) }
17
+ sig { params(root: ::String, environment: ::String).returns(T::Hash[::String, ::Module]) }
16
18
  def extract_relevant_paths(root, environment); end
17
19
 
18
20
  sig do
19
21
  params(
20
- all_paths: T::Array[::String],
22
+ all_paths: T::Hash[::String, ::Module],
21
23
  bundle_path: ::Pathname,
22
24
  rails_root: ::Pathname
23
- ).returns(T::Array[::Pathname])
25
+ ).returns(T::Hash[::Pathname, ::Module])
24
26
  end
25
27
  def filter_relevant_paths(all_paths, bundle_path: T.unsafe(nil), rails_root: T.unsafe(nil)); end
26
28
 
27
- sig { params(paths: T::Array[::Pathname], rails_root: ::Pathname).returns(T::Array[::String]) }
28
- def relative_path_strings(paths, rails_root: T.unsafe(nil)); end
29
+ sig do
30
+ params(
31
+ load_paths: T::Hash[::Pathname, ::Module],
32
+ rails_root: ::Pathname
33
+ ).returns(T::Hash[::String, ::Module])
34
+ end
35
+ def relative_path_strings(load_paths, rails_root: T.unsafe(nil)); end
29
36
 
30
37
  private
31
38
 
32
- sig { params(paths: T::Array[T.untyped]).void }
39
+ sig { params(paths: T::Hash[T.untyped, ::Module]).void }
33
40
  def assert_load_paths_present(paths); end
34
41
 
35
42
  sig { params(root: ::String, environment: ::String).void }
@@ -37,6 +44,8 @@ module Packwerk::ApplicationLoadPaths
37
44
  end
38
45
  end
39
46
 
47
+ # Checks the structure of the application and its packwerk configuration to make sure we can run a check and deliver
48
+ # correct results.
40
49
  class Packwerk::ApplicationValidator
41
50
  sig { params(config_file_path: ::String, configuration: ::Packwerk::Configuration, environment: ::String).void }
42
51
  def initialize(config_file_path:, configuration:, environment:); end
@@ -75,6 +84,13 @@ class Packwerk::ApplicationValidator
75
84
  end
76
85
  def assert_constants_can_be_loaded(constants, config_file_path); end
77
86
 
87
+ # Convert the cycles:
88
+ #
89
+ # [[a, b, c], [b, c]]
90
+ #
91
+ # to the string:
92
+ #
93
+ # ["a -> b -> c -> a", "b -> c -> b"]
78
94
  sig { params(cycles: T.untyped).returns(T::Array[::String]) }
79
95
  def build_cycle_strings(cycles); end
80
96
 
@@ -133,6 +149,33 @@ class Packwerk::ApplicationValidator::Result < ::T::Struct
133
149
  end
134
150
  end
135
151
 
152
+ # Extracts the implicit constant reference from an active record association
153
+ class Packwerk::AssociationInspector
154
+ include ::Packwerk::ConstantNameInspector
155
+
156
+ sig do
157
+ params(
158
+ inflector: T.class_of(ActiveSupport::Inflector),
159
+ custom_associations: T.any(T::Array[::Symbol], T::Set[::Symbol])
160
+ ).void
161
+ end
162
+ def initialize(inflector:, custom_associations: T.unsafe(nil)); end
163
+
164
+ sig { override.params(node: ::AST::Node, ancestors: T::Array[::AST::Node]).returns(T.nilable(::String)) }
165
+ def constant_name_from_node(node, ancestors:); end
166
+
167
+ private
168
+
169
+ sig { params(node: ::AST::Node).returns(T::Boolean) }
170
+ def association?(node); end
171
+
172
+ sig { params(arguments: T::Array[::AST::Node]).returns(T.nilable(T.any(::String, ::Symbol))) }
173
+ def association_name(arguments); end
174
+
175
+ sig { params(arguments: T::Array[::AST::Node]).returns(T.nilable(::AST::Node)) }
176
+ def custom_class_name(arguments); end
177
+ end
178
+
136
179
  Packwerk::AssociationInspector::CustomAssociations = T.type_alias { T.any(T::Array[::Symbol], T::Set[::Symbol]) }
137
180
  Packwerk::AssociationInspector::RAILS_ASSOCIATIONS = T.let(T.unsafe(nil), Set)
138
181
 
@@ -170,8 +213,6 @@ class Packwerk::Cache
170
213
  def with_cache(file_path, &block); end
171
214
  end
172
215
 
173
- Packwerk::Cache::CACHE_SHAPE = T.type_alias { T::Hash[::String, ::Packwerk::Cache::CacheContents] }
174
-
175
216
  class Packwerk::Cache::CacheContents < ::T::Struct
176
217
  const :file_contents_digest, ::String
177
218
  const :unresolved_references, T::Array[::Packwerk::UnresolvedReference]
@@ -187,6 +228,9 @@ class Packwerk::Cache::CacheContents < ::T::Struct
187
228
  end
188
229
  end
189
230
 
231
+ Packwerk::Cache::CacheShape = T.type_alias { T::Hash[::String, ::Packwerk::Cache::CacheContents] }
232
+
233
+ # A command-line interface to Packwerk.
190
234
  class Packwerk::Cli
191
235
  sig do
192
236
  params(
@@ -211,12 +255,7 @@ class Packwerk::Cli
211
255
  sig { returns(::Packwerk::ApplicationValidator) }
212
256
  def checker; end
213
257
 
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
258
+ sig { params(relative_file_paths: T::Array[::String], ignore_nested_packages: T::Boolean).returns(T::Set[::String]) }
220
259
  def fetch_files_to_process(relative_file_paths, ignore_nested_packages); end
221
260
 
222
261
  sig { returns(T::Boolean) }
@@ -239,20 +278,40 @@ class Packwerk::Cli
239
278
  end
240
279
 
241
280
  class Packwerk::Configuration
281
+ # @return [Configuration] a new instance of Configuration
242
282
  def initialize(configs = T.unsafe(nil), config_path: T.unsafe(nil)); end
243
283
 
284
+ # Returns the value of attribute cache_directory.
244
285
  def cache_directory; end
286
+
287
+ # @return [Boolean]
245
288
  def cache_enabled?; end
289
+
290
+ # Returns the value of attribute config_path.
246
291
  def config_path; end
292
+
293
+ # Returns the value of attribute custom_associations.
247
294
  def custom_associations; end
295
+
296
+ # Returns the value of attribute exclude.
248
297
  def exclude; end
298
+
299
+ # Returns the value of attribute include.
249
300
  def include; end
301
+
250
302
  def load_paths; end
303
+
304
+ # Returns the value of attribute package_paths.
251
305
  def package_paths; end
306
+
307
+ # @return [Boolean]
252
308
  def parallel?; end
309
+
310
+ # Returns the value of attribute root_path.
253
311
  def root_path; end
254
312
 
255
313
  class << self
314
+ # @raise [ArgumentError]
256
315
  def from_path(path = T.unsafe(nil)); end
257
316
 
258
317
  private
@@ -265,10 +324,41 @@ Packwerk::Configuration::DEFAULT_CONFIG_PATH = T.let(T.unsafe(nil), String)
265
324
  Packwerk::Configuration::DEFAULT_EXCLUDE_GLOBS = T.let(T.unsafe(nil), Array)
266
325
  Packwerk::Configuration::DEFAULT_INCLUDE_GLOBS = T.let(T.unsafe(nil), Array)
267
326
 
327
+ # Extracts a constant name from an AST node of type :const
328
+ class Packwerk::ConstNodeInspector
329
+ include ::Packwerk::ConstantNameInspector
330
+
331
+ sig { override.params(node: ::AST::Node, ancestors: T::Array[::AST::Node]).returns(T.nilable(::String)) }
332
+ def constant_name_from_node(node, ancestors:); end
333
+
334
+ private
335
+
336
+ sig { params(node: ::AST::Node, parent: ::AST::Node).returns(T.nilable(T::Boolean)) }
337
+ def constant_in_module_or_class_definition?(node, parent:); end
338
+
339
+ sig { params(ancestors: T::Array[::AST::Node]).returns(::String) }
340
+ def fully_qualify_constant(ancestors); end
341
+
342
+ sig { params(parent: T.nilable(::AST::Node)).returns(T::Boolean) }
343
+ def root_constant?(parent); end
344
+ end
345
+
346
+ # Get information about unresolved constants without loading the application code.
347
+ # Information gathered: Fully qualified name, path to file containing the definition, package,
348
+ # and visibility (public/private to the package).
349
+ #
350
+ # The implementation makes a few assumptions about the code base:
351
+ # - `Something::SomeOtherThing` is defined in a path of either `something/some_other_thing.rb` or `something.rb`,
352
+ # relative to the load path. Rails' `zeitwerk` autoloader makes the same assumption.
353
+ # - It is OK to not always infer the exact file defining the constant. For example, when a constant is inherited, we
354
+ # have no way of inferring the file it is defined in. You could argue though that inheritance means that another
355
+ # constant with the same name exists in the inheriting class, and this view is sufficient for all our use cases.
268
356
  class Packwerk::ConstantDiscovery
269
357
  sig { params(constant_resolver: ::ConstantResolver, packages: Packwerk::PackageSet).void }
270
358
  def initialize(constant_resolver:, packages:); end
271
359
 
360
+ # Analyze a constant via its name.
361
+ # If the constant is unresolved, we need the current namespace path to correctly infer its full name
272
362
  sig do
273
363
  params(
274
364
  const_name: ::String,
@@ -277,17 +367,48 @@ class Packwerk::ConstantDiscovery
277
367
  end
278
368
  def context_for(const_name, current_namespace_path: T.unsafe(nil)); end
279
369
 
370
+ # Get the package that owns a given file path.
280
371
  sig { params(path: ::String).returns(::Packwerk::Package) }
281
372
  def package_from_path(path); end
282
373
  end
283
374
 
284
375
  class Packwerk::ConstantDiscovery::ConstantContext < ::Struct
376
+ # Returns the value of attribute location
377
+ #
378
+ # @return [Object] the current value of location
285
379
  def location; end
380
+
381
+ # Sets the attribute location
382
+ #
383
+ # @param value [Object] the value to set the attribute location to.
384
+ # @return [Object] the newly set value
286
385
  def location=(_); end
386
+
387
+ # Returns the value of attribute name
388
+ #
389
+ # @return [Object] the current value of name
287
390
  def name; end
391
+
392
+ # Sets the attribute name
393
+ #
394
+ # @param value [Object] the value to set the attribute name to.
395
+ # @return [Object] the newly set value
288
396
  def name=(_); end
397
+
398
+ # Returns the value of attribute package
399
+ #
400
+ # @return [Object] the current value of package
289
401
  def package; end
402
+
403
+ # Sets the attribute package
404
+ #
405
+ # @param value [Object] the value to set the attribute package to.
406
+ # @return [Object] the newly set value
290
407
  def package=(_); end
408
+
409
+ # Returns the value of attribute public?
410
+ #
411
+ # @return [Object] the current value of public?
291
412
  def public?; end
292
413
 
293
414
  class << self
@@ -298,6 +419,17 @@ class Packwerk::ConstantDiscovery::ConstantContext < ::Struct
298
419
  end
299
420
  end
300
421
 
422
+ # An interface describing an object that can extract a constant name from an AST node.
423
+ #
424
+ # @abstract Subclasses must implement the `abstract` methods below.
425
+ module Packwerk::ConstantNameInspector
426
+ interface!
427
+
428
+ # @abstract
429
+ sig { abstract.params(node: ::AST::Node, ancestors: T::Array[::AST::Node]).returns(T.nilable(::String)) }
430
+ def constant_name_from_node(node, ancestors:); end
431
+ end
432
+
301
433
  class Packwerk::Debug
302
434
  class << self
303
435
  sig { params(out: ::String).void }
@@ -318,8 +450,8 @@ class Packwerk::DeprecatedReferences
318
450
  sig { params(reference: ::Packwerk::Reference, violation_type: ::Packwerk::ViolationType).returns(T::Boolean) }
319
451
  def listed?(reference, violation_type:); end
320
452
 
321
- sig { returns(T::Boolean) }
322
- def stale_violations?; end
453
+ sig { params(for_files: T::Set[::String]).returns(T::Boolean) }
454
+ def stale_violations?(for_files); end
323
455
 
324
456
  private
325
457
 
@@ -333,7 +465,41 @@ class Packwerk::DeprecatedReferences
333
465
  def prepare_entries_for_dump; end
334
466
  end
335
467
 
336
- Packwerk::DeprecatedReferences::ENTRIES_TYPE = T.type_alias { T::Hash[::String, T.untyped] }
468
+ Packwerk::DeprecatedReferences::EntriesType = T.type_alias { T::Hash[::String, T.untyped] }
469
+
470
+ class Packwerk::FileProcessor
471
+ sig do
472
+ params(
473
+ node_processor_factory: ::Packwerk::NodeProcessorFactory,
474
+ cache: ::Packwerk::Cache,
475
+ parser_factory: T.nilable(::Packwerk::Parsers::Factory)
476
+ ).void
477
+ end
478
+ def initialize(node_processor_factory:, cache:, parser_factory: T.unsafe(nil)); end
479
+
480
+ sig { params(relative_file: ::String).returns(::Packwerk::FileProcessor::ProcessedFile) }
481
+ def call(relative_file); end
482
+
483
+ private
484
+
485
+ sig { params(relative_file: ::String, parser: ::Packwerk::Parsers::ParserInterface).returns(T.untyped) }
486
+ def parse_into_ast(relative_file, parser); end
487
+
488
+ sig { params(file_path: ::String).returns(T.nilable(::Packwerk::Parsers::ParserInterface)) }
489
+ def parser_for(file_path); end
490
+
491
+ sig { params(node: ::Parser::AST::Node, relative_file: ::String).returns(T::Array[::Packwerk::UnresolvedReference]) }
492
+ def references_from_ast(node, relative_file); end
493
+ end
494
+
495
+ class Packwerk::FileProcessor::ProcessedFile < ::T::Struct
496
+ const :offenses, T::Array[::Packwerk::Offense], default: T.unsafe(nil)
497
+ const :unresolved_references, T::Array[::Packwerk::UnresolvedReference], default: T.unsafe(nil)
498
+
499
+ class << self
500
+ def inherited(s); end
501
+ end
502
+ end
337
503
 
338
504
  class Packwerk::FileProcessor::UnknownFileTypeResult < ::Packwerk::Offense
339
505
  sig { params(file: ::String).void }
@@ -350,25 +516,25 @@ class Packwerk::FilesForProcessing
350
516
  end
351
517
  def initialize(relative_file_paths, configuration, ignore_nested_packages); end
352
518
 
353
- sig { returns(T::Array[::String]) }
519
+ sig { returns(T::Set[::String]) }
354
520
  def files; end
355
521
 
356
522
  private
357
523
 
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]) }
524
+ sig { returns(T::Set[::String]) }
362
525
  def configured_excluded_files; end
363
526
 
364
- sig { returns(T::Array[::String]) }
527
+ sig { returns(T::Set[::String]) }
365
528
  def configured_included_files; end
366
529
 
367
- sig { returns(T::Array[::String]) }
530
+ sig { returns(T::Set[::String]) }
368
531
  def custom_files; end
369
532
 
370
- sig { params(absolute_file_path: ::String).returns(T::Array[::String]) }
371
- def custom_included_files(absolute_file_path); end
533
+ sig { params(relative_file_path: ::String).returns(T::Set[::String]) }
534
+ def custom_included_files(relative_file_path); end
535
+
536
+ sig { params(relative_globs: T::Array[::String]).returns(T::Set[::String]) }
537
+ def relative_files_for_globs(relative_globs); end
372
538
 
373
539
  class << self
374
540
  sig do
@@ -376,13 +542,16 @@ class Packwerk::FilesForProcessing
376
542
  relative_file_paths: T::Array[::String],
377
543
  configuration: ::Packwerk::Configuration,
378
544
  ignore_nested_packages: T::Boolean
379
- ).returns(T::Array[::String])
545
+ ).returns(T::Set[::String])
380
546
  end
381
547
  def fetch(relative_file_paths:, configuration:, ignore_nested_packages: T.unsafe(nil)); end
382
548
  end
383
549
  end
384
550
 
551
+ Packwerk::FilesForProcessing::RelativeFileSet = T.type_alias { T::Set[::String] }
552
+
385
553
  module Packwerk::Formatters
554
+ extend ::ActiveSupport::Autoload
386
555
  end
387
556
 
388
557
  class Packwerk::Formatters::OffensesFormatter
@@ -394,8 +563,14 @@ class Packwerk::Formatters::OffensesFormatter
394
563
  sig { override.params(offenses: T::Array[T.nilable(::Packwerk::Offense)]).returns(::String) }
395
564
  def show_offenses(offenses); end
396
565
 
397
- sig { override.params(offense_collection: ::Packwerk::OffenseCollection).returns(::String) }
398
- def show_stale_violations(offense_collection); end
566
+ sig do
567
+ override
568
+ .params(
569
+ offense_collection: ::Packwerk::OffenseCollection,
570
+ fileset: T::Set[::String]
571
+ ).returns(::String)
572
+ end
573
+ def show_stale_violations(offense_collection, fileset); end
399
574
 
400
575
  private
401
576
 
@@ -415,10 +590,11 @@ class Packwerk::Formatters::ProgressFormatter
415
590
  def mark_as_failed; end
416
591
  def mark_as_inspected; end
417
592
  def started(target_files); end
418
- def started_validation; end
593
+ def started_validation(&block); end
419
594
  end
420
595
 
421
596
  module Packwerk::Generators
597
+ extend ::ActiveSupport::Autoload
422
598
  end
423
599
 
424
600
  class Packwerk::Generators::ConfigurationFile
@@ -441,6 +617,7 @@ end
441
617
  Packwerk::Generators::ConfigurationFile::CONFIGURATION_TEMPLATE_FILE_PATH = T.let(T.unsafe(nil), String)
442
618
 
443
619
  class Packwerk::Generators::RootPackage
620
+ # @return [RootPackage] a new instance of RootPackage
444
621
  def initialize(root:, out: T.unsafe(nil)); end
445
622
 
446
623
  sig { returns(T::Boolean) }
@@ -451,10 +628,15 @@ class Packwerk::Generators::RootPackage
451
628
  end
452
629
  end
453
630
 
631
+ # A general implementation of a graph data structure with the ability to check for - and list - cycles.
454
632
  class Packwerk::Graph
633
+ # @param edges [Array<Array>] The edges of the graph; An edge being represented as an Array of two nodes.
634
+ # @return [Graph] a new instance of Graph
455
635
  def initialize(*edges); end
456
636
 
637
+ # @return [Boolean]
457
638
  def acyclic?; end
639
+
458
640
  def cycles; end
459
641
 
460
642
  private
@@ -466,13 +648,29 @@ class Packwerk::Graph
466
648
  def visit(node, visited_nodes: T.unsafe(nil), path: T.unsafe(nil)); end
467
649
  end
468
650
 
469
- module Packwerk::Node
470
- end
651
+ class Packwerk::Node; end
471
652
 
472
653
  class Packwerk::Node::Location < ::Struct
654
+ # Returns the value of attribute column
655
+ #
656
+ # @return [Object] the current value of column
473
657
  def column; end
658
+
659
+ # Sets the attribute column
660
+ #
661
+ # @param value [Object] the value to set the attribute column to.
662
+ # @return [Object] the newly set value
474
663
  def column=(_); end
664
+
665
+ # Returns the value of attribute line
666
+ #
667
+ # @return [Object] the current value of line
475
668
  def line; end
669
+
670
+ # Sets the attribute line
671
+ #
672
+ # @param value [Object] the value to set the attribute line to.
673
+ # @return [Object] the newly set value
476
674
  def line=(_); end
477
675
 
478
676
  class << self
@@ -483,11 +681,146 @@ class Packwerk::Node::Location < ::Struct
483
681
  end
484
682
  end
485
683
 
486
- class Packwerk::Node::TypeError < ::ArgumentError; end
684
+ # Convenience methods for working with Parser::AST::Node nodes.
685
+ module Packwerk::NodeHelpers
686
+ class << self
687
+ sig { params(node: ::AST::Node).returns(T::Boolean) }
688
+ def class?(node); end
689
+
690
+ sig { params(class_or_module_node: ::AST::Node).returns(::String) }
691
+ def class_or_module_name(class_or_module_node); end
692
+
693
+ sig { params(node: ::AST::Node).returns(T::Boolean) }
694
+ def constant?(node); end
695
+
696
+ sig { params(node: ::AST::Node).returns(T::Boolean) }
697
+ def constant_assignment?(node); end
698
+
699
+ sig { params(constant_node: ::AST::Node).returns(::String) }
700
+ def constant_name(constant_node); end
701
+
702
+ sig { params(node: ::AST::Node).returns(T.untyped) }
703
+ def each_child(node); end
704
+
705
+ sig { params(starting_node: ::AST::Node, ancestors: T::Array[::AST::Node]).returns(T::Array[::String]) }
706
+ def enclosing_namespace_path(starting_node, ancestors:); end
707
+
708
+ sig { params(node: ::AST::Node).returns(T::Boolean) }
709
+ def hash?(node); end
710
+
711
+ sig { params(string_or_symbol_node: ::AST::Node).returns(T.any(::String, ::Symbol)) }
712
+ def literal_value(string_or_symbol_node); end
713
+
714
+ sig { params(node: ::Parser::AST::Node).returns(::Packwerk::Node::Location) }
715
+ def location(node); end
716
+
717
+ # @raise [TypeError]
718
+ sig { params(method_call_node: ::AST::Node).returns(T::Array[::AST::Node]) }
719
+ def method_arguments(method_call_node); end
720
+
721
+ sig { params(node: ::AST::Node).returns(T::Boolean) }
722
+ def method_call?(node); end
723
+
724
+ # @raise [TypeError]
725
+ sig { params(method_call_node: ::AST::Node).returns(::Symbol) }
726
+ def method_name(method_call_node); end
727
+
728
+ sig { params(node: ::AST::Node).returns(T.nilable(::String)) }
729
+ def module_name_from_definition(node); end
730
+
731
+ sig { params(node: ::Parser::AST::Node).returns(T.nilable(::Packwerk::Node::Location)) }
732
+ def name_location(node); end
733
+
734
+ # @raise [TypeError]
735
+ sig { params(class_node: ::AST::Node).returns(T.nilable(::AST::Node)) }
736
+ def parent_class(class_node); end
737
+
738
+ sig { params(ancestors: T::Array[::AST::Node]).returns(::String) }
739
+ def parent_module_name(ancestors:); end
740
+
741
+ sig { params(node: ::AST::Node).returns(T::Boolean) }
742
+ def string?(node); end
743
+
744
+ sig { params(node: ::AST::Node).returns(T::Boolean) }
745
+ def symbol?(node); end
746
+
747
+ # @raise [TypeError]
748
+ sig { params(hash_node: ::AST::Node, key: ::Symbol).returns(T.untyped) }
749
+ def value_from_hash(hash_node, key); end
750
+
751
+ private
752
+
753
+ sig { params(node: T.nilable(::AST::Node)).returns(T::Boolean) }
754
+ def dynamic_class_creation?(node); end
755
+
756
+ # @raise [TypeError]
757
+ sig { params(hash_pair_node: ::AST::Node).returns(T.untyped) }
758
+ def hash_pair_key(hash_pair_node); end
759
+
760
+ # @raise [TypeError]
761
+ sig { params(hash_pair_node: ::AST::Node).returns(T.untyped) }
762
+ def hash_pair_value(hash_pair_node); end
763
+
764
+ # @raise [TypeError]
765
+ sig { params(hash_node: ::AST::Node).returns(T::Array[::AST::Node]) }
766
+ def hash_pairs(hash_node); end
767
+
768
+ # @raise [TypeError]
769
+ sig { params(block_node: ::AST::Node).returns(::AST::Node) }
770
+ def method_call_node(block_node); end
771
+
772
+ sig { params(node: ::AST::Node).returns(T::Boolean) }
773
+ def module_creation?(node); end
774
+
775
+ sig { params(node: ::AST::Node).returns(T.nilable(::String)) }
776
+ def name_from_block_definition(node); end
777
+
778
+ sig { params(node: ::AST::Node).returns(T.nilable(::String)) }
779
+ def name_part_from_definition(node); end
780
+
781
+ sig { params(method_call_or_block_node: ::AST::Node).returns(T.nilable(::AST::Node)) }
782
+ def receiver(method_call_or_block_node); end
783
+
784
+ sig { params(node: ::AST::Node).returns(::Symbol) }
785
+ def type_of(node); end
786
+ end
787
+ end
788
+
789
+ class Packwerk::NodeHelpers::TypeError < ::ArgumentError; end
487
790
 
791
+ # Processes a single node in an abstract syntax tree (AST) using the provided checkers.
488
792
  class Packwerk::NodeProcessor
793
+ sig { params(reference_extractor: ::Packwerk::ReferenceExtractor, relative_file: ::String).void }
794
+ def initialize(reference_extractor:, relative_file:); end
795
+
796
+ sig do
797
+ params(
798
+ node: ::Parser::AST::Node,
799
+ ancestors: T::Array[::Parser::AST::Node]
800
+ ).returns(T.nilable(::Packwerk::UnresolvedReference))
801
+ end
802
+ def call(node, ancestors); end
489
803
  end
490
804
 
805
+ class Packwerk::NodeProcessorFactory < ::T::Struct
806
+ const :constant_name_inspectors, T::Array[::Packwerk::ConstantNameInspector]
807
+ const :context_provider, ::Packwerk::ConstantDiscovery
808
+ const :root_path, ::String
809
+
810
+ sig { params(relative_file: ::String, node: ::AST::Node).returns(::Packwerk::NodeProcessor) }
811
+ def for(relative_file:, node:); end
812
+
813
+ private
814
+
815
+ sig { params(node: ::AST::Node).returns(::Packwerk::ReferenceExtractor) }
816
+ def reference_extractor(node:); end
817
+
818
+ class << self
819
+ def inherited(s); end
820
+ end
821
+ end
822
+
823
+ # Visits all nodes of an AST, processing them using a given node processor.
491
824
  class Packwerk::NodeVisitor
492
825
  sig { params(node_processor: ::Packwerk::NodeProcessor).void }
493
826
  def initialize(node_processor:); end
@@ -539,8 +872,8 @@ class Packwerk::OffenseCollection
539
872
  sig { returns(T::Array[::Packwerk::Offense]) }
540
873
  def outstanding_offenses; end
541
874
 
542
- sig { returns(T::Boolean) }
543
- def stale_violations?; end
875
+ sig { params(for_files: T::Set[::String]).returns(T::Boolean) }
876
+ def stale_violations?(for_files); end
544
877
 
545
878
  private
546
879
 
@@ -551,32 +884,47 @@ class Packwerk::OffenseCollection
551
884
  def deprecated_references_for(package); end
552
885
  end
553
886
 
887
+ # @abstract Subclasses must implement the `abstract` methods below.
554
888
  module Packwerk::OffensesFormatter
555
889
  interface!
556
890
 
891
+ # @abstract
557
892
  sig { abstract.params(offenses: T::Array[T.nilable(::Packwerk::Offense)]).returns(::String) }
558
893
  def show_offenses(offenses); end
559
894
 
560
- sig { abstract.params(offense_collection: ::Packwerk::OffenseCollection).returns(::String) }
561
- def show_stale_violations(offense_collection); end
895
+ # @abstract
896
+ sig do
897
+ abstract
898
+ .params(
899
+ offense_collection: ::Packwerk::OffenseCollection,
900
+ for_files: T::Set[::String]
901
+ ).returns(::String)
902
+ end
903
+ def show_stale_violations(offense_collection, for_files); end
562
904
  end
563
905
 
906
+ # @abstract Subclasses must implement the `abstract` methods below.
564
907
  module Packwerk::OutputStyle
565
908
  interface!
566
909
 
910
+ # @abstract
567
911
  sig { abstract.returns(::String) }
568
912
  def error; end
569
913
 
914
+ # @abstract
570
915
  sig { abstract.returns(::String) }
571
916
  def filename; end
572
917
 
918
+ # @abstract
573
919
  sig { abstract.returns(::String) }
574
920
  def reset; end
575
921
  end
576
922
 
577
923
  module Packwerk::OutputStyles
924
+ extend ::ActiveSupport::Autoload
578
925
  end
579
926
 
927
+ # See https://en.wikipedia.org/wiki/ANSI_escape_code#3/4_bit for ANSI escape colour codes
580
928
  class Packwerk::OutputStyles::Coloured
581
929
  include ::Packwerk::OutputStyle
582
930
 
@@ -603,6 +951,9 @@ class Packwerk::OutputStyles::Plain
603
951
  def reset; end
604
952
  end
605
953
 
954
+ # The basic unit of modularity for packwerk; a folder that has been declared to define a package.
955
+ # The package contains all constants defined in files in this folder and all subfolders that are not packages
956
+ # themselves.
606
957
  class Packwerk::Package
607
958
  include ::Comparable
608
959
 
@@ -654,12 +1005,11 @@ end
654
1005
 
655
1006
  Packwerk::Package::ROOT_PACKAGE_NAME = T.let(T.unsafe(nil), String)
656
1007
 
1008
+ # A set of {Packwerk::Package}s as well as methods to parse packages from the filesystem.
657
1009
  class Packwerk::PackageSet
658
1010
  extend T::Generic
659
1011
  include ::Enumerable
660
1012
 
661
- Elem = type_member(fixed: Packwerk::Package)
662
-
663
1013
  sig { params(packages: T::Array[::Packwerk::Package]).void }
664
1014
  def initialize(packages); end
665
1015
 
@@ -708,13 +1058,13 @@ Packwerk::PackageSet::PACKAGE_CONFIG_FILENAME = T.let(T.unsafe(nil), String)
708
1058
  class Packwerk::ParseRun
709
1059
  sig do
710
1060
  params(
711
- absolute_files: T::Array[::String],
1061
+ relative_file_set: T::Set[::String],
712
1062
  configuration: ::Packwerk::Configuration,
713
1063
  progress_formatter: ::Packwerk::Formatters::ProgressFormatter,
714
1064
  offenses_formatter: ::Packwerk::OffensesFormatter
715
1065
  ).void
716
1066
  end
717
- def initialize(absolute_files:, configuration:, progress_formatter: T.unsafe(nil), offenses_formatter: T.unsafe(nil)); end
1067
+ def initialize(relative_file_set:, configuration:, progress_formatter: T.unsafe(nil), offenses_formatter: T.unsafe(nil)); end
718
1068
 
719
1069
  sig { returns(::Packwerk::Result) }
720
1070
  def check; end
@@ -743,9 +1093,12 @@ end
743
1093
 
744
1094
  Packwerk::ParseRun::ProcessFileProc = T.type_alias { T.proc.params(path: ::String).returns(T::Array[::Packwerk::Offense]) }
745
1095
 
1096
+ # A collection of constant definitions parsed from an Abstract Syntax Tree (AST).
746
1097
  class Packwerk::ParsedConstantDefinitions
1098
+ # @return [ParsedConstantDefinitions] a new instance of ParsedConstantDefinitions
747
1099
  def initialize(root_node:); end
748
1100
 
1101
+ # @return [Boolean]
749
1102
  def local_reference?(constant_name, location: T.unsafe(nil), namespace_path: T.unsafe(nil)); end
750
1103
 
751
1104
  private
@@ -754,6 +1107,7 @@ class Packwerk::ParsedConstantDefinitions
754
1107
  def collect_local_definitions_from_root(node, current_namespace_path = T.unsafe(nil)); end
755
1108
 
756
1109
  class << self
1110
+ # What fully qualified constants can this constant refer to in this context?
757
1111
  def reference_qualifications(constant_name, namespace_path:); end
758
1112
  end
759
1113
  end
@@ -763,6 +1117,7 @@ module Packwerk::Parsers; end
763
1117
  class Packwerk::Parsers::Erb
764
1118
  include ::Packwerk::Parsers::ParserInterface
765
1119
 
1120
+ # @return [Erb] a new instance of Erb
766
1121
  def initialize(parser_class: T.unsafe(nil), ruby_parser: T.unsafe(nil)); end
767
1122
 
768
1123
  def call(io:, file_path: T.unsafe(nil)); end
@@ -770,7 +1125,9 @@ class Packwerk::Parsers::Erb
770
1125
 
771
1126
  private
772
1127
 
773
- def code_nodes(node); end
1128
+ # @yield [node]
1129
+ def code_nodes(node, &block); end
1130
+
774
1131
  def to_ruby_ast(erb_ast, file_path); end
775
1132
  end
776
1133
 
@@ -789,16 +1146,22 @@ Packwerk::Parsers::Factory::ERB_REGEX = T.let(T.unsafe(nil), Regexp)
789
1146
  Packwerk::Parsers::Factory::RUBY_REGEX = T.let(T.unsafe(nil), Regexp)
790
1147
 
791
1148
  class Packwerk::Parsers::ParseError < ::StandardError
1149
+ # @return [ParseError] a new instance of ParseError
792
1150
  def initialize(result); end
793
1151
 
1152
+ # Returns the value of attribute result.
794
1153
  def result; end
795
1154
  end
796
1155
 
797
1156
  class Packwerk::Parsers::ParseResult < ::Packwerk::Offense; end
798
1157
 
1158
+ # @abstract Subclasses must implement the `abstract` methods below.
799
1159
  module Packwerk::Parsers::ParserInterface
1160
+ requires_ancestor { Kernel }
1161
+
800
1162
  interface!
801
1163
 
1164
+ # @abstract
802
1165
  sig { abstract.params(io: ::File, file_path: ::String).returns(T.untyped) }
803
1166
  def call(io:, file_path:); end
804
1167
  end
@@ -806,21 +1169,67 @@ end
806
1169
  class Packwerk::Parsers::Ruby
807
1170
  include ::Packwerk::Parsers::ParserInterface
808
1171
 
1172
+ # @return [Ruby] a new instance of Ruby
809
1173
  def initialize(parser_class: T.unsafe(nil)); end
810
1174
 
811
1175
  def call(io:, file_path: T.unsafe(nil)); end
812
1176
  end
813
1177
 
1178
+ class Packwerk::Parsers::Ruby::RaiseExceptionsParser < ::Parser::Ruby27
1179
+ # @return [RaiseExceptionsParser] a new instance of RaiseExceptionsParser
1180
+ def initialize(builder); end
1181
+ end
1182
+
1183
+ class Packwerk::Parsers::Ruby::TolerateInvalidUtf8Builder < ::Parser::Builders::Default
1184
+ def string_value(token); end
1185
+ end
1186
+
814
1187
  Packwerk::PathSpec = T.type_alias { T.any(::String, T::Array[::String]) }
815
1188
 
1189
+ # A reference from a file in one package to a constant that may be defined in a different package.
816
1190
  class Packwerk::Reference < ::Struct
1191
+ # Returns the value of attribute constant
1192
+ #
1193
+ # @return [Object] the current value of constant
817
1194
  def constant; end
1195
+
1196
+ # Sets the attribute constant
1197
+ #
1198
+ # @param value [Object] the value to set the attribute constant to.
1199
+ # @return [Object] the newly set value
818
1200
  def constant=(_); end
1201
+
1202
+ # Returns the value of attribute relative_path
1203
+ #
1204
+ # @return [Object] the current value of relative_path
819
1205
  def relative_path; end
1206
+
1207
+ # Sets the attribute relative_path
1208
+ #
1209
+ # @param value [Object] the value to set the attribute relative_path to.
1210
+ # @return [Object] the newly set value
820
1211
  def relative_path=(_); end
1212
+
1213
+ # Returns the value of attribute source_location
1214
+ #
1215
+ # @return [Object] the current value of source_location
821
1216
  def source_location; end
1217
+
1218
+ # Sets the attribute source_location
1219
+ #
1220
+ # @param value [Object] the value to set the attribute source_location to.
1221
+ # @return [Object] the newly set value
822
1222
  def source_location=(_); end
1223
+
1224
+ # Returns the value of attribute source_package
1225
+ #
1226
+ # @return [Object] the current value of source_package
823
1227
  def source_package; end
1228
+
1229
+ # Sets the attribute source_package
1230
+ #
1231
+ # @param value [Object] the value to set the attribute source_package to.
1232
+ # @return [Object] the newly set value
824
1233
  def source_package=(_); end
825
1234
 
826
1235
  class << self
@@ -832,37 +1241,57 @@ class Packwerk::Reference < ::Struct
832
1241
  end
833
1242
 
834
1243
  module Packwerk::ReferenceChecking
1244
+ extend ::ActiveSupport::Autoload
835
1245
  end
836
1246
 
837
1247
  module Packwerk::ReferenceChecking::Checkers
1248
+ extend ::ActiveSupport::Autoload
838
1249
  end
839
1250
 
1251
+ # @abstract Subclasses must implement the `abstract` methods below.
840
1252
  module Packwerk::ReferenceChecking::Checkers::Checker
841
- interface!
1253
+ abstract!
842
1254
 
1255
+ # @abstract
843
1256
  sig { abstract.params(reference: ::Packwerk::Reference).returns(T::Boolean) }
844
1257
  def invalid_reference?(reference); end
845
1258
 
1259
+ # @abstract
1260
+ sig { abstract.params(reference: ::Packwerk::Reference).returns(::String) }
1261
+ def message(reference); end
1262
+
1263
+ sig { params(reference: ::Packwerk::Reference).returns(::String) }
1264
+ def standard_help_message(reference); end
1265
+
1266
+ # @abstract
846
1267
  sig { abstract.returns(::Packwerk::ViolationType) }
847
1268
  def violation_type; end
848
1269
  end
849
1270
 
1271
+ # Checks whether a given reference conforms to the configured graph of dependencies.
850
1272
  class Packwerk::ReferenceChecking::Checkers::DependencyChecker
851
1273
  include ::Packwerk::ReferenceChecking::Checkers::Checker
852
1274
 
853
1275
  sig { override.params(reference: ::Packwerk::Reference).returns(T::Boolean) }
854
1276
  def invalid_reference?(reference); end
855
1277
 
1278
+ sig { override.params(reference: ::Packwerk::Reference).returns(::String) }
1279
+ def message(reference); end
1280
+
856
1281
  sig { override.returns(::Packwerk::ViolationType) }
857
1282
  def violation_type; end
858
1283
  end
859
1284
 
1285
+ # Checks whether a given reference references a private constant of another package.
860
1286
  class Packwerk::ReferenceChecking::Checkers::PrivacyChecker
861
1287
  include ::Packwerk::ReferenceChecking::Checkers::Checker
862
1288
 
863
1289
  sig { override.params(reference: ::Packwerk::Reference).returns(T::Boolean) }
864
1290
  def invalid_reference?(reference); end
865
1291
 
1292
+ sig { override.params(reference: ::Packwerk::Reference).returns(::String) }
1293
+ def message(reference); end
1294
+
866
1295
  sig { override.returns(::Packwerk::ViolationType) }
867
1296
  def violation_type; end
868
1297
 
@@ -884,33 +1313,73 @@ class Packwerk::ReferenceChecking::ReferenceChecker
884
1313
  sig { params(checkers: T::Array[::Packwerk::ReferenceChecking::Checkers::Checker]).void }
885
1314
  def initialize(checkers); end
886
1315
 
887
- sig { params(reference: T.any(::Packwerk::Offense, ::Packwerk::Reference)).returns(T::Array[::Packwerk::Offense]) }
1316
+ sig { params(reference: ::Packwerk::Reference).returns(T::Array[::Packwerk::Offense]) }
888
1317
  def call(reference); end
889
1318
  end
890
1319
 
1320
+ # Extracts a possible constant reference from a given AST node.
891
1321
  class Packwerk::ReferenceExtractor
1322
+ sig do
1323
+ params(
1324
+ constant_name_inspectors: T::Array[::Packwerk::ConstantNameInspector],
1325
+ root_node: ::AST::Node,
1326
+ root_path: ::String
1327
+ ).void
1328
+ end
1329
+ def initialize(constant_name_inspectors:, root_node:, root_path:); end
1330
+
1331
+ sig do
1332
+ params(
1333
+ node: ::Parser::AST::Node,
1334
+ ancestors: T::Array[::Parser::AST::Node],
1335
+ relative_file: ::String
1336
+ ).returns(T.nilable(::Packwerk::UnresolvedReference))
1337
+ end
1338
+ def reference_from_node(node, ancestors:, relative_file:); end
1339
+
1340
+ private
1341
+
1342
+ # @return [Boolean]
1343
+ def local_reference?(constant_name, name_location, namespace_path); end
1344
+
1345
+ sig do
1346
+ params(
1347
+ constant_name: ::String,
1348
+ node: ::Parser::AST::Node,
1349
+ ancestors: T::Array[::Parser::AST::Node],
1350
+ relative_file: ::String
1351
+ ).returns(T.nilable(::Packwerk::UnresolvedReference))
1352
+ end
1353
+ def reference_from_constant(constant_name, node:, ancestors:, relative_file:); end
1354
+
1355
+ class << self
1356
+ sig do
1357
+ params(
1358
+ unresolved_references: T::Array[::Packwerk::UnresolvedReference],
1359
+ context_provider: ::Packwerk::ConstantDiscovery
1360
+ ).returns(T::Array[::Packwerk::Reference])
1361
+ end
1362
+ def get_fully_qualified_references_from(unresolved_references, context_provider); end
1363
+ end
892
1364
  end
893
1365
 
1366
+ # An offense related to a {Packwerk::Reference}.
894
1367
  class Packwerk::ReferenceOffense < ::Packwerk::Offense
895
1368
  sig do
896
1369
  params(
897
1370
  reference: ::Packwerk::Reference,
898
1371
  violation_type: ::Packwerk::ViolationType,
1372
+ message: ::String,
899
1373
  location: T.nilable(::Packwerk::Node::Location)
900
1374
  ).void
901
1375
  end
902
- def initialize(reference:, violation_type:, location: T.unsafe(nil)); end
1376
+ def initialize(reference:, violation_type:, message:, location: T.unsafe(nil)); end
903
1377
 
904
1378
  sig { returns(::Packwerk::Reference) }
905
1379
  def reference; end
906
1380
 
907
1381
  sig { returns(::Packwerk::ViolationType) }
908
1382
  def violation_type; end
909
-
910
- private
911
-
912
- sig { params(reference: ::Packwerk::Reference, violation_type: ::Packwerk::ViolationType).returns(::String) }
913
- def build_message(reference, violation_type); end
914
1383
  end
915
1384
 
916
1385
  class Packwerk::Result < ::T::Struct
@@ -922,19 +1391,101 @@ class Packwerk::Result < ::T::Struct
922
1391
  end
923
1392
  end
924
1393
 
1394
+ # Holds the context of a Packwerk run across multiple files.
925
1395
  class Packwerk::RunContext
1396
+ sig do
1397
+ params(
1398
+ root_path: ::String,
1399
+ load_paths: T::Hash[::String, ::Module],
1400
+ inflector: T.class_of(ActiveSupport::Inflector),
1401
+ cache_directory: ::Pathname,
1402
+ config_path: T.nilable(::String),
1403
+ package_paths: T.nilable(T.any(::String, T::Array[::String])),
1404
+ custom_associations: T.any(T::Array[::Symbol], T::Set[::Symbol]),
1405
+ checkers: T::Array[::Packwerk::ReferenceChecking::Checkers::Checker],
1406
+ cache_enabled: T::Boolean
1407
+ ).void
1408
+ end
1409
+ def initialize(root_path:, load_paths:, inflector:, cache_directory:, config_path: T.unsafe(nil), package_paths: T.unsafe(nil), custom_associations: T.unsafe(nil), checkers: T.unsafe(nil), cache_enabled: T.unsafe(nil)); end
1410
+
1411
+ sig { params(relative_file: ::String).returns(T::Array[::Packwerk::Offense]) }
1412
+ def process_file(relative_file:); end
1413
+
1414
+ private
1415
+
1416
+ sig { returns(T::Array[::Packwerk::ConstantNameInspector]) }
1417
+ def constant_name_inspectors; end
1418
+
1419
+ sig { returns(::Packwerk::ConstantDiscovery) }
1420
+ def context_provider; end
1421
+
1422
+ sig { returns(::Packwerk::FileProcessor) }
1423
+ def file_processor; end
1424
+
1425
+ sig { returns(::Packwerk::NodeProcessorFactory) }
1426
+ def node_processor_factory; end
1427
+
1428
+ sig { returns(Packwerk::PackageSet) }
1429
+ def package_set; end
1430
+
1431
+ sig { returns(::ConstantResolver) }
1432
+ def resolver; end
1433
+
1434
+ class << self
1435
+ sig { params(configuration: ::Packwerk::Configuration).returns(::Packwerk::RunContext) }
1436
+ def from_configuration(configuration); end
1437
+ end
926
1438
  end
927
1439
 
928
1440
  Packwerk::RunContext::DEFAULT_CHECKERS = T.let(T.unsafe(nil), Array)
929
1441
 
1442
+ # An unresolved reference from a file in one package to a constant that may be defined in a different package.
1443
+ # Unresolved means that we know how it's referred to in the file,
1444
+ # and we have enough context on that reference to figure out the fully qualified reference such that we
1445
+ # can produce a Reference in a separate pass. However, we have not yet resolved it to its fully qualified version.
930
1446
  class Packwerk::UnresolvedReference < ::Struct
1447
+ # Returns the value of attribute constant_name
1448
+ #
1449
+ # @return [Object] the current value of constant_name
931
1450
  def constant_name; end
1451
+
1452
+ # Sets the attribute constant_name
1453
+ #
1454
+ # @param value [Object] the value to set the attribute constant_name to.
1455
+ # @return [Object] the newly set value
932
1456
  def constant_name=(_); end
1457
+
1458
+ # Returns the value of attribute namespace_path
1459
+ #
1460
+ # @return [Object] the current value of namespace_path
933
1461
  def namespace_path; end
1462
+
1463
+ # Sets the attribute namespace_path
1464
+ #
1465
+ # @param value [Object] the value to set the attribute namespace_path to.
1466
+ # @return [Object] the newly set value
934
1467
  def namespace_path=(_); end
1468
+
1469
+ # Returns the value of attribute relative_path
1470
+ #
1471
+ # @return [Object] the current value of relative_path
935
1472
  def relative_path; end
1473
+
1474
+ # Sets the attribute relative_path
1475
+ #
1476
+ # @param value [Object] the value to set the attribute relative_path to.
1477
+ # @return [Object] the newly set value
936
1478
  def relative_path=(_); end
1479
+
1480
+ # Returns the value of attribute source_location
1481
+ #
1482
+ # @return [Object] the current value of source_location
937
1483
  def source_location; end
1484
+
1485
+ # Sets the attribute source_location
1486
+ #
1487
+ # @param value [Object] the value to set the attribute source_location to.
1488
+ # @return [Object] the newly set value
938
1489
  def source_location=(_); end
939
1490
 
940
1491
  class << self