packwerk 1.3.0 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (57) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +1 -0
  3. data/Gemfile.lock +11 -8
  4. data/README.md +2 -3
  5. data/TROUBLESHOOT.md +3 -3
  6. data/UPGRADING.md +54 -0
  7. data/USAGE.md +27 -53
  8. data/exe/packwerk +7 -1
  9. data/lib/packwerk/application_load_paths.rb +1 -0
  10. data/lib/packwerk/application_validator.rb +3 -54
  11. data/lib/packwerk/association_inspector.rb +1 -1
  12. data/lib/packwerk/cli.rb +37 -20
  13. data/lib/packwerk/configuration.rb +34 -4
  14. data/lib/packwerk/const_node_inspector.rb +3 -2
  15. data/lib/packwerk/constant_discovery.rb +1 -1
  16. data/lib/packwerk/constant_name_inspector.rb +1 -1
  17. data/lib/packwerk/deprecated_references.rb +19 -7
  18. data/lib/packwerk/file_processor.rb +39 -14
  19. data/lib/packwerk/files_for_processing.rb +15 -4
  20. data/lib/packwerk/formatters/offenses_formatter.rb +1 -1
  21. data/lib/packwerk/formatters/progress_formatter.rb +1 -1
  22. data/lib/packwerk/generators/configuration_file.rb +4 -19
  23. data/lib/packwerk/generators/templates/package.yml +1 -1
  24. data/lib/packwerk/generators/templates/packwerk.yml.erb +0 -6
  25. data/lib/packwerk/graph.rb +2 -0
  26. data/lib/packwerk/node.rb +1 -0
  27. data/lib/packwerk/node_processor.rb +10 -22
  28. data/lib/packwerk/node_processor_factory.rb +0 -2
  29. data/lib/packwerk/node_visitor.rb +4 -2
  30. data/lib/packwerk/package.rb +25 -4
  31. data/lib/packwerk/package_set.rb +43 -8
  32. data/lib/packwerk/parsed_constant_definitions.rb +1 -0
  33. data/lib/packwerk/reference.rb +2 -1
  34. data/lib/packwerk/reference_checking/checkers/checker.rb +21 -0
  35. data/lib/packwerk/reference_checking/checkers/dependency_checker.rb +31 -0
  36. data/lib/packwerk/reference_checking/checkers/privacy_checker.rb +58 -0
  37. data/lib/packwerk/reference_checking/reference_checker.rb +33 -0
  38. data/lib/packwerk/reference_extractor.rb +2 -2
  39. data/lib/packwerk/reference_offense.rb +1 -0
  40. data/lib/packwerk/run_context.rb +10 -7
  41. data/lib/packwerk/sanity_checker.rb +1 -1
  42. data/lib/packwerk/spring_command.rb +28 -0
  43. data/lib/packwerk/version.rb +1 -1
  44. data/lib/packwerk/violation_type.rb +1 -1
  45. data/lib/packwerk.rb +17 -12
  46. data/packwerk.gemspec +3 -1
  47. data/service.yml +0 -2
  48. data/sorbet/rbi/gems/psych@3.3.2.rbi +24 -0
  49. metadata +25 -11
  50. data/lib/packwerk/checker.rb +0 -17
  51. data/lib/packwerk/dependency_checker.rb +0 -26
  52. data/lib/packwerk/generators/inflections_file.rb +0 -43
  53. data/lib/packwerk/generators/templates/inflections.yml +0 -6
  54. data/lib/packwerk/inflections/custom.rb +0 -33
  55. data/lib/packwerk/inflections/default.rb +0 -73
  56. data/lib/packwerk/inflector.rb +0 -48
  57. data/lib/packwerk/privacy_checker.rb +0 -53
@@ -1,48 +0,0 @@
1
- # typed: true
2
- # frozen_string_literal: true
3
-
4
- require "active_support/inflector"
5
-
6
- module Packwerk
7
- class Inflector
8
- class << self
9
- extend T::Sig
10
-
11
- def default
12
- @default ||= new(custom_inflector: Inflections::Custom.new)
13
- end
14
-
15
- sig { params(inflections_file: String).returns(::Packwerk::Inflector) }
16
- def from_file(inflections_file)
17
- new(custom_inflector: Inflections::Custom.new(inflections_file))
18
- end
19
- end
20
-
21
- extend T::Sig
22
- include ::ActiveSupport::Inflector # For #camelize, #classify, #pluralize, #singularize
23
-
24
- sig do
25
- params(
26
- custom_inflector: Inflections::Custom
27
- ).void
28
- end
29
- def initialize(custom_inflector:)
30
- @inflections = ::ActiveSupport::Inflector::Inflections.new
31
-
32
- Inflections::Default.apply_to(@inflections)
33
- custom_inflector.apply_to(@inflections)
34
- end
35
-
36
- def pluralize(word, count = nil)
37
- if count == 1
38
- singularize(word)
39
- else
40
- super(word)
41
- end
42
- end
43
-
44
- def inflections(_ = nil)
45
- @inflections
46
- end
47
- end
48
- end
@@ -1,53 +0,0 @@
1
- # typed: strict
2
- # frozen_string_literal: true
3
-
4
- module Packwerk
5
- class PrivacyChecker
6
- extend T::Sig
7
- include Checker
8
-
9
- sig { override.returns(Packwerk::ViolationType) }
10
- def violation_type
11
- ViolationType::Privacy
12
- end
13
-
14
- sig do
15
- override
16
- .params(reference: Packwerk::Reference)
17
- .returns(T::Boolean)
18
- end
19
- def invalid_reference?(reference)
20
- return false if reference.constant.public?
21
-
22
- privacy_option = reference.constant.package.enforce_privacy
23
- return false if enforcement_disabled?(privacy_option)
24
-
25
- return false unless privacy_option == true ||
26
- explicitly_private_constant?(reference.constant, explicitly_private_constants: privacy_option)
27
-
28
- true
29
- end
30
-
31
- private
32
-
33
- sig do
34
- params(
35
- constant: ConstantDiscovery::ConstantContext,
36
- explicitly_private_constants: T::Array[String]
37
- ).returns(T::Boolean)
38
- end
39
- def explicitly_private_constant?(constant, explicitly_private_constants:)
40
- explicitly_private_constants.include?(constant.name) ||
41
- # nested constants
42
- explicitly_private_constants.any? { |epc| constant.name.start_with?(epc + "::") }
43
- end
44
-
45
- sig do
46
- params(privacy_option: T.nilable(T.any(T::Boolean, T::Array[String])))
47
- .returns(T::Boolean)
48
- end
49
- def enforcement_disabled?(privacy_option)
50
- [false, nil].include?(privacy_option)
51
- end
52
- end
53
- end