sorbet-progress 0.2.3 → 0.2.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/README.md +15 -8
- data/lib/sorbet_progress/calculator.rb +64 -0
- data/lib/sorbet_progress/cli.rb +32 -23
- data/lib/sorbet_progress/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a0c93d4070d02f6d4bbecf66b9fb82fda2a295600e3bc6f2e1a9a1b24e02fc3b
|
4
|
+
data.tar.gz: 93401c06da1739b906d904487d5a26d37785b625156eb7652cfc3425950b1e11
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8231c1f39a740fc5882e6dc49ce0c25f15c834e72a7f55446c56afd0a6a7ed5dde217f612fddf8f469b6f03718dee3aafa237c070da92e8c6f709f12a74fe8d6
|
7
|
+
data.tar.gz: 3b26b8c21c39118bda7b3023338fc76956522df3ddaa85f54470726d7c1f5aa92a21b7ccb17a1c632eeb1af0569fcaf90e358a901b1489609e1c5b7a35b75564
|
data/.gitignore
CHANGED
data/README.md
CHANGED
@@ -25,14 +25,21 @@ Or install it yourself:
|
|
25
25
|
bundle exec srb tc --metrics-file /tmp/sorbet_metrics.json
|
26
26
|
# No errors! Great job.
|
27
27
|
bundle exec sorbet_progress /tmp/sorbet_metrics.json
|
28
|
-
#
|
29
|
-
|
30
|
-
#
|
31
|
-
#
|
32
|
-
#
|
33
|
-
#
|
34
|
-
|
35
|
-
#
|
28
|
+
# Sorbet Progress
|
29
|
+
|
30
|
+
# Progress for sig coverage
|
31
|
+
# total_signatures 7528
|
32
|
+
# total_methods 183447
|
33
|
+
# total_classes 112433
|
34
|
+
|
35
|
+
# Progress for file coverage
|
36
|
+
# sigil_ignore 12 0.20 %
|
37
|
+
# sigil_false 5466 91.60 %
|
38
|
+
# sigil_true 460 7.71 %
|
39
|
+
# sigil_strict 12 0.20 %
|
40
|
+
# sigil_strong 17 0.28 %
|
41
|
+
# ---------------------------------------
|
42
|
+
# Total: 5967 100%
|
36
43
|
# Keep up the good work 👍
|
37
44
|
```
|
38
45
|
|
@@ -0,0 +1,64 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# typed: true
|
4
|
+
|
5
|
+
module SorbetProgress
|
6
|
+
# Computes the percentage stats for sigil metrics as well as other stats.
|
7
|
+
class Calculator
|
8
|
+
extend T::Sig
|
9
|
+
|
10
|
+
attr_reader :total, :sigil_percentages, :coverage_metrics
|
11
|
+
|
12
|
+
sig { params(metrics: Metrics).void }
|
13
|
+
def initialize(metrics)
|
14
|
+
values = collect_values(sigil_breakdown_stats, metrics)
|
15
|
+
@total = values.delete(:total_files)
|
16
|
+
|
17
|
+
@sigil_percentages = values.map do |label, value|
|
18
|
+
percentage = value * 1.0 / @total if @total && value
|
19
|
+
{
|
20
|
+
label: label,
|
21
|
+
value: value,
|
22
|
+
percentage: percentage
|
23
|
+
}
|
24
|
+
end
|
25
|
+
|
26
|
+
@coverage_metrics = collect_values(coverage_stats, metrics)
|
27
|
+
end
|
28
|
+
|
29
|
+
private
|
30
|
+
|
31
|
+
# Mapping of general coverage stats to their actual metric names.
|
32
|
+
sig { returns(T::Hash[Symbol, String]) }
|
33
|
+
def coverage_stats
|
34
|
+
{
|
35
|
+
total_signatures: "ruby_typer.unknown..types.sig.count",
|
36
|
+
total_methods: "ruby_typer.unknown..types.input.methods.total",
|
37
|
+
total_classes: "ruby_typer.unknown..types.input.classes.total",
|
38
|
+
}
|
39
|
+
end
|
40
|
+
|
41
|
+
# Mapping of sigil stats to their actual metric names.
|
42
|
+
sig { returns(T::Hash[Symbol, String]) }
|
43
|
+
def sigil_breakdown_stats
|
44
|
+
{
|
45
|
+
total_files: "ruby_typer.unknown..types.input.files",
|
46
|
+
sigil_ignore: "ruby_typer.unknown..types.input.files.sigil.ignore",
|
47
|
+
sigil_false: "ruby_typer.unknown..types.input.files.sigil.false",
|
48
|
+
sigil_true: "ruby_typer.unknown..types.input.files.sigil.true",
|
49
|
+
sigil_strict: "ruby_typer.unknown..types.input.files.sigil.strict",
|
50
|
+
sigil_strong: "ruby_typer.unknown..types.input.files.sigil.strong"
|
51
|
+
}
|
52
|
+
end
|
53
|
+
|
54
|
+
# Extract the requested metric values.
|
55
|
+
sig { params(requested_stats: T::Hash[Symbol, String], metrics: Metrics).returns(T::Hash[Symbol, T.nilable(Integer)]) }
|
56
|
+
def collect_values(requested_stats, metrics)
|
57
|
+
result = {}
|
58
|
+
requested_stats.map do |label, name|
|
59
|
+
result[label] = metrics[name]&.value
|
60
|
+
end
|
61
|
+
result
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
data/lib/sorbet_progress/cli.rb
CHANGED
@@ -2,6 +2,7 @@
|
|
2
2
|
|
3
3
|
# typed: true
|
4
4
|
|
5
|
+
require "sorbet_progress/calculator"
|
5
6
|
require "sorbet_progress/error"
|
6
7
|
require "sorbet_progress/metrics"
|
7
8
|
require "sorbet_progress/parser"
|
@@ -26,24 +27,30 @@ module SorbetProgress
|
|
26
27
|
sig { void }
|
27
28
|
def run
|
28
29
|
metrics = parse(@path)
|
29
|
-
puts "
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
30
|
+
puts "Sorbet Progress\n\n"
|
31
|
+
|
32
|
+
stats_calculator = Calculator.new(metrics)
|
33
|
+
|
34
|
+
puts "Progress for sig coverage"
|
35
|
+
stats_calculator.coverage_metrics.each do |label, value|
|
36
|
+
puts format_metric(label, value)
|
37
|
+
end
|
38
|
+
|
39
|
+
puts "\nProgress for file coverage"
|
40
|
+
|
41
|
+
stats_calculator.sigil_percentages.each do |elem|
|
42
|
+
percentage =
|
43
|
+
if elem[:percentage]
|
44
|
+
elem[:percentage] * 100
|
45
|
+
else
|
46
|
+
0
|
47
|
+
end
|
48
|
+
puts format("%-17s\t%d\t%.2f %%", elem[:label], elem[:value] || 0, percentage)
|
46
49
|
end
|
50
|
+
|
51
|
+
puts "---------------------------------------"
|
52
|
+
puts "Total: \t\t\t#{stats_calculator.total}\t100%"
|
53
|
+
|
47
54
|
puts "Keep up the good work 👍"
|
48
55
|
end
|
49
56
|
|
@@ -56,12 +63,14 @@ module SorbetProgress
|
|
56
63
|
raise Error.new(2, "Metrics file not found: " + e.message)
|
57
64
|
end
|
58
65
|
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
66
|
+
# Format a label and metric value into a presentable String.
|
67
|
+
sig { params(label: Symbol, value: Integer).returns(String) }
|
68
|
+
def format_metric(label, value)
|
69
|
+
if value.nil?
|
70
|
+
format("%-17s\tunknown", label)
|
71
|
+
else
|
72
|
+
format("%-17s\t%d", label, value)
|
73
|
+
end
|
65
74
|
end
|
66
75
|
end
|
67
76
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sorbet-progress
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jared Beck
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-10-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: sorbet
|
@@ -112,6 +112,7 @@ files:
|
|
112
112
|
- bin/sorbet_progress
|
113
113
|
- bin/test.sh
|
114
114
|
- lib/sorbet_progress.rb
|
115
|
+
- lib/sorbet_progress/calculator.rb
|
115
116
|
- lib/sorbet_progress/cli.rb
|
116
117
|
- lib/sorbet_progress/error.rb
|
117
118
|
- lib/sorbet_progress/metric.rb
|