Output number of table created from schema.rb or structure.sql, add polymorphic models count#37
Output number of table created from schema.rb or structure.sql, add polymorphic models count#37etagwerker merged 14 commits intomainfrom
Conversation
602404b to
8174700
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #37 +/- ##
==========================================
+ Coverage 82.86% 83.20% +0.33%
==========================================
Files 19 19
Lines 683 750 +67
==========================================
+ Hits 566 624 +58
- Misses 117 126 +9 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
0f6be4b to
baa9321
Compare
baa9321 to
4b93f2c
Compare
etagwerker
left a comment
There was a problem hiding this comment.
@hmdros Thanks for submitting this!
This is outside of the scope of #31:
STI models count: 1 STI classes
And it can be quite complex to implement.
Could you please submit a new issue about STIs?
I think we could merge this PR without the STIs code and then you can work on the STIs code in a separate PR.
Thank you!
lib/rails_stats/stats_calculator.rb
Outdated
| @sti = 0 | ||
| Dir.glob(File.join(@root_directory, "app", "models", "*.rb")).each do |file| | ||
| File.foreach(file) do |line| | ||
| if line =~ /class\s+(\w+)\s*<\s*(\w+)/ && !(line =~ /class\s+(\w+)\s*<\s*(ActiveRecord::Base|ApplicationRecord)/) |
There was a problem hiding this comment.
@hmdros I think this is too optimistic and it will generate false positives in certain applications.
Many projects use app/models as a place to put models that don't necessarily extend an ActiveRecord::Base|ApplicationRecord descendant.
I see that in your test you have this example:
class Pets < User
end
That's certainly an STI.
But what if someone has this in their app/models directory:
class Pets < User
end
And then:
class User
...
end
That is not an STI and it will be counted as one (or two?)
There was a problem hiding this comment.
I do agree that this can get confusing and the code to check this would need to be extra careful for this. I can try to get this in a different PR then. Removing
Closes #31
CHANGELOG.mdthat links to this PR under the "main (unreleased)" heading.Description:
Adds to the output:
I will abide by the code of conduct.