Skip to content

Commit 6e27cbc

Browse files
committed
Rmove STI count changes
1 parent 11b360c commit 6e27cbc

File tree

6 files changed

+2
-31
lines changed

6 files changed

+2
-31
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
* [BUGFIX: Fix JSON output missing Code and Tests total count](https://github.com/fastruby/rails_stats/pull/40)
44
* Update README examples
5-
* [FEATURE: Output number of table created from schema.rb or structure.sql, add STI count add polymorphic models count](https://github.com/fastruby/rails_stats/pull/37)
5+
* [FEATURE: Output number of table created from schema.rb or structure.sql, add polymorphic models count](https://github.com/fastruby/rails_stats/pull/37)
66

77
# v2.0.1 ([commits](https://github.com/fastruby/rails_stats/compare/v2.0.0...v2.0.1))
88

lib/rails_stats/console_formatter.rb

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ def to_s
1818
end
1919

2020
print_code_test_stats
21-
print_sti_stats
2221
print_polymorphic_stats
2322
print_schema_stats
2423
end
@@ -57,10 +56,6 @@ def print_code_test_stats
5756
puts ""
5857
end
5958

60-
def print_sti_stats
61-
puts " STI models count: #{calculator.sti} STI classes"
62-
end
63-
6459
def print_polymorphic_stats
6560
puts " Polymorphic models count: #{calculator.polymorphic} polymorphic associations"
6661
end

lib/rails_stats/json_formatter.rb

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ def result
1818
@result << stat_hash("Total", @grand_total).merge(code_test_hash) if @grand_total
1919

2020
@result << { "schema_stats" => schema_info }
21-
@result << { "sti_stats" => print_sti_stat }
2221
@result << { "polymorphic_stats" => print_polymorphic_stats }
2322

2423
@result
@@ -55,14 +54,6 @@ def stat_hash(name, statistics)
5554
}
5655
end
5756

58-
def print_sti_stat
59-
if calculator.sti
60-
{
61-
"sti_models_count" => calculator.sti,
62-
}
63-
end
64-
end
65-
6657
def print_polymorphic_stats
6758
if calculator.polymorphic
6859
{

lib/rails_stats/stats_calculator.rb

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,11 @@ def initialize(root_directory)
1717
@code_loc = calculate_code
1818
@test_loc = calculate_tests
1919
@schema = calculate_create_table_calls
20-
@sti = calculate_sti
2120
@polymorphic = calculate_polymorphic
2221
@files_total, @code_total, @tests_total, @grand_total = calculate_totals
2322
end
2423

25-
attr_reader :code_loc, :code_total, :files_total, :grand_total, :statistics, :test_loc, :tests_total, :schema, :schema_path, :structure_path, :sti, :polymorphic
24+
attr_reader :code_loc, :code_total, :files_total, :grand_total, :statistics, :test_loc, :tests_total, :schema, :schema_path, :structure_path, :polymorphic
2625

2726
private
2827

@@ -155,18 +154,6 @@ def count_create_table_calls(file_path, keyword)
155154
create_table_count
156155
end
157156

158-
def calculate_sti
159-
@sti = 0
160-
Dir.glob(File.join(@root_directory, "app", "models", "*.rb")).each do |file|
161-
File.foreach(file) do |line|
162-
if line =~ /class\s+(\w+)\s*<\s*(\w+)/ && !(line =~ /class\s+(\w+)\s*<\s*(ActiveRecord::Base|ApplicationRecord)/)
163-
@sti += 1
164-
end
165-
end
166-
end
167-
@sti
168-
end
169-
170157
def calculate_polymorphic
171158
polymorphic_count = 0
172159
Dir.glob(File.join(@root_directory, "app", "models", "*.rb")).each do |file|

test/fixtures/console-output.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,5 @@
3939
+----------------------+---------+---------+---------+---------+---------+-----+-------+
4040
Code LOC: 152 Test LOC: 6 Code to Test Ratio: 1:0.0 Files: 37
4141

42-
STI models count: 1 STI classes
4342
Polymorphic models count: 1 polymorphic associations
4443
Schema Stats: 2 `create_table` calls in schema.rb

test/lib/rails_stats/json_formatter_test.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,6 @@
255255
{"schema_path":
256256
"#{Dir.pwd}/test/dummy/db/schema.rb",
257257
"create_table calls count": 2}},
258-
{"sti_stats": {"sti_models_count": 1}},
259258
{"polymorphic_stats": {"polymorphic_models_count": 1}
260259
}
261260
]

0 commit comments

Comments
 (0)