rails_stats 2.0.0 → 2.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 06f66a7f398a3206774d6dc5b80ce346e8c518f3469c386da5b23e2d4ebdc63e
4
- data.tar.gz: a3628487b836738a60f55facfbb79d5617f641391e30ac0488e294a995b9332e
3
+ metadata.gz: a444e6b90de2ab6eead56780299fc2b2a24811f6318877007238eb45a4be0591
4
+ data.tar.gz: c790a1e79d70ea1ab78476052bf27b71cc3491b63c8b7bd2a2d180e81a817aa0
5
5
  SHA512:
6
- metadata.gz: 03d2f39eeace55a4580f7222c1c50f53bfd2110459f69be3a976889d836f4477e7ba3d9e4969818270529a457a88c9929b2346cc81effc446a9c71a239ee9093
7
- data.tar.gz: 75d02d452ef3f44b8a429bb80bd07e67bece730d5de1e60c25b4cd215a66deb8d7ebbe6134d305873856f1793488ba1bde41778204edc3e7a60515c3093c1474
6
+ metadata.gz: b3971dca0766fd9d81aa927823111c80d5de66fe6b70e20fbc620395d5e95f1a847f9b2c6ff09dc51611423a444e797cb1d373a5f87ad7df8b58f18ca68ce50d
7
+ data.tar.gz: 3d250b31139d4abf61a1c835e0f4022c17b62e57d57646935548f3a2086b1712b42dfd9a69d7d447aeeff465e69842660332f75faff87eed58f6c2d27e0b024a
@@ -13,30 +13,38 @@ jobs:
13
13
  runs-on: ubuntu-latest
14
14
  strategy:
15
15
  matrix:
16
- ruby-version: ["2.5", "2.6", "2.7", "3.0"]
16
+ include:
17
+ - ruby-version: "2.5"
18
+ bundler-version: "2.3.27"
19
+ - ruby-version: "2.6"
20
+ bundler-version: "2.4.0"
21
+ - ruby-version: "2.7"
22
+ bundler-version: "2.4.0"
23
+ - ruby-version: "3.0"
24
+ - ruby-version: "3.1"
25
+ - ruby-version: "3.2"
26
+ - ruby-version: "3.3"
27
+ - ruby-version: "3.4"
17
28
 
18
29
  steps:
19
- - uses: actions/checkout@v1
30
+ - uses: actions/checkout@v4
20
31
  - name: Setup Ruby
21
32
  uses: ruby/setup-ruby@v1
22
33
  with:
23
34
  ruby-version: ${{ matrix.ruby-version }}
24
- bundler-cache: true
25
- - name: Uninstall existing Bundler
26
- run: |
27
- gem uninstall bundler -a -x || true
35
+ # Disable bundler-cache when a custom bundler version is required,
36
+ # as setup-ruby's cache is tied to the bundler it installs.
37
+ bundler-cache: ${{ !matrix.bundler-version }}
28
38
  - name: Install Bundler
29
- run: |
30
- if [[ "${{ matrix.ruby-version }}" == "2.6" || "${{ matrix.ruby-version }}" == "2.7" ]]; then
31
- gem install bundler -v "~> 2.4.0"
32
- else
33
- gem install bundler
34
- fi
39
+ if: matrix.bundler-version
40
+ run: gem install bundler -v "~> ${{ matrix.bundler-version }}"
41
+ - name: Install gems
42
+ if: matrix.bundler-version
43
+ run: bundle install
35
44
  - name: Build and run tests
36
45
  env:
37
46
  COVERAGE: true
47
+ # TERM is required for colored/formatted test output in CI
38
48
  TERM: xterm
39
49
  CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
40
- run: |
41
- bundle install --jobs 4 --retry 3
42
- bundle exec rake test
50
+ run: bundle exec rake test
data/CHANGELOG.md CHANGED
@@ -1,6 +1,18 @@
1
- # main ([unreleased](https://github.com/fastruby/rails_stats/compare/v1.0.2...main))
1
+ # main ([unreleased](https://github.com/fastruby/rails_stats/compare/v2.1.0...main))
2
2
 
3
- *
3
+ * [CHORE: Improve the GH Test Workflow](https://github.com/fastruby/rails_stats/pull/35)
4
+ * [BUGFIX: Explicitly set format as text for `Bundler::Stats::CLI` on `ConsoleFormatter`](https://github.com/fastruby/rails_stats/pull/43)
5
+
6
+ # v2.1.0 ([commits](https://github.com/fastruby/rails_stats/compare/v2.1.0...v2.0.1))
7
+
8
+ * [BUGFIX: Fix JSON output missing Code and Tests total count](https://github.com/fastruby/rails_stats/pull/40)
9
+ * Update README examples
10
+ * [FEATURE: Output number of tables created from schema.rb or structure.sql, add polymorphic models count](https://github.com/fastruby/rails_stats/pull/37)
11
+ * [FEATURE: Add TS|TSX|JSX files count to Javascripts](https://github.com/fastruby/rails_stats/pull/42)
12
+
13
+ # v2.0.1 ([commits](https://github.com/fastruby/rails_stats/compare/v2.0.0...v2.0.1))
14
+
15
+ * [BUGFIX: Remove conditional byebug](https://github.com/fastruby/rails_stats/pull/29)
4
16
 
5
17
  # v2.0.0 ([commits](https://github.com/fastruby/rails_stats/compare/v1.0.2...v2.0.0))
6
18
 
@@ -18,4 +30,4 @@
18
30
  # v1.0.1 / 2018-10-8
19
31
 
20
32
  * [FEATURE: add more aggregate stats](https://github.com/fastruby/rails_stats/pull/5)
21
- * [FEATURE: More detailed introspection of app](https://github.com/fastruby/rails_stats/pull/1)
33
+ * [FEATURE: More detailed introspection of app](https://github.com/fastruby/rails_stats/pull/1)
data/Gemfile CHANGED
@@ -5,10 +5,10 @@ gemspec
5
5
  group :development, :test do
6
6
  gem "bundler", ">= 1.6", "< 3.0"
7
7
  gem "byebug"
8
- gem "codecov"
8
+ gem "codecov", "~> 0.6.0"
9
9
  gem "minitest"
10
10
  gem "minitest-around"
11
11
  gem "minitest-spec-context"
12
- gem "simplecov"
12
+ gem "simplecov", "~> 0.21"
13
13
  gem "simplecov-console"
14
14
  end
data/README.md CHANGED
@@ -23,26 +23,46 @@ $ rake stats\[/path/to/app/\]
23
23
 
24
24
  Directory: /path/to/app/
25
25
 
26
- +----------------------+-------+-------+---------+---------+-----+-------+
27
- | Name | Lines | LOC | Classes | Methods | M/C | LOC/M |
28
- +----------------------+-------+-------+---------+---------+-----+-------+
29
- | Controllers | 1848 | 1483 | 32 | 174 | 5 | 6 |
30
- | Helpers | 2257 | 1892 | 45 | 245 | 5 | 5 |
31
- | Jobs | 399 | 295 | 11 | 33 | 3 | 6 |
32
- | Models | 4584 | 3509 | 61 | 526 | 8 | 4 |
33
- | Observers | 42 | 22 | 2 | 5 | 2 | 2 |
34
- | Libraries | 2987 | 2272 | 30 | 287 | 9 | 5 |
35
- | Configuration | 1233 | 669 | 4 | 17 | 4 | 37 |
36
- | Spec Support | 1416 | 1152 | 4 | 30 | 7 | 36 |
37
- | Integration Tests | 91 | 73 | 0 | 1 | 0 | 71 |
38
- | Lib Tests | 101 | 83 | 0 | 1 | 0 | 81 |
39
- | Model Tests | 3397 | 2522 | 0 | 18 | 0 | 138 |
40
- | Cucumber Support | 739 | 521 | 0 | 1 | 0 | 519 |
41
- | Cucumber Features | 2711 | 2487 | 29 | 145 | 5 | 15 |
42
- +----------------------+-------+-------+---------+---------+-----+-------+
43
- | Total | 21805 | 16980 | 218 | 1483 | 6 | 9 |
44
- +----------------------+-------+-------+---------+---------+-----+-------+
45
- Code LOC: 10142 Test LOC: 6838 Code to Test Ratio: 1:0.7
26
+ +-----------------------|------------|----------------+
27
+ | Name | Total Deps | 1st Level Deps |
28
+ +-----------------------|------------|----------------+
29
+ | simplecov-console | 7 | 3 |
30
+ | codecov | 5 | 2 |
31
+ | rails_stats | 4 | 2 |
32
+ | simplecov | 3 | 3 |
33
+ | minitest-around | 1 | 1 |
34
+ | bundler | 0 | 0 |
35
+ | byebug | 0 | 0 |
36
+ | minitest | 0 | 0 |
37
+ | minitest-spec-context | 0 | 0 |
38
+ +-----------------------|------------|----------------+
39
+
40
+ Declared Gems 9
41
+ Total Gems 18
42
+ Unpinned Versions 8
43
+ Github Refs 0
44
+
45
+ +----------------------+---------+---------+---------+---------+---------+-----+-------+
46
+ | Name | Files | Lines | LOC | Classes | Methods | M/C | LOC/M |
47
+ +----------------------+---------+---------+---------+---------+---------+-----+-------+
48
+ | Channels | 2 | 8 | 8 | 2 | 0 | 0 | 0 |
49
+ | Configuration | 19 | 417 | 111 | 1 | 0 | 0 | 0 |
50
+ | Controllers | 1 | 7 | 6 | 1 | 1 | 1 | 4 |
51
+ | Helpers | 1 | 3 | 3 | 0 | 0 | 0 | 0 |
52
+ | Javascripts | 3 | 27 | 7 | 0 | 0 | 0 | 0 |
53
+ | Jobs | 1 | 7 | 2 | 1 | 0 | 0 | 0 |
54
+ | Libraries | 1 | 1 | 1 | 0 | 0 | 0 | 0 |
55
+ | Mailers | 1 | 4 | 4 | 1 | 0 | 0 | 0 |
56
+ | Model Tests | 2 | 5 | 4 | 2 | 0 | 0 | 0 |
57
+ | Models | 1 | 3 | 3 | 1 | 0 | 0 | 0 |
58
+ | Spec Support | 1 | 1 | 1 | 0 | 0 | 0 | 0 |
59
+ | Test Support | 1 | 1 | 1 | 0 | 0 | 0 | 0 |
60
+ +----------------------+---------+---------+---------+---------+---------+-----+-------+
61
+ | Code | 30 | 477 | 145 | 7 | 1 | 0 | 143 |
62
+ | Tests | 4 | 7 | 6 | 2 | 0 | 0 | 0 |
63
+ | Total | 34 | 484 | 151 | 9 | 1 | 0 | 149 |
64
+ +----------------------+---------+---------+---------+---------+---------+-----+-------+
65
+ Code LOC: 145 Test LOC: 6 Code to Test Ratio: 1:0.0 Files: 34
46
66
  ```
47
67
 
48
68
  ### Run it on many Rails engines
@@ -80,193 +100,88 @@ RailsStats adds more coverage than the default.
80
100
  Here are some open source Rails projects and their output.
81
101
 
82
102
  ```bash
83
- $ bundle exec rake stats[/users/brian/examples/diaspora/]
84
-
85
- Directory: /users/brian/examples/diaspora
86
-
87
- +----------------------+-------+-------+---------+---------+-----+-------+
88
- | Name | Lines | LOC | Classes | Methods | M/C | LOC/M |
89
- +----------------------+-------+-------+---------+---------+-----+-------+
90
- | Collections | 259 | 198 | 0 | 56 | 0 | 1 |
91
- | Helpers | 1863 | 1478 | 0 | 218 | 0 | 4 |
92
- | Models | 4694 | 3517 | 55 | 580 | 10 | 4 |
93
- | Pages | 201 | 158 | 0 | 21 | 0 | 5 |
94
- | Controllers | 2797 | 2168 | 40 | 208 | 5 | 8 |
95
- | Mailers | 313 | 263 | 13 | 32 | 2 | 6 |
96
- | Presenters | 516 | 425 | 18 | 71 | 3 | 3 |
97
- | Uploaders | 84 | 63 | 2 | 9 | 4 | 5 |
98
- | Workers | 600 | 399 | 32 | 33 | 1 | 10 |
99
- | Javascripts | 7550 | 4941 | 0 | 741 | 0 | 4 |
100
- | Libraries | 7031 | 4890 | 69 | 701 | 10 | 4 |
101
- | Configuration | 2556 | 833 | 5 | 10 | 2 | 81 |
102
- | Controller Tests | 4628 | 3775 | 0 | 2 | 0 | 1885 |
103
- | Spec Support | 1141 | 900 | 6 | 56 | 9 | 14 |
104
- | Helper Tests | 771 | 615 | 0 | 6 | 0 | 100 |
105
- | Integration Tests | 891 | 647 | 0 | 14 | 0 | 44 |
106
- | Lib Tests | 4076 | 3259 | 2 | 4 | 2 | 812 |
107
- | Other Tests | 120 | 101 | 0 | 0 | 0 | 0 |
108
- | Mailer Tests | 412 | 328 | 0 | 0 | 0 | 0 |
109
- | Model Tests | 6120 | 4964 | 0 | 1 | 0 | 4962 |
110
- | Presenter Tests | 353 | 303 | 0 | 0 | 0 | 0 |
111
- | Worker Tests | 821 | 648 | 0 | 0 | 0 | 0 |
112
- | Cucumber Features | 2157 | 1863 | 47 | 155 | 3 | 10 |
113
- +----------------------+-------+-------+---------+---------+-----+-------+
114
- | Total | 49954 | 36736 | 289 | 2918 | 10 | 10 |
115
- +----------------------+-------+-------+---------+---------+-----+-------+
116
- Code LOC: 19333 Test LOC: 17403 Code to Test Ratio: 1:0.9
117
-
118
-
119
- $ bundle exec rake stats[/users/brian/examples/discourse]
120
-
121
- Directory: /users/brian/examples/discourse
122
-
123
- +----------------------+-------+-------+---------+---------+-----+-------+
124
- | Name | Lines | LOC | Classes | Methods | M/C | LOC/M |
125
- +----------------------+-------+-------+---------+---------+-----+-------+
126
- | Controllers | 5005 | 3812 | 56 | 416 | 7 | 7 |
127
- | Helpers | 286 | 218 | 0 | 32 | 0 | 4 |
128
- | Jobs | 1830 | 1343 | 53 | 114 | 2 | 9 |
129
- | Mailers | 438 | 340 | 7 | 24 | 3 | 12 |
130
- | Models | 12378 | 8393 | 123 | 983 | 7 | 6 |
131
- | Serializers | 2809 | 2223 | 73 | 374 | 5 | 3 |
132
- | Services | 1353 | 1060 | 20 | 106 | 5 | 8 |
133
- | Javascripts | 21722 | 13649 | 0 | 1844 | 0 | 5 |
134
- | Libraries | 35298 | 27521 | 189 | 2565 | 13 | 8 |
135
- | Configuration | 1758 | 1179 | 6 | 12 | 2 | 96 |
136
- | Other Tests | 12998 | 9830 | 20 | 41 | 2 | 237 |
137
- | Controller Tests | 7673 | 5911 | 0 | 4 | 0 | 1475 |
138
- | Spec Support | 707 | 560 | 1 | 16 | 16 | 33 |
139
- | Helper Tests | 88 | 71 | 0 | 0 | 0 | 0 |
140
- | Integration Tests | 307 | 235 | 0 | 1 | 0 | 233 |
141
- | Job Tests | 1343 | 1017 | 3 | 9 | 3 | 111 |
142
- | Mailer Tests | 421 | 302 | 0 | 1 | 0 | 300 |
143
- | Model Tests | 11236 | 8599 | 2 | 49 | 24 | 173 |
144
- | Serializer Tests | 297 | 236 | 0 | 2 | 0 | 116 |
145
- | Service Tests | 1767 | 1406 | 0 | 2 | 0 | 701 |
146
- +----------------------+-------+-------+---------+---------+-----+-------+
147
- | Total | 119714| 87905 | 553 | 6595 | 11 | 11 |
148
- +----------------------+-------+-------+---------+---------+-----+-------+
149
- Code LOC: 59738 Test LOC: 28167 Code to Test Ratio: 1:0.5
150
-
151
-
152
- $ bundle exec rake stats[/users/brian/examples/gitlabhq]
153
-
154
- Directory: /users/brian/examples/gitlabhq
155
-
156
- +----------------------+-------+-------+---------+---------+-----+-------+
157
- | Name | Lines | LOC | Classes | Methods | M/C | LOC/M |
158
- +----------------------+-------+-------+---------+---------+-----+-------+
159
- | Controllers | 3690 | 2890 | 66 | 384 | 5 | 5 |
160
- | Finders | 428 | 267 | 8 | 27 | 3 | 7 |
161
- | Helpers | 2280 | 1761 | 0 | 222 | 0 | 5 |
162
- | Mailers | 382 | 275 | 1 | 29 | 29 | 7 |
163
- | Models | 6922 | 4680 | 58 | 714 | 12 | 4 |
164
- | Services | 2021 | 1502 | 51 | 149 | 2 | 8 |
165
- | Uploaders | 81 | 62 | 2 | 14 | 7 | 2 |
166
- | Workers | 128 | 99 | 6 | 8 | 1 | 10 |
167
- | Javascripts | 3843 | 2936 | 1 | 534 | 534 | 3 |
168
- | Libraries | 7246 | 4785 | 120 | 438 | 3 | 8 |
169
- | Configuration | 1421 | 782 | 4 | 11 | 2 | 69 |
170
- | Controller Tests | 428 | 334 | 0 | 0 | 0 | 0 |
171
- | Spec Support | 1119 | 715 | 2 | 27 | 13 | 24 |
172
- | Other Tests | 67 | 55 | 0 | 0 | 0 | 0 |
173
- | Feature Tests | 2209 | 1765 | 0 | 8 | 0 | 218 |
174
- | Finder Tests | 281 | 230 | 0 | 0 | 0 | 0 |
175
- | Helper Tests | 1608 | 1255 | 0 | 5 | 0 | 249 |
176
- | Lib Tests | 1459 | 1180 | 1 | 11 | 11 | 105 |
177
- | Mailer Tests | 630 | 478 | 0 | 0 | 0 | 0 |
178
- | Model Tests | 3856 | 2669 | 0 | 10 | 0 | 264 |
179
- | Request Tests | 4229 | 3600 | 0 | 10 | 0 | 358 |
180
- | Routing Tests | 849 | 520 | 0 | 0 | 0 | 0 |
181
- | Service Tests | 1611 | 1307 | 0 | 34 | 0 | 36 |
182
- | Worker Tests | 45 | 35 | 0 | 2 | 0 | 15 |
183
- | Cucumber Features | 6749 | 5734 | 141 | 947 | 6 | 4 |
184
- | Cucumber Support | 6235 | 4980 | 65 | 71 | 1 | 68 |
185
- +----------------------+-------+-------+---------+---------+-----+-------+
186
- | Total | 59817 | 44896 | 526 | 3655 | 6 | 10 |
187
- +----------------------+-------+-------+---------+---------+-----+-------+
188
- Code LOC: 20039 Test LOC: 24857 Code to Test Ratio: 1:1.2
189
-
190
103
 
191
104
  $ bundle exec rake stats[/users/brian/examples/redmine/]
192
105
 
193
- Directory: /users/brian/examples/redmine
194
-
195
- +----------------------+-------+-------+---------+---------+-----+-------+
196
- | Name | Lines | LOC | Classes | Methods | M/C | LOC/M |
197
- +----------------------+-------+-------+---------+---------+-----+-------+
198
- | Controllers | 6738 | 5005 | 51 | 416 | 8 | 10 |
199
- | Helpers | 4445 | 3014 | 2 | 281 | 140 | 8 |
200
- | Models | 13221 | 9369 | 86 | 1026 | 11 | 7 |
201
- | Libraries | 19041 | 13499 | 137 | 1147 | 8 | 9 |
202
- | Configuration | 779 | 550 | 14 | 18 | 1 | 28 |
203
- | Integration Tests | 8286 | 6032 | 92 | 202 | 2 | 27 |
204
- | Other Tests | 669 | 521 | 3 | 53 | 17 | 7 |
205
- | Test Support | 1102 | 791 | 8 | 70 | 8 | 9 |
206
- | Functional Tests | 18448 | 14784 | 61 | 1372 | 22 | 8 |
207
- | Unit Tests | 23680 | 18217 | 117 | 1783 | 15 | 8 |
208
- | Helper Tests | 3321 | 2567 | 16 | 171 | 10 | 13 |
209
- +----------------------+-------+-------+---------+---------+-----+-------+
210
- | Total | 99730 | 74349 | 587 | 6539 | 11 | 9 |
211
- +----------------------+-------+-------+---------+---------+-----+-------+
212
- Code LOC: 31437 Test LOC: 42912 Code to Test Ratio: 1:1.4
213
-
214
-
215
- $ bundle exec rake stats[/users/brian/examples/refinerycms]
216
-
217
- Directory: /users/brian/examples/refinerycms
218
-
219
- +----------------------+-------+-------+---------+---------+-----+-------+
220
- | Name | Lines | LOC | Classes | Methods | M/C | LOC/M |
221
- +----------------------+-------+-------+---------+---------+-----+-------+
222
- | Controllers | 950 | 748 | 17 | 83 | 4 | 7 |
223
- | Helpers | 399 | 308 | 0 | 28 | 0 | 9 |
224
- | Mailers | 22 | 18 | 1 | 2 | 2 | 7 |
225
- | Models | 846 | 570 | 14 | 86 | 6 | 4 |
226
- | Presenters | 365 | 271 | 8 | 44 | 5 | 4 |
227
- | Javascripts | 717 | 531 | 0 | 52 | 0 | 8 |
228
- | Libraries | 4 | 4 | 0 | 0 | 0 | 0 |
229
- | Gems | 4166 | 2997 | 44 | 372 | 8 | 6 |
230
- | Controller Tests | 207 | 170 | 1 | 1 | 1 | 168 |
231
- | Spec Support | 309 | 243 | 2 | 6 | 3 | 38 |
232
- | Feature Tests | 1907 | 1484 | 0 | 4 | 0 | 369 |
233
- | Lib Tests | 1952 | 1687 | 6 | 4 | 0 | 419 |
234
- | Model Tests | 1323 | 1072 | 0 | 5 | 0 | 212 |
235
- | Helper Tests | 324 | 264 | 0 | 1 | 0 | 262 |
236
- | Presenter Tests | 355 | 299 | 0 | 0 | 0 | 0 |
237
- +----------------------+-------+-------+---------+---------+-----+-------+
238
- | Total | 13846 | 10666 | 93 | 688 | 7 | 13 |
239
- +----------------------+-------+-------+---------+---------+-----+-------+
240
- Code LOC: 5447 Test LOC: 5219 Code to Test Ratio: 1:1.0
241
-
242
-
243
- $ bundle exec rake stats[/users/brian/examples/spree]
244
-
245
- Directory: /users/brian/examples/spree
246
-
247
- +----------------------+-------+-------+---------+---------+-----+-------+
248
- | Name | Lines | LOC | Classes | Methods | M/C | LOC/M |
249
- +----------------------+-------+-------+---------+---------+-----+-------+
250
- | Controllers | 4653 | 3800 | 86 | 492 | 5 | 5 |
251
- | Helpers | 1142 | 949 | 0 | 90 | 0 | 8 |
252
- | Models | 9893 | 7308 | 167 | 973 | 5 | 5 |
253
- | Javascripts | 2770 | 2100 | 9 | 416 | 46 | 3 |
254
- | Mailers | 63 | 58 | 5 | 8 | 1 | 5 |
255
- | Libraries | 15 | 14 | 0 | 0 | 0 | 0 |
256
- | Gems | 4690 | 3641 | 35 | 254 | 7 | 12 |
257
- | Controller Tests | 7344 | 6000 | 6 | 19 | 3 | 313 |
258
- | Model Tests | 16747 | 13452 | 20 | 27 | 1 | 496 |
259
- | Request Tests | 32 | 24 | 0 | 0 | 0 | 0 |
260
- | Spec Support | 577 | 427 | 3 | 9 | 3 | 45 |
261
- | Feature Tests | 6079 | 4809 | 0 | 17 | 0 | 280 |
262
- | Helper Tests | 602 | 470 | 2 | 1 | 0 | 468 |
263
- | Lib Tests | 1455 | 1216 | 8 | 11 | 1 | 108 |
264
- | Mailer Tests | 252 | 208 | 0 | 0 | 0 | 0 |
265
- | Other Tests | 33 | 27 | 0 | 0 | 0 | 0 |
266
- +----------------------+-------+-------+---------+---------+-----+-------+
267
- | Total | 56347 | 44503 | 341 | 2317 | 6 | 17 |
268
- +----------------------+-------+-------+---------+---------+-----+-------+
269
- Code LOC: 17870 Test LOC: 26633 Code to Test Ratio: 1:1.5
106
+ +-----------------------|------------|----------------+
107
+ | Name | Total Deps | 1st Level Deps |
108
+ +-----------------------|------------|----------------+
109
+ | rails | 62 | 13 |
110
+ | roadie-rails | 45 | 2 |
111
+ | actionpack-xml_parser | 41 | 2 |
112
+ | importmap-rails | 41 | 3 |
113
+ | propshaft | 41 | 4 |
114
+ | stimulus-rails | 41 | 1 |
115
+ | rubocop-rails | 28 | 5 |
116
+ | rubocop-performance | 15 | 3 |
117
+ | html-pipeline | 14 | 2 |
118
+ | rails-dom-testing | 14 | 3 |
119
+ | rubocop | 14 | 10 |
120
+ | bullet | 13 | 2 |
121
+ | capybara | 10 | 8 |
122
+ | debug | 10 | 2 |
123
+ | mail | 7 | 4 |
124
+ | selenium-webdriver | 5 | 5 |
125
+ | rails_stats | 4 | 2 |
126
+ | svg_sprite | 4 | 3 |
127
+ | bundle-audit | 3 | 1 |
128
+ | listen | 3 | 2 |
129
+ | net-imap | 3 | 2 |
130
+ | sanitize | 3 | 2 |
131
+ | simplecov | 3 | 3 |
132
+ | mini_magick | 2 | 2 |
133
+ | net-pop | 2 | 1 |
134
+ | net-smtp | 2 | 1 |
135
+ | rbpdf | 2 | 2 |
136
+ | rqrcode | 2 | 2 |
137
+ | addressable | 1 | 1 |
138
+ | i18n | 1 | 1 |
139
+ | mocha | 1 | 1 |
140
+ | nokogiri | 1 | 1 |
141
+ | puma | 1 | 1 |
142
+ | commonmarker | 0 | 0 |
143
+ | csv | 0 | 0 |
144
+ | ffi | 0 | 0 |
145
+ | marcel | 0 | 0 |
146
+ | mini_mime | 0 | 0 |
147
+ | net-ldap | 0 | 0 |
148
+ | rack | 0 | 0 |
149
+ | rotp | 0 | 0 |
150
+ | rouge | 0 | 0 |
151
+ | rubyzip | 0 | 0 |
152
+ | tzinfo-data | 0 | 0 |
153
+ | yard | 0 | 0 |
154
+ +-----------------------|------------|----------------+
155
+
156
+ Declared Gems 45
157
+ Total Gems 144
158
+ Unpinned Versions 19
159
+ Github Refs 0
160
+
161
+ +----------------------+---------+---------+---------+---------+---------+-----+-------+
162
+ | Name | Files | Lines | LOC | Classes | Methods | M/C | LOC/M |
163
+ +----------------------+---------+---------+---------+---------+---------+-----+-------+
164
+ | Configuration | 17 | 1090 | 666 | 7 | 14 | 2 | 45 |
165
+ | Controllers | 57 | 9042 | 6746 | 60 | 554 | 9 | 10 |
166
+ | Functional Tests | 65 | 35754 | 30234 | 65 | 2104 | 32 | 12 |
167
+ | Helper Tests | 27 | 5369 | 4090 | 28 | 302 | 10 | 11 |
168
+ | Helpers | 49 | 7068 | 5168 | 1 | 413 | 413 | 10 |
169
+ | Integration Tests | 98 | 10349 | 7237 | 104 | 297 | 2 | 22 |
170
+ | Javascripts | 117 | 6930 | 5362 | 0 | 446 | 0 | 10 |
171
+ | Job Tests | 2 | 142 | 94 | 2 | 2 | 1 | 45 |
172
+ | Jobs | 3 | 115 | 90 | 3 | 9 | 3 | 8 |
173
+ | Libraries | 134 | 18922 | 13178 | 128 | 1167 | 9 | 9 |
174
+ | Models | 88 | 20110 | 14528 | 110 | 1532 | 13 | 7 |
175
+ | Other Tests | 19 | 2339 | 1525 | 19 | 98 | 5 | 13 |
176
+ | Test Support | 16 | 1637 | 1229 | 20 | 142 | 7 | 6 |
177
+ | Unit Tests | 147 | 37173 | 28642 | 161 | 2778 | 17 | 8 |
178
+ | Validators | 1 | 29 | 10 | 1 | 1 | 1 | 8 |
179
+ +----------------------+---------+---------+---------+---------+---------+-----+-------+
180
+ | Code | 466 | 63306 | 45748 | 310 | 4136 | 13 | 9 |
181
+ | Tests | 374 | 92763 | 73051 | 399 | 5723 | 14 | 10 |
182
+ | Total | 840 | 156069 | 118799 | 709 | 9859 | 13 | 10 |
183
+ +----------------------+---------+---------+---------+---------+---------+-----+-------+
184
+ Code LOC: 45748 Test LOC: 73051 Code to Test Ratio: 1:1.6 Files: 840
270
185
 
271
186
  ```
272
187
 
@@ -277,9 +192,9 @@ If you want to export the details using JSON, you can use this command:
277
192
  ```
278
193
  $ rake stats\[test/dummy,json\]
279
194
 
280
- Directory: /Users/etagwerker/Projects/fastruby/rails_stats/test/dummy
195
+ Directory: /Users/etagwerker/Projects/redmine
281
196
 
282
- [{"name":"Mailers","lines":"4","loc":"4","classes":"1","methods":"0","m_over_c":"0","loc_over_m":"0"},{"name":"Models","lines":"3","loc":"3","classes":"1","methods":"0","m_over_c":"0","loc_over_m":"0"},{"name":"Javascripts","lines":"27","loc":"7","classes":"0","methods":"0","m_over_c":"0","loc_over_m":"0"},{"name":"Jobs","lines":"7","loc":"2","classes":"1","methods":"0","m_over_c":"0","loc_over_m":"0"},{"name":"Controllers","lines":"7","loc":"6","classes":"1","methods":"1","m_over_c":"1","loc_over_m":"4"},{"name":"Helpers","lines":"3","loc":"3","classes":"0","methods":"0","m_over_c":"0","loc_over_m":"0"},{"name":"Channels","lines":"8","loc":"8","classes":"2","methods":"0","m_over_c":"0","loc_over_m":"0"},{"name":"Configuration","lines":"417","loc":"111","classes":"1","methods":"0","m_over_c":"0","loc_over_m":"0"},{"name":"Total","lines":"476","loc":"144","classes":"7","methods":"1","m_over_c":"0","loc_over_m":"142","code_to_test_ratio":"0.0","total":true}]
197
+ [{"summary":{"declared":45,"unpinned":19,"total":144,"github":0},"gems":[{"name":"rails","total_dependencies":62,"first_level_dependencies":13,"top_level_dependencies":{},"transitive_dependencies":["actioncable (= 7.2.2.1)","actionmailbox (= 7.2.2.1)","actionmailer (= 7.2.2.1)","actionpack (= 7.2.2.1)","actiontext (= 7.2.2.1)","actionview (= 7.2.2.1)","activejob (= 7.2.2.1)","activemodel (= 7.2.2.1)","activerecord (= 7.2.2.1)","activestorage (= 7.2.2.1)","activesupport (= 7.2.2.1)","bundler (>= 1.15.0)","railties (= 7.2.2.1)","nio4r (~> 2.0)","websocket-driver (>= 0.6.1)","zeitwerk (~> 2.6)","nokogiri (>= 1.8.5)","racc (>= 0)","rack (>= 2.2.4, < 3.2)","rack-session (>= 1.0.1)","rack-test (>= 0.6.3)","rails-dom-testing (~> 2.2)","rails-html-sanitizer (~> 1.6)","useragent (~> 0.16)","builder (~> 3.1)","erubi (~> 1.11)","base64 (>= 0)","benchmark (>= 0.3)","bigdecimal (>= 0)","concurrent-ruby (~> 1.0, >= 1.3.1)","connection_pool (>= 2.2.5)","drb (>= 0)","i18n (>= 1.6, < 2)","logger (>= 1.4.2)","minitest (>= 5.1)","securerandom (>= 0.3)","tzinfo (~> 2.0, >= 2.0.5)","loofah (~> 2.21)","crass (~> 1.0.2)","websocket-extensions (>= 0.1.0)","mail (>= 2.8.0)","globalid (>= 0.3.6)","timeout (>= 0.4.0)","marcel (~> 1.0)","mini_mime (>= 0.1.1)","net-imap (>= 0)","net-pop (>= 0)","net-smtp (>= 0)","date (>= 0)","net-protocol (>= 0)","irb (~> 1.13)","rackup (>= 1.0.0)","rake (>= 12.2)","thor (~> 1.0, >= 1.2.2)","pp (>= 0.6.0)","rdoc (>= 4.0.0)","reline (>= 0.4.2)","prettyprint (>= 0)","erb (>= 0)","psych (>= 4.0.0)","stringio (>= 0)","io-console (~> 0.5)"]},{"name":"roadie-rails","total_dependencies":45,"first_level_dependencies":2,"top_level_dependencies":{},"transitive_dependencies":["railties (>= 5.1, < 8.1)","roadie (~> 5.0)","actionpack (= 7.2.2.1)","activesupport (= 7.2.2.1)","irb (~> 1.13)","rackup (>= 1.0.0)","rake (>= 12.2)","thor (~> 1.0, >= 1.2.2)","zeitwerk (~> 2.6)","actionview (= 7.2.2.1)","nokogiri (>= 1.8.5)","racc (>= 0)","rack (>= 2.2.4, < 3.2)","rack-session (>= 1.0.1)","rack-test (>= 0.6.3)","rails-dom-testing (~> 2.2)","rails-html-sanitizer (~> 1.6)","useragent (~> 0.16)","builder (~> 3.1)","erubi (~> 1.11)","base64 (>= 0)","benchmark (>= 0.3)","bigdecimal (>= 0)","concurrent-ruby (~> 1.0, >= 1.3.1)","connection_pool (>= 2.2.5)","drb (>= 0)","i18n (>= 1.6, < 2)","logger (>= 1.4.2)","minitest (>= 5.1)","securerandom (>= 0.3)","tzinfo (~> 2.0, >= 2.0.5)","loofah (~> 2.21)","crass (~> 1.0.2)","pp (>= 0.6.0)","rdoc (>= 4.0.0)","reline (>= 0.4.2)","prettyprint (>= 0)","erb (>= 0)","psych (>= 4.0.0)","date (>= 0)","stringio (>= 0)","io-console (~> 0.5)","css_parser (~> 1.4)","addressable (>= 0)","public_suffix (>= 2.0.2, < 7.0)"]},{"name":"actionpack-xml_parser","total_dependencies":41,"first_level_dependencies":2,"top_level_dependencies":{},"transitive_dependencies":["actionpack (>= 5.0)","railties (>= 5.0)","actionview (= 7.2.2.1)","activesupport (= 7.2.2.1)","nokogiri (>= 1.8.5)","racc (>= 0)","rack (>= 2.2.4, < 3.2)","rack-session (>= 1.0.1)","rack-test (>= 0.6.3)","rails-dom-testing (~> 2.2)","rails-html-sanitizer (~> 1.6)","useragent (~> 0.16)","builder (~> 3.1)","erubi (~> 1.11)","base64 (>= 0)","benchmark (>= 0.3)","bigdecimal (>= 0)","concurrent-ruby (~> 1.0, >= 1.3.1)","connection_pool (>= 2.2.5)","drb (>= 0)","i18n (>= 1.6, < 2)","logger (>= 1.4.2)","minitest (>= 5.1)","securerandom (>= 0.3)","tzinfo (~> 2.0, >= 2.0.5)","loofah (~> 2.21)","crass (~> 1.0.2)","irb (~> 1.13)","rackup (>= 1.0.0)","rake (>= 12.2)","thor (~> 1.0, >= 1.2.2)","zeitwerk (~> 2.6)","pp (>= 0.6.0)","rdoc (>= 4.0.0)","reline (>= 0.4.2)","prettyprint (>= 0)","erb (>= 0)","psych (>= 4.0.0)","date (>= 0)","stringio (>= 0)","io-console (~> 0.5)"]},{"name":"importmap-rails","total_dependencies":41,"first_level_dependencies":3,"top_level_dependencies":{},"transitive_dependencies":["actionpack (>= 6.0.0)","activesupport (>= 6.0.0)","railties (>= 6.0.0)","actionview (= 7.2.2.1)","nokogiri (>= 1.8.5)","racc (>= 0)","rack (>= 2.2.4, < 3.2)","rack-session (>= 1.0.1)","rack-test (>= 0.6.3)","rails-dom-testing (~> 2.2)","rails-html-sanitizer (~> 1.6)","useragent (~> 0.16)","builder (~> 3.1)","erubi (~> 1.11)","base64 (>= 0)","benchmark (>= 0.3)","bigdecimal (>= 0)","concurrent-ruby (~> 1.0, >= 1.3.1)","connection_pool (>= 2.2.5)","drb (>= 0)","i18n (>= 1.6, < 2)","logger (>= 1.4.2)","minitest (>= 5.1)","securerandom (>= 0.3)","tzinfo (~> 2.0, >= 2.0.5)","loofah (~> 2.21)","crass (~> 1.0.2)","irb (~> 1.13)","rackup (>= 1.0.0)","rake (>= 12.2)","thor (~> 1.0, >= 1.2.2)","zeitwerk (~> 2.6)","pp (>= 0.6.0)","rdoc (>= 4.0.0)","reline (>= 0.4.2)","prettyprint (>= 0)","erb (>= 0)","psych (>= 4.0.0)","date (>= 0)","stringio (>= 0)","io-console (~> 0.5)"]},{"name":"propshaft","total_dependencies":41,"first_level_dependencies":4,"top_level_dependencies":{},"transitive_dependencies":["actionpack (>= 7.0.0)","activesupport (>= 7.0.0)","rack (>= 0)","railties (>= 7.0.0)","actionview (= 7.2.2.1)","nokogiri (>= 1.8.5)","racc (>= 0)","rack-session (>= 1.0.1)","rack-test (>= 0.6.3)","rails-dom-testing (~> 2.2)","rails-html-sanitizer (~> 1.6)","useragent (~> 0.16)","builder (~> 3.1)","erubi (~> 1.11)","base64 (>= 0)","benchmark (>= 0.3)","bigdecimal (>= 0)","concurrent-ruby (~> 1.0, >= 1.3.1)","connection_pool (>= 2.2.5)","drb (>= 0)","i18n (>= 1.6, < 2)","logger (>= 1.4.2)","minitest (>= 5.1)","securerandom (>= 0.3)","tzinfo (~> 2.0, >= 2.0.5)","loofah (~> 2.21)","crass (~> 1.0.2)","irb (~> 1.13)","rackup (>= 1.0.0)","rake (>= 12.2)","thor (~> 1.0, >= 1.2.2)","zeitwerk (~> 2.6)","pp (>= 0.6.0)","rdoc (>= 4.0.0)","reline (>= 0.4.2)","prettyprint (>= 0)","erb (>= 0)","psych (>= 4.0.0)","date (>= 0)","stringio (>= 0)","io-console (~> 0.5)"]},{"name":"stimulus-rails","total_dependencies":41,"first_level_dependencies":1,"top_level_dependencies":{},"transitive_dependencies":["railties (>= 6.0.0)","actionpack (= 7.2.2.1)","activesupport (= 7.2.2.1)","irb (~> 1.13)","rackup (>= 1.0.0)","rake (>= 12.2)","thor (~> 1.0, >= 1.2.2)","zeitwerk (~> 2.6)","actionview (= 7.2.2.1)","nokogiri (>= 1.8.5)","racc (>= 0)","rack (>= 2.2.4, < 3.2)","rack-session (>= 1.0.1)","rack-test (>= 0.6.3)","rails-dom-testing (~> 2.2)","rails-html-sanitizer (~> 1.6)","useragent (~> 0.16)","builder (~> 3.1)","erubi (~> 1.11)","base64 (>= 0)","benchmark (>= 0.3)","bigdecimal (>= 0)","concurrent-ruby (~> 1.0, >= 1.3.1)","connection_pool (>= 2.2.5)","drb (>= 0)","i18n (>= 1.6, < 2)","logger (>= 1.4.2)","minitest (>= 5.1)","securerandom (>= 0.3)","tzinfo (~> 2.0, >= 2.0.5)","loofah (~> 2.21)","crass (~> 1.0.2)","pp (>= 0.6.0)","rdoc (>= 4.0.0)","reline (>= 0.4.2)","prettyprint (>= 0)","erb (>= 0)","psych (>= 4.0.0)","date (>= 0)","stringio (>= 0)","io-console (~> 0.5)"]},{"name":"rubocop-rails","total_dependencies":28,"first_level_dependencies":5,"top_level_dependencies":{},"transitive_dependencies":["activesupport (>= 4.2.0)","lint_roller (~> 1.1)","rack (>= 1.1)","rubocop (>= 1.75.0, < 2.0)","rubocop-ast (>= 1.38.0, < 2.0)","base64 (>= 0)","benchmark (>= 0.3)","bigdecimal (>= 0)","concurrent-ruby (~> 1.0, >= 1.3.1)","connection_pool (>= 2.2.5)","drb (>= 0)","i18n (>= 1.6, < 2)","logger (>= 1.4.2)","minitest (>= 5.1)","securerandom (>= 0.3)","tzinfo (~> 2.0, >= 2.0.5)","json (~> 2.3)","language_server-protocol (~> 3.17.0.2)","parallel (~> 1.10)","parser (>= 3.3.0.2)","rainbow (>= 2.2.2, < 4.0)","regexp_parser (>= 2.9.3, < 3.0)","ruby-progressbar (~> 1.7)","unicode-display_width (>= 2.4.0, < 4.0)","ast (~> 2.4.1)","racc (>= 0)","prism (~> 1.4)","unicode-emoji (~> 4.0, >= 4.0.4)"]},{"name":"rubocop-performance","total_dependencies":15,"first_level_dependencies":3,"top_level_dependencies":{},"transitive_dependencies":["lint_roller (~> 1.1)","rubocop (>= 1.75.0, < 2.0)","rubocop-ast (>= 1.38.0, < 2.0)","json (~> 2.3)","language_server-protocol (~> 3.17.0.2)","parallel (~> 1.10)","parser (>= 3.3.0.2)","rainbow (>= 2.2.2, < 4.0)","regexp_parser (>= 2.9.3, < 3.0)","ruby-progressbar (~> 1.7)","unicode-display_width (>= 2.4.0, < 4.0)","ast (~> 2.4.1)","racc (>= 0)","prism (~> 1.4)","unicode-emoji (~> 4.0, >= 4.0.4)"]},{"name":"html-pipeline","total_dependencies":14,"first_level_dependencies":2,"top_level_dependencies":{},"transitive_dependencies":["activesupport (>= 2)","nokogiri (>= 1.4)","base64 (>= 0)","benchmark (>= 0.3)","bigdecimal (>= 0)","concurrent-ruby (~> 1.0, >= 1.3.1)","connection_pool (>= 2.2.5)","drb (>= 0)","i18n (>= 1.6, < 2)","logger (>= 1.4.2)","minitest (>= 5.1)","securerandom (>= 0.3)","tzinfo (~> 2.0, >= 2.0.5)","racc (~> 1.4)"]},{"name":"rails-dom-testing","total_dependencies":14,"first_level_dependencies":3,"top_level_dependencies":{"actioncable":"actioncable (7.2.2.1)","actionmailbox":"actionmailbox (7.2.2.1)","actionmailer":"actionmailer (7.2.2.1)","actionpack":"actionpack (7.2.2.1)","actionpack-xml_parser":"actionpack-xml_parser (2.0.1)","actiontext":"actiontext (7.2.2.1)","actionview":"actionview (7.2.2.1)","activestorage":"activestorage (7.2.2.1)","importmap-rails":"importmap-rails (2.1.0)","propshaft":"propshaft (1.1.0)","rails":"rails (7.2.2.1)","railties":"railties (7.2.2.1)","roadie-rails":"roadie-rails (3.3.0)","stimulus-rails":"stimulus-rails (1.3.4)"},"transitive_dependencies":["activesupport (>= 5.0.0)","minitest (>= 0)","nokogiri (>= 1.6)","base64 (>= 0)","benchmark (>= 0.3)","bigdecimal (>= 0)","concurrent-ruby (~> 1.0, >= 1.3.1)","connection_pool (>= 2.2.5)","drb (>= 0)","i18n (>= 1.6, < 2)","logger (>= 1.4.2)","securerandom (>= 0.3)","tzinfo (~> 2.0, >= 2.0.5)","racc (~> 1.4)"]},{"name":"rubocop","total_dependencies":14,"first_level_dependencies":10,"top_level_dependencies":{"rubocop-performance":"rubocop-performance (1.25.0)","rubocop-rails":"rubocop-rails (2.31.0)"},"transitive_dependencies":["json (~> 2.3)","language_server-protocol (~> 3.17.0.2)","lint_roller (~> 1.1.0)","parallel (~> 1.10)","parser (>= 3.3.0.2)","rainbow (>= 2.2.2, < 4.0)","regexp_parser (>= 2.9.3, < 3.0)","rubocop-ast (>= 1.44.0, < 2.0)","ruby-progressbar (~> 1.7)","unicode-display_width (>= 2.4.0, < 4.0)","ast (~> 2.4.1)","racc (>= 0)","prism (~> 1.4)","unicode-emoji (~> 4.0, >= 4.0.4)"]},{"name":"bullet","total_dependencies":13,"first_level_dependencies":2,"top_level_dependencies":{},"transitive_dependencies":["activesupport (>= 3.0.0)","uniform_notifier (~> 1.11)","base64 (>= 0)","benchmark (>= 0.3)","bigdecimal (>= 0)","concurrent-ruby (~> 1.0, >= 1.3.1)","connection_pool (>= 2.2.5)","drb (>= 0)","i18n (>= 1.6, < 2)","logger (>= 1.4.2)","minitest (>= 5.1)","securerandom (>= 0.3)","tzinfo (~> 2.0, >= 2.0.5)"]},{"name":"capybara","total_dependencies":10,"first_level_dependencies":8,"top_level_dependencies":{},"transitive_dependencies":["addressable (>= 0)","matrix (>= 0)","mini_mime (>= 0.1.3)","nokogiri (~> 1.11)","rack (>= 1.6.0)","rack-test (>= 0.6.3)","regexp_parser (>= 1.5, < 3.0)","xpath (~> 3.2)","public_suffix (>= 2.0.2, < 7.0)","racc (~> 1.4)"]},{"name":"debug","total_dependencies":10,"first_level_dependencies":2,"top_level_dependencies":{},"transitive_dependencies":["irb (~> 1.10)","reline (>= 0.3.8)","pp (>= 0.6.0)","rdoc (>= 4.0.0)","prettyprint (>= 0)","erb (>= 0)","psych (>= 4.0.0)","date (>= 0)","stringio (>= 0)","io-console (~> 0.5)"]},{"name":"mail","total_dependencies":7,"first_level_dependencies":4,"top_level_dependencies":{"actionmailbox":"actionmailbox (7.2.2.1)","actionmailer":"actionmailer (7.2.2.1)","rails":"rails (7.2.2.1)"},"transitive_dependencies":["mini_mime (>= 0.1.1)","net-imap (>= 0)","net-pop (>= 0)","net-smtp (>= 0)","date (>= 0)","net-protocol (>= 0)","timeout (>= 0)"]},{"name":"selenium-webdriver","total_dependencies":5,"first_level_dependencies":5,"top_level_dependencies":{},"transitive_dependencies":["base64 (~> 0.2)","logger (~> 1.4)","rexml (~> 3.2, >= 3.2.5)","rubyzip (>= 1.2.2, < 3.0)","websocket (~> 1.0)"]},{"name":"rails_stats","total_dependencies":4,"first_level_dependencies":2,"top_level_dependencies":{},"transitive_dependencies":["bundler-stats (>= 2.1)","rake (>= 0)","bundler (>= 1.9, < 3)","thor (>= 0.19.0, < 2.0)"]},{"name":"svg_sprite","total_dependencies":4,"first_level_dependencies":3,"top_level_dependencies":{},"transitive_dependencies":["nokogiri (>= 0)","svg_optimizer (>= 0)","thor (>= 0)","racc (~> 1.4)"]},{"name":"bundle-audit","total_dependencies":3,"first_level_dependencies":1,"top_level_dependencies":{},"transitive_dependencies":["bundler-audit (>= 0)","bundler (>= 1.2.0, < 3)","thor (~> 1.0)"]},{"name":"listen","total_dependencies":3,"first_level_dependencies":2,"top_level_dependencies":{},"transitive_dependencies":["rb-fsevent (~> 0.10, >= 0.10.3)","rb-inotify (~> 0.9, >= 0.9.10)","ffi (~> 1.0)"]},{"name":"net-imap","total_dependencies":3,"first_level_dependencies":2,"top_level_dependencies":{"actionmailbox":"actionmailbox (7.2.2.1)","actionmailer":"actionmailer (7.2.2.1)","mail":"mail (2.8.1)","rails":"rails (7.2.2.1)"},"transitive_dependencies":["date (>= 0)","net-protocol (>= 0)","timeout (>= 0)"]},{"name":"sanitize","total_dependencies":3,"first_level_dependencies":2,"top_level_dependencies":{},"transitive_dependencies":["crass (~> 1.0.2)","nokogiri (>= 1.12.0)","racc (~> 1.4)"]},{"name":"simplecov","total_dependencies":3,"first_level_dependencies":3,"top_level_dependencies":{},"transitive_dependencies":["docile (~> 1.1)","simplecov-html (~> 0.11)","simplecov_json_formatter (~> 0.1)"]},{"name":"mini_magick","total_dependencies":2,"first_level_dependencies":2,"top_level_dependencies":{},"transitive_dependencies":["benchmark (>= 0)","logger (>= 0)"]},{"name":"net-pop","total_dependencies":2,"first_level_dependencies":1,"top_level_dependencies":{"actionmailbox":"actionmailbox (7.2.2.1)","actionmailer":"actionmailer (7.2.2.1)","mail":"mail (2.8.1)","rails":"rails (7.2.2.1)"},"transitive_dependencies":["net-protocol (>= 0)","timeout (>= 0)"]},{"name":"net-smtp","total_dependencies":2,"first_level_dependencies":1,"top_level_dependencies":{"actionmailbox":"actionmailbox (7.2.2.1)","actionmailer":"actionmailer (7.2.2.1)","mail":"mail (2.8.1)","rails":"rails (7.2.2.1)"},"transitive_dependencies":["net-protocol (>= 0)","timeout (>= 0)"]},{"name":"rbpdf","total_dependencies":2,"first_level_dependencies":2,"top_level_dependencies":{},"transitive_dependencies":["htmlentities (>= 0)","rbpdf-font (~> 1.19.0)"]},{"name":"rqrcode","total_dependencies":2,"first_level_dependencies":2,"top_level_dependencies":{},"transitive_dependencies":["chunky_png (~> 1.0)","rqrcode_core (~> 2.0)"]},{"name":"addressable","total_dependencies":1,"first_level_dependencies":1,"top_level_dependencies":{"capybara":"capybara (3.40.0)","css_parser":"css_parser (1.21.1)","roadie":"roadie (5.2.1)","roadie-rails":"roadie-rails (3.3.0)"},"transitive_dependencies":["public_suffix (>= 2.0.2, < 7.0)"]},{"name":"i18n","total_dependencies":1,"first_level_dependencies":1,"top_level_dependencies":{"actioncable":"actioncable (7.2.2.1)","actionmailbox":"actionmailbox (7.2.2.1)","actionmailer":"actionmailer (7.2.2.1)","actionpack":"actionpack (7.2.2.1)","actionpack-xml_parser":"actionpack-xml_parser (2.0.1)","actiontext":"actiontext (7.2.2.1)","actionview":"actionview (7.2.2.1)","activejob":"activejob (7.2.2.1)","activemodel":"activemodel (7.2.2.1)","activerecord":"activerecord (7.2.2.1)","activestorage":"activestorage (7.2.2.1)","activesupport":"activesupport (7.2.2.1)","bullet":"bullet (8.0.7)","globalid":"globalid (1.2.1)","html-pipeline":"html-pipeline (2.13.2)","importmap-rails":"importmap-rails (2.1.0)","propshaft":"propshaft (1.1.0)","rails":"rails (7.2.2.1)","rails-dom-testing":"rails-dom-testing (2.2.0)","railties":"railties (7.2.2.1)","roadie-rails":"roadie-rails (3.3.0)","rubocop-rails":"rubocop-rails (2.31.0)","stimulus-rails":"stimulus-rails (1.3.4)"},"transitive_dependencies":["concurrent-ruby (~> 1.0)"]},{"name":"mocha","total_dependencies":1,"first_level_dependencies":1,"top_level_dependencies":{},"transitive_dependencies":["ruby2_keywords (>= 0.0.5)"]},{"name":"nokogiri","total_dependencies":1,"first_level_dependencies":1,"top_level_dependencies":{"actioncable":"actioncable (7.2.2.1)","actionmailbox":"actionmailbox (7.2.2.1)","actionmailer":"actionmailer (7.2.2.1)","actionpack":"actionpack (7.2.2.1)","actionpack-xml_parser":"actionpack-xml_parser (2.0.1)","actiontext":"actiontext (7.2.2.1)","actionview":"actionview (7.2.2.1)","activestorage":"activestorage (7.2.2.1)","capybara":"capybara (3.40.0)","html-pipeline":"html-pipeline (2.13.2)","importmap-rails":"importmap-rails (2.1.0)","loofah":"loofah (2.24.1)","propshaft":"propshaft (1.1.0)","rails":"rails (7.2.2.1)","rails-dom-testing":"rails-dom-testing (2.2.0)","rails-html-sanitizer":"rails-html-sanitizer (1.6.2)","railties":"railties (7.2.2.1)","roadie":"roadie (5.2.1)","roadie-rails":"roadie-rails (3.3.0)","sanitize":"sanitize (6.1.3)","stimulus-rails":"stimulus-rails (1.3.4)","svg_optimizer":"svg_optimizer (0.3.0)","svg_sprite":"svg_sprite (1.0.3)","xpath":"xpath (3.2.0)"},"transitive_dependencies":["racc (~> 1.4)"]},{"name":"puma","total_dependencies":1,"first_level_dependencies":1,"top_level_dependencies":{},"transitive_dependencies":["nio4r (~> 2.0)"]},{"name":"commonmarker","total_dependencies":0,"first_level_dependencies":0,"top_level_dependencies":{},"transitive_dependencies":[]},{"name":"csv","total_dependencies":0,"first_level_dependencies":0,"top_level_dependencies":{},"transitive_dependencies":[]},{"name":"ffi","total_dependencies":0,"first_level_dependencies":0,"top_level_dependencies":{"listen":"listen (3.9.0)","rb-inotify":"rb-inotify (0.11.1)"},"transitive_dependencies":[]},{"name":"marcel","total_dependencies":0,"first_level_dependencies":0,"top_level_dependencies":{"actionmailbox":"actionmailbox (7.2.2.1)","actiontext":"actiontext (7.2.2.1)","activestorage":"activestorage (7.2.2.1)","rails":"rails (7.2.2.1)"},"transitive_dependencies":[]},{"name":"mini_mime","total_dependencies":0,"first_level_dependencies":0,"top_level_dependencies":{"actionmailbox":"actionmailbox (7.2.2.1)","actionmailer":"actionmailer (7.2.2.1)","capybara":"capybara (3.40.0)","mail":"mail (2.8.1)","rails":"rails (7.2.2.1)"},"transitive_dependencies":[]},{"name":"net-ldap","total_dependencies":0,"first_level_dependencies":0,"top_level_dependencies":{},"transitive_dependencies":[]},{"name":"rack","total_dependencies":0,"first_level_dependencies":0,"top_level_dependencies":{"actioncable":"actioncable (7.2.2.1)","actionmailbox":"actionmailbox (7.2.2.1)","actionmailer":"actionmailer (7.2.2.1)","actionpack":"actionpack (7.2.2.1)","actionpack-xml_parser":"actionpack-xml_parser (2.0.1)","actiontext":"actiontext (7.2.2.1)","activestorage":"activestorage (7.2.2.1)","capybara":"capybara (3.40.0)","importmap-rails":"importmap-rails (2.1.0)","propshaft":"propshaft (1.1.0)","rack-session":"rack-session (2.1.1)","rack-test":"rack-test (2.2.0)","rackup":"rackup (2.2.1)","rails":"rails (7.2.2.1)","railties":"railties (7.2.2.1)","roadie-rails":"roadie-rails (3.3.0)","rubocop-rails":"rubocop-rails (2.31.0)","stimulus-rails":"stimulus-rails (1.3.4)"},"transitive_dependencies":[]},{"name":"rotp","total_dependencies":0,"first_level_dependencies":0,"top_level_dependencies":{},"transitive_dependencies":[]},{"name":"rouge","total_dependencies":0,"first_level_dependencies":0,"top_level_dependencies":{},"transitive_dependencies":[]},{"name":"rubyzip","total_dependencies":0,"first_level_dependencies":0,"top_level_dependencies":{"selenium-webdriver":"selenium-webdriver (4.32.0)"},"transitive_dependencies":[]},{"name":"tzinfo-data","total_dependencies":0,"first_level_dependencies":0,"top_level_dependencies":{},"transitive_dependencies":[]},{"name":"yard","total_dependencies":0,"first_level_dependencies":0,"top_level_dependencies":{},"transitive_dependencies":[]}]},{"name":"Models","files":"88","lines":"20110","loc":"14528","classes":"110","methods":"1532","m_over_c":"13","loc_over_m":"7"},{"name":"Validators","files":"1","lines":"29","loc":"10","classes":"1","methods":"1","m_over_c":"1","loc_over_m":"8"},{"name":"Javascripts","files":"117","lines":"6930","loc":"5362","classes":"0","methods":"446","m_over_c":"0","loc_over_m":"10"},{"name":"Jobs","files":"3","lines":"115","loc":"90","classes":"3","methods":"9","m_over_c":"3","loc_over_m":"8"},{"name":"Controllers","files":"57","lines":"9042","loc":"6746","classes":"60","methods":"554","m_over_c":"9","loc_over_m":"10"},{"name":"Helpers","files":"49","lines":"7068","loc":"5168","classes":"1","methods":"413","m_over_c":"413","loc_over_m":"10"},{"name":"Libraries","files":"134","lines":"18922","loc":"13178","classes":"128","methods":"1167","m_over_c":"9","loc_over_m":"9"},{"name":"Configuration","files":"17","lines":"1090","loc":"666","classes":"7","methods":"14","m_over_c":"2","loc_over_m":"45"},{"name":"Integration Tests","files":"98","lines":"10349","loc":"7237","classes":"104","methods":"297","m_over_c":"2","loc_over_m":"22"},{"name":"Test Support","files":"16","lines":"1637","loc":"1229","classes":"20","methods":"142","m_over_c":"7","loc_over_m":"6"},{"name":"Other Tests","files":"19","lines":"2339","loc":"1525","classes":"19","methods":"98","m_over_c":"5","loc_over_m":"13"},{"name":"Functional Tests","files":"65","lines":"35754","loc":"30234","classes":"65","methods":"2104","m_over_c":"32","loc_over_m":"12"},{"name":"Helper Tests","files":"27","lines":"5369","loc":"4090","classes":"28","methods":"302","m_over_c":"10","loc_over_m":"11"},{"name":"Unit Tests","files":"147","lines":"37173","loc":"28642","classes":"161","methods":"2778","m_over_c":"17","loc_over_m":"8"},{"name":"Job Tests","files":"2","lines":"142","loc":"94","classes":"2","methods":"2","m_over_c":"1","loc_over_m":"45"},{"name":"Code","files":"466","lines":"63306","loc":"45748","classes":"310","methods":"4136","m_over_c":"13","loc_over_m":"9","code_to_test_ratio":"1.6","total":true},{"name":"Tests","files":"374","lines":"92763","loc":"73051","classes":"399","methods":"5723","m_over_c":"14","loc_over_m":"10","code_to_test_ratio":"1.6","total":true},{"name":"Total","files":"840","lines":"156069","loc":"118799","classes":"709","methods":"9859","m_over_c":"13","loc_over_m":"10","code_to_test_ratio":"1.6","total":true}]
283
198
  ```
284
199
 
285
200
  ### Testing
@@ -287,15 +202,15 @@ Directory: /Users/etagwerker/Projects/fastruby/rails_stats/test/dummy
287
202
  In order to run the tests for this gem:
288
203
 
289
204
  ```bash
290
- bundle exec rake
205
+ bundle exec rake test
291
206
 
292
207
  # Running:
293
208
 
294
- .
209
+ ..
295
210
 
296
- Fabulous run in 0.013349s, 74.9120 runs/s, 74.9120 assertions/s.
211
+ Fabulous run in 0.097903s, 20.4284 runs/s, 142.9987 assertions/s.
297
212
 
298
- 1 runs, 1 assertions, 0 failures, 0 errors, 0 skips
213
+ 2 runs, 14 assertions, 0 failures, 0 errors, 0 skips
299
214
  ```
300
215
 
301
216
  ### TODO
@@ -18,6 +18,24 @@ module RailsStats
18
18
  end_block_comment: %r{\*/},
19
19
  method: /function(\s+[_a-zA-Z][\da-zA-Z]*)?\s*\(/,
20
20
  },
21
+ jsx: {
22
+ line_comment: %r{^\s*//},
23
+ begin_block_comment: %r{^\s*/\*},
24
+ end_block_comment: %r{\*/},
25
+ method: /^\s*function(\s+[_a-zA-Z][\da-zA-Z]*)?\s*\(/,
26
+ },
27
+ ts: {
28
+ line_comment: %r{^\s*//},
29
+ begin_block_comment: %r{^\s*/\*},
30
+ end_block_comment: %r{\*/},
31
+ method: /^\s*function(\s+[_a-zA-Z][\da-zA-Z]*)?\s*\(/,
32
+ },
33
+ tsx: {
34
+ line_comment: %r{^\s*//},
35
+ begin_block_comment: %r{^\s*/\*},
36
+ end_block_comment: %r{\*/},
37
+ method: /^\s*function(\s+[_a-zA-Z][\da-zA-Z]*)?\s*\(/,
38
+ },
21
39
  coffee: {
22
40
  line_comment: /^\s*#/,
23
41
  begin_block_comment: /^\s*###/,
@@ -3,7 +3,7 @@ require "bundler/stats/cli"
3
3
  module RailsStats
4
4
  class ConsoleFormatter < StatsFormatter
5
5
  def to_s
6
- Bundler::Stats::CLI.start
6
+ Bundler::Stats::CLI.start(['--format', 'text'])
7
7
 
8
8
  print_header
9
9
  sorted_keys = @statistics.keys.sort
@@ -18,6 +18,8 @@ module RailsStats
18
18
  end
19
19
 
20
20
  print_code_test_stats
21
+ print_polymorphic_stats
22
+ print_schema_stats
21
23
  end
22
24
 
23
25
  private
@@ -36,8 +38,6 @@ module RailsStats
36
38
  m_over_c = (statistics.methods / statistics.classes) rescue m_over_c = 0
37
39
  loc_over_m = (statistics.code_lines / statistics.methods) - 2 rescue loc_over_m = 0
38
40
 
39
- require 'byebug'; byebug if statistics.nil?
40
-
41
41
  puts "| #{name.ljust(20)} " \
42
42
  "| #{statistics.files_total.to_s.rjust(7)} " \
43
43
  "| #{statistics.lines.to_s.rjust(7)} " \
@@ -55,5 +55,19 @@ module RailsStats
55
55
  puts " Code LOC: #{code} Test LOC: #{tests} Code to Test Ratio: 1:#{sprintf("%.1f", tests.to_f/code)} Files: #{calculator.files_total}"
56
56
  puts ""
57
57
  end
58
+
59
+ def print_polymorphic_stats
60
+ puts " Polymorphic models count: #{calculator.polymorphic} polymorphic associations"
61
+ end
62
+
63
+ def print_schema_stats
64
+ if File.exist?(calculator.schema_path)
65
+ puts " Schema Stats: #{calculator.schema} `create_table` calls in schema.rb"
66
+ elsif File.exist?(calculator.structure_path)
67
+ puts " Schema Stats: #{calculator.schema} `CREATE TABLE` calls in structure.sql"
68
+ else
69
+ puts " Schema Stats: No schema.rb or structure.sql file found"
70
+ end
71
+ end
58
72
  end
59
- end
73
+ end
@@ -3,17 +3,28 @@ require "json"
3
3
  module RailsStats
4
4
  class JSONFormatter < StatsFormatter
5
5
  def result
6
- @result = @statistics.map { |key, stats| stat_hash(key, stats) }
6
+ @result = []
7
+ old_stdout = $stdout
8
+ $stdout = StringIO.new
9
+ Bundler::Stats::CLI.start(["-f", "json"])
10
+ bundler_stats_cli_json_result = $stdout.string
11
+ $stdout = old_stdout
7
12
 
8
- if @grand_total
9
- @result << stat_hash("Total", @grand_total).merge(code_test_hash)
10
- end
13
+ @result << JSON.parse(bundler_stats_cli_json_result) unless bundler_stats_cli_json_result.strip.empty?
14
+
15
+ @result += @statistics.map { |key, stats| stat_hash(key, stats) }
16
+ @result << stat_hash("Code", @code_total).merge(code_test_hash) if @code_total
17
+ @result << stat_hash("Tests", @tests_total).merge(code_test_hash) if @tests_total
18
+ @result << stat_hash("Total", @grand_total).merge(code_test_hash) if @grand_total
19
+
20
+ @result << { "schema_stats" => schema_info }
21
+ @result << { "polymorphic_stats" => print_polymorphic_stats }
11
22
 
12
23
  @result
13
24
  end
14
25
 
15
26
  def to_s
16
- puts result.to_json
27
+ puts JSON.generate(result, ascii_only: false)
17
28
  end
18
29
 
19
30
  private
@@ -42,5 +53,29 @@ module RailsStats
42
53
  "loc_over_m" => loc_over_m.to_s
43
54
  }
44
55
  end
56
+
57
+ def print_polymorphic_stats
58
+ if calculator.polymorphic
59
+ {
60
+ "polymorphic_models_count" => calculator.polymorphic,
61
+ }
62
+ end
63
+ end
64
+
65
+ def schema_info
66
+ if File.exist?(calculator.schema_path)
67
+ {
68
+ "schema_path" => calculator.schema_path,
69
+ "create_table calls count" => calculator.schema,
70
+ }
71
+ elsif File.exist?(calculator.structure_path)
72
+ {
73
+ "structure_path" => calculator.structure_path,
74
+ "create_table calls count" => calculator.schema
75
+ }
76
+ else
77
+ { "schema_stats" => "No schema.rb or structure.sql file found" }
78
+ end
79
+ end
45
80
  end
46
- end
81
+ end
@@ -9,15 +9,19 @@ module RailsStats
9
9
 
10
10
  def initialize(root_directory)
11
11
  @root_directory = root_directory
12
+ @schema_path = File.join(@root_directory, "db", "schema.rb")
13
+ @structure_path = File.join(@root_directory, "db", "structure.sql")
12
14
  @key_concepts = calculate_key_concepts
13
15
  @projects = calculate_projects
14
16
  @statistics = calculate_statistics
15
17
  @code_loc = calculate_code
16
18
  @test_loc = calculate_tests
19
+ @schema = calculate_create_table_calls
20
+ @polymorphic = calculate_polymorphic
17
21
  @files_total, @code_total, @tests_total, @grand_total = calculate_totals
18
22
  end
19
23
 
20
- attr_reader :code_loc, :code_total, :files_total, :grand_total, :statistics, :test_loc, :tests_total
24
+ attr_reader :code_loc, :code_total, :files_total, :grand_total, :statistics, :test_loc, :tests_total, :schema, :schema_path, :structure_path, :polymorphic
21
25
 
22
26
  private
23
27
 
@@ -46,7 +50,6 @@ module RailsStats
46
50
  out
47
51
  end
48
52
 
49
-
50
53
  def app_projects
51
54
  @app_projects ||= calculate_app_projects
52
55
  end
@@ -79,7 +82,6 @@ module RailsStats
79
82
  end
80
83
  end
81
84
 
82
-
83
85
  def calculate_root_projects
84
86
  [RootStatistics.new(@root_directory)]
85
87
  end
@@ -133,5 +135,35 @@ module RailsStats
133
135
  @statistics.each { |k, v| @test_loc += v.code_lines if v.test }
134
136
  @test_loc
135
137
  end
138
+
139
+ def calculate_create_table_calls
140
+ if @schema_path && File.exist?(@schema_path)
141
+ count_create_table_calls(schema_path, "create_table")
142
+ elsif @structure_path && File.exist?(@structure_path)
143
+ count_create_table_calls(structure_path, "CREATE TABLE")
144
+ else
145
+ 0
146
+ end
147
+ end
148
+
149
+ def count_create_table_calls(file_path, keyword)
150
+ create_table_count = 0
151
+ File.foreach(file_path) do |line|
152
+ create_table_count += 1 if line.strip.start_with?(keyword)
153
+ end
154
+ create_table_count
155
+ end
156
+
157
+ def calculate_polymorphic
158
+ polymorphic_count = 0
159
+ Dir.glob(File.join(@root_directory, "app", "models", "*.rb")).each do |file|
160
+ File.foreach(file) do |line|
161
+ if line =~ /belongs_to\s+:\w+,\s+polymorphic:\s+true/
162
+ polymorphic_count += 1
163
+ end
164
+ end
165
+ end
166
+ polymorphic_count
167
+ end
136
168
  end
137
169
  end
@@ -75,7 +75,7 @@ module RailsStats
75
75
  out
76
76
  end
77
77
 
78
- def calculate_directory_statistics(directory, pattern = /.*\.(rb|js|coffee|feature)$/)
78
+ def calculate_directory_statistics(directory, pattern = /.*\.(rb|js|jsx|ts|tsx|coffee|feature)$/)
79
79
  stats = CodeStatisticsCalculator.new
80
80
 
81
81
  Dir.foreach(directory) do |file_name|
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module RailsStats
4
- VERSION = "2.0.0"
4
+ VERSION = "2.1.0"
5
5
  end
@@ -0,0 +1 @@
1
+
File without changes
File without changes
@@ -0,0 +1,3 @@
1
+ class Comments < ApplicationRecord
2
+ belongs_to :commentable, polymorphic: true
3
+ end
@@ -0,0 +1,2 @@
1
+ class Pets < User
2
+ end
@@ -0,0 +1,2 @@
1
+ class Users < ApplicationRecord
2
+ end
@@ -0,0 +1,10 @@
1
+
2
+ ActiveRecord::Schema[7.0].define(version: 2023_04_25_154701) do
3
+ create_table "users", force: :cascade do |t|
4
+ t.string "email"
5
+ end
6
+ create_table "comments", force: :cascade do |t|
7
+ t.bigint :commentable_id
8
+ t.string :commentable_type
9
+ end
10
+ end
@@ -1,22 +1,3 @@
1
- +-----------------------|------------|----------------+
2
- | Name | Total Deps | 1st Level Deps |
3
- +-----------------------|------------|----------------+
4
- | simplecov-console | 7 | 3 |
5
- | codecov | 5 | 2 |
6
- | rails_stats | 4 | 2 |
7
- | simplecov | 3 | 3 |
8
- | minitest-around | 1 | 1 |
9
- | bundler | 0 | 0 |
10
- | byebug | 0 | 0 |
11
- | minitest | 0 | 0 |
12
- | minitest-spec-context | 0 | 0 |
13
- +-----------------------|------------|----------------+
14
-
15
- Declared Gems 9
16
- Total Gems 18
17
- Unpinned Versions 8
18
- Github Refs 0
19
-
20
1
  +----------------------+---------+---------+---------+---------+---------+-----+-------+
21
2
  | Name | Files | Lines | LOC | Classes | Methods | M/C | LOC/M |
22
3
  +----------------------+---------+---------+---------+---------+---------+-----+-------+
@@ -24,17 +5,20 @@
24
5
  | Configuration | 19 | 417 | 111 | 1 | 0 | 0 | 0 |
25
6
  | Controllers | 1 | 7 | 6 | 1 | 1 | 1 | 4 |
26
7
  | Helpers | 1 | 3 | 3 | 0 | 0 | 0 | 0 |
27
- | Javascripts | 3 | 27 | 7 | 0 | 0 | 0 | 0 |
8
+ | Javascripts | 6 | 28 | 7 | 0 | 0 | 0 | 0 |
28
9
  | Jobs | 1 | 7 | 2 | 1 | 0 | 0 | 0 |
29
10
  | Libraries | 1 | 1 | 1 | 0 | 0 | 0 | 0 |
30
11
  | Mailers | 1 | 4 | 4 | 1 | 0 | 0 | 0 |
31
12
  | Model Tests | 2 | 5 | 4 | 2 | 0 | 0 | 0 |
32
- | Models | 1 | 3 | 3 | 1 | 0 | 0 | 0 |
13
+ | Models | 4 | 10 | 10 | 4 | 0 | 0 | 0 |
33
14
  | Spec Support | 1 | 1 | 1 | 0 | 0 | 0 | 0 |
34
15
  | Test Support | 1 | 1 | 1 | 0 | 0 | 0 | 0 |
35
16
  +----------------------+---------+---------+---------+---------+---------+-----+-------+
36
- | Code | 30 | 477 | 145 | 7 | 1 | 0 | 143 |
17
+ | Code | 36 | 485 | 152 | 10 | 1 | 0 | 150 |
37
18
  | Tests | 4 | 7 | 6 | 2 | 0 | 0 | 0 |
38
- | Total | 34 | 484 | 151 | 9 | 1 | 0 | 149 |
19
+ | Total | 40 | 492 | 158 | 12 | 1 | 0 | 156 |
39
20
  +----------------------+---------+---------+---------+---------+---------+-----+-------+
40
- Code LOC: 145 Test LOC: 6 Code to Test Ratio: 1:0.0 Files: 34
21
+ Code LOC: 152 Test LOC: 6 Code to Test Ratio: 1:0.0 Files: 40
22
+
23
+ Polymorphic models count: 1 polymorphic associations
24
+ Schema Stats: 2 `create_table` calls in schema.rb
@@ -8,13 +8,13 @@ describe RailsStats::CodeStatistics do
8
8
  describe "#to_s" do
9
9
  it "outputs useful stats for a Rails project" do
10
10
  root_directory = File.expand_path('../../../test/dummy', File.dirname(__FILE__))
11
- table = File.read(File.expand_path('../../../fixtures/console-output.txt', __FILE__))
11
+ expected_table = File.read(File.expand_path('../../../fixtures/console-output.txt', __FILE__))
12
12
 
13
- out, err = capture_io do
14
- RailsStats::CodeStatistics.new(root_directory).to_s
15
- end
13
+ expected_bundler_table, _ = capture_io { Bundler::Stats::CLI.start }
16
14
 
17
- assert_equal table.delete(" \n"), out.delete(" \n")
15
+ output, _ = capture_io { RailsStats::CodeStatistics.new(root_directory).to_s }
16
+
17
+ assert_equal([expected_bundler_table, expected_table].join, output)
18
18
  end
19
19
  end
20
20
  end
@@ -0,0 +1,26 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'test_helper'
4
+
5
+ describe RailsStats::ConsoleFormatter do
6
+ describe '#to_s' do
7
+ it 'invokes Bundler::Stats::CLI with text format' do
8
+ root_directory = File.absolute_path('./test/dummy')
9
+ calculator = RailsStats::StatsCalculator.new(root_directory)
10
+ formatter = RailsStats::ConsoleFormatter.new(calculator)
11
+
12
+ received_args = nil
13
+ original = Bundler::Stats::CLI.method(:start)
14
+ Bundler::Stats::CLI.define_singleton_method(:start) { |args = []| received_args = args }
15
+
16
+ begin
17
+ capture_io { formatter.to_s }
18
+ ensure
19
+ Bundler::Stats::CLI.singleton_class.remove_method(:start)
20
+ Bundler::Stats::CLI.define_singleton_method(:start, original)
21
+ end
22
+
23
+ assert_equal ['--format', 'text'], received_args
24
+ end
25
+ end
26
+ end
@@ -4,141 +4,84 @@ require "test_helper"
4
4
 
5
5
  describe RailsStats::JSONFormatter do
6
6
  describe "#result" do
7
- JSON_STRING = <<~EOS
8
- [{
9
- "name": "Libraries",
10
- "files": "1",
11
- "lines": "1",
12
- "loc": "1",
13
- "classes": "0",
14
- "methods": "0",
15
- "m_over_c": "0",
16
- "loc_over_m": "0"
17
- }, {
18
- "name": "Mailers",
19
- "files": "1",
20
- "lines": "4",
21
- "loc": "4",
22
- "classes": "1",
23
- "methods": "0",
24
- "m_over_c": "0",
25
- "loc_over_m": "0"
26
- }, {
27
- "name": "Model Tests",
28
- "files": "2",
29
- "lines": "5",
30
- "loc": "4",
31
- "classes": "2",
32
- "methods": "0",
33
- "m_over_c": "0",
34
- "loc_over_m": "0"
35
- }, {
36
- "name": "Models",
37
- "files": "1",
38
- "lines": "3",
39
- "loc": "3",
40
- "classes": "1",
41
- "methods": "0",
42
- "m_over_c": "0",
43
- "loc_over_m": "0"
44
- }, {
45
- "name": "Javascripts",
46
- "files": "3",
47
- "lines": "27",
48
- "loc": "7",
49
- "classes": "0",
50
- "methods": "0",
51
- "m_over_c": "0",
52
- "loc_over_m": "0"
53
- }, {
54
- "name": "Jobs",
55
- "files": "1",
56
- "lines": "7",
57
- "loc": "2",
58
- "classes": "1",
59
- "methods": "0",
60
- "m_over_c": "0",
61
- "loc_over_m": "0"
62
- }, {
63
- "name": "Controllers",
64
- "files": "1",
65
- "lines": "7",
66
- "loc": "6",
67
- "classes": "1",
68
- "methods": "1",
69
- "m_over_c": "1",
70
- "loc_over_m": "4"
71
- }, {
72
- "name": "Helpers",
73
- "files": "1",
74
- "lines": "3",
75
- "loc": "3",
76
- "classes": "0",
77
- "methods": "0",
78
- "m_over_c": "0",
79
- "loc_over_m": "0"
80
- }, {
81
- "name": "Channels",
82
- "files": "2",
83
- "lines": "8",
84
- "loc": "8",
85
- "classes": "2",
86
- "methods": "0",
87
- "m_over_c": "0",
88
- "loc_over_m": "0"
89
- }, {
90
- "name": "Configuration",
91
- "files": "19",
92
- "lines": "417",
93
- "loc": "111",
94
- "classes": "1",
95
- "methods": "0",
96
- "m_over_c": "0",
97
- "loc_over_m": "0"
98
- }, {
99
- "name": "Spec Support",
100
- "files": "1",
101
- "lines": "1",
102
- "loc": "1",
103
- "classes": "0",
104
- "methods": "0",
105
- "m_over_c": "0",
106
- "loc_over_m": "0"
107
- }, {
108
- "name": "Test Support",
109
- "files": "1",
110
- "lines": "1",
111
- "loc": "1",
112
- "classes": "0",
113
- "methods": "0",
114
- "m_over_c": "0",
115
- "loc_over_m": "0"
116
- }, {
117
- "name": "Total",
118
- "files": "34",
119
- "lines": "484",
120
- "loc": "151",
121
- "classes": "9",
122
- "methods": "1",
123
- "m_over_c": "0",
124
- "loc_over_m": "149",
125
- "code_to_test_ratio": "0.0",
126
- "total": true
127
- }]
128
- EOS
7
+ def code_stat(name, files:, lines:, loc:, classes:, methods: "0", m_over_c: "0", loc_over_m: "0")
8
+ {"name"=>name, "files"=>files, "lines"=>lines, "loc"=>loc,
9
+ "classes"=>classes, "methods"=>methods, "m_over_c"=>m_over_c, "loc_over_m"=>loc_over_m}
10
+ end
11
+
12
+ def total_stat(name, files:, lines:, loc:, classes:, methods: "0", m_over_c: "0", loc_over_m: "0", code_to_test_ratio: "0.0")
13
+ code_stat(name, files: files, lines: lines, loc: loc, classes: classes,
14
+ methods: methods, m_over_c: m_over_c, loc_over_m: loc_over_m)
15
+ .merge("code_to_test_ratio" => code_to_test_ratio, "total" => true)
16
+ end
17
+
18
+ EXPECTED_GEM_NAMES = %w[
19
+ simplecov-console codecov rails_stats simplecov minitest-around
20
+ bundler byebug minitest minitest-spec-context
21
+ ].freeze
129
22
 
130
23
  it "outputs useful stats for a Rails project" do
131
24
  root_directory = File.absolute_path("./test/dummy")
132
25
 
133
26
  calculator = RailsStats::StatsCalculator.new(root_directory)
134
27
  formatter = RailsStats::JSONFormatter.new(calculator)
28
+ result = formatter.result
29
+
30
+ # Verify bundler-stats structure (without asserting on version-specific values)
31
+ gems_section = result.find { |h| h["gems"] }
32
+ assert gems_section, "Expected a gems section in the result"
33
+ assert gems_section["summary"], "Expected a summary in the gems section"
34
+ %w[declared unpinned total github].each do |key|
35
+ assert gems_section["summary"].key?(key), "Expected summary to have '#{key}'"
36
+ end
135
37
 
136
- sorted_expectation = JSON.parse(JSON_STRING).sort {|x, y| x["name"] <=> y["name"] }
137
- sorted_result = formatter.result.sort {|x, y| x["name"] <=> y["name"] }
38
+ gem_names = gems_section["gems"].map { |g| g["name"] }
39
+ assert_equal EXPECTED_GEM_NAMES.sort, gem_names.sort
138
40
 
139
- sorted_expectation.each_with_index do |x, i|
140
- assert_equal x, sorted_result[i]
41
+ gems_section["gems"].each do |gem|
42
+ %w[name total_dependencies first_level_dependencies top_level_dependencies transitive_dependencies].each do |key|
43
+ assert gem.key?(key), "Expected gem '#{gem["name"]}' to have '#{key}'"
44
+ end
141
45
  end
46
+
47
+ # Verify code stats (these are stable across Ruby versions)
48
+ expected_code_stats = [
49
+ code_stat("Mailers", files: "1", lines: "4", loc: "4", classes: "1"),
50
+ code_stat("Models", files: "4", lines: "10", loc: "10", classes: "4"),
51
+ code_stat("Controllers", files: "1", lines: "7", loc: "6", classes: "1", methods: "1", m_over_c: "1", loc_over_m: "4"),
52
+ code_stat("Helpers", files: "1", lines: "3", loc: "3", classes: "0"),
53
+ code_stat("Jobs", files: "1", lines: "7", loc: "2", classes: "1"),
54
+ code_stat("Channels", files: "2", lines: "8", loc: "8", classes: "2"),
55
+ code_stat("Javascripts", files: "6", lines: "28", loc: "7", classes: "0"),
56
+ code_stat("Libraries", files: "1", lines: "1", loc: "1", classes: "0"),
57
+ code_stat("Configuration", files: "19", lines: "417", loc: "111", classes: "1"),
58
+ code_stat("Model Tests", files: "2", lines: "5", loc: "4", classes: "2"),
59
+ code_stat("Spec Support", files: "1", lines: "1", loc: "1", classes: "0"),
60
+ code_stat("Test Support", files: "1", lines: "1", loc: "1", classes: "0"),
61
+ ]
62
+
63
+ code_stats = result.select { |h| h["name"] && !h["total"] }
64
+ assert_equal expected_code_stats.sort_by { |h| h["name"] }, code_stats.sort_by { |h| h["name"] }
65
+
66
+ # Verify totals
67
+ expected_totals = [
68
+ total_stat("Code", files: "36", lines: "485", loc: "152", classes: "10", methods: "1", loc_over_m: "150"),
69
+ total_stat("Tests", files: "4", lines: "7", loc: "6", classes: "2"),
70
+ total_stat("Total", files: "40", lines: "492", loc: "158", classes: "12", methods: "1", loc_over_m: "156"),
71
+ ]
72
+
73
+ totals = result.select { |h| h["total"] }
74
+ assert_equal expected_totals.sort_by { |h| h["name"] }, totals.sort_by { |h| h["name"] }
75
+
76
+ # Verify schema and polymorphic stats
77
+ schema_stats = result.find { |h| h["schema_stats"] }
78
+ assert schema_stats, "Expected schema_stats in result"
79
+ assert_equal "#{Dir.pwd}/test/dummy/db/schema.rb", schema_stats["schema_stats"]["schema_path"]
80
+ assert_equal 2, schema_stats["schema_stats"]["create_table calls count"]
81
+
82
+ polymorphic_stats = result.find { |h| h["polymorphic_stats"] }
83
+ assert polymorphic_stats, "Expected polymorphic_stats in result"
84
+ assert_equal 1, polymorphic_stats["polymorphic_stats"]["polymorphic_models_count"]
142
85
  end
143
86
  end
144
- end
87
+ end
metadata CHANGED
@@ -1,14 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails_stats
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0
4
+ version: 2.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brian Leonard
8
- autorequire:
9
8
  bindir: bin
10
9
  cert_chain: []
11
- date: 2024-12-19 00:00:00.000000000 Z
10
+ date: 2026-04-07 00:00:00.000000000 Z
12
11
  dependencies:
13
12
  - !ruby/object:Gem::Dependency
14
13
  name: rake
@@ -86,11 +85,17 @@ files:
86
85
  - test/dummy/app/helpers/application_helper.rb
87
86
  - test/dummy/app/javascript/channels/consumer.js
88
87
  - test/dummy/app/javascript/channels/index.js
88
+ - test/dummy/app/javascript/dummy.jsx
89
+ - test/dummy/app/javascript/dummy.tsx
90
+ - test/dummy/app/javascript/index.ts
89
91
  - test/dummy/app/javascript/packs/application.js
90
92
  - test/dummy/app/jobs/application_job.rb
91
93
  - test/dummy/app/mailers/application_mailer.rb
92
94
  - test/dummy/app/models/application_record.rb
95
+ - test/dummy/app/models/comment.rb
93
96
  - test/dummy/app/models/concerns/.keep
97
+ - test/dummy/app/models/pet.rb
98
+ - test/dummy/app/models/user.rb
94
99
  - test/dummy/app/views/layouts/application.html.erb
95
100
  - test/dummy/app/views/layouts/mailer.html.erb
96
101
  - test/dummy/app/views/layouts/mailer.text.erb
@@ -124,6 +129,7 @@ files:
124
129
  - test/dummy/config/routes.rb
125
130
  - test/dummy/config/spring.rb
126
131
  - test/dummy/config/storage.yml
132
+ - test/dummy/db/schema.rb
127
133
  - test/dummy/lib/monkeypatches.rb
128
134
  - test/dummy/package.json
129
135
  - test/dummy/spec/models/user_spec.rb
@@ -132,13 +138,13 @@ files:
132
138
  - test/dummy/test/support/test_helper.rb
133
139
  - test/fixtures/console-output.txt
134
140
  - test/lib/rails_stats/code_statistics_test.rb
141
+ - test/lib/rails_stats/console_formatter_test.rb
135
142
  - test/lib/rails_stats/json_formatter_test.rb
136
143
  - test/test_helper.rb
137
144
  homepage: https://github.com/fastruby/rails_stats
138
145
  licenses:
139
146
  - MIT
140
147
  metadata: {}
141
- post_install_message:
142
148
  rdoc_options: []
143
149
  require_paths:
144
150
  - lib
@@ -153,8 +159,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
153
159
  - !ruby/object:Gem::Version
154
160
  version: '0'
155
161
  requirements: []
156
- rubygems_version: 3.0.3.1
157
- signing_key:
162
+ rubygems_version: 3.6.2
158
163
  specification_version: 4
159
164
  summary: Analyze a Rails project
160
165
  test_files:
@@ -170,11 +175,17 @@ test_files:
170
175
  - test/dummy/app/helpers/application_helper.rb
171
176
  - test/dummy/app/javascript/channels/consumer.js
172
177
  - test/dummy/app/javascript/channels/index.js
178
+ - test/dummy/app/javascript/dummy.jsx
179
+ - test/dummy/app/javascript/dummy.tsx
180
+ - test/dummy/app/javascript/index.ts
173
181
  - test/dummy/app/javascript/packs/application.js
174
182
  - test/dummy/app/jobs/application_job.rb
175
183
  - test/dummy/app/mailers/application_mailer.rb
176
184
  - test/dummy/app/models/application_record.rb
185
+ - test/dummy/app/models/comment.rb
177
186
  - test/dummy/app/models/concerns/.keep
187
+ - test/dummy/app/models/pet.rb
188
+ - test/dummy/app/models/user.rb
178
189
  - test/dummy/app/views/layouts/application.html.erb
179
190
  - test/dummy/app/views/layouts/mailer.html.erb
180
191
  - test/dummy/app/views/layouts/mailer.text.erb
@@ -208,6 +219,7 @@ test_files:
208
219
  - test/dummy/config/routes.rb
209
220
  - test/dummy/config/spring.rb
210
221
  - test/dummy/config/storage.yml
222
+ - test/dummy/db/schema.rb
211
223
  - test/dummy/lib/monkeypatches.rb
212
224
  - test/dummy/package.json
213
225
  - test/dummy/spec/models/user_spec.rb
@@ -216,5 +228,6 @@ test_files:
216
228
  - test/dummy/test/support/test_helper.rb
217
229
  - test/fixtures/console-output.txt
218
230
  - test/lib/rails_stats/code_statistics_test.rb
231
+ - test/lib/rails_stats/console_formatter_test.rb
219
232
  - test/lib/rails_stats/json_formatter_test.rb
220
233
  - test/test_helper.rb