Shopify / Shopify/rubydex

Duplicates unresolved constant

Open
#809 1 comment 3 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Rust
Stars
355
Forks
24
Avg merge
2d 6h
Merged PRs (30d)
17

Description

In the code bellow unresolved constant occurs twice in graph.constant_references with same location. The first time as SomeHttpTransport, the second time as <SomeHttpTransport>. It's confusing

equire "bundler/inline"

gemfile do
  source "https://rubygems.org"
  gem "rubydex"
end

File.binwrite("file1.rb", <<~RUBY)
  module Tracer
    def notify
      SomeHttpTransport.get("https://tracer.com/")
    end
  end
RUBY

module Rubydex
  class Location
    def to_file_path = uri
  end
end

graph = Rubydex::Graph.new
graph.index_all(Dir.glob("*.rb"))

graph.constant_references do |reference|
  next unless reference.is_a?(Rubydex::UnresolvedConstantReference)

  puts "#{reference.name} #{reference.location}"
end
BasicObject rubydex:built-in:8:22-8:33
Module rubydex:built-in:15:21-15:27
Kernel rubydex:built-in:9:17-9:23
**<SomeHttpTransport> file:///home/dev/projects/gp/const_stricter/bin/tmp/file1.rb:3:5-3:22**
Object rubydex:built-in:12:22-12:28
**SomeHttpTransport file:///home/dev/projects/gp/const_stricter/bin/tmp/file1.rb:3:5-3:22**

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the example using Rubydex::Graph#index_all and inspect how graph.constant_references yields Rubydex::UnresolvedConstantReference objects for file1.rb. Trace the two references at the same location and determine where their names diverge. Done means the duplicate unresolved constant is no longer reported twice for that location.

Written by the indexing model from the issue text.

Assessment

Tech stack
ruby, rust
Domain
devtools
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.