djezzzl / database_consistency

The tool to avoid various issues due to inconsistencies and inefficiencies between a database schema and application models.
MIT License
1.02k stars 43 forks source link

Exclude anonymous classes from project classes #221

Open sirdharma opened 7 months ago

sirdharma commented 7 months ago

When anonymous classes are defined (most commonly in a previously required spec file), DatabaseConsistency::Helper#project_klass? fails with the following error:

DatabaseConsistency::Helper#project_klass when the class is anonymous 
Failure/Error: !Module.const_source_location(klass.to_s).first.to_s.include?(Bundler.bundle_path.to_s)

NameError:
  wrong constant name #<Class:0x0000000104cb4b20>

This PR fixes the issue by excluding anonymous class from being considered project classes.

Thank you for this project! 🙏

djezzzl commented 7 months ago

Hi @sirdharma,

Thank you for the suggested fix!

Are there other ways to prove the class is anonymous instead of asking for .name?

And could you please fix the specs? I will merge and release it as soon as possible.

sirdharma commented 7 months ago

Hi @sirdharma,

Thank you for the suggested fix!

Are there other ways to prove the class is anonymous instead of asking for .name?

And could you please fix the specs? I will merge and release it as soon as possible.

Thank you @djezzzl , will do! I am leaving this comment to let you know that I will resume working on this PR after the holiday season 🎄