spoom 1.5.4 → 1.6.1
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 +4 -4
- data/lib/spoom/backtrace_filter/minitest.rb +2 -3
- data/lib/spoom/cli/deadcode.rb +1 -2
- data/lib/spoom/cli/helper.rb +36 -28
- data/lib/spoom/cli/srb/assertions.rb +48 -0
- data/lib/spoom/cli/srb/bump.rb +1 -2
- data/lib/spoom/cli/srb/sigs.rb +138 -18
- data/lib/spoom/cli/srb.rb +8 -4
- data/lib/spoom/cli.rb +1 -2
- data/lib/spoom/colors.rb +2 -6
- data/lib/spoom/context/bundle.rb +8 -9
- data/lib/spoom/context/exec.rb +2 -5
- data/lib/spoom/context/file_system.rb +12 -19
- data/lib/spoom/context/git.rb +14 -19
- data/lib/spoom/context/sorbet.rb +13 -26
- data/lib/spoom/context.rb +3 -7
- data/lib/spoom/coverage/d3/base.rb +6 -8
- data/lib/spoom/coverage/d3/circle_map.rb +6 -16
- data/lib/spoom/coverage/d3/pie.rb +14 -19
- data/lib/spoom/coverage/d3/timeline.rb +46 -47
- data/lib/spoom/coverage/d3.rb +2 -4
- data/lib/spoom/coverage/report.rb +38 -76
- data/lib/spoom/coverage/snapshot.rb +7 -13
- data/lib/spoom/coverage.rb +3 -5
- data/lib/spoom/deadcode/definition.rb +12 -14
- data/lib/spoom/deadcode/erb.rb +10 -8
- data/lib/spoom/deadcode/index.rb +19 -23
- data/lib/spoom/deadcode/indexer.rb +5 -6
- data/lib/spoom/deadcode/plugins/action_mailer.rb +2 -3
- data/lib/spoom/deadcode/plugins/action_mailer_preview.rb +2 -3
- data/lib/spoom/deadcode/plugins/actionpack.rb +4 -4
- data/lib/spoom/deadcode/plugins/active_model.rb +2 -3
- data/lib/spoom/deadcode/plugins/active_record.rb +2 -3
- data/lib/spoom/deadcode/plugins/active_support.rb +2 -1
- data/lib/spoom/deadcode/plugins/base.rb +29 -32
- data/lib/spoom/deadcode/plugins/graphql.rb +2 -3
- data/lib/spoom/deadcode/plugins/minitest.rb +4 -4
- data/lib/spoom/deadcode/plugins/namespaces.rb +5 -5
- data/lib/spoom/deadcode/plugins/rails.rb +5 -5
- data/lib/spoom/deadcode/plugins/rubocop.rb +4 -4
- data/lib/spoom/deadcode/plugins/ruby.rb +3 -4
- data/lib/spoom/deadcode/plugins/sorbet.rb +12 -6
- data/lib/spoom/deadcode/plugins/thor.rb +2 -3
- data/lib/spoom/deadcode/plugins.rb +2 -4
- data/lib/spoom/deadcode/remover.rb +37 -59
- data/lib/spoom/deadcode/send.rb +2 -8
- data/lib/spoom/file_collector.rb +10 -18
- data/lib/spoom/file_tree.rb +31 -46
- data/lib/spoom/location.rb +9 -20
- data/lib/spoom/model/builder.rb +60 -15
- data/lib/spoom/model/model.rb +65 -68
- data/lib/spoom/model/namespace_visitor.rb +3 -2
- data/lib/spoom/model/reference.rb +4 -8
- data/lib/spoom/model/references_visitor.rb +49 -29
- data/lib/spoom/parse.rb +17 -3
- data/lib/spoom/poset.rb +17 -19
- data/lib/spoom/printer.rb +10 -13
- data/lib/spoom/sorbet/assertions.rb +278 -0
- data/lib/spoom/sorbet/config.rb +8 -12
- data/lib/spoom/sorbet/errors.rb +16 -31
- data/lib/spoom/sorbet/lsp/base.rb +9 -15
- data/lib/spoom/sorbet/lsp/errors.rb +8 -16
- data/lib/spoom/sorbet/lsp/structures.rb +36 -59
- data/lib/spoom/sorbet/lsp.rb +15 -17
- data/lib/spoom/sorbet/metrics.rb +3 -5
- data/lib/spoom/sorbet/sigils.rb +7 -11
- data/lib/spoom/sorbet/sigs.rb +132 -33
- data/lib/spoom/sorbet.rb +3 -9
- data/lib/spoom/timeline.rb +4 -6
- data/lib/spoom/version.rb +1 -1
- data/lib/spoom/visitor.rb +298 -151
- data/lib/spoom.rb +0 -2
- data/rbi/spoom.rbi +3969 -0
- metadata +6 -3
@@ -7,21 +7,18 @@ module Spoom
|
|
7
7
|
module Coverage
|
8
8
|
module D3
|
9
9
|
class Timeline < Base
|
10
|
-
extend T::Sig
|
11
10
|
extend T::Helpers
|
12
11
|
|
13
12
|
abstract!
|
14
13
|
|
15
|
-
|
14
|
+
#: (String id, untyped data, Array[String] keys) -> void
|
16
15
|
def initialize(id, data, keys)
|
17
16
|
super(id, data)
|
18
17
|
@keys = keys
|
19
18
|
end
|
20
19
|
|
21
20
|
class << self
|
22
|
-
|
23
|
-
|
24
|
-
sig { returns(String) }
|
21
|
+
#: -> String
|
25
22
|
def header_style
|
26
23
|
<<~CSS
|
27
24
|
.domain {
|
@@ -75,7 +72,7 @@ module Spoom
|
|
75
72
|
CSS
|
76
73
|
end
|
77
74
|
|
78
|
-
|
75
|
+
#: -> String
|
79
76
|
def header_script
|
80
77
|
<<~JS
|
81
78
|
var parseVersion = function(version) {
|
@@ -97,7 +94,8 @@ module Spoom
|
|
97
94
|
end
|
98
95
|
end
|
99
96
|
|
100
|
-
|
97
|
+
# @override
|
98
|
+
#: -> String
|
101
99
|
def script
|
102
100
|
<<~HTML
|
103
101
|
#{tooltip}
|
@@ -125,7 +123,7 @@ module Spoom
|
|
125
123
|
sig { abstract.returns(String) }
|
126
124
|
def plot; end
|
127
125
|
|
128
|
-
|
126
|
+
#: -> String
|
129
127
|
def x_scale
|
130
128
|
<<~HTML
|
131
129
|
var xScale_#{id} = d3.scaleTime()
|
@@ -141,7 +139,7 @@ module Spoom
|
|
141
139
|
HTML
|
142
140
|
end
|
143
141
|
|
144
|
-
|
142
|
+
#: -> String
|
145
143
|
def x_ticks
|
146
144
|
<<~HTML
|
147
145
|
svg_#{id}.append("g")
|
@@ -154,7 +152,7 @@ module Spoom
|
|
154
152
|
HTML
|
155
153
|
end
|
156
154
|
|
157
|
-
|
155
|
+
#: (min: String, max: String, ticks: String) -> String
|
158
156
|
def y_scale(min:, max:, ticks:)
|
159
157
|
<<~HTML
|
160
158
|
var yScale_#{id} = d3.scaleLinear()
|
@@ -170,7 +168,7 @@ module Spoom
|
|
170
168
|
HTML
|
171
169
|
end
|
172
170
|
|
173
|
-
|
171
|
+
#: (ticks: String, format: String, padding: Integer) -> String
|
174
172
|
def y_ticks(ticks:, format:, padding:)
|
175
173
|
<<~HTML
|
176
174
|
svg_#{id}.append("g")
|
@@ -183,7 +181,7 @@ module Spoom
|
|
183
181
|
HTML
|
184
182
|
end
|
185
183
|
|
186
|
-
|
184
|
+
#: (y: String, ?color: String, ?curve: String) -> String
|
187
185
|
def area(y:, color: "#ccc", curve: "curveCatmullRom.alpha(1)")
|
188
186
|
<<~HTML
|
189
187
|
svg_#{id}.append("path")
|
@@ -199,7 +197,7 @@ module Spoom
|
|
199
197
|
HTML
|
200
198
|
end
|
201
199
|
|
202
|
-
|
200
|
+
#: (y: String, ?color: String, ?curve: String) -> String
|
203
201
|
def line(y:, color: "#ccc", curve: "curveCatmullRom.alpha(1)")
|
204
202
|
<<~HTML
|
205
203
|
svg_#{id}.append("path")
|
@@ -213,7 +211,7 @@ module Spoom
|
|
213
211
|
HTML
|
214
212
|
end
|
215
213
|
|
216
|
-
|
214
|
+
#: (y: String) -> String
|
217
215
|
def points(y:)
|
218
216
|
<<~HTML
|
219
217
|
svg_#{id}.selectAll("circle")
|
@@ -230,9 +228,7 @@ module Spoom
|
|
230
228
|
end
|
231
229
|
|
232
230
|
class Versions < Timeline
|
233
|
-
|
234
|
-
|
235
|
-
sig { params(id: String, snapshots: T::Array[Snapshot]).void }
|
231
|
+
#: (String id, Array[Snapshot] snapshots) -> void
|
236
232
|
def initialize(id, snapshots)
|
237
233
|
data = snapshots.map do |snapshot|
|
238
234
|
{
|
@@ -245,7 +241,8 @@ module Spoom
|
|
245
241
|
super(id, data, [])
|
246
242
|
end
|
247
243
|
|
248
|
-
|
244
|
+
# @override
|
245
|
+
#: -> String
|
249
246
|
def tooltip
|
250
247
|
<<~JS
|
251
248
|
function tooltip_#{id}(d) {
|
@@ -259,7 +256,8 @@ module Spoom
|
|
259
256
|
JS
|
260
257
|
end
|
261
258
|
|
262
|
-
|
259
|
+
# @override
|
260
|
+
#: -> String
|
263
261
|
def plot
|
264
262
|
<<~JS
|
265
263
|
#{x_scale}
|
@@ -280,9 +278,7 @@ module Spoom
|
|
280
278
|
end
|
281
279
|
|
282
280
|
class Runtimes < Timeline
|
283
|
-
|
284
|
-
|
285
|
-
sig { params(id: String, snapshots: T::Array[Snapshot]).void }
|
281
|
+
#: (String id, Array[Snapshot] snapshots) -> void
|
286
282
|
def initialize(id, snapshots)
|
287
283
|
data = snapshots.map do |snapshot|
|
288
284
|
{
|
@@ -294,7 +290,8 @@ module Spoom
|
|
294
290
|
super(id, data, [])
|
295
291
|
end
|
296
292
|
|
297
|
-
|
293
|
+
# @override
|
294
|
+
#: -> String
|
298
295
|
def tooltip
|
299
296
|
<<~JS
|
300
297
|
function tooltip_#{id}(d) {
|
@@ -307,7 +304,8 @@ module Spoom
|
|
307
304
|
JS
|
308
305
|
end
|
309
306
|
|
310
|
-
|
307
|
+
# @override
|
308
|
+
#: -> String
|
311
309
|
def plot
|
312
310
|
<<~JS
|
313
311
|
#{x_scale}
|
@@ -327,12 +325,12 @@ module Spoom
|
|
327
325
|
end
|
328
326
|
|
329
327
|
class Stacked < Timeline
|
330
|
-
extend T::Sig
|
331
328
|
extend T::Helpers
|
332
329
|
|
333
330
|
abstract!
|
334
331
|
|
335
|
-
|
332
|
+
# @override
|
333
|
+
#: -> String
|
336
334
|
def script
|
337
335
|
<<~JS
|
338
336
|
#{tooltip}
|
@@ -373,7 +371,8 @@ module Spoom
|
|
373
371
|
JS
|
374
372
|
end
|
375
373
|
|
376
|
-
|
374
|
+
# @override
|
375
|
+
#: -> String
|
377
376
|
def plot
|
378
377
|
<<~JS
|
379
378
|
#{x_scale}
|
@@ -384,7 +383,8 @@ module Spoom
|
|
384
383
|
JS
|
385
384
|
end
|
386
385
|
|
387
|
-
|
386
|
+
# @override
|
387
|
+
#: (y: String, ?color: String, ?curve: String) -> String
|
388
388
|
def line(y:, color: "strictnessColor(d.key)", curve: "curveCatmullRom.alpha(1)")
|
389
389
|
<<~JS
|
390
390
|
var area_#{id} = d3.area()
|
@@ -419,9 +419,7 @@ module Spoom
|
|
419
419
|
end
|
420
420
|
|
421
421
|
class Sigils < Stacked
|
422
|
-
|
423
|
-
|
424
|
-
sig { params(id: String, snapshots: T::Array[Snapshot]).void }
|
422
|
+
#: (String id, Array[Snapshot] snapshots) -> void
|
425
423
|
def initialize(id, snapshots)
|
426
424
|
keys = Snapshot::STRICTNESSES
|
427
425
|
data = snapshots.map do |snapshot|
|
@@ -435,7 +433,8 @@ module Spoom
|
|
435
433
|
super(id, data, keys)
|
436
434
|
end
|
437
435
|
|
438
|
-
|
436
|
+
# @override
|
437
|
+
#: -> String
|
439
438
|
def tooltip
|
440
439
|
<<~JS
|
441
440
|
function tooltip_#{id}(d) {
|
@@ -446,9 +445,7 @@ module Spoom
|
|
446
445
|
end
|
447
446
|
|
448
447
|
class Calls < Stacked
|
449
|
-
|
450
|
-
|
451
|
-
sig { params(id: String, snapshots: T::Array[Snapshot]).void }
|
448
|
+
#: (String id, Array[Snapshot] snapshots) -> void
|
452
449
|
def initialize(id, snapshots)
|
453
450
|
keys = ["false", "true"]
|
454
451
|
data = snapshots.map do |snapshot|
|
@@ -462,7 +459,8 @@ module Spoom
|
|
462
459
|
super(id, data, keys)
|
463
460
|
end
|
464
461
|
|
465
|
-
|
462
|
+
# @override
|
463
|
+
#: -> String
|
466
464
|
def tooltip
|
467
465
|
<<~JS
|
468
466
|
function tooltip_#{id}(d) {
|
@@ -473,9 +471,7 @@ module Spoom
|
|
473
471
|
end
|
474
472
|
|
475
473
|
class Sigs < Stacked
|
476
|
-
|
477
|
-
|
478
|
-
sig { params(id: String, snapshots: T::Array[Snapshot]).void }
|
474
|
+
#: (String id, Array[Snapshot] snapshots) -> void
|
479
475
|
def initialize(id, snapshots)
|
480
476
|
keys = ["false", "true"]
|
481
477
|
data = snapshots.map do |snapshot|
|
@@ -492,7 +488,8 @@ module Spoom
|
|
492
488
|
super(id, data, keys)
|
493
489
|
end
|
494
490
|
|
495
|
-
|
491
|
+
# @override
|
492
|
+
#: -> String
|
496
493
|
def tooltip
|
497
494
|
<<~JS
|
498
495
|
function tooltip_#{id}(d) {
|
@@ -503,9 +500,7 @@ module Spoom
|
|
503
500
|
end
|
504
501
|
|
505
502
|
class RBIs < Stacked
|
506
|
-
|
507
|
-
|
508
|
-
sig { params(id: String, snapshots: T::Array[Snapshot]).void }
|
503
|
+
#: (String id, Array[Snapshot] snapshots) -> void
|
509
504
|
def initialize(id, snapshots)
|
510
505
|
keys = ["rbis", "files"]
|
511
506
|
data = snapshots.map do |snapshot|
|
@@ -519,7 +514,8 @@ module Spoom
|
|
519
514
|
super(id, data, keys)
|
520
515
|
end
|
521
516
|
|
522
|
-
|
517
|
+
# @override
|
518
|
+
#: -> String
|
523
519
|
def tooltip
|
524
520
|
<<~JS
|
525
521
|
function tooltip_#{id}(d) {
|
@@ -533,7 +529,8 @@ module Spoom
|
|
533
529
|
JS
|
534
530
|
end
|
535
531
|
|
536
|
-
|
532
|
+
# @override
|
533
|
+
#: -> String
|
537
534
|
def script
|
538
535
|
<<~JS
|
539
536
|
#{tooltip}
|
@@ -573,7 +570,8 @@ module Spoom
|
|
573
570
|
JS
|
574
571
|
end
|
575
572
|
|
576
|
-
|
573
|
+
# @override
|
574
|
+
#: (y: String, ?color: String, ?curve: String) -> String
|
577
575
|
def line(y:, color: "strictnessColor(d.key)", curve: "curveCatmullRom.alpha(1)")
|
578
576
|
<<~JS
|
579
577
|
var area_#{id} = d3.area()
|
@@ -613,7 +611,8 @@ module Spoom
|
|
613
611
|
JS
|
614
612
|
end
|
615
613
|
|
616
|
-
|
614
|
+
# @override
|
615
|
+
#: -> String
|
617
616
|
def plot
|
618
617
|
<<~JS
|
619
618
|
#{x_scale}
|
data/lib/spoom/coverage/d3.rb
CHANGED
@@ -15,9 +15,7 @@ module Spoom
|
|
15
15
|
COLOR_STRONG = "#064828"
|
16
16
|
|
17
17
|
class << self
|
18
|
-
|
19
|
-
|
20
|
-
sig { returns(String) }
|
18
|
+
#: -> String
|
21
19
|
def header_style
|
22
20
|
<<~CSS
|
23
21
|
svg {
|
@@ -57,7 +55,7 @@ module Spoom
|
|
57
55
|
CSS
|
58
56
|
end
|
59
57
|
|
60
|
-
|
58
|
+
#: (ColorPalette palette) -> String
|
61
59
|
def header_script(palette)
|
62
60
|
<<~JS
|
63
61
|
var parseDate = d3.timeParse("%s");
|
@@ -8,28 +8,27 @@ require "erb"
|
|
8
8
|
module Spoom
|
9
9
|
module Coverage
|
10
10
|
class Template
|
11
|
-
extend T::Sig
|
12
11
|
extend T::Helpers
|
13
12
|
|
14
13
|
abstract!
|
15
14
|
|
16
15
|
# Create a new template from an Erb file path
|
17
|
-
|
16
|
+
#: (template: String) -> void
|
18
17
|
def initialize(template:)
|
19
18
|
@template = template
|
20
19
|
end
|
21
20
|
|
22
|
-
|
21
|
+
#: -> String
|
23
22
|
def erb
|
24
23
|
File.read(@template)
|
25
24
|
end
|
26
25
|
|
27
|
-
|
26
|
+
#: -> String
|
28
27
|
def html
|
29
28
|
ERB.new(erb).result(get_binding)
|
30
29
|
end
|
31
30
|
|
32
|
-
|
31
|
+
#: -> Binding
|
33
32
|
def get_binding # rubocop:disable Naming/AccessorMethodName
|
34
33
|
binding
|
35
34
|
end
|
@@ -43,35 +42,35 @@ module Spoom
|
|
43
42
|
|
44
43
|
TEMPLATE = T.let("#{Spoom::SPOOM_PATH}/templates/page.erb", String)
|
45
44
|
|
46
|
-
|
45
|
+
#: String
|
47
46
|
attr_reader :title
|
48
47
|
|
49
|
-
|
48
|
+
#: D3::ColorPalette
|
50
49
|
attr_reader :palette
|
51
50
|
|
52
|
-
|
51
|
+
#: (title: String, palette: D3::ColorPalette, ?template: String) -> void
|
53
52
|
def initialize(title:, palette:, template: TEMPLATE)
|
54
53
|
super(template: template)
|
55
54
|
@title = title
|
56
55
|
@palette = palette
|
57
56
|
end
|
58
57
|
|
59
|
-
|
58
|
+
#: -> String
|
60
59
|
def header_style
|
61
60
|
D3.header_style
|
62
61
|
end
|
63
62
|
|
64
|
-
|
63
|
+
#: -> String
|
65
64
|
def header_script
|
66
65
|
D3.header_script(palette)
|
67
66
|
end
|
68
67
|
|
69
|
-
|
68
|
+
#: -> String
|
70
69
|
def header_html
|
71
70
|
"<h1 class='display-3'>#{title}</h1>"
|
72
71
|
end
|
73
72
|
|
74
|
-
|
73
|
+
#: -> String
|
75
74
|
def body_html
|
76
75
|
cards.map(&:html).join("\n")
|
77
76
|
end
|
@@ -79,7 +78,7 @@ module Spoom
|
|
79
78
|
sig { abstract.returns(T::Array[Cards::Card]) }
|
80
79
|
def cards; end
|
81
80
|
|
82
|
-
|
81
|
+
#: -> String
|
83
82
|
def footer_html
|
84
83
|
"Generated by <a href='https://github.com/Shopify/spoom'>spoom</a> on #{Time.now.utc}."
|
85
84
|
end
|
@@ -91,10 +90,10 @@ module Spoom
|
|
91
90
|
|
92
91
|
TEMPLATE = T.let("#{Spoom::SPOOM_PATH}/templates/card.erb", String)
|
93
92
|
|
94
|
-
|
93
|
+
#: String?
|
95
94
|
attr_reader :title, :body
|
96
95
|
|
97
|
-
|
96
|
+
#: (?template: String, ?title: String?, ?body: String?) -> void
|
98
97
|
def initialize(template: TEMPLATE, title: nil, body: nil)
|
99
98
|
super(template: template)
|
100
99
|
@title = title
|
@@ -103,15 +102,15 @@ module Spoom
|
|
103
102
|
end
|
104
103
|
|
105
104
|
class Erb < Card
|
106
|
-
extend T::Sig
|
107
105
|
extend T::Helpers
|
108
106
|
|
109
107
|
abstract!
|
110
108
|
|
111
|
-
|
109
|
+
#: -> void
|
112
110
|
def initialize; end # rubocop:disable Lint/MissingSuper
|
113
111
|
|
114
|
-
|
112
|
+
# @override
|
113
|
+
#: -> String
|
115
114
|
def html
|
116
115
|
ERB.new(erb).result(get_binding)
|
117
116
|
end
|
@@ -121,46 +120,35 @@ module Spoom
|
|
121
120
|
end
|
122
121
|
|
123
122
|
class Snapshot < Card
|
124
|
-
extend T::Sig
|
125
|
-
|
126
123
|
TEMPLATE = T.let("#{Spoom::SPOOM_PATH}/templates/card_snapshot.erb", String)
|
127
124
|
|
128
|
-
|
125
|
+
#: Coverage::Snapshot
|
129
126
|
attr_reader :snapshot
|
130
127
|
|
131
|
-
|
128
|
+
#: (snapshot: Coverage::Snapshot, ?title: String) -> void
|
132
129
|
def initialize(snapshot:, title: "Snapshot")
|
133
130
|
super(template: TEMPLATE, title: title)
|
134
131
|
@snapshot = snapshot
|
135
132
|
end
|
136
133
|
|
137
|
-
|
134
|
+
#: -> D3::Pie::Sigils
|
138
135
|
def pie_sigils
|
139
136
|
D3::Pie::Sigils.new("pie_sigils", "Sigils", snapshot)
|
140
137
|
end
|
141
138
|
|
142
|
-
|
139
|
+
#: -> D3::Pie::Calls
|
143
140
|
def pie_calls
|
144
141
|
D3::Pie::Calls.new("pie_calls", "Calls", snapshot)
|
145
142
|
end
|
146
143
|
|
147
|
-
|
144
|
+
#: -> D3::Pie::Sigs
|
148
145
|
def pie_sigs
|
149
146
|
D3::Pie::Sigs.new("pie_sigs", "Sigs", snapshot)
|
150
147
|
end
|
151
148
|
end
|
152
149
|
|
153
150
|
class Map < Card
|
154
|
-
|
155
|
-
|
156
|
-
sig do
|
157
|
-
params(
|
158
|
-
file_tree: FileTree,
|
159
|
-
nodes_strictnesses: T::Hash[FileTree::Node, T.nilable(String)],
|
160
|
-
nodes_strictness_scores: T::Hash[FileTree::Node, Float],
|
161
|
-
title: String,
|
162
|
-
).void
|
163
|
-
end
|
151
|
+
#: (file_tree: FileTree, nodes_strictnesses: Hash[FileTree::Node, String?], nodes_strictness_scores: Hash[FileTree::Node, Float], ?title: String) -> void
|
164
152
|
def initialize(file_tree:, nodes_strictnesses:, nodes_strictness_scores:, title: "Strictness Map")
|
165
153
|
super(
|
166
154
|
title: title,
|
@@ -175,62 +163,48 @@ module Spoom
|
|
175
163
|
end
|
176
164
|
|
177
165
|
class Timeline < Card
|
178
|
-
|
179
|
-
|
180
|
-
sig { params(title: String, timeline: D3::Timeline).void }
|
166
|
+
#: (title: String, timeline: D3::Timeline) -> void
|
181
167
|
def initialize(title:, timeline:)
|
182
168
|
super(title: title, body: timeline.html)
|
183
169
|
end
|
184
170
|
|
185
171
|
class Sigils < Timeline
|
186
|
-
|
187
|
-
|
188
|
-
sig { params(snapshots: T::Array[Coverage::Snapshot], title: String).void }
|
172
|
+
#: (snapshots: Array[Coverage::Snapshot], ?title: String) -> void
|
189
173
|
def initialize(snapshots:, title: "Sigils Timeline")
|
190
174
|
super(title: title, timeline: D3::Timeline::Sigils.new("timeline_sigils", snapshots))
|
191
175
|
end
|
192
176
|
end
|
193
177
|
|
194
178
|
class Calls < Timeline
|
195
|
-
|
196
|
-
|
197
|
-
sig { params(snapshots: T::Array[Coverage::Snapshot], title: String).void }
|
179
|
+
#: (snapshots: Array[Coverage::Snapshot], ?title: String) -> void
|
198
180
|
def initialize(snapshots:, title: "Calls Timeline")
|
199
181
|
super(title: title, timeline: D3::Timeline::Calls.new("timeline_calls", snapshots))
|
200
182
|
end
|
201
183
|
end
|
202
184
|
|
203
185
|
class Sigs < Timeline
|
204
|
-
|
205
|
-
|
206
|
-
sig { params(snapshots: T::Array[Coverage::Snapshot], title: String).void }
|
186
|
+
#: (snapshots: Array[Coverage::Snapshot], ?title: String) -> void
|
207
187
|
def initialize(snapshots:, title: "Signatures Timeline")
|
208
188
|
super(title: title, timeline: D3::Timeline::Sigs.new("timeline_sigs", snapshots))
|
209
189
|
end
|
210
190
|
end
|
211
191
|
|
212
192
|
class RBIs < Timeline
|
213
|
-
|
214
|
-
|
215
|
-
sig { params(snapshots: T::Array[Coverage::Snapshot], title: String).void }
|
193
|
+
#: (snapshots: Array[Coverage::Snapshot], ?title: String) -> void
|
216
194
|
def initialize(snapshots:, title: "RBIs Timeline")
|
217
195
|
super(title: title, timeline: D3::Timeline::RBIs.new("timeline_rbis", snapshots))
|
218
196
|
end
|
219
197
|
end
|
220
198
|
|
221
199
|
class Versions < Timeline
|
222
|
-
|
223
|
-
|
224
|
-
sig { params(snapshots: T::Array[Coverage::Snapshot], title: String).void }
|
200
|
+
#: (snapshots: Array[Coverage::Snapshot], ?title: String) -> void
|
225
201
|
def initialize(snapshots:, title: "Sorbet Versions Timeline")
|
226
202
|
super(title: title, timeline: D3::Timeline::Versions.new("timeline_versions", snapshots))
|
227
203
|
end
|
228
204
|
end
|
229
205
|
|
230
206
|
class Runtimes < Timeline
|
231
|
-
|
232
|
-
|
233
|
-
sig { params(snapshots: T::Array[Coverage::Snapshot], title: String).void }
|
207
|
+
#: (snapshots: Array[Coverage::Snapshot], ?title: String) -> void
|
234
208
|
def initialize(snapshots:, title: "Sorbet Typechecking Time")
|
235
209
|
super(title: title, timeline: D3::Timeline::Runtimes.new("timeline_runtimes", snapshots))
|
236
210
|
end
|
@@ -238,15 +212,14 @@ module Spoom
|
|
238
212
|
end
|
239
213
|
|
240
214
|
class SorbetIntro < Erb
|
241
|
-
|
242
|
-
|
243
|
-
sig { params(sorbet_intro_commit: T.nilable(String), sorbet_intro_date: T.nilable(Time)).void }
|
215
|
+
#: (?sorbet_intro_commit: String?, ?sorbet_intro_date: Time?) -> void
|
244
216
|
def initialize(sorbet_intro_commit: nil, sorbet_intro_date: nil) # rubocop:disable Lint/MissingSuper
|
245
217
|
@sorbet_intro_commit = sorbet_intro_commit
|
246
218
|
@sorbet_intro_date = sorbet_intro_date
|
247
219
|
end
|
248
220
|
|
249
|
-
|
221
|
+
# @override
|
222
|
+
#: -> String
|
250
223
|
def erb
|
251
224
|
<<~ERB
|
252
225
|
<div class="text-center" style="margin-top: 30px">
|
@@ -259,20 +232,7 @@ module Spoom
|
|
259
232
|
end
|
260
233
|
|
261
234
|
class Report < Page
|
262
|
-
|
263
|
-
|
264
|
-
sig do
|
265
|
-
params(
|
266
|
-
project_name: String,
|
267
|
-
palette: D3::ColorPalette,
|
268
|
-
snapshots: T::Array[Snapshot],
|
269
|
-
file_tree: FileTree,
|
270
|
-
nodes_strictnesses: T::Hash[FileTree::Node, T.nilable(String)],
|
271
|
-
nodes_strictness_scores: T::Hash[FileTree::Node, Float],
|
272
|
-
sorbet_intro_commit: T.nilable(String),
|
273
|
-
sorbet_intro_date: T.nilable(Time),
|
274
|
-
).void
|
275
|
-
end
|
235
|
+
#: (project_name: String, palette: D3::ColorPalette, snapshots: Array[Snapshot], file_tree: FileTree, nodes_strictnesses: Hash[FileTree::Node, String?], nodes_strictness_scores: Hash[FileTree::Node, Float], ?sorbet_intro_commit: String?, ?sorbet_intro_date: Time?) -> void
|
276
236
|
def initialize(
|
277
237
|
project_name:,
|
278
238
|
palette:,
|
@@ -293,7 +253,8 @@ module Spoom
|
|
293
253
|
@sorbet_intro_date = sorbet_intro_date
|
294
254
|
end
|
295
255
|
|
296
|
-
|
256
|
+
# @override
|
257
|
+
#: -> String
|
297
258
|
def header_html
|
298
259
|
last = T.must(@snapshots.last)
|
299
260
|
<<~ERB
|
@@ -304,7 +265,8 @@ module Spoom
|
|
304
265
|
ERB
|
305
266
|
end
|
306
267
|
|
307
|
-
|
268
|
+
# @override
|
269
|
+
#: -> Array[Cards::Card]
|
308
270
|
def cards
|
309
271
|
last = T.must(@snapshots.last)
|
310
272
|
cards = []
|
@@ -4,8 +4,6 @@
|
|
4
4
|
module Spoom
|
5
5
|
module Coverage
|
6
6
|
class Snapshot < T::Struct
|
7
|
-
extend T::Sig
|
8
|
-
|
9
7
|
prop :timestamp, Integer, default: Time.new.getutc.to_i
|
10
8
|
prop :version_static, T.nilable(String), default: nil
|
11
9
|
prop :version_runtime, T.nilable(String), default: nil
|
@@ -29,26 +27,24 @@ module Spoom
|
|
29
27
|
# The strictness name as found in the Sorbet metrics file
|
30
28
|
STRICTNESSES = T.let(["ignore", "false", "true", "strict", "strong", "stdlib"].freeze, T::Array[String])
|
31
29
|
|
32
|
-
|
30
|
+
#: (?out: (IO | StringIO), ?colors: bool, ?indent_level: Integer) -> void
|
33
31
|
def print(out: $stdout, colors: true, indent_level: 0)
|
34
32
|
printer = SnapshotPrinter.new(out: out, colors: colors, indent_level: indent_level)
|
35
33
|
printer.print_snapshot(self)
|
36
34
|
end
|
37
35
|
|
38
|
-
|
36
|
+
#: (*untyped arg) -> String
|
39
37
|
def to_json(*arg)
|
40
38
|
serialize.to_json(*arg)
|
41
39
|
end
|
42
40
|
|
43
41
|
class << self
|
44
|
-
|
45
|
-
|
46
|
-
sig { params(json: String).returns(Snapshot) }
|
42
|
+
#: (String json) -> Snapshot
|
47
43
|
def from_json(json)
|
48
44
|
from_obj(JSON.parse(json))
|
49
45
|
end
|
50
46
|
|
51
|
-
|
47
|
+
#: (Hash[String, untyped] obj) -> Snapshot
|
52
48
|
def from_obj(obj)
|
53
49
|
snapshot = Snapshot.new
|
54
50
|
snapshot.timestamp = obj.fetch("timestamp", 0)
|
@@ -93,9 +89,7 @@ module Spoom
|
|
93
89
|
end
|
94
90
|
|
95
91
|
class SnapshotPrinter < Spoom::Printer
|
96
|
-
|
97
|
-
|
98
|
-
sig { params(snapshot: Snapshot).void }
|
92
|
+
#: (Snapshot snapshot) -> void
|
99
93
|
def print_snapshot(snapshot)
|
100
94
|
methods = snapshot.methods_with_sig + snapshot.methods_without_sig
|
101
95
|
methods_excluding_rbis = snapshot.methods_with_sig_excluding_rbis + snapshot.methods_without_sig_excluding_rbis
|
@@ -143,7 +137,7 @@ module Spoom
|
|
143
137
|
|
144
138
|
private
|
145
139
|
|
146
|
-
|
140
|
+
#: (Hash[String, Integer] hash, Integer total) -> void
|
147
141
|
def print_map(hash, total)
|
148
142
|
indent
|
149
143
|
hash.each do |key, value|
|
@@ -154,7 +148,7 @@ module Spoom
|
|
154
148
|
dedent
|
155
149
|
end
|
156
150
|
|
157
|
-
|
151
|
+
#: (Integer? value, Integer? total) -> String
|
158
152
|
def percent(value, total)
|
159
153
|
return "" if value.nil? || total.nil? || total == 0
|
160
154
|
|