Module: Spoom::Coverage
- Extended by:
- T::Sig
- Defined in:
- lib/spoom/coverage.rb,
lib/spoom/coverage/d3.rb,
lib/spoom/coverage/d3/pie.rb,
lib/spoom/coverage/report.rb,
lib/spoom/coverage/d3/base.rb,
lib/spoom/coverage/snapshot.rb,
lib/spoom/coverage/d3/timeline.rb,
lib/spoom/coverage/d3/circle_map.rb
Defined Under Namespace
Modules: Cards, D3
Classes: Page, Report, Snapshot, SnapshotPrinter, Template
Class Method Summary
collapse
Class Method Details
.report(snapshots, palette:, path: ".") ⇒ Object
48
49
50
51
52
53
54
55
56
57
58
59
60
|
# File 'lib/spoom/coverage.rb', line 48
def self.report(snapshots, palette:, path: ".")
intro_commit = Git.sorbet_intro_commit(path: path)
intro_date = intro_commit ? Git.commit_time(intro_commit, path: path) : nil
Report.new(
project_name: File.basename(File.expand_path(path)),
palette: palette,
snapshots: snapshots,
sigils_tree: sigils_tree(path: path),
sorbet_intro_commit: intro_commit,
sorbet_intro_date: intro_date,
)
end
|
.sigils_tree(path: ".") ⇒ Object
63
64
65
66
67
68
69
70
71
|
# File 'lib/spoom/coverage.rb', line 63
def self.sigils_tree(path: ".")
config_file = "#{path}/#{Spoom::Config::SORBET_CONFIG}"
return FileTree.new unless File.exist?(config_file)
config = Sorbet::Config.parse_file(config_file)
files = Sorbet.srb_files(config, path: path)
files.select! { |file| file =~ /\.rb$/ }
files.reject! { |file| file =~ %r{/test/} }
FileTree.new(files, strip_prefix: path)
end
|
.snapshot(path: '.') ⇒ Object
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
# File 'lib/spoom/coverage.rb', line 15
def self.snapshot(path: '.')
snapshot = Snapshot.new
metrics = Spoom::Sorbet.srb_metrics(path: path, capture_err: true)
return snapshot unless metrics
sha = Spoom::Git.last_commit(path: path)
snapshot.commit_sha = sha
snapshot.commit_timestamp = Spoom::Git.commit_timestamp(sha, path: path).to_i if sha
snapshot.files = metrics.fetch("types.input.files", 0)
snapshot.modules = metrics.fetch("types.input.modules.total", 0)
snapshot.classes = metrics.fetch("types.input.classes.total", 0)
snapshot.singleton_classes = metrics.fetch("types.input.singleton_classes.total", 0)
snapshot.methods_with_sig = metrics.fetch("types.sig.count", 0)
snapshot.methods_without_sig = metrics.fetch("types.input.methods.total", 0) - snapshot.methods_with_sig
snapshot.calls_typed = metrics.fetch("types.input.sends.typed", 0)
snapshot.calls_untyped = metrics.fetch("types.input.sends.total", 0) - snapshot.calls_typed
snapshot.duration += metrics.fetch("run.utilization.system_time.us", 0)
snapshot.duration += metrics.fetch("run.utilization.user_time.us", 0)
Snapshot::STRICTNESSES.each do |strictness|
next unless metrics.key?("types.input.files.sigil.#{strictness}")
snapshot.sigils[strictness] = T.must(metrics["types.input.files.sigil.#{strictness}"])
end
snapshot.version_static = Spoom::Sorbet.version_from_gemfile_lock(gem: "sorbet-static", path: path)
snapshot.version_runtime = Spoom::Sorbet.version_from_gemfile_lock(gem: "sorbet-runtime", path: path)
snapshot
end
|