-
Notifications
You must be signed in to change notification settings - Fork 120
Description
Description
When using module_parent in a class definition, packwerk raises this error:
spec/my_spec.rb
Packwerk encountered an internal error.
For now, you can add this file topackwerk.ymlexcludelist.
Please file an issue and include this error message and stacktrace:Packwerk::NodeHelpers::TypeError ruby/3.0.6/lib/ruby/gems/3.0.0/gems/packwerk-3.2.0/lib/packwerk/node_helpers.rb:58:in
'"constant_name' ruby/3.0.6/lib/ruby/gems/3.0.0/gems/packwerk-3.2.0/lib/packwerk/node_helpers.rb:53:inconstant_name'
ruby/3.0.6/lib/ruby/gems/3.0.0/gems/packwerk-3.2.0/lib/packwerk/const_node_inspector.rb:45:inconstant_in_module_or_class_definition?' ruby/3.0.6/lib/ruby/gems/3.0.0/gems/packwerk-3.2.0/lib/packwerk/const_node_inspector.rb:24:inconstant_name_from_node'
ruby/3.0.6/lib/ruby/gems/3.0.0/gems/packwerk-3.2.0/lib/packwerk/reference_extractor.rb:83:inblock in reference_from_node' ruby/3.0.6/lib/ruby/gems/3.0.0/gems/packwerk-3.2.0/lib/packwerk/reference_extractor.rb:82:ineach'
ruby/3.0.6/lib/ruby/gems/3.0.0/gems/packwerk-3.2.0/lib/packwerk/reference_extractor.rb:82:inreference_from_node' ruby/gems/3.0.0/gems/packwerk-3.2.0/lib/packwerk/node_processor.rb:29:incall'
ruby/3.0.6/lib/ruby/gems/3.0.0/gems/packwerk-3.2.0/lib/packwerk/node_visitor.rb:22:invisit' ruby/3.0.6/lib/ruby/gems/3.0.0/gems/packwerk-3.2.0/lib/packwerk/node_visitor.rb:27:inblock in visit'
ruby/3.0.6/lib/ruby/gems/3.0.0/gems/packwerk-3.2.0/lib/packwerk/node_helpers.rb:71:inblock in each_child' ruby/3.0.6/lib/ruby/gems/3.0.0/gems/packwerk-3.2.0/lib/packwerk/node_helpers.rb:70:ineach'
ruby/3.0.6/lib/ruby/gems/3.0.0/gems/packwerk-3.2.0/lib/packwerk/node_helpers.rb:70:ineach_child' ruby/3.0.6/lib/ruby/gems/3.0.0/gems/packwerk-3.2.0/lib/packwerk/node_visitor.rb:26:invisit'
ruby/3.0.6/lib/ruby/gems/3.0.0/gems/packwerk-3.2.0/lib/packwerk/node_visitor.rb:27:inblock in visit' ruby/3.0.6/lib/ruby/gems/3.0.0/gems/packwerk-3.2.0/lib/packwerk/node_helpers.rb:71:inblock in each_child'
ruby/3.0.6/lib/ruby/gems/3.0.0/gems/packwerk-3.2.0/lib/packwerk/node_helpers.rb:70:ineach' ruby/3.0.6/lib/ruby/gems/3.0.0/gems/packwerk-3.2.0/lib/packwerk/node_helpers.rb:70:ineach_child'
ruby/3.0.6/lib/ruby/gems/3.0.0/gems/packwerk-3.2.0/lib/packwerk/node_visitor.rb:26:invisit' ruby/3.0.6/lib/ruby/gems/3.0.0/gems/packwerk-3.2.0/lib/packwerk/node_visitor.rb:27:inblock in visit'
ruby/3.0.6/lib/ruby/gems/3.0.0/gems/packwerk-3.2.0/lib/packwerk/node_helpers.rb:71:inblock in each_child' ruby/3.0.6/lib/ruby/gems/3.0.0/gems/packwerk-3.2.0/lib/packwerk/node_helpers.rb:70:ineach'
ruby/3.0.6/lib/ruby/gems/3.0.0/gems/packwerk-3.2.0/lib/packwerk/node_helpers.rb:70:ineach_child' ruby/3.0.6/lib/ruby/gems/3.0.0/gems/packwerk-3.2.0/lib/packwerk/node_visitor.rb:26:invisit'
ruby/3.0.6/lib/ruby/gems/3.0.0/gems/packwerk-3.2.0/lib/packwerk/node_visitor.rb:27:inblock in visit' ruby/3.0.6/lib/ruby/gems/3.0.0/gems/packwerk-3.2.0/lib/packwerk/node_helpers.rb:71:inblock in each_child'
ruby/3.0.6/lib/ruby/gems/3.0.0/gems/packwerk-3.2.0/lib/packwerk/node_helpers.rb:70:ineach' ruby/3.0.6/lib/ruby/gems/3.0.0/gems/packwerk-3.2.0/lib/packwerk/node_helpers.rb:70:ineach_child'
ruby/3.0.6/lib/ruby/gems/3.0.0/gems/packwerk-3.2.0/lib/packwerk/node_visitor.rb:26:invisit' ruby/3.0.6/lib/ruby/gems/3.0.0/gems/packwerk-3.2.0/lib/packwerk/node_visitor.rb:27:inblock in visit'
ruby/3.0.6/lib/ruby/gems/3.0.0/gems/packwerk-3.2.0/lib/packwerk/node_helpers.rb:71:inblock in each_child' ruby/3.0.6/lib/ruby/gems/3.0.0/gems/packwerk-3.2.0/lib/packwerk/node_helpers.rb:70:ineach'
ruby/3.0.6/lib/ruby/gems/3.0.0/gems/packwerk-3.2.0/lib/packwerk/node_helpers.rb:70:ineach_child' ruby/3.0.6/lib/ruby/gems/3.0.0/gems/packwerk-3.2.0/lib/packwerk/node_visitor.rb:26:invisit'
ruby/3.0.6/lib/ruby/gems/3.0.0/gems/packwerk-3.2.0/lib/packwerk/node_visitor.rb:27:inblock in visit' ruby/3.0.6/lib/ruby/gems/3.0.0/gems/packwerk-3.2.0/lib/packwerk/node_helpers.rb:71:inblock in each_child'
ruby/3.0.6/lib/ruby/gems/3.0.0/gems/packwerk-3.2.0/lib/packwerk/node_helpers.rb:70:ineach' ruby/3.0.6/lib/ruby/gems/3.0.0/gems/packwerk-3.2.0/lib/packwerk/node_helpers.rb:70:ineach_child'
ruby/3.0.6/lib/ruby/gems/3.0.0/gems/packwerk-3.2.0/lib/packwerk/node_visitor.rb:26:invisit' ruby/3.0.6/lib/ruby/gems/3.0.0/gems/packwerk-3.2.0/lib/packwerk/node_visitor.rb:27:inblock in visit'
ruby/3.0.6/lib/ruby/gems/3.0.0/gems/packwerk-3.2.0/lib/packwerk/node_helpers.rb:71:inblock in each_child' ruby/3.0.6/lib/ruby/gems/3.0.0/gems/packwerk-3.2.0/lib/packwerk/node_helpers.rb:70:ineach'
ruby/3.0.6/lib/ruby/gems/3.0.0/gems/packwerk-3.2.0/lib/packwerk/node_helpers.rb:70:ineach_child' ruby/3.0.6/lib/ruby/gems/3.0.0/gems/packwerk-3.2.0/lib/packwerk/node_visitor.rb:26:invisit'
ruby/3.0.6/lib/ruby/gems/3.0.0/gems/packwerk-3.2.0/lib/packwerk/node_visitor.rb:27:inblock in visit' ruby/3.0.6/lib/ruby/gems/3.0.0/gems/packwerk-3.2.0/lib/packwerk/node_helpers.rb:71:inblock in each_child'
ruby/3.0.6/lib/ruby/gems/3.0.0/gems/packwerk-3.2.0/lib/packwerk/node_helpers.rb:70:ineach' ruby/3.0.6/lib/ruby/gems/3.0.0/gems/packwerk-3.2.0/lib/packwerk/node_helpers.rb:70:ineach_child'
ruby/3.0.6/lib/ruby/gems/3.0.0/gems/packwerk-3.2.0/lib/packwerk/node_visitor.rb:26:invisit' ruby/3.0.6/lib/ruby/gems/3.0.0/gems/packwerk-3.2.0/lib/packwerk/node_visitor.rb:27:inblock in visit'
ruby/3.0.6/lib/ruby/gems/3.0.0/gems/packwerk-3.2.0/lib/packwerk/node_helpers.rb:71:inblock in each_child' ruby/3.0.6/lib/ruby/gems/3.0.0/gems/packwerk-3.2.0/lib/packwerk/node_helpers.rb:70:ineach'
ruby/3.0.6/lib/ruby/gems/3.0.0/gems/packwerk-3.2.0/lib/packwerk/node_helpers.rb:70:ineach_child' ruby/3.0.6/lib/ruby/gems/3.0.0/gems/packwerk-3.2.0/lib/packwerk/node_visitor.rb:26:invisit'
ruby/3.0.6/lib/ruby/gems/3.0.0/gems/packwerk-3.2.0/lib/packwerk/node_visitor.rb:27:inblock in visit' ruby/3.0.6/lib/ruby/gems/3.0.0/gems/packwerk-3.2.0/lib/packwerk/node_helpers.rb:71:inblock in each_child'
ruby/3.0.6/lib/ruby/gems/3.0.0/gems/packwerk-3.2.0/lib/packwerk/node_helpers.rb:70:ineach' ruby/3.0.6/lib/ruby/gems/3.0.0/gems/packwerk-3.2.0/lib/packwerk/node_helpers.rb:70:ineach_child'
ruby/3.0.6/lib/ruby/gems/3.0.0/gems/packwerk-3.2.0/lib/packwerk/node_visitor.rb:26:invisit' ruby/3.0.6/lib/ruby/gems/3.0.0/gems/packwerk-3.2.0/lib/packwerk/node_visitor.rb:27:inblock in visit'
ruby/3.0.6/lib/ruby/gems/3.0.0/gems/packwerk-3.2.0/lib/packwerk/node_helpers.rb:71:inblock in each_child' ruby/3.0.6/lib/ruby/gems/3.0.0/gems/packwerk-3.2.0/lib/packwerk/node_helpers.rb:70:ineach'
ruby/3.0.6/lib/ruby/gems/3.0.0/gems/packwerk-3.2.0/lib/packwerk/node_helpers.rb:70:ineach_child' ruby/3.0.6/lib/ruby/gems/3.0.0/gems/packwerk-3.2.0/lib/packwerk/node_visitor.rb:26:invisit'
ruby/3.0.6/lib/ruby/gems/3.0.0/gems/packwerk-3.2.0/lib/packwerk/file_processor.rb:79:inreferences_from_ast' ruby/3.0.6/lib/ruby/gems/3.0.0/gems/packwerk-3.2.0/lib/packwerk/file_processor.rb:50:inblock in call'
ruby/3.0.6/lib/ruby/gems/3.0.0/gems/packwerk-3.2.0/lib/packwerk/cache.rb:78:inwith_cache' ruby/3.0.6/lib/ruby/gems/3.0.0/gems/packwerk-3.2.0/lib/packwerk/file_processor.rb:46:incall'
ruby/3.0.6/lib/ruby/gems/3.0.0/gems/packwerk-3.2.0/lib/packwerk/run_context.rb:78:inprocess_file' ruby/3.0.6/lib/ruby/gems/3.0.0/gems/packwerk-3.2.0/lib/packwerk/parse_run.rb:57:inblock in process_file_proc'
ruby/3.0.6/lib/ruby/gems/3.0.0/gems/parallel-1.22.1/lib/parallel.rb:587:incall_with_index' ruby/3.0.6/lib/ruby/gems/3.0.0/gems/parallel-1.22.1/lib/parallel.rb:557:inprocess_incoming_jobs'
ruby/3.0.6/lib/ruby/gems/3.0.0/gems/parallel-1.22.1/lib/parallel.rb:537:inblock in worker' ruby/3.0.6/lib/ruby/gems/3.0.0/gems/activesupport-7.0.8.1/lib/active_support/fork_tracker.rb:20:inblock in fork'
ruby/3.0.6/lib/ruby/gems/3.0.0/gems/activesupport-7.0.8.1/lib/active_support/fork_tracker.rb:18:infork' ruby/3.0.6/lib/ruby/gems/3.0.0/gems/activesupport-7.0.8.1/lib/active_support/fork_tracker.rb:18:infork'
ruby/3.0.6/lib/ruby/gems/3.0.0/gems/parallel-1.22.1/lib/parallel.rb:528:inworker' ruby/3.0.6/lib/ruby/gems/3.0.0/gems/parallel-1.22.1/lib/parallel.rb:519:inblock in create_workers'
ruby/3.0.6/lib/ruby/gems/3.0.0/gems/parallel-1.22.1/lib/parallel.rb:518:ineach' ruby/3.0.6/lib/ruby/gems/3.0.0/gems/parallel-1.22.1/lib/parallel.rb:518:ineach_with_index'
ruby/3.0.6/lib/ruby/gems/3.0.0/gems/parallel-1.22.1/lib/parallel.rb:518:increate_workers' ruby/3.0.6/lib/ruby/gems/3.0.0/gems/parallel-1.22.1/lib/parallel.rb:457:inwork_in_processes'
ruby/3.0.6/lib/ruby/gems/3.0.0/gems/parallel-1.22.1/lib/parallel.rb:294:inmap' ruby/3.0.6/lib/ruby/gems/3.0.0/gems/parallel-1.22.1/lib/parallel.rb:307:inflat_map'
ruby/3.0.6/lib/ruby/gems/3.0.0/gems/packwerk-3.2.0/lib/packwerk/parse_run.rb:38:infind_offenses' ruby/3.0.6/lib/ruby/gems/3.0.0/gems/sorbet-runtime-0.5.11122/lib/types/private/methods/_methods.rb:277:inbind_call'
ruby/3.0.6/lib/ruby/gems/3.0.0/gems/sorbet-runtime-0.5.11122/lib/types/private/methods/_methods.rb:277:inblock in _on_method_added' ruby/3.0.6/lib/ruby/gems/3.0.0/gems/packwerk-3.2.0/lib/packwerk/commands/check_command.rb:27:inblock in run'
ruby/3.0.6/lib/ruby/gems/3.0.0/gems/benchmark-0.2.1/lib/benchmark.rb:311:inrealtime' ruby/3.0.6/lib/ruby/gems/3.0.0/gems/packwerk-3.2.0/lib/packwerk/formatters/progress_formatter.rb:29:instarted_inspection'
ruby/3.0.6/lib/ruby/gems/3.0.0/gems/sorbet-runtime-0.5.11122/lib/types/private/methods/_methods.rb:277:inbind_call' ruby/3.0.6/lib/ruby/gems/3.0.0/gems/sorbet-runtime-0.5.11122/lib/types/private/methods/_methods.rb:277:inblock in _on_method_added'
ruby/3.0.6/lib/ruby/gems/3.0.0/gems/packwerk-3.2.0/lib/packwerk/commands/check_command.rb:26:inrun' ruby/3.0.6/lib/ruby/gems/3.0.0/gems/sorbet-runtime-0.5.11122/lib/types/private/methods/_methods.rb:277:inbind_call'
ruby/3.0.6/lib/ruby/gems/3.0.0/gems/sorbet-runtime-0.5.11122/lib/types/private/methods/_methods.rb:277:inblock in _on_method_added' ruby/3.0.6/lib/ruby/gems/3.0.0/gems/packwerk-3.2.0/lib/packwerk/cli.rb:58:inexecute_command'
ruby/3.0.6/lib/ruby/gems/3.0.0/gems/sorbet-runtime-0.5.11122/lib/types/private/methods/_methods.rb:277:inbind_call' ruby/3.0.6/lib/ruby/gems/3.0.0/gems/sorbet-runtime-0.5.11122/lib/types/private/methods/_methods.rb:277:inblock in _on_method_added'
ruby/3.0.6/lib/ruby/gems/3.0.0/gems/packwerk-3.2.0/lib/packwerk/cli.rb:41:inrun' ruby/3.0.6/lib/ruby/gems/3.0.0/gems/sorbet-runtime-0.5.11122/lib/types/private/methods/_methods.rb:277:inbind_call'
ruby/3.0.6/lib/ruby/gems/3.0.0/gems/sorbet-runtime-0.5.11122/lib/types/private/methods/_methods.rb:277:inblock in _on_method_added' ruby/3.0.6/lib/ruby/gems/3.0.0/gems/packwerk-3.2.0/exe/packwerk:16:in<top (required)>'
bin/packwerk:31:inload' bin/packwerk:31:in
To Reproduce
- Create a spec file like so:
RSpec.describe "this bug" do
class self::MyTestClass
end
context "my nested context" do
class self::MyTestClass < module_parent::MyTestClass
end
end
end
- Run packwerk check on the spec file
- Watch Packwerk explode
Expected Behaviour
Packwerk not to crash with an exception
Version Information
- Packwerk: [3.2.0]
- Ruby [3.0.6]
Additional Context
There is a workaround by simply omitting the module_parent prefix like so:
RSpec.describe "this bug" do
class self::MyTestClass
end
context "my nested context" do
class self::MyTestClass < self::MyTestClass
end
end
end
This appears to be equivalent in Ruby and does not crash packwerk. However, this less explicit syntax may be less understandable for some people.