Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@ git_source(:github) { |repo_name| "https://github.com/#{repo_name}.git" }

gemspec

gem("rubydex", ">= 0.2.3")

# Specify the same dependency sources as the application Gemfile

gem("spring")
gem("constant_resolver", require: false)
gem("rubocop-performance", require: false)
gem("rubocop-sorbet", require: false)
gem("mocha", require: false)
Expand All @@ -25,3 +26,7 @@ gem("m")
gem("rake")
gem("sorbet-static")
gem("zeitwerk")

# Ruby 4.0 removed ostruct from stdlib; yard/tapioca need it
gem("ostruct")
gem("mutex_m")
36 changes: 16 additions & 20 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,11 @@ PATH
specs:
packwerk (3.3.0)
activesupport (>= 6.0)
ast
benchmark
better_html
bundler
constant_resolver (>= 0.3)
parallel (< 2)
parser
herb
prism (>= 1.4.0)
zeitwerk (>= 2.6.1)
rubydex (>= 0.2.3)

GEM
remote: https://rubygems.org/
Expand Down Expand Up @@ -50,26 +46,22 @@ GEM
ast (2.4.3)
base64 (0.3.0)
benchmark (0.5.0)
better_html (2.1.1)
actionview (>= 6.0)
activesupport (>= 6.0)
ast (~> 2.0)
erubi (~> 1.4)
parser (>= 2.4)
smart_properties
bigdecimal (4.1.2)
builder (3.3.0)
byebug (11.1.3)
cgi (0.5.1)
concurrent-ruby (1.3.6)
connection_pool (3.0.2)
constant_resolver (0.3.0)
crass (1.0.6)
date (3.4.1)
drb (2.2.3)
erb (4.0.4.1)
cgi (>= 0.3.3)
erubi (1.13.1)
herb (0.10.1-aarch64-linux-gnu)
herb (0.10.1-arm64-darwin)
herb (0.10.1-x86_64-darwin)
herb (0.10.1-x86_64-linux-gnu)
i18n (1.14.8)
concurrent-ruby (~> 1.0)
io-console (0.8.0)
Expand All @@ -94,6 +86,7 @@ GEM
minitest-mock (5.27.0)
mocha (2.5.0)
ruby2_keywords (>= 0.0.5)
mutex_m (0.3.0)
netrc (0.11.0)
nokogiri (1.19.3-aarch64-linux-gnu)
racc (~> 1.4)
Expand All @@ -103,6 +96,7 @@ GEM
racc (~> 1.4)
nokogiri (1.19.3-x86_64-linux-gnu)
racc (~> 1.4)
ostruct (0.6.3)
parallel (1.28.0)
parser (3.3.11.1)
ast (~> 2.4.1)
Expand Down Expand Up @@ -180,12 +174,11 @@ GEM
rubocop (>= 0.90.0)
ruby-progressbar (1.13.0)
ruby2_keywords (0.0.5)
rubydex (0.2.0-aarch64-linux)
rubydex (0.2.0-arm64-darwin)
rubydex (0.2.0-x86_64-darwin)
rubydex (0.2.0-x86_64-linux)
rubydex (0.2.3-aarch64-linux)
rubydex (0.2.3-arm64-darwin)
rubydex (0.2.3-x86_64-darwin)
rubydex (0.2.3-x86_64-linux)
securerandom (0.4.1)
smart_properties (1.17.0)
sorbet (0.6.13184)
sorbet-static (= 0.6.13184)
sorbet-runtime (0.6.13184)
Expand Down Expand Up @@ -232,25 +225,28 @@ PLATFORMS
arm64-darwin-21
arm64-darwin-22
arm64-darwin-23
arm64-darwin-24
arm64-darwin-25
x86_64-darwin
x86_64-darwin-20
x86_64-linux

DEPENDENCIES
byebug
constant_resolver
m
minitest-focus
minitest-mock
mocha
mutex_m
ostruct
packwerk!
railties
rake
rbi (< 0.3.11)
rubocop-performance
rubocop-shopify
rubocop-sorbet
rubydex (>= 0.2.3)
sorbet-static
spring
tapioca
Expand Down
3 changes: 0 additions & 3 deletions exe/packwerk
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@

require "packwerk"

# Needs to be run in test environment in order to have test helper paths available in the autoload paths
ENV["RAILS_ENV"] = "test"

# Command line arguments needs to be duplicated because spring modifies it
packwerk_argv = ARGV.dup
cli = Packwerk::Cli.new(style: Packwerk::OutputStyles::Coloured.new)
Expand Down
16 changes: 2 additions & 14 deletions lib/packwerk.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
require "active_support/core_ext/string"
# Provides Object#to_json
require "active_support/core_ext/object/json"
# Provides Object#present? / #blank?
require "active_support/core_ext/object/blank"

module Packwerk
extend ActiveSupport::Autoload
Expand All @@ -28,7 +30,6 @@ module Packwerk
autoload :PackageSet
autoload :PackageTodo
autoload :Parsers
autoload :RailsLoadPaths
autoload :Reference
autoload :ReferenceOffense
autoload :Validator
Expand Down Expand Up @@ -56,24 +57,11 @@ module Validators
# Private APIs
# Please submit an issue if you have a use-case for these
autoload :ApplicationValidator
autoload :AssociationInspector
autoload :Cache
autoload :ConstantDiscovery
autoload :ConstantNameInspector
autoload :ConstNodeInspector
autoload :ExtensionLoader
autoload :FileProcessor
autoload :FilesForProcessing
autoload :Graph
autoload :NodeHelpers
autoload :NodeProcessor
autoload :NodeProcessorFactory
autoload :NodeVisitor
autoload :ParsedConstantDefinitions
autoload :ParseRun
autoload :ReferenceExtractor
autoload :RunContext
autoload :UnresolvedReference

module Generators
extend ActiveSupport::Autoload
Expand Down
27 changes: 16 additions & 11 deletions lib/packwerk/application_validator.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# typed: strict
# frozen_string_literal: true

require "constant_resolver"
require "rubydex"
require "pathname"
require "yaml"

Expand Down Expand Up @@ -71,18 +71,23 @@ def check_package_manifest_syntax(configuration)

#: (Configuration configuration) -> Validator::Result
def check_application_structure(configuration)
resolver = ConstantResolver.new(
root_path: configuration.root_path.to_s,
load_paths: configuration.load_paths,
exclude: configuration.exclude,
)

begin
resolver.file_map
graph = Rubydex::Graph.new(workspace_path: configuration.root_path)
files = FilesForProcessing.fetch(
relative_file_paths: [],
configuration: configuration,
).files.to_a
graph.index_all(files)
graph.resolve

diagnostics = graph.diagnostics
if diagnostics.empty?
Validator::Result.new(ok: true)
rescue => e
Validator::Result.new(ok: false, error_value: e.message)
else
messages = diagnostics.map(&:message).join("\n")
Validator::Result.new(ok: false, error_value: messages)
end
rescue => e
Validator::Result.new(ok: false, error_value: e.message)
end

#: (Configuration configuration) -> Validator::Result
Expand Down
77 changes: 0 additions & 77 deletions lib/packwerk/association_inspector.rb

This file was deleted.

Loading
Loading