danger-packwerk 0.9.0 → 0.11.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: cf8895f7ae2e94e0b1d09e146176b6777ba8f952fe03381380071114fcec2bd4
4
- data.tar.gz: 2e68e2096375433cfad68d85ca8d5eac7855dcb542b34f79417a53b1e4c9eb1b
3
+ metadata.gz: 0f8b77fc9b24c94b59f84416ca3a564d4bc83b2e0cb0e33608aa4ed08dc2fc69
4
+ data.tar.gz: df82d0bf21d6702747060d5d4d3e1ae8a3ed39973abdede4db7490d4e77aa2cd
5
5
  SHA512:
6
- metadata.gz: bfbe7e86650ac170c89c014f7519d0d40abdb3d864b995d8cdb5ef2478ec3e4fe6f2e3afc4854dbc216e622a8adc99761bd7d9a420167553db6b70084446740f
7
- data.tar.gz: b6729e1b52a5f25ae5da573d706bb1f3fc4217c750976dcd51aafd7611a5c7f53b4851727e3fd20cb66065570d2a99b0c4a4c367572c84fc08fb6918dfdfeb6b
6
+ metadata.gz: ab8300d69b2b95d6ee14c451d5cb266b4bea7b99b9c2e1a9691877a660128b367df2a65b6231c131591e19964aa2f75a0cb0c88277fba67a7c69f84ed9022e97
7
+ data.tar.gz: 97692e72e269be921be02e80094403e56ed9175089395827fd5443babbdbe7a6ae4ce47f8b75b821571c54df36734423426271f32fe293867be44e3f152e7ded
@@ -47,7 +47,7 @@ module DangerPackwerk
47
47
 
48
48
  from_package = ParsePackwerk.package_from_path(package_todo_yml_pathname)
49
49
  from_package_name = from_package.name
50
- violations = Private::PackageTodo.from(package_todo_yml_pathname).violations
50
+ violations = ParsePackwerk::PackageTodo.from(package_todo_yml_pathname).violations
51
51
 
52
52
  # See the larger comment below for more information on why we need this information.
53
53
  # This is a small optimization that lets us find the location of referenced files within
@@ -19,18 +19,24 @@ module DangerPackwerk
19
19
  DEFAULT_MAX_COMMENTS = 5
20
20
  BeforeComment = T.type_alias { T.proc.params(violation_diff: ViolationDiff, changed_package_todo_ymls: T::Array[String]).void }
21
21
  DEFAULT_BEFORE_COMMENT = T.let(->(violation_diff, changed_package_todo_ymls) {}, BeforeComment)
22
+ DEFAULT_VIOLATION_TYPES = T.let([
23
+ DEPENDENCY_VIOLATION_TYPE,
24
+ PRIVACY_VIOLATION_TYPE
25
+ ], T::Array[String])
22
26
 
23
27
  sig do
24
28
  params(
25
29
  offenses_formatter: T.nilable(Update::OffensesFormatter),
26
30
  before_comment: BeforeComment,
27
- max_comments: Integer
31
+ max_comments: Integer,
32
+ violation_types: T::Array[String]
28
33
  ).void
29
34
  end
30
35
  def check(
31
36
  offenses_formatter: nil,
32
37
  before_comment: DEFAULT_BEFORE_COMMENT,
33
- max_comments: DEFAULT_MAX_COMMENTS
38
+ max_comments: DEFAULT_MAX_COMMENTS,
39
+ violation_types: DEFAULT_VIOLATION_TYPES
34
40
  )
35
41
  offenses_formatter ||= Update::DefaultFormatter.new
36
42
  repo_link = github.pr_json[:base][:repo][:html_url]
@@ -38,7 +44,7 @@ module DangerPackwerk
38
44
 
39
45
  changed_package_todo_ymls = (git.modified_files + git.added_files + git.deleted_files).grep(PACKAGE_TODO_PATTERN)
40
46
 
41
- violation_diff = get_violation_diff
47
+ violation_diff = get_violation_diff(violation_types)
42
48
 
43
49
  before_comment.call(
44
50
  violation_diff,
@@ -62,8 +68,8 @@ module DangerPackwerk
62
68
  end
63
69
  end
64
70
 
65
- sig { returns(ViolationDiff) }
66
- def get_violation_diff # rubocop:disable Naming/AccessorMethodName
71
+ sig { params(violation_types: T::Array[String]).returns(ViolationDiff) }
72
+ def get_violation_diff(violation_types)
67
73
  added_violations = T.let([], T::Array[BasicReferenceOffense])
68
74
  removed_violations = T.let([], T::Array[BasicReferenceOffense])
69
75
 
@@ -117,12 +123,18 @@ module DangerPackwerk
117
123
  end
118
124
 
119
125
  relevant_added_violations = added_violations.reject do |violation|
120
- renamed_files_after.include?(violation.file) || renamed_constants.include?(violation.class_name)
126
+ renamed_files_after.include?(violation.file) ||
127
+ renamed_constants.include?(violation.class_name) ||
128
+ !violation_types.include?(violation.type)
129
+ end
130
+
131
+ relevant_removed_violations = removed_violations.select do |violation|
132
+ violation_types.include?(violation.type)
121
133
  end
122
134
 
123
135
  ViolationDiff.new(
124
136
  added_violations: relevant_added_violations,
125
- removed_violations: removed_violations
137
+ removed_violations: relevant_removed_violations
126
138
  )
127
139
  end
128
140
 
@@ -21,6 +21,10 @@ module DangerPackwerk
21
21
  DEFAULT_ON_FAILURE = T.let(->(offenses) {}, OnFailure)
22
22
  DEFAULT_FAIL = false
23
23
  DEFAULT_FAILURE_MESSAGE = 'Packwerk violations were detected! Please resolve them to unblock the build.'
24
+ DEFAULT_VIOLATION_TYPES = T.let([
25
+ DEPENDENCY_VIOLATION_TYPE,
26
+ PRIVACY_VIOLATION_TYPE
27
+ ], T::Array[String])
24
28
 
25
29
  class CommentGroupingStrategy < ::T::Enum
26
30
  enums do
@@ -38,6 +42,7 @@ module DangerPackwerk
38
42
  fail_build: T::Boolean,
39
43
  failure_message: String,
40
44
  on_failure: OnFailure,
45
+ violation_types: T::Array[String],
41
46
  grouping_strategy: CommentGroupingStrategy
42
47
  ).void
43
48
  end
@@ -47,6 +52,7 @@ module DangerPackwerk
47
52
  fail_build: DEFAULT_FAIL,
48
53
  failure_message: DEFAULT_FAILURE_MESSAGE,
49
54
  on_failure: DEFAULT_ON_FAILURE,
55
+ violation_types: DEFAULT_VIOLATION_TYPES,
50
56
  grouping_strategy: CommentGroupingStrategy::PerConstantPerLocation
51
57
  )
52
58
  offenses_formatter ||= Check::DefaultFormatter.new
@@ -88,11 +94,13 @@ module DangerPackwerk
88
94
 
89
95
  renamed_files = git.renamed_files.map { |before_after_file| before_after_file[:after] }
90
96
 
91
- # Ignore references that have been renamed
92
97
  packwerk_reference_offenses_to_care_about = packwerk_reference_offenses.reject do |packwerk_reference_offense|
93
98
  constant_name = packwerk_reference_offense.reference.constant.name
94
99
  filepath_that_defines_this_constant = Private.constant_resolver.resolve(constant_name)&.location
95
- renamed_files.include?(filepath_that_defines_this_constant)
100
+ # Ignore references that have been renamed
101
+ renamed_files.include?(filepath_that_defines_this_constant) ||
102
+ # Ignore violations that are not in the allow-list of violation types to leave comments for
103
+ !violation_types.include?(packwerk_reference_offense.violation_type)
96
104
  end
97
105
 
98
106
  # 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
@@ -56,7 +56,9 @@ module DangerPackwerk
56
56
  ''
57
57
  end
58
58
 
59
- sig { override.params(offense_collection: Packwerk::OffenseCollection, for_files: T::Set[String]).returns(String) }
59
+ # T.untyped should be Packwerk::OffenseCollection, but is currently private until
60
+ # https://github.com/Shopify/packwerk/pull/289 merges
61
+ sig { override.params(offense_collection: T.untyped, for_files: T::Set[String]).returns(String) }
60
62
  def show_stale_violations(offense_collection, for_files)
61
63
  ''
62
64
  end
@@ -1,6 +1,5 @@
1
1
  # typed: strict
2
2
 
3
- require 'danger-packwerk/private/package_todo'
4
3
  require 'danger-packwerk/private/ownership_information'
5
4
  require 'constant_resolver'
6
5
 
@@ -2,5 +2,5 @@
2
2
  # frozen_string_literal: true
3
3
 
4
4
  module DangerPackwerk
5
- VERSION = '0.9.0'
5
+ VERSION = '0.11.0'
6
6
  end
@@ -67,7 +67,7 @@ class Packwerk::ApplicationValidator
67
67
  .params(
68
68
  package_set: Packwerk::PackageSet,
69
69
  configuration: ::Packwerk::Configuration
70
- ).returns(::Packwerk::ApplicationValidator::Result)
70
+ ).returns(::Packwerk::Validator::Result)
71
71
  end
72
72
  def call(package_set, configuration); end
73
73
 
@@ -76,24 +76,24 @@ class Packwerk::ApplicationValidator
76
76
  params(
77
77
  package_set: Packwerk::PackageSet,
78
78
  configuration: ::Packwerk::Configuration
79
- ).returns(::Packwerk::ApplicationValidator::Result)
79
+ ).returns(::Packwerk::Validator::Result)
80
80
  end
81
81
  def check_all(package_set, configuration); end
82
82
 
83
83
  # source://packwerk//lib/packwerk/application_validator.rb#69
84
- sig { params(configuration: ::Packwerk::Configuration).returns(::Packwerk::ApplicationValidator::Result) }
84
+ sig { params(configuration: ::Packwerk::Configuration).returns(::Packwerk::Validator::Result) }
85
85
  def check_application_structure(configuration); end
86
86
 
87
87
  # source://packwerk//lib/packwerk/application_validator.rb#84
88
- sig { params(configuration: ::Packwerk::Configuration).returns(::Packwerk::ApplicationValidator::Result) }
88
+ sig { params(configuration: ::Packwerk::Configuration).returns(::Packwerk::Validator::Result) }
89
89
  def check_package_manifest_paths(configuration); end
90
90
 
91
91
  # source://packwerk//lib/packwerk/application_validator.rb#41
92
- sig { params(configuration: ::Packwerk::Configuration).returns(::Packwerk::ApplicationValidator::Result) }
92
+ sig { params(configuration: ::Packwerk::Configuration).returns(::Packwerk::Validator::Result) }
93
93
  def check_package_manifest_syntax(configuration); end
94
94
 
95
95
  # source://packwerk//lib/packwerk/application_validator.rb#105
96
- sig { params(configuration: ::Packwerk::Configuration).returns(::Packwerk::ApplicationValidator::Result) }
96
+ sig { params(configuration: ::Packwerk::Configuration).returns(::Packwerk::Validator::Result) }
97
97
  def check_root_package_exists(configuration); end
98
98
 
99
99
  # source://packwerk//lib/packwerk/application_validator.rb#34
@@ -111,21 +111,6 @@ class Packwerk::ApplicationValidator
111
111
  def relative_paths(configuration, paths); end
112
112
  end
113
113
 
114
- # source://packwerk//lib/packwerk/application_validator/result.rb#6
115
- class Packwerk::ApplicationValidator::Result < ::T::Struct
116
- const :ok, T::Boolean
117
- const :error_value, T.nilable(::String)
118
-
119
- # source://packwerk//lib/packwerk/application_validator/result.rb#13
120
- sig { returns(T::Boolean) }
121
- def ok?; end
122
-
123
- class << self
124
- # source://sorbet-runtime/0.5.10588/lib/types/struct.rb#13
125
- def inherited(s); end
126
- end
127
- end
128
-
129
114
  # Extracts the implicit constant reference from an active record association
130
115
  #
131
116
  # source://packwerk//lib/packwerk/association_inspector.rb#6
@@ -287,6 +272,8 @@ end
287
272
  #
288
273
  # source://packwerk//lib/packwerk/cli.rb#8
289
274
  class Packwerk::Cli
275
+ extend ::ActiveSupport::Autoload
276
+
290
277
  # source://packwerk//lib/packwerk/cli.rb#21
291
278
  sig do
292
279
  params(
@@ -327,19 +314,19 @@ class Packwerk::Cli
327
314
  sig { returns(T::Boolean) }
328
315
  def init; end
329
316
 
330
- # source://packwerk//lib/packwerk/cli.rb#174
331
- sig { params(result: ::Packwerk::ApplicationValidator::Result).void }
317
+ # source://packwerk//lib/packwerk/cli.rb#176
318
+ sig { params(result: ::Packwerk::Validator::Result).void }
332
319
  def list_validation_errors(result); end
333
320
 
334
321
  # source://packwerk//lib/packwerk/cli.rb#123
335
- sig { params(result: ::Packwerk::Result).returns(T::Boolean) }
322
+ sig { params(result: ::Packwerk::Cli::Result).returns(T::Boolean) }
336
323
  def output_result(result); end
337
324
 
338
- # source://packwerk//lib/packwerk/cli.rb#166
325
+ # source://packwerk//lib/packwerk/cli.rb#168
339
326
  sig { returns(Packwerk::PackageSet) }
340
327
  def package_set; end
341
328
 
342
- # source://packwerk//lib/packwerk/cli.rb#186
329
+ # source://packwerk//lib/packwerk/cli.rb#188
343
330
  sig { params(args: T::Array[::String]).returns(::Packwerk::ParseRun) }
344
331
  def parse_run(args); end
345
332
 
@@ -351,11 +338,22 @@ class Packwerk::Cli
351
338
  sig { params(_paths: T::Array[::String]).returns(T::Boolean) }
352
339
  def validate(_paths); end
353
340
 
354
- # source://packwerk//lib/packwerk/cli.rb#161
341
+ # source://packwerk//lib/packwerk/cli.rb#163
355
342
  sig { returns(::Packwerk::ApplicationValidator) }
356
343
  def validator; end
357
344
  end
358
345
 
346
+ # source://packwerk//lib/packwerk/cli/result.rb#6
347
+ class Packwerk::Cli::Result < ::T::Struct
348
+ const :message, ::String
349
+ const :status, T::Boolean
350
+
351
+ class << self
352
+ # source://sorbet-runtime/0.5.10588/lib/types/struct.rb#13
353
+ def inherited(s); end
354
+ end
355
+ end
356
+
359
357
  # source://packwerk//lib/packwerk/configuration.rb#8
360
358
  class Packwerk::Configuration
361
359
  # @return [Configuration] a new instance of Configuration
@@ -462,44 +460,8 @@ class Packwerk::ConstNodeInspector
462
460
  def root_constant?(parent); end
463
461
  end
464
462
 
465
- # Get information about unresolved constants without loading the application code.
466
- # Information gathered: Fully qualified name, path to file containing the definition, package,
467
- # and visibility (public/private to the package).
468
- #
469
- # The implementation makes a few assumptions about the code base:
470
- # - `Something::SomeOtherThing` is defined in a path of either `something/some_other_thing.rb` or `something.rb`,
471
- # relative to the load path. Rails' `zeitwerk` autoloader makes the same assumption.
472
- # - It is OK to not always infer the exact file defining the constant. For example, when a constant is inherited, we
473
- # have no way of inferring the file it is defined in. You could argue though that inheritance means that another
474
- # constant with the same name exists in the inheriting class, and this view is sufficient for all our use cases.
475
- #
476
- # source://packwerk//lib/packwerk/constant_discovery.rb#17
477
- class Packwerk::ConstantDiscovery
478
- # source://packwerk//lib/packwerk/constant_discovery.rb#27
479
- sig { params(constant_resolver: ::ConstantResolver, packages: Packwerk::PackageSet).void }
480
- def initialize(constant_resolver:, packages:); end
481
-
482
- # Analyze a constant via its name.
483
- # If the constant is unresolved, we need the current namespace path to correctly infer its full name
484
- #
485
- # source://packwerk//lib/packwerk/constant_discovery.rb#60
486
- sig do
487
- params(
488
- const_name: ::String,
489
- current_namespace_path: T.nilable(T::Array[::String])
490
- ).returns(T.nilable(::Packwerk::ConstantDiscovery::ConstantContext))
491
- end
492
- def context_for(const_name, current_namespace_path: T.unsafe(nil)); end
493
-
494
- # Get the package that owns a given file path.
495
- #
496
- # source://packwerk//lib/packwerk/constant_discovery.rb#43
497
- sig { params(path: ::String).returns(::Packwerk::Package) }
498
- def package_from_path(path); end
499
- end
500
-
501
- # source://packwerk//lib/packwerk/constant_discovery.rb#20
502
- class Packwerk::ConstantDiscovery::ConstantContext < ::Struct
463
+ # source://packwerk//lib/packwerk/constant_context.rb#9
464
+ class Packwerk::ConstantContext < ::Struct
503
465
  # Returns the value of attribute location
504
466
  #
505
467
  # @return [Object] the current value of location
@@ -510,7 +472,7 @@ class Packwerk::ConstantDiscovery::ConstantContext < ::Struct
510
472
  # @param value [Object] the value to set the attribute location to.
511
473
  # @return [Object] the newly set value
512
474
  #
513
- # source://packwerk//lib/packwerk/constant_discovery.rb#20
475
+ # source://packwerk//lib/packwerk/constant_context.rb#9
514
476
  def location=(_); end
515
477
 
516
478
  # Returns the value of attribute name
@@ -523,7 +485,7 @@ class Packwerk::ConstantDiscovery::ConstantContext < ::Struct
523
485
  # @param value [Object] the value to set the attribute name to.
524
486
  # @return [Object] the newly set value
525
487
  #
526
- # source://packwerk//lib/packwerk/constant_discovery.rb#20
488
+ # source://packwerk//lib/packwerk/constant_context.rb#9
527
489
  def name=(_); end
528
490
 
529
491
  # Returns the value of attribute package
@@ -536,7 +498,7 @@ class Packwerk::ConstantDiscovery::ConstantContext < ::Struct
536
498
  # @param value [Object] the value to set the attribute package to.
537
499
  # @return [Object] the newly set value
538
500
  #
539
- # source://packwerk//lib/packwerk/constant_discovery.rb#20
501
+ # source://packwerk//lib/packwerk/constant_context.rb#9
540
502
  def package=(_); end
541
503
 
542
504
  class << self
@@ -547,6 +509,42 @@ class Packwerk::ConstantDiscovery::ConstantContext < ::Struct
547
509
  end
548
510
  end
549
511
 
512
+ # Get information about unresolved constants without loading the application code.
513
+ # Information gathered: Fully qualified name, path to file containing the definition, package,
514
+ # and visibility (public/private to the package).
515
+ #
516
+ # The implementation makes a few assumptions about the code base:
517
+ # - `Something::SomeOtherThing` is defined in a path of either `something/some_other_thing.rb` or `something.rb`,
518
+ # relative to the load path. Rails' `zeitwerk` autoloader makes the same assumption.
519
+ # - It is OK to not always infer the exact file defining the constant. For example, when a constant is inherited, we
520
+ # have no way of inferring the file it is defined in. You could argue though that inheritance means that another
521
+ # constant with the same name exists in the inheriting class, and this view is sufficient for all our use cases.
522
+ #
523
+ # source://packwerk//lib/packwerk/constant_discovery.rb#17
524
+ class Packwerk::ConstantDiscovery
525
+ # source://packwerk//lib/packwerk/constant_discovery.rb#25
526
+ sig { params(constant_resolver: ::ConstantResolver, packages: Packwerk::PackageSet).void }
527
+ def initialize(constant_resolver:, packages:); end
528
+
529
+ # Analyze a constant via its name.
530
+ # If the constant is unresolved, we need the current namespace path to correctly infer its full name
531
+ #
532
+ # source://packwerk//lib/packwerk/constant_discovery.rb#58
533
+ sig do
534
+ params(
535
+ const_name: ::String,
536
+ current_namespace_path: T.nilable(T::Array[::String])
537
+ ).returns(T.nilable(::Packwerk::ConstantContext))
538
+ end
539
+ def context_for(const_name, current_namespace_path: T.unsafe(nil)); end
540
+
541
+ # Get the package that owns a given file path.
542
+ #
543
+ # source://packwerk//lib/packwerk/constant_discovery.rb#41
544
+ sig { params(path: ::String).returns(::Packwerk::Package) }
545
+ def package_from_path(path); end
546
+ end
547
+
550
548
  # An interface describing an object that can extract a constant name from an AST node.
551
549
  #
552
550
  # @abstract Subclasses must implement the `abstract` methods below.
@@ -694,24 +692,24 @@ end
694
692
  # source://packwerk//lib/packwerk/files_for_processing.rb#8
695
693
  Packwerk::FilesForProcessing::RelativeFileSet = T.type_alias { T::Set[::String] }
696
694
 
697
- # source://packwerk//lib/packwerk.rb#66
695
+ # source://packwerk//lib/packwerk.rb#51
698
696
  module Packwerk::Formatters
699
697
  extend ::ActiveSupport::Autoload
700
698
  end
701
699
 
702
- # source://packwerk//lib/packwerk/formatters/offenses_formatter.rb#6
703
- class Packwerk::Formatters::OffensesFormatter
700
+ # source://packwerk//lib/packwerk/formatters/default_offenses_formatter.rb#6
701
+ class Packwerk::Formatters::DefaultOffensesFormatter
704
702
  include ::Packwerk::OffensesFormatter
705
703
 
706
- # source://packwerk//lib/packwerk/formatters/offenses_formatter.rb#33
704
+ # source://packwerk//lib/packwerk/formatters/default_offenses_formatter.rb#33
707
705
  sig { override.returns(::String) }
708
706
  def identifier; end
709
707
 
710
- # source://packwerk//lib/packwerk/formatters/offenses_formatter.rb#14
708
+ # source://packwerk//lib/packwerk/formatters/default_offenses_formatter.rb#14
711
709
  sig { override.params(offenses: T::Array[T.nilable(::Packwerk::Offense)]).returns(::String) }
712
710
  def show_offenses(offenses); end
713
711
 
714
- # source://packwerk//lib/packwerk/formatters/offenses_formatter.rb#24
712
+ # source://packwerk//lib/packwerk/formatters/default_offenses_formatter.rb#24
715
713
  sig do
716
714
  override
717
715
  .params(
@@ -721,31 +719,31 @@ class Packwerk::Formatters::OffensesFormatter
721
719
  end
722
720
  def show_stale_violations(offense_collection, fileset); end
723
721
 
724
- # source://packwerk//lib/packwerk/formatters/offenses_formatter.rb#38
722
+ # source://packwerk//lib/packwerk/formatters/default_offenses_formatter.rb#38
725
723
  sig { override.params(strict_mode_violations: T::Array[::Packwerk::ReferenceOffense]).returns(::String) }
726
724
  def show_strict_mode_violations(strict_mode_violations); end
727
725
 
728
726
  private
729
727
 
730
- # source://packwerk//lib/packwerk/formatters/offenses_formatter.rb#54
728
+ # source://packwerk//lib/packwerk/formatters/default_offenses_formatter.rb#54
731
729
  sig { params(offense: ::Packwerk::ReferenceOffense).returns(::String) }
732
730
  def format_strict_mode_violation(offense); end
733
731
 
734
- # source://packwerk//lib/packwerk/formatters/offenses_formatter.rb#62
732
+ # source://packwerk//lib/packwerk/formatters/default_offenses_formatter.rb#62
735
733
  sig { params(offenses: T::Array[T.nilable(::Packwerk::Offense)]).returns(::String) }
736
734
  def offenses_list(offenses); end
737
735
 
738
- # source://packwerk//lib/packwerk/formatters/offenses_formatter.rb#70
736
+ # source://packwerk//lib/packwerk/formatters/default_offenses_formatter.rb#70
739
737
  sig { params(offenses: T::Array[T.nilable(::Packwerk::Offense)]).returns(::String) }
740
738
  def offenses_summary(offenses); end
741
739
 
742
- # source://packwerk//lib/packwerk/formatters/offenses_formatter.rb#49
740
+ # source://packwerk//lib/packwerk/formatters/default_offenses_formatter.rb#49
743
741
  sig { returns(::Packwerk::OutputStyle) }
744
742
  def style; end
745
743
  end
746
744
 
747
- # source://packwerk//lib/packwerk/formatters/offenses_formatter.rb#9
748
- Packwerk::Formatters::OffensesFormatter::IDENTIFIER = T.let(T.unsafe(nil), String)
745
+ # source://packwerk//lib/packwerk/formatters/default_offenses_formatter.rb#9
746
+ Packwerk::Formatters::DefaultOffensesFormatter::IDENTIFIER = T.let(T.unsafe(nil), String)
749
747
 
750
748
  # source://packwerk//lib/packwerk/formatters/progress_formatter.rb#8
751
749
  class Packwerk::Formatters::ProgressFormatter
@@ -753,58 +751,69 @@ class Packwerk::Formatters::ProgressFormatter
753
751
  sig { params(out: T.any(::IO, ::StringIO), style: ::Packwerk::OutputStyle).void }
754
752
  def initialize(out, style: T.unsafe(nil)); end
755
753
 
756
- # source://packwerk//lib/packwerk/formatters/progress_formatter.rb#39
754
+ # source://packwerk//lib/packwerk/formatters/progress_formatter.rb#44
755
+ sig { void }
757
756
  def interrupted; end
758
757
 
759
- # source://packwerk//lib/packwerk/formatters/progress_formatter.rb#35
758
+ # source://packwerk//lib/packwerk/formatters/progress_formatter.rb#39
759
+ sig { void }
760
760
  def mark_as_failed; end
761
761
 
762
- # source://packwerk//lib/packwerk/formatters/progress_formatter.rb#31
762
+ # source://packwerk//lib/packwerk/formatters/progress_formatter.rb#34
763
+ sig { void }
763
764
  def mark_as_inspected; end
764
765
 
765
- # source://packwerk//lib/packwerk/formatters/progress_formatter.rb#24
766
+ # source://packwerk//lib/packwerk/formatters/progress_formatter.rb#26
767
+ sig { params(target_files: T::Set[::String], block: T.proc.void).void }
766
768
  def started_inspection(target_files, &block); end
767
769
 
768
- # source://packwerk//lib/packwerk/formatters/progress_formatter.rb#17
770
+ # source://packwerk//lib/packwerk/formatters/progress_formatter.rb#18
771
+ sig { params(block: T.proc.void).void }
769
772
  def started_validation(&block); end
770
773
 
771
774
  private
772
775
 
773
- # source://packwerk//lib/packwerk/formatters/progress_formatter.rb#46
776
+ # source://packwerk//lib/packwerk/formatters/progress_formatter.rb#52
777
+ sig { params(execution_time: ::Float).void }
774
778
  def finished(execution_time); end
775
779
 
776
- # source://packwerk//lib/packwerk/formatters/progress_formatter.rb#55
780
+ # source://packwerk//lib/packwerk/formatters/progress_formatter.rb#63
781
+ sig { params(target_files: T::Set[::String]).void }
777
782
  def start_inspection(target_files); end
778
783
 
779
- # source://packwerk//lib/packwerk/formatters/progress_formatter.rb#51
784
+ # source://packwerk//lib/packwerk/formatters/progress_formatter.rb#58
785
+ sig { void }
780
786
  def start_validation; end
781
787
  end
782
788
 
783
- # source://packwerk//lib/packwerk.rb#72
789
+ # source://packwerk//lib/packwerk.rb#87
784
790
  module Packwerk::Generators
785
791
  extend ::ActiveSupport::Autoload
786
792
  end
787
793
 
788
794
  # source://packwerk//lib/packwerk/generators/configuration_file.rb#8
789
795
  class Packwerk::Generators::ConfigurationFile
790
- # source://packwerk//lib/packwerk/generators/configuration_file.rb#20
796
+ # source://packwerk//lib/packwerk/generators/configuration_file.rb#23
791
797
  sig { params(root: ::String, out: T.any(::IO, ::StringIO)).void }
792
798
  def initialize(root:, out: T.unsafe(nil)); end
793
799
 
794
- # source://packwerk//lib/packwerk/generators/configuration_file.rb#26
800
+ # source://packwerk//lib/packwerk/generators/configuration_file.rb#29
795
801
  sig { returns(T::Boolean) }
796
802
  def generate; end
797
803
 
798
804
  private
799
805
 
800
- # source://packwerk//lib/packwerk/generators/configuration_file.rb#43
806
+ # source://packwerk//lib/packwerk/generators/configuration_file.rb#47
807
+ sig { returns(::String) }
801
808
  def render; end
802
809
 
803
- # source://packwerk//lib/packwerk/generators/configuration_file.rb#47
810
+ # source://packwerk//lib/packwerk/generators/configuration_file.rb#52
811
+ sig { returns(::String) }
804
812
  def template; end
805
813
 
806
814
  class << self
807
- # source://packwerk//lib/packwerk/generators/configuration_file.rb#14
815
+ # source://packwerk//lib/packwerk/generators/configuration_file.rb#17
816
+ sig { params(root: ::String, out: T.any(::IO, ::StringIO)).returns(T::Boolean) }
808
817
  def generate(root:, out:); end
809
818
  end
810
819
  end
@@ -814,17 +823,17 @@ Packwerk::Generators::ConfigurationFile::CONFIGURATION_TEMPLATE_FILE_PATH = T.le
814
823
 
815
824
  # source://packwerk//lib/packwerk/generators/root_package.rb#6
816
825
  class Packwerk::Generators::RootPackage
817
- # @return [RootPackage] a new instance of RootPackage
818
- #
819
- # source://packwerk//lib/packwerk/generators/root_package.rb#15
826
+ # source://packwerk//lib/packwerk/generators/root_package.rb#19
827
+ sig { params(root: ::String, out: T.any(::IO, ::StringIO)).void }
820
828
  def initialize(root:, out: T.unsafe(nil)); end
821
829
 
822
- # source://packwerk//lib/packwerk/generators/root_package.rb#21
830
+ # source://packwerk//lib/packwerk/generators/root_package.rb#25
823
831
  sig { returns(T::Boolean) }
824
832
  def generate; end
825
833
 
826
834
  class << self
827
- # source://packwerk//lib/packwerk/generators/root_package.rb#10
835
+ # source://packwerk//lib/packwerk/generators/root_package.rb#13
836
+ sig { params(root: ::String, out: T.any(::IO, ::StringIO)).returns(T::Boolean) }
828
837
  def generate(root:, out:); end
829
838
  end
830
839
  end
@@ -864,7 +873,7 @@ class Packwerk::Graph
864
873
  end
865
874
 
866
875
  # source://packwerk//lib/packwerk/node.rb#5
867
- class Packwerk::Node; end
876
+ module Packwerk::Node; end
868
877
 
869
878
  # source://packwerk//lib/packwerk/node.rb#6
870
879
  class Packwerk::Node::Location < ::Struct
@@ -1279,7 +1288,7 @@ module Packwerk::OutputStyle
1279
1288
  def reset; end
1280
1289
  end
1281
1290
 
1282
- # source://packwerk//lib/packwerk.rb#55
1291
+ # source://packwerk//lib/packwerk.rb#40
1283
1292
  module Packwerk::OutputStyles
1284
1293
  extend ::ActiveSupport::Autoload
1285
1294
  end
@@ -1503,11 +1512,11 @@ class Packwerk::ParseRun
1503
1512
  def initialize(relative_file_set:, configuration:, file_set_specified: T.unsafe(nil), offenses_formatter: T.unsafe(nil), progress_formatter: T.unsafe(nil)); end
1504
1513
 
1505
1514
  # source://packwerk//lib/packwerk/parse_run.rb#61
1506
- sig { returns(::Packwerk::Result) }
1515
+ sig { returns(::Packwerk::Cli::Result) }
1507
1516
  def check; end
1508
1517
 
1509
1518
  # source://packwerk//lib/packwerk/parse_run.rb#39
1510
- sig { returns(::Packwerk::Result) }
1519
+ sig { returns(::Packwerk::Cli::Result) }
1511
1520
  def update_todo; end
1512
1521
 
1513
1522
  private
@@ -1569,25 +1578,33 @@ module Packwerk::Parsers; end
1569
1578
  class Packwerk::Parsers::Erb
1570
1579
  include ::Packwerk::Parsers::ParserInterface
1571
1580
 
1572
- # @return [Erb] a new instance of Erb
1573
- #
1574
- # source://packwerk//lib/packwerk/parsers/erb.rb#14
1581
+ # source://packwerk//lib/packwerk/parsers/erb.rb#17
1582
+ sig { params(parser_class: T.untyped, ruby_parser: ::Packwerk::Parsers::Ruby).void }
1575
1583
  def initialize(parser_class: T.unsafe(nil), ruby_parser: T.unsafe(nil)); end
1576
1584
 
1577
- # source://packwerk//lib/packwerk/parsers/erb.rb#19
1585
+ # source://packwerk//lib/packwerk/parsers/erb.rb#23
1586
+ sig { override.params(io: T.any(::IO, ::StringIO), file_path: ::String).returns(T.untyped) }
1578
1587
  def call(io:, file_path: T.unsafe(nil)); end
1579
1588
 
1580
- # source://packwerk//lib/packwerk/parsers/erb.rb#25
1589
+ # source://packwerk//lib/packwerk/parsers/erb.rb#30
1590
+ sig { params(buffer: ::Parser::Source::Buffer, file_path: ::String).returns(T.nilable(::AST::Node)) }
1581
1591
  def parse_buffer(buffer, file_path:); end
1582
1592
 
1583
1593
  private
1584
1594
 
1585
1595
  # @yield [node]
1586
1596
  #
1587
- # source://packwerk//lib/packwerk/parsers/erb.rb#52
1597
+ # source://packwerk//lib/packwerk/parsers/erb.rb#71
1598
+ sig do
1599
+ params(
1600
+ node: T.nilable(T.any(::AST::Node, ::String)),
1601
+ block: T.nilable(T.proc.params(arg0: ::AST::Node).void)
1602
+ ).returns(T.nilable(T.any(T::Array[::String], T::Enumerator[::AST::Node])))
1603
+ end
1588
1604
  def code_nodes(node, &block); end
1589
1605
 
1590
- # source://packwerk//lib/packwerk/parsers/erb.rb#38
1606
+ # source://packwerk//lib/packwerk/parsers/erb.rb#49
1607
+ sig { params(erb_ast: T.all(::AST::Node, ::Object), file_path: ::String).returns(T.nilable(::AST::Node)) }
1591
1608
  def to_ruby_ast(erb_ast, file_path); end
1592
1609
  end
1593
1610
 
@@ -1596,13 +1613,19 @@ class Packwerk::Parsers::Factory
1596
1613
  include ::Singleton
1597
1614
  extend ::Singleton::SingletonClassMethods
1598
1615
 
1599
- # source://packwerk//lib/packwerk/parsers/factory.rb#33
1616
+ # source://packwerk//lib/packwerk/parsers/factory.rb#24
1617
+ sig { void }
1618
+ def initialize; end
1619
+
1620
+ # source://packwerk//lib/packwerk/parsers/factory.rb#41
1621
+ sig { returns(::Class) }
1600
1622
  def erb_parser_class; end
1601
1623
 
1602
- # source://packwerk//lib/packwerk/parsers/factory.rb#37
1624
+ # source://packwerk//lib/packwerk/parsers/factory.rb#46
1625
+ sig { params(klass: T.nilable(::Class)).void }
1603
1626
  def erb_parser_class=(klass); end
1604
1627
 
1605
- # source://packwerk//lib/packwerk/parsers/factory.rb#24
1628
+ # source://packwerk//lib/packwerk/parsers/factory.rb#31
1606
1629
  sig { params(path: ::String).returns(T.nilable(::Packwerk::Parsers::ParserInterface)) }
1607
1630
  def for_path(path); end
1608
1631
  end
@@ -1640,7 +1663,7 @@ module Packwerk::Parsers::ParserInterface
1640
1663
  # @abstract
1641
1664
  #
1642
1665
  # source://packwerk//lib/packwerk/parsers/parser_interface.rb#15
1643
- sig { abstract.params(io: ::File, file_path: ::String).returns(T.untyped) }
1666
+ sig { abstract.params(io: T.any(::IO, ::StringIO), file_path: ::String).returns(T.untyped) }
1644
1667
  def call(io:, file_path:); end
1645
1668
  end
1646
1669
 
@@ -1648,26 +1671,26 @@ end
1648
1671
  class Packwerk::Parsers::Ruby
1649
1672
  include ::Packwerk::Parsers::ParserInterface
1650
1673
 
1651
- # @return [Ruby] a new instance of Ruby
1652
- #
1653
- # source://packwerk//lib/packwerk/parsers/ruby.rb#25
1674
+ # source://packwerk//lib/packwerk/parsers/ruby.rb#34
1675
+ sig { params(parser_class: T.untyped).void }
1654
1676
  def initialize(parser_class: T.unsafe(nil)); end
1655
1677
 
1656
- # source://packwerk//lib/packwerk/parsers/ruby.rb#30
1678
+ # source://packwerk//lib/packwerk/parsers/ruby.rb#40
1679
+ sig { override.params(io: T.any(::IO, ::StringIO), file_path: ::String).returns(T.nilable(::Parser::AST::Node)) }
1657
1680
  def call(io:, file_path: T.unsafe(nil)); end
1658
1681
  end
1659
1682
 
1660
- # source://packwerk//lib/packwerk/parsers/ruby.rb#12
1683
+ # source://packwerk//lib/packwerk/parsers/ruby.rb#14
1661
1684
  class Packwerk::Parsers::Ruby::RaiseExceptionsParser < ::Parser::Ruby27
1662
- # @return [RaiseExceptionsParser] a new instance of RaiseExceptionsParser
1663
- #
1664
- # source://packwerk//lib/packwerk/parsers/ruby.rb#13
1685
+ # source://packwerk//lib/packwerk/parsers/ruby.rb#18
1686
+ sig { params(builder: T.untyped).void }
1665
1687
  def initialize(builder); end
1666
1688
  end
1667
1689
 
1668
- # source://packwerk//lib/packwerk/parsers/ruby.rb#19
1690
+ # source://packwerk//lib/packwerk/parsers/ruby.rb#24
1669
1691
  class Packwerk::Parsers::Ruby::TolerateInvalidUtf8Builder < ::Parser::Builders::Default
1670
- # source://packwerk//lib/packwerk/parsers/ruby.rb#20
1692
+ # source://packwerk//lib/packwerk/parsers/ruby.rb#28
1693
+ sig { params(token: T.untyped).returns(T.untyped) }
1671
1694
  def string_value(token); end
1672
1695
  end
1673
1696
 
@@ -1738,12 +1761,12 @@ class Packwerk::Reference < ::Struct
1738
1761
  end
1739
1762
  end
1740
1763
 
1741
- # source://packwerk//lib/packwerk.rb#79
1764
+ # source://packwerk//lib/packwerk.rb#96
1742
1765
  module Packwerk::ReferenceChecking
1743
1766
  extend ::ActiveSupport::Autoload
1744
1767
  end
1745
1768
 
1746
- # source://packwerk//lib/packwerk.rb#84
1769
+ # source://packwerk//lib/packwerk.rb#101
1747
1770
  module Packwerk::ReferenceChecking::Checkers
1748
1771
  extend ::ActiveSupport::Autoload
1749
1772
  end
@@ -1805,7 +1828,7 @@ class Packwerk::ReferenceExtractor
1805
1828
  end
1806
1829
  def initialize(constant_name_inspectors:, root_node:, root_path:); end
1807
1830
 
1808
- # source://packwerk//lib/packwerk/reference_extractor.rb#76
1831
+ # source://packwerk//lib/packwerk/reference_extractor.rb#79
1809
1832
  sig do
1810
1833
  params(
1811
1834
  node: ::Parser::AST::Node,
@@ -1817,12 +1840,17 @@ class Packwerk::ReferenceExtractor
1817
1840
 
1818
1841
  private
1819
1842
 
1820
- # @return [Boolean]
1821
- #
1822
- # source://packwerk//lib/packwerk/reference_extractor.rb#120
1843
+ # source://packwerk//lib/packwerk/reference_extractor.rb#130
1844
+ sig do
1845
+ params(
1846
+ constant_name: ::String,
1847
+ name_location: T.nilable(::Packwerk::Node::Location),
1848
+ namespace_path: T::Array[::String]
1849
+ ).returns(T::Boolean)
1850
+ end
1823
1851
  def local_reference?(constant_name, name_location, namespace_path); end
1824
1852
 
1825
- # source://packwerk//lib/packwerk/reference_extractor.rb#105
1853
+ # source://packwerk//lib/packwerk/reference_extractor.rb#108
1826
1854
  sig do
1827
1855
  params(
1828
1856
  constant_name: ::String,
@@ -1869,17 +1897,6 @@ class Packwerk::ReferenceOffense < ::Packwerk::Offense
1869
1897
  def violation_type; end
1870
1898
  end
1871
1899
 
1872
- # source://packwerk//lib/packwerk/result.rb#5
1873
- class Packwerk::Result < ::T::Struct
1874
- const :message, ::String
1875
- const :status, T::Boolean
1876
-
1877
- class << self
1878
- # source://sorbet-runtime/0.5.10588/lib/types/struct.rb#13
1879
- def inherited(s); end
1880
- end
1881
- end
1882
-
1883
1900
  # Holds the context of a Packwerk run across multiple files.
1884
1901
  #
1885
1902
  # source://packwerk//lib/packwerk/run_context.rb#8
@@ -2011,6 +2028,8 @@ Packwerk::VERSION = T.let(T.unsafe(nil), String)
2011
2028
  #
2012
2029
  # source://packwerk//lib/packwerk/validator.rb#9
2013
2030
  module Packwerk::Validator
2031
+ extend ::ActiveSupport::Autoload
2032
+
2014
2033
  abstract!
2015
2034
 
2016
2035
  # @abstract
@@ -2021,18 +2040,18 @@ module Packwerk::Validator
2021
2040
  .params(
2022
2041
  package_set: Packwerk::PackageSet,
2023
2042
  configuration: ::Packwerk::Configuration
2024
- ).returns(::Packwerk::ApplicationValidator::Result)
2043
+ ).returns(::Packwerk::Validator::Result)
2025
2044
  end
2026
2045
  def call(package_set, configuration); end
2027
2046
 
2028
2047
  # source://packwerk//lib/packwerk/validator.rb#67
2029
2048
  sig do
2030
2049
  params(
2031
- results: T::Array[::Packwerk::ApplicationValidator::Result],
2050
+ results: T::Array[::Packwerk::Validator::Result],
2032
2051
  separator: ::String,
2033
2052
  before_errors: ::String,
2034
2053
  after_errors: ::String
2035
- ).returns(::Packwerk::ApplicationValidator::Result)
2054
+ ).returns(::Packwerk::Validator::Result)
2036
2055
  end
2037
2056
  def merge_results(results, separator: T.unsafe(nil), before_errors: T.unsafe(nil), after_errors: T.unsafe(nil)); end
2038
2057
 
@@ -2074,6 +2093,21 @@ module Packwerk::Validator
2074
2093
  end
2075
2094
  end
2076
2095
 
2096
+ # source://packwerk//lib/packwerk/validator/result.rb#6
2097
+ class Packwerk::Validator::Result < ::T::Struct
2098
+ const :ok, T::Boolean
2099
+ const :error_value, T.nilable(::String)
2100
+
2101
+ # source://packwerk//lib/packwerk/validator/result.rb#13
2102
+ sig { returns(T::Boolean) }
2103
+ def ok?; end
2104
+
2105
+ class << self
2106
+ # source://sorbet-runtime/0.5.10588/lib/types/struct.rb#13
2107
+ def inherited(s); end
2108
+ end
2109
+ end
2110
+
2077
2111
  # source://packwerk//lib/packwerk/validators/dependency_validator.rb#5
2078
2112
  module Packwerk::Validators; end
2079
2113
 
@@ -2087,7 +2121,7 @@ class Packwerk::Validators::DependencyValidator
2087
2121
  .params(
2088
2122
  package_set: Packwerk::PackageSet,
2089
2123
  configuration: ::Packwerk::Configuration
2090
- ).returns(::Packwerk::ApplicationValidator::Result)
2124
+ ).returns(::Packwerk::Validator::Result)
2091
2125
  end
2092
2126
  def call(package_set, configuration); end
2093
2127
 
@@ -2110,15 +2144,15 @@ class Packwerk::Validators::DependencyValidator
2110
2144
  def build_cycle_strings(cycles); end
2111
2145
 
2112
2146
  # source://packwerk//lib/packwerk/validators/dependency_validator.rb#66
2113
- sig { params(package_set: Packwerk::PackageSet).returns(::Packwerk::ApplicationValidator::Result) }
2147
+ sig { params(package_set: Packwerk::PackageSet).returns(::Packwerk::Validator::Result) }
2114
2148
  def check_acyclic_graph(package_set); end
2115
2149
 
2116
2150
  # source://packwerk//lib/packwerk/validators/dependency_validator.rb#34
2117
- sig { params(configuration: ::Packwerk::Configuration).returns(::Packwerk::ApplicationValidator::Result) }
2151
+ sig { params(configuration: ::Packwerk::Configuration).returns(::Packwerk::Validator::Result) }
2118
2152
  def check_package_manifest_syntax(configuration); end
2119
2153
 
2120
2154
  # source://packwerk//lib/packwerk/validators/dependency_validator.rb#92
2121
- sig { params(configuration: ::Packwerk::Configuration).returns(::Packwerk::ApplicationValidator::Result) }
2155
+ sig { params(configuration: ::Packwerk::Configuration).returns(::Packwerk::Validator::Result) }
2122
2156
  def check_valid_package_dependencies(configuration); end
2123
2157
 
2124
2158
  # source://packwerk//lib/packwerk/validators/dependency_validator.rb#128
@@ -0,0 +1,224 @@
1
+ # typed: true
2
+
3
+ # DO NOT EDIT MANUALLY
4
+ # This is an autogenerated file for types exported from the `parse_packwerk` gem.
5
+ # Please instead update this file by running `bin/tapioca gem parse_packwerk`.
6
+
7
+ # source://parse_packwerk//lib/parse_packwerk/constants.rb#3
8
+ module ParsePackwerk
9
+ class << self
10
+ # source://parse_packwerk//lib/parse_packwerk.rb#28
11
+ sig { returns(T::Array[::ParsePackwerk::Package]) }
12
+ def all; end
13
+
14
+ # source://parse_packwerk//lib/parse_packwerk.rb#112
15
+ sig { void }
16
+ def bust_cache!; end
17
+
18
+ # source://parse_packwerk//lib/parse_packwerk.rb#33
19
+ sig { params(name: ::String).returns(T.nilable(::ParsePackwerk::Package)) }
20
+ def find(name); end
21
+
22
+ # source://parse_packwerk//lib/parse_packwerk.rb#43
23
+ sig { params(file_path: T.any(::Pathname, ::String)).returns(::ParsePackwerk::Package) }
24
+ def package_from_path(file_path); end
25
+
26
+ # source://parse_packwerk//lib/parse_packwerk.rb#54
27
+ sig { params(package: ::ParsePackwerk::Package).void }
28
+ def write_package_yml!(package); end
29
+
30
+ # source://parse_packwerk//lib/parse_packwerk.rb#38
31
+ sig { returns(::ParsePackwerk::Configuration) }
32
+ def yml; end
33
+
34
+ private
35
+
36
+ # We memoize packages_by_name for fast lookup.
37
+ # Since Graph is an immutable value object, we can create indexes and general caching mechanisms safely.
38
+ #
39
+ # source://parse_packwerk//lib/parse_packwerk.rb#100
40
+ sig { returns(T::Hash[::String, ::ParsePackwerk::Package]) }
41
+ def packages_by_name; end
42
+ end
43
+ end
44
+
45
+ # source://parse_packwerk//lib/parse_packwerk/configuration.rb#4
46
+ class ParsePackwerk::Configuration < ::T::Struct
47
+ const :exclude, T::Array[::String]
48
+ const :package_paths, T::Array[::String]
49
+
50
+ class << self
51
+ # source://parse_packwerk//lib/parse_packwerk/configuration.rb#28
52
+ sig { params(config_hash: T::Hash[T.untyped, T.untyped]).returns(T::Array[::String]) }
53
+ def excludes(config_hash); end
54
+
55
+ # source://parse_packwerk//lib/parse_packwerk/configuration.rb#11
56
+ sig { returns(::ParsePackwerk::Configuration) }
57
+ def fetch; end
58
+
59
+ # source://sorbet-runtime/0.5.10588/lib/types/struct.rb#13
60
+ def inherited(s); end
61
+
62
+ # source://parse_packwerk//lib/parse_packwerk/configuration.rb#40
63
+ sig { params(config_hash: T::Hash[T.untyped, T.untyped]).returns(T::Array[::String]) }
64
+ def package_paths(config_hash); end
65
+ end
66
+ end
67
+
68
+ # source://parse_packwerk//lib/parse_packwerk/constants.rb#22
69
+ ParsePackwerk::DEFAULT_EXCLUDE_GLOBS = T.let(T.unsafe(nil), Array)
70
+
71
+ # source://parse_packwerk//lib/parse_packwerk/constants.rb#23
72
+ ParsePackwerk::DEFAULT_PACKAGE_PATHS = T.let(T.unsafe(nil), Array)
73
+
74
+ # source://parse_packwerk//lib/parse_packwerk/constants.rb#24
75
+ ParsePackwerk::DEFAULT_PUBLIC_PATH = T.let(T.unsafe(nil), String)
76
+
77
+ # source://parse_packwerk//lib/parse_packwerk/constants.rb#14
78
+ ParsePackwerk::DEPENDENCIES = T.let(T.unsafe(nil), String)
79
+
80
+ # source://parse_packwerk//lib/parse_packwerk/constants.rb#10
81
+ ParsePackwerk::DEPENDENCY_VIOLATION_TYPE = T.let(T.unsafe(nil), String)
82
+
83
+ # source://parse_packwerk//lib/parse_packwerk/constants.rb#8
84
+ ParsePackwerk::ENFORCE_DEPENDENCIES = T.let(T.unsafe(nil), String)
85
+
86
+ # source://parse_packwerk//lib/parse_packwerk/constants.rb#9
87
+ ParsePackwerk::ENFORCE_PRIVACY = T.let(T.unsafe(nil), String)
88
+
89
+ # source://parse_packwerk//lib/parse_packwerk/constants.rb#13
90
+ ParsePackwerk::METADATA = T.let(T.unsafe(nil), String)
91
+
92
+ # Since this metadata is unstructured YAML, it could be any type. We leave it to clients of `ParsePackwerk::Package`
93
+ # to add types based on their known usage of metadata.
94
+ #
95
+ # source://parse_packwerk//lib/parse_packwerk/constants.rb#18
96
+ ParsePackwerk::MetadataYmlType = T.type_alias { T::Hash[T.untyped, T.untyped] }
97
+
98
+ # source://parse_packwerk//lib/parse_packwerk.rb#14
99
+ class ParsePackwerk::MissingConfiguration < ::StandardError
100
+ # source://parse_packwerk//lib/parse_packwerk.rb#18
101
+ sig { params(packwerk_file_name: ::Pathname).void }
102
+ def initialize(packwerk_file_name); end
103
+ end
104
+
105
+ # source://parse_packwerk//lib/parse_packwerk/constants.rb#7
106
+ ParsePackwerk::PACKAGE_TODO_YML_NAME = T.let(T.unsafe(nil), String)
107
+
108
+ # source://parse_packwerk//lib/parse_packwerk/constants.rb#5
109
+ ParsePackwerk::PACKAGE_YML_NAME = T.let(T.unsafe(nil), String)
110
+
111
+ # source://parse_packwerk//lib/parse_packwerk/constants.rb#6
112
+ ParsePackwerk::PACKWERK_YML_NAME = T.let(T.unsafe(nil), String)
113
+
114
+ # source://parse_packwerk//lib/parse_packwerk/constants.rb#11
115
+ ParsePackwerk::PRIVACY_VIOLATION_TYPE = T.let(T.unsafe(nil), String)
116
+
117
+ # source://parse_packwerk//lib/parse_packwerk/constants.rb#12
118
+ ParsePackwerk::PUBLIC_PATH = T.let(T.unsafe(nil), String)
119
+
120
+ # source://parse_packwerk//lib/parse_packwerk/package.rb#4
121
+ class ParsePackwerk::Package < ::T::Struct
122
+ const :name, ::String
123
+ const :enforce_dependencies, T::Boolean
124
+ const :enforce_privacy, T::Boolean
125
+ const :public_path, ::String, default: T.unsafe(nil)
126
+ const :metadata, T::Hash[T.untyped, T.untyped]
127
+ const :dependencies, T::Array[::String]
128
+
129
+ # source://parse_packwerk//lib/parse_packwerk/package.rb#35
130
+ sig { returns(::Pathname) }
131
+ def directory; end
132
+
133
+ # source://parse_packwerk//lib/parse_packwerk/package.rb#45
134
+ sig { returns(T::Boolean) }
135
+ def enforces_dependencies?; end
136
+
137
+ # source://parse_packwerk//lib/parse_packwerk/package.rb#50
138
+ sig { returns(T::Boolean) }
139
+ def enforces_privacy?; end
140
+
141
+ # source://parse_packwerk//lib/parse_packwerk/package.rb#40
142
+ sig { returns(::Pathname) }
143
+ def public_directory; end
144
+
145
+ # source://parse_packwerk//lib/parse_packwerk/package.rb#55
146
+ sig { returns(T::Array[::ParsePackwerk::Violation]) }
147
+ def violations; end
148
+
149
+ # source://parse_packwerk//lib/parse_packwerk/package.rb#30
150
+ sig { returns(::Pathname) }
151
+ def yml; end
152
+
153
+ class << self
154
+ # source://parse_packwerk//lib/parse_packwerk/package.rb#15
155
+ sig { params(pathname: ::Pathname).returns(::ParsePackwerk::Package) }
156
+ def from(pathname); end
157
+
158
+ # source://sorbet-runtime/0.5.10588/lib/types/struct.rb#13
159
+ def inherited(s); end
160
+ end
161
+ end
162
+
163
+ # source://parse_packwerk//lib/parse_packwerk/package_set.rb#8
164
+ class ParsePackwerk::PackageSet
165
+ class << self
166
+ # source://parse_packwerk//lib/parse_packwerk/package_set.rb#12
167
+ sig do
168
+ params(
169
+ package_pathspec: T::Array[::String],
170
+ exclude_pathspec: T::Array[::String]
171
+ ).returns(T::Array[::ParsePackwerk::Package])
172
+ end
173
+ def from(package_pathspec:, exclude_pathspec:); end
174
+
175
+ private
176
+
177
+ # source://parse_packwerk//lib/parse_packwerk/package_set.rb#28
178
+ sig { params(globs: T::Array[::String], path: ::Pathname).returns(T::Boolean) }
179
+ def exclude_path?(globs, path); end
180
+ end
181
+ end
182
+
183
+ # source://parse_packwerk//lib/parse_packwerk/package_todo.rb#4
184
+ class ParsePackwerk::PackageTodo < ::T::Struct
185
+ const :pathname, ::Pathname
186
+ const :violations, T::Array[::ParsePackwerk::Violation]
187
+
188
+ class << self
189
+ # source://parse_packwerk//lib/parse_packwerk/package_todo.rb#11
190
+ sig { params(package: ::ParsePackwerk::Package).returns(::ParsePackwerk::PackageTodo) }
191
+ def for(package); end
192
+
193
+ # source://parse_packwerk//lib/parse_packwerk/package_todo.rb#17
194
+ sig { params(pathname: ::Pathname).returns(::ParsePackwerk::PackageTodo) }
195
+ def from(pathname); end
196
+
197
+ # source://sorbet-runtime/0.5.10588/lib/types/struct.rb#13
198
+ def inherited(s); end
199
+ end
200
+ end
201
+
202
+ # source://parse_packwerk//lib/parse_packwerk/constants.rb#4
203
+ ParsePackwerk::ROOT_PACKAGE_NAME = T.let(T.unsafe(nil), String)
204
+
205
+ # source://parse_packwerk//lib/parse_packwerk/violation.rb#4
206
+ class ParsePackwerk::Violation < ::T::Struct
207
+ const :type, ::String
208
+ const :to_package_name, ::String
209
+ const :class_name, ::String
210
+ const :files, T::Array[::String]
211
+
212
+ # source://parse_packwerk//lib/parse_packwerk/violation.rb#13
213
+ sig { returns(T::Boolean) }
214
+ def dependency?; end
215
+
216
+ # source://parse_packwerk//lib/parse_packwerk/violation.rb#18
217
+ sig { returns(T::Boolean) }
218
+ def privacy?; end
219
+
220
+ class << self
221
+ # source://sorbet-runtime/0.5.10588/lib/types/struct.rb#13
222
+ def inherited(s); end
223
+ end
224
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: danger-packwerk
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.0
4
+ version: 0.11.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-12-14 00:00:00.000000000 Z
11
+ date: 2022-12-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: code_ownership
@@ -209,7 +209,6 @@ files:
209
209
  - lib/danger-packwerk/packwerk_wrapper.rb
210
210
  - lib/danger-packwerk/private.rb
211
211
  - lib/danger-packwerk/private/ownership_information.rb
212
- - lib/danger-packwerk/private/package_todo.rb
213
212
  - lib/danger-packwerk/update/default_formatter.rb
214
213
  - lib/danger-packwerk/update/offenses_formatter.rb
215
214
  - lib/danger-packwerk/version.rb
@@ -261,9 +260,9 @@ files:
261
260
  - sorbet/rbi/gems/nokogiri@1.13.8.rbi
262
261
  - sorbet/rbi/gems/octokit@5.6.1.rbi
263
262
  - sorbet/rbi/gems/open4@1.3.4.rbi
264
- - sorbet/rbi/gems/packwerk@2.2.1-7e8e7a50705833b41fe40c201eadb85ff9a1a422.rbi
263
+ - sorbet/rbi/gems/packwerk@2.2.1-8476bb3cd5452765ad452d36aa45ae724f1d44f5.rbi
265
264
  - sorbet/rbi/gems/parallel@1.22.1.rbi
266
- - sorbet/rbi/gems/parse_packwerk@0.12.1.rbi
265
+ - sorbet/rbi/gems/parse_packwerk@0.16.0.rbi
267
266
  - sorbet/rbi/gems/parser@3.1.2.1.rbi
268
267
  - sorbet/rbi/gems/pry@0.14.1.rbi
269
268
  - sorbet/rbi/gems/public_suffix@5.0.0.rbi
@@ -1,65 +0,0 @@
1
- # typed: strict
2
-
3
- module DangerPackwerk
4
- module Private
5
- #
6
- # The `Violation` and `PackageTodo` classes come from Gusto's private `ParsePackwerk` gem.
7
- # Until we decide to open source that gem, we inline these as a private implementation detail of `DangerPackwerk` for now.
8
- #
9
- class Violation < T::Struct
10
- extend T::Sig
11
-
12
- const :type, String
13
- const :to_package_name, String
14
- const :class_name, String
15
- const :files, T::Array[String]
16
-
17
- sig { returns(T::Boolean) }
18
- def dependency?
19
- type == 'dependency'
20
- end
21
-
22
- sig { returns(T::Boolean) }
23
- def privacy?
24
- type == 'privacy'
25
- end
26
- end
27
-
28
- class PackageTodo < T::Struct
29
- extend T::Sig
30
-
31
- const :pathname, Pathname
32
- const :violations, T::Array[Violation]
33
-
34
- sig { params(pathname: Pathname).returns(PackageTodo) }
35
- def self.from(pathname)
36
- if pathname.exist?
37
- package_todo_loaded_yml = YAML.load_file(pathname)
38
-
39
- all_violations = []
40
- package_todo_loaded_yml&.each_key do |to_package_name|
41
- package_todo_per_package = package_todo_loaded_yml[to_package_name]
42
- package_todo_per_package.each_key do |class_name|
43
- symbol_usage = package_todo_per_package[class_name]
44
- files = symbol_usage['files']
45
- violations = symbol_usage['violations']
46
- all_violations << Violation.new(type: 'dependency', to_package_name: to_package_name, class_name: class_name, files: files) if violations.include? 'dependency'
47
-
48
- all_violations << Violation.new(type: 'privacy', to_package_name: to_package_name, class_name: class_name, files: files) if violations.include? 'privacy'
49
- end
50
- end
51
-
52
- new(
53
- pathname: pathname.cleanpath,
54
- violations: all_violations
55
- )
56
- else
57
- new(
58
- pathname: pathname.cleanpath,
59
- violations: []
60
- )
61
- end
62
- end
63
- end
64
- end
65
- end
@@ -1,146 +0,0 @@
1
- # typed: true
2
-
3
- # DO NOT EDIT MANUALLY
4
- # This is an autogenerated file for types exported from the `parse_packwerk` gem.
5
- # Please instead update this file by running `bin/tapioca gem parse_packwerk`.
6
-
7
- module ParsePackwerk
8
- class << self
9
- sig { returns(T::Array[::ParsePackwerk::Package]) }
10
- def all; end
11
-
12
- sig { void }
13
- def bust_cache!; end
14
-
15
- sig { params(name: ::String).returns(T.nilable(::ParsePackwerk::Package)) }
16
- def find(name); end
17
-
18
- sig { params(file_path: T.any(::Pathname, ::String)).returns(::ParsePackwerk::Package) }
19
- def package_from_path(file_path); end
20
-
21
- sig { params(package: ::ParsePackwerk::Package).void }
22
- def write_package_yml!(package); end
23
-
24
- sig { returns(::ParsePackwerk::Configuration) }
25
- def yml; end
26
-
27
- private
28
-
29
- sig { returns(T::Hash[::String, ::ParsePackwerk::Package]) }
30
- def packages_by_name; end
31
- end
32
- end
33
-
34
- class ParsePackwerk::Configuration < ::T::Struct
35
- const :exclude, T::Array[::String]
36
- const :package_paths, T::Array[::String]
37
-
38
- class << self
39
- sig { params(config_hash: T::Hash[T.untyped, T.untyped]).returns(T::Array[::String]) }
40
- def excludes(config_hash); end
41
-
42
- sig { returns(::ParsePackwerk::Configuration) }
43
- def fetch; end
44
-
45
- def inherited(s); end
46
-
47
- sig { params(config_hash: T::Hash[T.untyped, T.untyped]).returns(T::Array[::String]) }
48
- def package_paths(config_hash); end
49
- end
50
- end
51
-
52
- ParsePackwerk::DEFAULT_EXCLUDE_GLOBS = T.let(T.unsafe(nil), Array)
53
- ParsePackwerk::DEFAULT_PACKAGE_PATHS = T.let(T.unsafe(nil), Array)
54
- ParsePackwerk::DEPENDENCIES = T.let(T.unsafe(nil), String)
55
- ParsePackwerk::DEPRECATED_REFERENCES_YML_NAME = T.let(T.unsafe(nil), String)
56
-
57
- class ParsePackwerk::DeprecatedReferences < ::T::Struct
58
- const :pathname, ::Pathname
59
- const :violations, T::Array[::ParsePackwerk::Violation]
60
-
61
- class << self
62
- sig { params(package: ::ParsePackwerk::Package).returns(::ParsePackwerk::DeprecatedReferences) }
63
- def for(package); end
64
-
65
- sig { params(pathname: ::Pathname).returns(::ParsePackwerk::DeprecatedReferences) }
66
- def from(pathname); end
67
-
68
- def inherited(s); end
69
- end
70
- end
71
-
72
- ParsePackwerk::ENFORCE_DEPENDENCIES = T.let(T.unsafe(nil), String)
73
- ParsePackwerk::ENFORCE_PRIVACY = T.let(T.unsafe(nil), String)
74
- ParsePackwerk::METADATA = T.let(T.unsafe(nil), String)
75
- ParsePackwerk::MetadataYmlType = T.type_alias { T::Hash[T.untyped, T.untyped] }
76
-
77
- class ParsePackwerk::MissingConfiguration < ::StandardError
78
- sig { params(packwerk_file_name: ::Pathname).void }
79
- def initialize(packwerk_file_name); end
80
- end
81
-
82
- ParsePackwerk::PACKAGE_YML_NAME = T.let(T.unsafe(nil), String)
83
- ParsePackwerk::PACKWERK_YML_NAME = T.let(T.unsafe(nil), String)
84
-
85
- class ParsePackwerk::Package < ::T::Struct
86
- const :dependencies, T::Array[::String]
87
- const :enforce_dependencies, T::Boolean
88
- const :enforce_privacy, T::Boolean
89
- const :metadata, T::Hash[T.untyped, T.untyped]
90
- const :name, ::String
91
-
92
- sig { returns(::Pathname) }
93
- def directory; end
94
-
95
- sig { returns(T::Boolean) }
96
- def enforces_dependencies?; end
97
-
98
- sig { returns(T::Boolean) }
99
- def enforces_privacy?; end
100
-
101
- sig { returns(::Pathname) }
102
- def yml; end
103
-
104
- class << self
105
- sig { params(pathname: ::Pathname).returns(::ParsePackwerk::Package) }
106
- def from(pathname); end
107
-
108
- def inherited(s); end
109
- end
110
- end
111
-
112
- class ParsePackwerk::PackageSet
113
- class << self
114
- sig do
115
- params(
116
- package_pathspec: T::Array[::String],
117
- exclude_pathspec: T::Array[::String]
118
- ).returns(T::Array[::ParsePackwerk::Package])
119
- end
120
- def from(package_pathspec:, exclude_pathspec:); end
121
-
122
- private
123
-
124
- sig { params(globs: T::Array[::String], path: ::Pathname).returns(T::Boolean) }
125
- def exclude_path?(globs, path); end
126
- end
127
- end
128
-
129
- ParsePackwerk::ROOT_PACKAGE_NAME = T.let(T.unsafe(nil), String)
130
-
131
- class ParsePackwerk::Violation < ::T::Struct
132
- const :class_name, ::String
133
- const :files, T::Array[::String]
134
- const :to_package_name, ::String
135
- const :type, ::String
136
-
137
- sig { returns(T::Boolean) }
138
- def dependency?; end
139
-
140
- sig { returns(T::Boolean) }
141
- def privacy?; end
142
-
143
- class << self
144
- def inherited(s); end
145
- end
146
- end