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 +4 -4
- data/Gemfile.lock +5 -5
- data/USAGE.md +2 -3
- data/lib/packwerk/checker.rb +2 -2
- data/lib/packwerk/commands/check_command.rb +4 -2
- data/lib/packwerk/file_processor.rb +1 -1
- data/lib/packwerk/generators/templates/package.yml +2 -2
- data/lib/packwerk/parsers/ruby.rb +2 -2
- data/lib/packwerk/reference_checking/checkers/dependency_checker.rb +3 -3
- data/lib/packwerk/version.rb +1 -1
- data/packwerk.gemspec +1 -0
- data/sorbet/rbi/gems/{nokogiri@1.13.8.rbi → nokogiri@1.15.3.rbi} +1854 -1031
- data/sorbet/rbi/gems/prism@0.24.0.rbi +29982 -0
- metadata +19 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 98dd65426866ebc6f1421486a1a8573ea539dc143c448cd6632b77c5ca5ef5d8
|
4
|
+
data.tar.gz: 960fe5383ebd4ebadfc05698a64bd2537b1cf9c03525cd1780ff1f27ea5bd468
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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.
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
```
|
data/lib/packwerk/checker.rb
CHANGED
@@ -51,8 +51,8 @@ module Packwerk
|
|
51
51
|
sig { abstract.returns(String) }
|
52
52
|
def violation_type; end
|
53
53
|
|
54
|
-
sig { abstract.params(
|
55
|
-
def strict_mode_violation?(
|
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(
|
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
|
-
|
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
|
-
#
|
6
|
-
enforce_dependencies:
|
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 "
|
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
|
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(
|
51
|
-
def strict_mode_violation?(
|
52
|
-
referencing_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
|
|
data/lib/packwerk/version.rb
CHANGED
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")
|