packwerk 2.1.1 → 2.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile.lock +20 -19
- data/README.md +7 -2
- data/lib/packwerk/application_load_paths.rb +12 -18
- data/lib/packwerk/cli.rb +14 -7
- data/lib/packwerk/file_processor.rb +15 -13
- data/lib/packwerk/files_for_processing.rb +21 -19
- data/lib/packwerk/package_set.rb +1 -1
- data/lib/packwerk/parse_run.rb +6 -6
- data/lib/packwerk/parsers/parser_interface.rb +2 -0
- data/lib/packwerk/reference_checking/reference_checker.rb +1 -3
- data/lib/packwerk/reference_extractor.rb +7 -13
- data/lib/packwerk/run_context.rb +7 -5
- data/lib/packwerk/version.rb +1 -1
- data/packwerk.gemspec +3 -2
- metadata +20 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dfc6290decd1cdaa95140a3d8495fb324c3c6d3cf01b4794e40068baff8eb663
|
4
|
+
data.tar.gz: cb01a5adb6f0118473a635b3d38416a4287207651262ee8a20b0f7833d8bfa37
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 85e01c90d7d35d169f773b4a9dd281b0cf563c5586d68e7592317d5747da81aba396b0330a9d77e776c01d098353fbc27c08d80f314ff6db88e5bf3117d06b41
|
7
|
+
data.tar.gz: 650a4a5852353ed999c54159c7951905c3984e1d21a17c99e51c94462733df2f20f55931b76ecab2590e179c41756da862df170263d7c6077e5976465e802fe9
|
data/Gemfile.lock
CHANGED
@@ -87,16 +87,16 @@ GIT
|
|
87
87
|
PATH
|
88
88
|
remote: .
|
89
89
|
specs:
|
90
|
-
packwerk (2.
|
90
|
+
packwerk (2.2.0)
|
91
91
|
activesupport (>= 5.2)
|
92
92
|
ast
|
93
93
|
better_html
|
94
94
|
bundler
|
95
|
-
constant_resolver
|
95
|
+
constant_resolver (>= 0.2.0)
|
96
96
|
digest
|
97
97
|
parallel
|
98
98
|
parser
|
99
|
-
sorbet-runtime
|
99
|
+
sorbet-runtime (>= 0.5.9914)
|
100
100
|
|
101
101
|
GEM
|
102
102
|
remote: https://rubygems.org/
|
@@ -117,7 +117,7 @@ GEM
|
|
117
117
|
commander (4.5.2)
|
118
118
|
highline (~> 2.0.0)
|
119
119
|
concurrent-ruby (1.1.8)
|
120
|
-
constant_resolver (0.
|
120
|
+
constant_resolver (0.2.0)
|
121
121
|
crass (1.0.6)
|
122
122
|
digest (3.1.0)
|
123
123
|
erubi (1.10.0)
|
@@ -144,10 +144,10 @@ GEM
|
|
144
144
|
minitest (>= 4, < 6)
|
145
145
|
mocha (1.12.0)
|
146
146
|
nio4r (2.5.7)
|
147
|
-
nokogiri (1.13.
|
147
|
+
nokogiri (1.13.4)
|
148
148
|
mini_portile2 (~> 2.8.0)
|
149
149
|
racc (~> 1.4)
|
150
|
-
nokogiri (1.13.
|
150
|
+
nokogiri (1.13.4-x86_64-darwin)
|
151
151
|
racc (~> 1.4)
|
152
152
|
parallel (1.20.1)
|
153
153
|
parlour (6.0.0)
|
@@ -194,18 +194,18 @@ GEM
|
|
194
194
|
rubocop
|
195
195
|
ruby-progressbar (1.11.0)
|
196
196
|
smart_properties (1.17.0)
|
197
|
-
sorbet (0.5.
|
198
|
-
sorbet-static (= 0.5.
|
199
|
-
sorbet-runtime (0.5.
|
200
|
-
sorbet-static (0.5.
|
201
|
-
sorbet-static (0.5.
|
202
|
-
sorbet-static (0.5.
|
203
|
-
sorbet-static (0.5.
|
204
|
-
sorbet-static (0.5.
|
205
|
-
sorbet-static (0.5.
|
206
|
-
sorbet-static (0.5.
|
207
|
-
sorbet-static (0.5.
|
208
|
-
sorbet-static (0.5.
|
197
|
+
sorbet (0.5.9914)
|
198
|
+
sorbet-static (= 0.5.9914)
|
199
|
+
sorbet-runtime (0.5.9914)
|
200
|
+
sorbet-static (0.5.9914-universal-darwin-14)
|
201
|
+
sorbet-static (0.5.9914-universal-darwin-15)
|
202
|
+
sorbet-static (0.5.9914-universal-darwin-16)
|
203
|
+
sorbet-static (0.5.9914-universal-darwin-17)
|
204
|
+
sorbet-static (0.5.9914-universal-darwin-18)
|
205
|
+
sorbet-static (0.5.9914-universal-darwin-19)
|
206
|
+
sorbet-static (0.5.9914-universal-darwin-20)
|
207
|
+
sorbet-static (0.5.9914-universal-darwin-21)
|
208
|
+
sorbet-static (0.5.9914-x86_64-linux)
|
209
209
|
spoom (1.1.0)
|
210
210
|
colorize
|
211
211
|
sorbet (>= 0.5.6347)
|
@@ -258,6 +258,7 @@ DEPENDENCIES
|
|
258
258
|
sorbet-runtime
|
259
259
|
spring
|
260
260
|
tapioca
|
261
|
+
zeitwerk
|
261
262
|
|
262
263
|
BUNDLED WITH
|
263
|
-
2.3.
|
264
|
+
2.3.5
|
data/README.md
CHANGED
@@ -1,6 +1,9 @@
|
|
1
1
|
# Packwerk [](https://github.com/Shopify/packwerk/actions?query=workflow%3ACI)
|
2
2
|
|
3
|
-
|
3
|
+
### ⚠️ While Shopify is actively using `packwerk`, we consider it feature complete.
|
4
|
+
We are keeping `packwerk` compatible with current versions of Ruby and Rails, but will accept feature requests only in rare cases. Please submit bug fixes though!
|
5
|
+
|
6
|
+
---
|
4
7
|
|
5
8
|
> "I know who you are and because of that I know what you do."
|
6
9
|
> This knowledge is a dependency that raises the cost of change.
|
@@ -58,10 +61,12 @@ Read [USAGE.md](USAGE.md) for usage once Packwerk is installed on your project.
|
|
58
61
|
|
59
62
|
## Ecosystem
|
60
63
|
|
61
|
-
|
64
|
+
Various third parties have built tooling on top of packwerk. Here's a selection of some that might prove useful:
|
62
65
|
|
63
66
|
- https://github.com/bellroy/graphwerk draws a graph of your package dependencies
|
64
67
|
- https://github.com/Gusto/packwerk-vscode integrates packwerk into Visual Studio Code so you can see violations right in your editor
|
68
|
+
- https://github.com/Gusto/stimpack sets up Rails autoloading, as well as `rspec` and `FactoryBot` integration, for packages arranged in a flat list. Stimpack is quite convenient, but for autoloading we recommend to use `Rails::Engine`s instead.
|
69
|
+
- https://github.com/BigRails/danger-packwerk integrates packwerk with [danger.systems](https://danger.systems) to provide packwerk feedback as Github inline PR comments
|
65
70
|
|
66
71
|
## Development
|
67
72
|
|
@@ -9,7 +9,7 @@ module Packwerk
|
|
9
9
|
class << self
|
10
10
|
extend T::Sig
|
11
11
|
|
12
|
-
sig { params(root: String, environment: String).returns(T::
|
12
|
+
sig { params(root: String, environment: String).returns(T::Hash[String, Module]) }
|
13
13
|
def extract_relevant_paths(root, environment)
|
14
14
|
require_application(root, environment)
|
15
15
|
all_paths = extract_application_autoload_paths
|
@@ -18,36 +18,30 @@ module Packwerk
|
|
18
18
|
relative_path_strings(relevant_paths)
|
19
19
|
end
|
20
20
|
|
21
|
-
sig { returns(T::
|
21
|
+
sig { returns(T::Hash[String, Module]) }
|
22
22
|
def extract_application_autoload_paths
|
23
|
-
Rails.
|
24
|
-
.
|
25
|
-
|
26
|
-
.flat_map do |engine|
|
27
|
-
paths = (engine.config.autoload_paths + engine.config.eager_load_paths + engine.config.autoload_once_paths)
|
28
|
-
paths.map(&:to_s).uniq
|
29
|
-
end
|
23
|
+
Rails.autoloaders.inject({}) do |h, loader|
|
24
|
+
h.merge(loader.root_dirs)
|
25
|
+
end
|
30
26
|
end
|
31
27
|
|
32
28
|
sig do
|
33
|
-
params(all_paths: T::
|
34
|
-
.returns(T::
|
29
|
+
params(all_paths: T::Hash[String, Module], bundle_path: Pathname, rails_root: Pathname)
|
30
|
+
.returns(T::Hash[Pathname, Module])
|
35
31
|
end
|
36
32
|
def filter_relevant_paths(all_paths, bundle_path: Bundler.bundle_path, rails_root: Rails.root)
|
37
33
|
bundle_path_match = bundle_path.join("**")
|
38
34
|
rails_root_match = rails_root.join("**")
|
39
35
|
|
40
36
|
all_paths
|
41
|
-
.
|
37
|
+
.transform_keys { |path| Pathname.new(path).expand_path }
|
42
38
|
.select { |path| path.fnmatch(rails_root_match.to_s) } # path needs to be in application directory
|
43
39
|
.reject { |path| path.fnmatch(bundle_path_match.to_s) } # reject paths from vendored gems
|
44
40
|
end
|
45
41
|
|
46
|
-
sig { params(
|
47
|
-
def relative_path_strings(
|
48
|
-
|
49
|
-
.map { |path| path.relative_path_from(rails_root).to_s }
|
50
|
-
.uniq
|
42
|
+
sig { params(load_paths: T::Hash[Pathname, Module], rails_root: Pathname).returns(T::Hash[String, Module]) }
|
43
|
+
def relative_path_strings(load_paths, rails_root: Rails.root)
|
44
|
+
load_paths.transform_keys { |path| Pathname.new(path).relative_path_from(rails_root).to_s }
|
51
45
|
end
|
52
46
|
|
53
47
|
private
|
@@ -65,7 +59,7 @@ module Packwerk
|
|
65
59
|
end
|
66
60
|
end
|
67
61
|
|
68
|
-
sig { params(paths: T::
|
62
|
+
sig { params(paths: T::Hash[T.untyped, Module]).void }
|
69
63
|
def assert_load_paths_present(paths)
|
70
64
|
if paths.empty?
|
71
65
|
raise <<~EOS
|
data/lib/packwerk/cli.rb
CHANGED
@@ -32,8 +32,10 @@ module Packwerk
|
|
32
32
|
@style = style
|
33
33
|
@configuration = T.let(configuration || Configuration.from_path, Configuration)
|
34
34
|
@progress_formatter = T.let(Formatters::ProgressFormatter.new(@out, style: style), Formatters::ProgressFormatter)
|
35
|
-
@offenses_formatter = T.let(
|
36
|
-
OffensesFormatter)
|
35
|
+
@offenses_formatter = T.let(
|
36
|
+
offenses_formatter || Formatters::OffensesFormatter.new(style: @style),
|
37
|
+
OffensesFormatter
|
38
|
+
)
|
37
39
|
end
|
38
40
|
|
39
41
|
sig { params(args: T::Array[String]).returns(T.noreturn) }
|
@@ -122,16 +124,21 @@ module Packwerk
|
|
122
124
|
result.status
|
123
125
|
end
|
124
126
|
|
125
|
-
sig
|
127
|
+
sig do
|
128
|
+
params(
|
129
|
+
relative_file_paths: T::Array[String],
|
130
|
+
ignore_nested_packages: T::Boolean
|
131
|
+
).returns(FilesForProcessing::AbsoluteFileSet)
|
132
|
+
end
|
126
133
|
def fetch_files_to_process(relative_file_paths, ignore_nested_packages)
|
127
|
-
|
134
|
+
absolute_file_set = FilesForProcessing.fetch(
|
128
135
|
relative_file_paths: relative_file_paths,
|
129
136
|
ignore_nested_packages: ignore_nested_packages,
|
130
137
|
configuration: @configuration
|
131
138
|
)
|
132
139
|
abort("No files found or given. "\
|
133
|
-
"Specify files or check the include and exclude glob in the config file.") if
|
134
|
-
|
140
|
+
"Specify files or check the include and exclude glob in the config file.") if absolute_file_set.empty?
|
141
|
+
absolute_file_set
|
135
142
|
end
|
136
143
|
|
137
144
|
sig { params(_paths: T::Array[String]).returns(T::Boolean) }
|
@@ -183,7 +190,7 @@ module Packwerk
|
|
183
190
|
end
|
184
191
|
|
185
192
|
ParseRun.new(
|
186
|
-
|
193
|
+
absolute_file_set: fetch_files_to_process(relative_file_paths, ignore_nested_packages),
|
187
194
|
configuration: @configuration,
|
188
195
|
progress_formatter: @progress_formatter,
|
189
196
|
offenses_formatter: @offenses_formatter
|
@@ -29,28 +29,30 @@ module Packwerk
|
|
29
29
|
@parser_factory = T.let(parser_factory || Packwerk::Parsers::Factory.instance, Parsers::Factory)
|
30
30
|
end
|
31
31
|
|
32
|
+
class ProcessedFile < T::Struct
|
33
|
+
const :unresolved_references, T::Array[UnresolvedReference], default: []
|
34
|
+
const :offenses, T::Array[Offense], default: []
|
35
|
+
end
|
36
|
+
|
32
37
|
sig do
|
33
|
-
params(absolute_file: String).returns(
|
34
|
-
T::Array[
|
35
|
-
T.any(
|
36
|
-
Packwerk::UnresolvedReference,
|
37
|
-
Packwerk::Offense,
|
38
|
-
)
|
39
|
-
]
|
40
|
-
)
|
38
|
+
params(absolute_file: String).returns(ProcessedFile)
|
41
39
|
end
|
42
40
|
def call(absolute_file)
|
43
41
|
parser = parser_for(absolute_file)
|
44
|
-
|
42
|
+
if parser.nil?
|
43
|
+
return ProcessedFile.new(offenses: [UnknownFileTypeResult.new(file: absolute_file)])
|
44
|
+
end
|
45
45
|
|
46
|
-
@cache.with_cache(absolute_file) do
|
47
|
-
node = parse_into_ast(absolute_file,
|
48
|
-
return
|
46
|
+
unresolved_references = @cache.with_cache(absolute_file) do
|
47
|
+
node = parse_into_ast(absolute_file, parser)
|
48
|
+
return ProcessedFile.new unless node
|
49
49
|
|
50
50
|
references_from_ast(node, absolute_file)
|
51
51
|
end
|
52
|
+
|
53
|
+
ProcessedFile.new(unresolved_references: unresolved_references)
|
52
54
|
rescue Parsers::ParseError => e
|
53
|
-
[e.result]
|
55
|
+
ProcessedFile.new(offenses: [e.result])
|
54
56
|
end
|
55
57
|
|
56
58
|
private
|
@@ -5,6 +5,8 @@ module Packwerk
|
|
5
5
|
class FilesForProcessing
|
6
6
|
extend T::Sig
|
7
7
|
|
8
|
+
AbsoluteFileSet = T.type_alias { T::Set[String] }
|
9
|
+
|
8
10
|
class << self
|
9
11
|
extend T::Sig
|
10
12
|
|
@@ -13,7 +15,7 @@ module Packwerk
|
|
13
15
|
relative_file_paths: T::Array[String],
|
14
16
|
configuration: Configuration,
|
15
17
|
ignore_nested_packages: T::Boolean
|
16
|
-
).returns(
|
18
|
+
).returns(AbsoluteFileSet)
|
17
19
|
end
|
18
20
|
def fetch(relative_file_paths:, configuration:, ignore_nested_packages: false)
|
19
21
|
new(relative_file_paths, configuration, ignore_nested_packages).files
|
@@ -31,10 +33,10 @@ module Packwerk
|
|
31
33
|
@relative_file_paths = relative_file_paths
|
32
34
|
@configuration = configuration
|
33
35
|
@ignore_nested_packages = ignore_nested_packages
|
34
|
-
@custom_files = T.let(nil, T.nilable(
|
36
|
+
@custom_files = T.let(nil, T.nilable(AbsoluteFileSet))
|
35
37
|
end
|
36
38
|
|
37
|
-
sig { returns(
|
39
|
+
sig { returns(AbsoluteFileSet) }
|
38
40
|
def files
|
39
41
|
include_files = if custom_files.empty?
|
40
42
|
configured_included_files
|
@@ -47,19 +49,21 @@ module Packwerk
|
|
47
49
|
|
48
50
|
private
|
49
51
|
|
50
|
-
sig { returns(
|
52
|
+
sig { returns(AbsoluteFileSet) }
|
51
53
|
def custom_files
|
52
|
-
@custom_files ||=
|
53
|
-
|
54
|
-
|
55
|
-
absolute_file_path
|
56
|
-
|
57
|
-
|
54
|
+
@custom_files ||= Set.new(
|
55
|
+
@relative_file_paths.map do |relative_file_path|
|
56
|
+
absolute_file_path = File.expand_path(relative_file_path, @configuration.root_path)
|
57
|
+
if File.file?(absolute_file_path)
|
58
|
+
absolute_file_path
|
59
|
+
else
|
60
|
+
custom_included_files(absolute_file_path)
|
61
|
+
end
|
58
62
|
end
|
59
|
-
|
63
|
+
).flatten
|
60
64
|
end
|
61
65
|
|
62
|
-
sig { params(absolute_file_path: String).returns(
|
66
|
+
sig { params(absolute_file_path: String).returns(AbsoluteFileSet) }
|
63
67
|
def custom_included_files(absolute_file_path)
|
64
68
|
# Note, assuming include globs are always relative paths
|
65
69
|
absolute_includes = @configuration.include.map do |glob|
|
@@ -82,24 +86,22 @@ module Packwerk
|
|
82
86
|
end
|
83
87
|
end
|
84
88
|
|
85
|
-
absolute_files
|
89
|
+
Set.new(absolute_files)
|
86
90
|
end
|
87
91
|
|
88
|
-
sig { returns(
|
92
|
+
sig { returns(AbsoluteFileSet) }
|
89
93
|
def configured_included_files
|
90
94
|
absolute_files_for_globs(@configuration.include)
|
91
95
|
end
|
92
96
|
|
93
|
-
sig { returns(
|
97
|
+
sig { returns(AbsoluteFileSet) }
|
94
98
|
def configured_excluded_files
|
95
99
|
absolute_files_for_globs(@configuration.exclude)
|
96
100
|
end
|
97
101
|
|
98
|
-
sig { params(relative_globs: T::Array[String]).returns(
|
102
|
+
sig { params(relative_globs: T::Array[String]).returns(AbsoluteFileSet) }
|
99
103
|
def absolute_files_for_globs(relative_globs)
|
100
|
-
relative_globs
|
101
|
-
.flat_map { |glob| Dir[File.expand_path(glob, @configuration.root_path)] }
|
102
|
-
.uniq
|
104
|
+
Set.new(relative_globs.flat_map { |glob| Dir[File.expand_path(glob, @configuration.root_path)] })
|
103
105
|
end
|
104
106
|
end
|
105
107
|
end
|
data/lib/packwerk/package_set.rb
CHANGED
data/lib/packwerk/parse_run.rb
CHANGED
@@ -14,14 +14,14 @@ module Packwerk
|
|
14
14
|
|
15
15
|
sig do
|
16
16
|
params(
|
17
|
-
|
17
|
+
absolute_file_set: FilesForProcessing::AbsoluteFileSet,
|
18
18
|
configuration: Configuration,
|
19
19
|
progress_formatter: Formatters::ProgressFormatter,
|
20
20
|
offenses_formatter: OffensesFormatter,
|
21
21
|
).void
|
22
22
|
end
|
23
23
|
def initialize(
|
24
|
-
|
24
|
+
absolute_file_set:,
|
25
25
|
configuration:,
|
26
26
|
progress_formatter: Formatters::ProgressFormatter.new(StringIO.new),
|
27
27
|
offenses_formatter: Formatters::OffensesFormatter.new
|
@@ -29,7 +29,7 @@ module Packwerk
|
|
29
29
|
@configuration = configuration
|
30
30
|
@progress_formatter = progress_formatter
|
31
31
|
@offenses_formatter = offenses_formatter
|
32
|
-
@
|
32
|
+
@absolute_file_set = absolute_file_set
|
33
33
|
end
|
34
34
|
|
35
35
|
sig { returns(Result) }
|
@@ -73,7 +73,7 @@ module Packwerk
|
|
73
73
|
sig { params(show_errors: T::Boolean).returns(OffenseCollection) }
|
74
74
|
def find_offenses(show_errors: false)
|
75
75
|
offense_collection = OffenseCollection.new(@configuration.root_path)
|
76
|
-
@progress_formatter.started(@
|
76
|
+
@progress_formatter.started(@absolute_file_set)
|
77
77
|
|
78
78
|
run_context = Packwerk::RunContext.from_configuration(@configuration)
|
79
79
|
all_offenses = T.let([], T::Array[Offense])
|
@@ -87,7 +87,7 @@ module Packwerk
|
|
87
87
|
|
88
88
|
execution_time = Benchmark.realtime do
|
89
89
|
all_offenses = if @configuration.parallel?
|
90
|
-
Parallel.flat_map(@
|
90
|
+
Parallel.flat_map(@absolute_file_set, &process_file)
|
91
91
|
else
|
92
92
|
serial_find_offenses(&process_file)
|
93
93
|
end
|
@@ -103,7 +103,7 @@ module Packwerk
|
|
103
103
|
def serial_find_offenses(&block)
|
104
104
|
all_offenses = T.let([], T::Array[Offense])
|
105
105
|
begin
|
106
|
-
@
|
106
|
+
@absolute_file_set.each do |absolute_file|
|
107
107
|
offenses = block.call(absolute_file)
|
108
108
|
all_offenses.concat(offenses)
|
109
109
|
end
|
@@ -13,12 +13,10 @@ module Packwerk
|
|
13
13
|
|
14
14
|
sig do
|
15
15
|
params(
|
16
|
-
reference:
|
16
|
+
reference: Reference
|
17
17
|
).returns(T::Array[Packwerk::Offense])
|
18
18
|
end
|
19
19
|
def call(reference)
|
20
|
-
return [reference] if reference.is_a?(Packwerk::Offense)
|
21
|
-
|
22
20
|
@checkers.each_with_object([]) do |checker, violations|
|
23
21
|
next unless checker.invalid_reference?(reference)
|
24
22
|
offense = Packwerk::ReferenceOffense.new(
|
@@ -51,20 +51,14 @@ module Packwerk
|
|
51
51
|
|
52
52
|
sig do
|
53
53
|
params(
|
54
|
-
|
54
|
+
unresolved_references: T::Array[UnresolvedReference],
|
55
55
|
context_provider: ConstantDiscovery
|
56
|
-
).returns(T::Array[
|
56
|
+
).returns(T::Array[Reference])
|
57
57
|
end
|
58
|
-
def self.
|
59
|
-
|
60
|
-
|
61
|
-
unresolved_references_and_offenses.each do |unresolved_references_or_offense|
|
62
|
-
if unresolved_references_or_offense.is_a?(Offense)
|
63
|
-
fully_qualified_references_and_offenses << unresolved_references_or_offense
|
64
|
-
|
65
|
-
next
|
66
|
-
end
|
58
|
+
def self.get_fully_qualified_references_from(unresolved_references, context_provider)
|
59
|
+
fully_qualified_references = T.let([], T::Array[Reference])
|
67
60
|
|
61
|
+
unresolved_references.each do |unresolved_references_or_offense|
|
68
62
|
unresolved_reference = unresolved_references_or_offense
|
69
63
|
|
70
64
|
constant =
|
@@ -83,7 +77,7 @@ module Packwerk
|
|
83
77
|
|
84
78
|
next if source_package == package_for_constant
|
85
79
|
|
86
|
-
|
80
|
+
fully_qualified_references << Reference.new(
|
87
81
|
source_package,
|
88
82
|
unresolved_reference.relative_path,
|
89
83
|
constant,
|
@@ -91,7 +85,7 @@ module Packwerk
|
|
91
85
|
)
|
92
86
|
end
|
93
87
|
|
94
|
-
|
88
|
+
fully_qualified_references
|
95
89
|
end
|
96
90
|
|
97
91
|
private
|
data/lib/packwerk/run_context.rb
CHANGED
@@ -38,7 +38,7 @@ module Packwerk
|
|
38
38
|
sig do
|
39
39
|
params(
|
40
40
|
root_path: String,
|
41
|
-
load_paths: T::
|
41
|
+
load_paths: T::Hash[String, Module],
|
42
42
|
inflector: T.class_of(ActiveSupport::Inflector),
|
43
43
|
cache_directory: Pathname,
|
44
44
|
config_path: T.nilable(String),
|
@@ -79,13 +79,15 @@ module Packwerk
|
|
79
79
|
|
80
80
|
sig { params(absolute_file: String).returns(T::Array[Packwerk::Offense]) }
|
81
81
|
def process_file(absolute_file:)
|
82
|
-
|
83
|
-
|
84
|
-
|
82
|
+
processed_file = file_processor.call(absolute_file)
|
83
|
+
|
84
|
+
references = ReferenceExtractor.get_fully_qualified_references_from(
|
85
|
+
processed_file.unresolved_references,
|
85
86
|
context_provider
|
86
87
|
)
|
87
88
|
reference_checker = ReferenceChecking::ReferenceChecker.new(@checkers)
|
88
|
-
|
89
|
+
|
90
|
+
processed_file.offenses + references.flat_map { |reference| reference_checker.call(reference) }
|
89
91
|
end
|
90
92
|
|
91
93
|
private
|
data/lib/packwerk/version.rb
CHANGED
data/packwerk.gemspec
CHANGED
@@ -41,9 +41,9 @@ Gem::Specification.new do |spec|
|
|
41
41
|
spec.required_ruby_version = ">= 2.6"
|
42
42
|
|
43
43
|
spec.add_dependency("activesupport", ">= 5.2")
|
44
|
-
spec.add_dependency("constant_resolver")
|
44
|
+
spec.add_dependency("constant_resolver", ">=0.2.0")
|
45
45
|
spec.add_dependency("parallel")
|
46
|
-
spec.add_dependency("sorbet-runtime")
|
46
|
+
spec.add_dependency("sorbet-runtime", ">=0.5.9914")
|
47
47
|
spec.add_dependency("bundler")
|
48
48
|
spec.add_dependency("digest")
|
49
49
|
|
@@ -52,6 +52,7 @@ Gem::Specification.new do |spec|
|
|
52
52
|
spec.add_development_dependency("m")
|
53
53
|
# https://github.com/ruby/psych/pull/487
|
54
54
|
spec.add_development_dependency("psych", "~> 3")
|
55
|
+
spec.add_development_dependency("zeitwerk")
|
55
56
|
|
56
57
|
# For Ruby parsing
|
57
58
|
spec.add_dependency("ast")
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: packwerk
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Shopify Inc.
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-04-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -30,14 +30,14 @@ dependencies:
|
|
30
30
|
requirements:
|
31
31
|
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version:
|
33
|
+
version: 0.2.0
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version:
|
40
|
+
version: 0.2.0
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: parallel
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -58,14 +58,14 @@ dependencies:
|
|
58
58
|
requirements:
|
59
59
|
- - ">="
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version:
|
61
|
+
version: 0.5.9914
|
62
62
|
type: :runtime
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
66
|
- - ">="
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version:
|
68
|
+
version: 0.5.9914
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: bundler
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -150,6 +150,20 @@ dependencies:
|
|
150
150
|
- - "~>"
|
151
151
|
- !ruby/object:Gem::Version
|
152
152
|
version: '3'
|
153
|
+
- !ruby/object:Gem::Dependency
|
154
|
+
name: zeitwerk
|
155
|
+
requirement: !ruby/object:Gem::Requirement
|
156
|
+
requirements:
|
157
|
+
- - ">="
|
158
|
+
- !ruby/object:Gem::Version
|
159
|
+
version: '0'
|
160
|
+
type: :development
|
161
|
+
prerelease: false
|
162
|
+
version_requirements: !ruby/object:Gem::Requirement
|
163
|
+
requirements:
|
164
|
+
- - ">="
|
165
|
+
- !ruby/object:Gem::Version
|
166
|
+
version: '0'
|
153
167
|
- !ruby/object:Gem::Dependency
|
154
168
|
name: ast
|
155
169
|
requirement: !ruby/object:Gem::Requirement
|