Skip to content

Unrendered ERB Ruby templates are scanned as methods #155

Description

@jbrown9513

At main commit 014fc18, Perch treats unrendered ERB migration templates whose filename ends in .rb as ordinary Ruby source. This is distinct from #137: parser recovery now keeps the surrounding methods, but these template files are still offered as scan candidates before ERB substitution.

Public reproduction: alexreisner/geocoder at commit 1ff64c47b6fc21d9c5ce30a6549d9eaa67c81a9e, paths:

  • lib/generators/geocoder/maxmind/templates/migration/geolite_city.rb
  • lib/generators/geocoder/maxmind/templates/migration/geolite_country.rb

Both begin with a class declaration containing ActiveRecord::Migration<%= migration_version %>. With the current createSourceAnalyzer().analyzeSource(source, 'ruby'), each returns parser_status: parsed, two method declarations (up and down), and syntax diagnostics at the ERB marker. sourceFile({type: 'blob', path}) returns true for both. Running analyzeFiles over just these two tracked blobs yields parsed: 2, parsed_with_errors: 2, four method scan candidates, and zero parse failures.

Expected: identify unrendered ERB content in a .rb template as a template rather than executable Ruby source. It should not contribute direct method questions or call-graph nodes until rendered, and the ERB marker should not be reported as a Ruby syntax failure. Keep ordinary .rb source with recoverable syntax errors eligible under #137.

The earlier scanner classified these two files as parse failures, which marked an otherwise usable whole-repository graph partial. The parser-recovery change fixes that completeness symptom, but the template classification remains.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: scannerSource selection, analysis, localization, and scan behaviorbugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions