quality_report 1.0.0 → 1.2.0
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/README.md +2 -0
- data/exe/ruby-author-warnings +6 -4
- data/exe/ruby-line-authors +2 -2
- data/exe/ruby-quality-report +54 -10
- data/lib/quality_report/version.rb +1 -1
- metadata +15 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1aafbd19100b614829f3aa4a2d7043b7b7028da09443bb536e37ee809809b6c0
|
4
|
+
data.tar.gz: cf7797690c19a1dc7c1f89737d828a4270bee1b9c36c3183ea642109998fdb45
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e5b3663e60903633291665affbc5347c604fb60037adf8ac7661ddd82929009ad36335ad5e754d09f58b88f916df74d899ef7c75472fdbeb505ac3e2c06796a5
|
7
|
+
data.tar.gz: 9076995297047c26ede10b5c0c892a07eeb0b178e562da85aaf0a61a0a4e8bf173cfdecc62f86045d465d6c58a0d731923c871da28daa19604c2ea3c8e8038c8
|
data/README.md
CHANGED
data/exe/ruby-author-warnings
CHANGED
@@ -21,10 +21,12 @@ RUBOCOP_WARNINGS = `rubocop --format json --force-default-config --only Metrics/
|
|
21
21
|
|
22
22
|
LOCATIONS =
|
23
23
|
JSON
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
24
|
+
.parse(RUBOCOP_WARNINGS)['files']
|
25
|
+
.reject { |f| f['offenses'].empty? }
|
26
|
+
.map do |f|
|
27
|
+
f['offenses']
|
28
|
+
.map { |o| { path: f['path'], begin: o['location']['start_line'], end: o['location']['last_line'] } }
|
29
|
+
end
|
28
30
|
.flatten
|
29
31
|
|
30
32
|
LOCATIONS.each do |location|
|
data/exe/ruby-line-authors
CHANGED
data/exe/ruby-quality-report
CHANGED
@@ -1,4 +1,7 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
require 'tty-table'
|
2
5
|
|
3
6
|
#
|
4
7
|
# ruby-quality-report
|
@@ -14,11 +17,12 @@ def create_combined_stats(part_stats, whole_stats)
|
|
14
17
|
|
15
18
|
whole_data.map do |label, whole_count|
|
16
19
|
part_count = part_data[label] || 0
|
20
|
+
|
17
21
|
{
|
18
22
|
label:,
|
19
23
|
part_count:,
|
20
24
|
whole_count:,
|
21
|
-
percent: part_count.to_f / whole_count
|
25
|
+
percent: float_to_percent(part_count.to_f / whole_count)
|
22
26
|
}
|
23
27
|
end
|
24
28
|
end
|
@@ -27,27 +31,67 @@ def make_data_set(two_column_data)
|
|
27
31
|
hash = {}
|
28
32
|
two_column_data.each_line do |line|
|
29
33
|
count, label = line.split(' ')
|
30
|
-
hash[label]
|
34
|
+
hash[label] = count.to_i
|
31
35
|
end
|
32
36
|
hash
|
33
37
|
end
|
34
38
|
|
35
39
|
def generate_csv(combined_stats)
|
40
|
+
generate_data(combined_stats)
|
41
|
+
.map { |stats| [stats[:label], stats[:percent], stats[:part_count], stats[:whole_count]].join(',') }
|
42
|
+
.tap { |x| x.prepend(['Author,Percent Flagged,Flagged Lines,All Lines']) }
|
43
|
+
.join("\n")
|
44
|
+
end
|
45
|
+
|
46
|
+
def generate_table(combined_stats)
|
47
|
+
table = TTY::Table.new(header: ['Author', 'Percent Flagged', 'Flagged Lines', 'All Lines'])
|
48
|
+
|
49
|
+
generate_data(combined_stats).each do |stats|
|
50
|
+
next if should_skip?(stats)
|
51
|
+
|
52
|
+
table << [stats[:label], "#{stats[:percent]}%", stats[:part_count], stats[:whole_count]]
|
53
|
+
end
|
54
|
+
|
55
|
+
table.render(:unicode)
|
56
|
+
end
|
57
|
+
|
58
|
+
def generate_data(combined_stats)
|
36
59
|
combined_stats
|
37
|
-
.sort_by{|s| s[:percent]}
|
60
|
+
.sort_by { |s| s[:percent] }
|
38
61
|
.reverse
|
39
|
-
.map{ |stats| [stats[:label], stats[:percent], stats[:part_count], stats[:whole_count]].join(',') }
|
40
|
-
.tap{|x| x.prepend(["Author,Percent Flagged,Flagged Lines,All Lines"])}
|
41
|
-
.join("\n")
|
42
62
|
end
|
43
63
|
|
64
|
+
def should_skip?(stats)
|
65
|
+
less_than_200_lines_total?(stats) || no_commits_in_last_60_days?(stats)
|
66
|
+
end
|
67
|
+
|
68
|
+
def less_than_200_lines_total?(stats)
|
69
|
+
stats[:whole_count] < 200
|
70
|
+
end
|
71
|
+
|
72
|
+
def no_commits_in_last_60_days?(stats)
|
73
|
+
author = stats[:label]
|
74
|
+
|
75
|
+
# Get the last commit timestamp in Unix epoch format
|
76
|
+
last_commit = `git log -1 --format="%at" --author="#{author}"`.chomp
|
77
|
+
return true if last_commit.empty? # Handle case where author has no commits
|
78
|
+
|
79
|
+
# Convert Unix timestamp to Time object
|
80
|
+
last_commit_time = Time.at(last_commit.to_i)
|
81
|
+
sixty_days_ago = Time.now - (60 * 24 * 60 * 60) # 60 days in seconds
|
82
|
+
|
83
|
+
last_commit_time < sixty_days_ago
|
84
|
+
end
|
85
|
+
|
86
|
+
def float_to_percent(a_float)
|
87
|
+
(Float(a_float) * 100).round(1)
|
88
|
+
end
|
44
89
|
|
45
90
|
#
|
46
91
|
# Execution begins here
|
47
92
|
#
|
48
|
-
PART_STATS
|
49
|
-
WHOLE_STATS
|
50
|
-
|
93
|
+
PART_STATS = `ruby-author-warnings | frequency-list`.freeze
|
94
|
+
WHOLE_STATS = `ruby-line-authors | frequency-list`.freeze
|
51
95
|
COMBINED_STATS = create_combined_stats(PART_STATS, WHOLE_STATS)
|
52
96
|
|
53
|
-
puts
|
97
|
+
puts generate_table(COMBINED_STATS)
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: quality_report
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Robb Shecter
|
@@ -24,6 +24,20 @@ dependencies:
|
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '1.68'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: tty-table
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 0.12.0
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 0.12.0
|
27
41
|
- !ruby/object:Gem::Dependency
|
28
42
|
name: rspec
|
29
43
|
requirement: !ruby/object:Gem::Requirement
|