Module: Spoom::Coverage
- 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
-
.file_tree(context) ⇒ Object
: (Context context) -> FileTree.
-
.report(context, snapshots, palette:) ⇒ Object
: (Context context, Array snapshots, palette: D3::ColorPalette) -> Report.
-
.snapshot(context, rbi: true, sorbet_bin: nil) ⇒ Object
: (Context context, ?rbi: bool, ?sorbet_bin: String?) -> Snapshot.
Class Method Details
.file_tree(context) ⇒ Object
: (Context context) -> FileTree
101 102 103 104 105 106 107 |
# File 'lib/spoom/coverage.rb', line 101 def file_tree(context) config = context.sorbet_config config.ignore += ["test"] files = context.srb_files(with_config: config, include_rbis: false) FileTree.new(files) end |
.report(context, snapshots, palette:) ⇒ Object
: (Context context, Array snapshots, palette: D3::ColorPalette) -> Report
81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 |
# File 'lib/spoom/coverage.rb', line 81 def report(context, snapshots, palette:) intro_commit = context.sorbet_intro_commit file_tree = file_tree(context) v = FileTree::CollectScores.new(context) v.visit_tree(file_tree) Report.new( project_name: File.basename(context.absolute_path), palette: palette, snapshots: snapshots, file_tree: file_tree, nodes_strictnesses: v.strictnesses, nodes_strictness_scores: v.scores, sorbet_intro_commit: intro_commit&.sha, sorbet_intro_date: intro_commit&.time, ) end |
.snapshot(context, rbi: true, sorbet_bin: nil) ⇒ Object
: (Context context, ?rbi: bool, ?sorbet_bin: String?) -> Snapshot
14 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 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 |
# File 'lib/spoom/coverage.rb', line 14 def snapshot(context, rbi: true, sorbet_bin: nil) config = context.sorbet_config config.allowed_extensions.push(".rb", ".rbi") if config.allowed_extensions.empty? new_config = config.copy new_config.allowed_extensions.reject! { |ext| !rbi && ext == ".rbi" } flags = [ "--no-config", "--no-error-sections", "--no-error-count", "--isolate-error-code=0", new_config., ] metrics = context.srb_metrics(*flags, sorbet_bin: sorbet_bin) # Collect extra information using a different configuration flags << "--ignore sorbet/rbi/" metrics_without_rbis = context.srb_metrics(*flags, sorbet_bin: sorbet_bin) snapshot = Snapshot.new return snapshot unless metrics last_commit = context.git_last_commit snapshot.commit_sha = last_commit&.sha snapshot. = last_commit&. 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) if metrics_without_rbis snapshot.methods_with_sig_excluding_rbis = metrics_without_rbis.fetch("types.sig.count", 0) snapshot.methods_without_sig_excluding_rbis = metrics_without_rbis.fetch( "types.input.methods.total", 0, ) - snapshot.methods_with_sig_excluding_rbis end Snapshot::STRICTNESSES.each do |strictness| if metrics.key?("types.input.files.sigil.#{strictness}") snapshot.sigils[strictness] = T.must(metrics["types.input.files.sigil.#{strictness}"]) end if metrics_without_rbis&.key?("types.input.files.sigil.#{strictness}") snapshot.sigils_excluding_rbis[strictness] = T.must(metrics_without_rbis["types.input.files.sigil.#{strictness}"]) end end snapshot.version_static = context.gem_version_from_gemfile_lock("sorbet-static").to_s snapshot.version_runtime = context.gem_version_from_gemfile_lock("sorbet-runtime").to_s files = context.srb_files(with_config: new_config) snapshot.rbi_files = files.count { |file| file.end_with?(".rbi") } snapshot end |