Skip to content

Explore assumptions made when we can't find a constant #19

@thegedge

Description

@thegedge

With the constant ::Foo::Bar::Spam we look for these files on all load paths:

  1. foo/bar/spam.rb
  2. foo/bar.rb
  3. foo.rb

The first of those to exist is the file that defines the constant. If it's an exact match, we can guarantee a match (in any sane, Ruby app). This may not be correct for (2) or (3) though, if both exist.

This potentially gets even more confusing when we consider things that are loaded via require in paths that reflect a similar structure as autoload paths. Unit tests, for example, can often fit the same hierarchical structure as their counterparts.

Let's look into how we can either a) not make any assumptions and avoid false positives, or b) another solution that completely avoids false positives.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions