quality_report 1.6.0 → 1.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +2 -0
- data/exe/ruby-quality-report +20 -16
- data/lib/quality_report/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 51abac0022982e8c18d66396b580a4acadcbc14f86fd698f6e551e0d95cd304a
|
4
|
+
data.tar.gz: 8f4c5b26c6dd55268206ebe402642a88a287e5339d93a7dcd2532b11093e5564
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 701288fc0a288adba125cb2299810b79067ef86486ae1c94cdf87f86b0ebdf030226cb4c925c10a43455ee606a2a70f3396b5d538feb5b07200cbeedb22acde2
|
7
|
+
data.tar.gz: cfca2cab37975eed90e80b6c018f35c7a193f4977c7c6d62b21057f6d8513d0a3b3fd1bc33e4f1f9f826bbd5887bfd81bd7a69134b793cec5a22c6beb9c3138d
|
data/README.md
CHANGED
@@ -73,6 +73,8 @@ Complex code introduces bugs in a second, more subtle way. This is because code
|
|
73
73
|
|
74
74
|
- [x] Colorize the output to separate high, medium, and low warning percentages.
|
75
75
|
- [x] Fix the numerical alignment.
|
76
|
+
- [ ] --add-column option.
|
77
|
+
- [ ] --skip option.
|
76
78
|
- [ ] Add a progress bar.
|
77
79
|
- [ ] Speed up the scan.
|
78
80
|
- [ ] Refactor from script-style coding to a more standard Ruby project.
|
data/exe/ruby-quality-report
CHANGED
@@ -21,56 +21,60 @@ def create_combined_stats(part_stats, whole_stats)
|
|
21
21
|
part_data = make_data_set(part_stats)
|
22
22
|
whole_data = make_data_set(whole_stats)
|
23
23
|
|
24
|
-
whole_data.map do |
|
25
|
-
part_count = part_data[
|
24
|
+
whole_data.map do |author, whole_count|
|
25
|
+
part_count = part_data[author] || 0
|
26
26
|
percent = float_to_percent(part_count.to_f / whole_count)
|
27
27
|
|
28
|
-
{
|
28
|
+
{ author:, part_count:, whole_count:, percent: }
|
29
29
|
end
|
30
30
|
end
|
31
31
|
|
32
32
|
def make_data_set(two_column_data)
|
33
33
|
hash = {}
|
34
34
|
two_column_data.each_line do |line|
|
35
|
-
count,
|
36
|
-
hash[
|
35
|
+
count, author = line.split(' ')
|
36
|
+
hash[author] = count.to_i
|
37
37
|
end
|
38
38
|
hash
|
39
39
|
end
|
40
40
|
|
41
41
|
def generate_csv(combined_stats)
|
42
42
|
generate_data(combined_stats)
|
43
|
-
.map { |stats| [stats[:
|
43
|
+
.map { |stats| [stats[:author], stats[:percent], stats[:part_count], stats[:whole_count]].join(',') }
|
44
44
|
.tap { |x| x.prepend(['Author,Percent Flagged,Flagged Lines,All Lines']) }
|
45
45
|
.join("\n")
|
46
46
|
end
|
47
47
|
|
48
48
|
def generate_table(combined_stats, colspec: {}, skip: '')
|
49
|
-
|
50
|
-
static_heading = colspec.keys&.first
|
51
|
-
|
49
|
+
author_heading = ['Author']
|
50
|
+
static_heading = [colspec.keys&.first].compact
|
51
|
+
default_headings = ['Percent Flagged', 'Flagged Lines', 'All lines']
|
52
|
+
all_headings = author_heading + static_heading + default_headings
|
52
53
|
|
53
54
|
table = TTY::Table.new(header: all_headings)
|
54
55
|
table_data = generate_data(combined_stats).reject { should_skip?(_1) }
|
55
|
-
static_values = colspec[static_heading] || {}
|
56
|
+
static_values = colspec[static_heading.first] || {}
|
56
57
|
|
57
58
|
table_data.each do |stats|
|
58
|
-
next if skip.include?(stats[:
|
59
|
+
next if skip.include?(stats[:author])
|
59
60
|
|
60
|
-
|
61
|
-
|
61
|
+
author_column = [{ value: stats[:author], alignment: :left }]
|
62
|
+
static_column = [static_heading.any? ? { value: static_values[stats[:author]], alignment: :left } : nil]
|
63
|
+
dynamic_columns = [
|
62
64
|
{ value: "#{stats[:percent]}%", alignment: :right },
|
63
65
|
{ value: int_to_accounting(stats[:part_count]), alignment: :right },
|
64
66
|
{ value: int_to_accounting(stats[:whole_count]), alignment: :right }
|
65
67
|
]
|
66
|
-
new_row << { value: static_values[stats[:label]], alignment: :left } if static_heading
|
67
68
|
|
68
|
-
table <<
|
69
|
+
table << (author_column + static_column + dynamic_columns).compact
|
69
70
|
end
|
70
71
|
|
71
72
|
render_table(table, table_data)
|
72
73
|
end
|
73
74
|
|
75
|
+
##
|
76
|
+
# Renders the table with color coding based on the percentage of flagged lines.
|
77
|
+
#
|
74
78
|
def render_table(table, table_data)
|
75
79
|
pastel = Pastel.new
|
76
80
|
|
@@ -108,7 +112,7 @@ def less_than_200_lines_total?(stats)
|
|
108
112
|
end
|
109
113
|
|
110
114
|
def no_commits_in_last_60_days?(stats)
|
111
|
-
author = stats[:
|
115
|
+
author = stats[:author]
|
112
116
|
|
113
117
|
# Get the last commit timestamp in Unix epoch format
|
114
118
|
last_commit = `git log -1 --format="%at" --author="#{author}"`.chomp
|