packwerk 3.1.0 → 3.2.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: d72fbde4259baa5a5e7f8bc2ca4406d9bc6a835051efafefc23ef6ef3ae13f32
4
- data.tar.gz: 65bff304e2be348e16800b0d4f65ab33a1b5fb84ab15ba495e03904d099be4a0
3
+ metadata.gz: 98dd65426866ebc6f1421486a1a8573ea539dc143c448cd6632b77c5ca5ef5d8
4
+ data.tar.gz: 960fe5383ebd4ebadfc05698a64bd2537b1cf9c03525cd1780ff1f27ea5bd468
5
5
  SHA512:
6
- metadata.gz: e25488e4af51932d503d4120e458fe92bc4ae2945ca8009219e01f4f2e7756e0430a0d9a6176f01d864d55644f262a06fb88494234b43aae43ba254437d7fb49
7
- data.tar.gz: 2c821f3e11a16c52d84f7f4e68f01e788e95d5723fd77305f69e15aba07f5f1f81ea43e9c60b6c00ca4503df036eb2b3ea0e0ae1378f0c584d7252614064f9d9
6
+ metadata.gz: d91230970adbcfb9deaedd33a6745531b5245f929da676fb382ae0b661777777e522c14876ba9ace23d2f39dd4f72e528bc0543c1ecaaa463ba293113efab1bd
7
+ data.tar.gz: d2e1cbb00dc3dcaa1a92548f506124e0f05b4b8fa9f5c5837fa271ffb2e3847277fae8945b13cae0a05223540c386ead8efb7e8108436af2732c9525f9b00b4c
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- packwerk (3.1.0)
4
+ packwerk (3.2.0)
5
5
  activesupport (>= 6.0)
6
6
  ast
7
7
  better_html
@@ -9,6 +9,7 @@ PATH
9
9
  constant_resolver (>= 0.2.0)
10
10
  parallel
11
11
  parser
12
+ prism (>= 0.24.0)
12
13
  sorbet-runtime (>= 0.5.9914)
13
14
  zeitwerk (>= 2.6.1)
14
15
 
@@ -60,14 +61,12 @@ GEM
60
61
  method_source (>= 0.6.7)
61
62
  rake (>= 0.9.2.2)
62
63
  method_source (1.0.0)
63
- mini_portile2 (2.8.4)
64
64
  minitest (5.16.2)
65
65
  minitest-focus (1.3.1)
66
66
  minitest (>= 4, < 6)
67
67
  mocha (1.14.0)
68
68
  netrc (0.11.0)
69
- nokogiri (1.15.3)
70
- mini_portile2 (~> 2.8.2)
69
+ nokogiri (1.15.3-arm64-darwin)
71
70
  racc (~> 1.4)
72
71
  nokogiri (1.15.3-x86_64-darwin)
73
72
  racc (~> 1.4)
@@ -77,6 +76,7 @@ GEM
77
76
  parser (3.2.2.0)
78
77
  ast (~> 2.4.1)
79
78
  prettier_print (0.1.0)
79
+ prism (0.24.0)
80
80
  pry (0.14.1)
81
81
  coderay (~> 1.1)
82
82
  method_source (~> 1.0)
@@ -179,7 +179,7 @@ GEM
179
179
  zeitwerk (2.6.4)
180
180
 
181
181
  PLATFORMS
182
- ruby
182
+ arm64-darwin-21
183
183
  x86_64-darwin
184
184
  x86_64-darwin-20
185
185
  x86_64-linux
data/USAGE.md CHANGED
@@ -20,7 +20,6 @@
20
20
  * [Understanding how to respond to new violations](#understanding-how-to-respond-to-new-violations)
21
21
  * [Recording existing violations](#recording-existing-violations)
22
22
  * [Understanding the package todo file](#understanding-the-package-todo-file)
23
- * [Understanding the list of deprecated references](#understanding-the-list-of-deprecated-references)
24
23
  * [Loading extensions](#loading-extensions)
25
24
 
26
25
  ## What problem does Packwerk solve?
@@ -42,7 +41,7 @@ A package is a folder containing autoloaded code. To decide whether code belongs
42
41
 
43
42
  Package principles help to guide the organization of classes in a large system. These principles can also be applied to packages in large and complex codebases.
44
43
 
45
- The [package principles](https://en.wikipedia.org/wiki/Package_principles) page on Wikipedia does a good job explaining what well designed packages look like.
44
+ They are well described in Robert Martin's [Design Principles and Design Patterns](https://drive.google.com/file/d/0BwhCYaYDn8EgODUxZTJhOWEtMTZlMi00OWRiLTg0ZmEtZWQ5ODRlY2RmNDlk/view) (right after the SOLID principles).
46
45
 
47
46
  ## Getting started
48
47
 
@@ -165,7 +164,7 @@ It will be a dependency violation when `components/shop_identity` tries to refer
165
164
 
166
165
  #### Using strict mode
167
166
 
168
- Once there are no more violations in a package, you can turn on `strict` mode, which will prevent new violations from being added to the package's `package_todo.yml`. To use this, simply change `enforce_dependencies: true` to `enforce_dependencies: strict` in your `package.yml`.
167
+ You can turn on `strict` mode to prevent new violations from being added to the package's `package_todo.yml`. To use this, simply change `enforce_dependencies: true` to `enforce_dependencies: strict` in your `package.yml`.
169
168
 
170
169
  Then, when you run `bin/packwerk check`, new violations will cause the following error to be displayed:
171
170
  ```
@@ -51,8 +51,8 @@ module Packwerk
51
51
  sig { abstract.returns(String) }
52
52
  def violation_type; end
53
53
 
54
- sig { abstract.params(listed_offense: ReferenceOffense).returns(T::Boolean) }
55
- def strict_mode_violation?(listed_offense); end
54
+ sig { abstract.params(offense: ReferenceOffense).returns(T::Boolean) }
55
+ def strict_mode_violation?(offense); end
56
56
 
57
57
  sig { abstract.params(reference: Reference).returns(T::Boolean) }
58
58
  def invalid_reference?(reference); end
@@ -31,17 +31,19 @@ module Packwerk
31
31
  end
32
32
  offense_collection.add_offenses(all_offenses)
33
33
 
34
+ unlisted_strict_mode_violations = offense_collection.unlisted_strict_mode_violations
35
+
34
36
  messages = [
35
37
  offenses_formatter.show_offenses(offense_collection.outstanding_offenses),
36
38
  offenses_formatter.show_stale_violations(offense_collection, @files_for_processing.files),
37
- offenses_formatter.show_strict_mode_violations(offense_collection.strict_mode_violations),
39
+ offenses_formatter.show_strict_mode_violations(unlisted_strict_mode_violations),
38
40
  ]
39
41
 
40
42
  out.puts(messages.select(&:present?).join("\n") + "\n")
41
43
 
42
44
  offense_collection.outstanding_offenses.empty? &&
43
45
  !offense_collection.stale_violations?(@files_for_processing.files) &&
44
- offense_collection.strict_mode_violations.empty?
46
+ unlisted_strict_mode_violations.empty?
45
47
  end
46
48
 
47
49
  private
@@ -59,7 +59,7 @@ module Packwerk
59
59
  For now, you can add this file to `packwerk.yml` `exclude` list.
60
60
  Please file an issue and include this error message and stacktrace:
61
61
 
62
- #{e.message} #{e.backtrace}"
62
+ #{e.message} #{e.backtrace&.join("\n")}"
63
63
  MSG
64
64
 
65
65
  offense = Parsers::ParseResult.new(file: relative_file, message: message)
@@ -2,8 +2,8 @@
2
2
  # Please validate the configuration using `packwerk validate` (for Rails applications) or running the auto generated
3
3
  # test case (for non-Rails projects). You can then use `packwerk check` to check your code.
4
4
 
5
- # Turn on dependency checks for this package
6
- enforce_dependencies: true
5
+ # Change to `true` to turn on dependency checks for this package
6
+ enforce_dependencies: false
7
7
 
8
8
  # A list of this package's dependencies
9
9
  # Note that packages in this list require their own `package.yml` file
@@ -2,7 +2,7 @@
2
2
  # frozen_string_literal: true
3
3
 
4
4
  require "parser"
5
- require "parser/current"
5
+ require "prism"
6
6
 
7
7
  module Packwerk
8
8
  module Parsers
@@ -11,7 +11,7 @@ module Packwerk
11
11
 
12
12
  include ParserInterface
13
13
 
14
- class RaiseExceptionsParser < Parser::CurrentRuby
14
+ class RaiseExceptionsParser < Prism::Translation::Parser
15
15
  extend T::Sig
16
16
 
17
17
  sig { params(builder: T.untyped).void }
@@ -47,9 +47,9 @@ module Packwerk
47
47
  EOS
48
48
  end
49
49
 
50
- sig { override.params(listed_offense: ReferenceOffense).returns(T::Boolean) }
51
- def strict_mode_violation?(listed_offense)
52
- referencing_package = listed_offense.reference.package
50
+ sig { override.params(offense: ReferenceOffense).returns(T::Boolean) }
51
+ def strict_mode_violation?(offense)
52
+ referencing_package = offense.reference.package
53
53
  referencing_package.config["enforce_dependencies"] == "strict"
54
54
  end
55
55
 
@@ -2,5 +2,5 @@
2
2
  # frozen_string_literal: true
3
3
 
4
4
  module Packwerk
5
- VERSION = "3.1.0"
5
+ VERSION = "3.2.0"
6
6
  end
data/packwerk.gemspec CHANGED
@@ -50,6 +50,7 @@ Gem::Specification.new do |spec|
50
50
  # For Ruby parsing
51
51
  spec.add_dependency("ast")
52
52
  spec.add_dependency("parser")
53
+ spec.add_dependency("prism", ">= 0.24.0") # 0.24.0 fixes a performance issue with the parser translator
53
54
 
54
55
  # For ERB parsing
55
56
  spec.add_dependency("better_html")