quality_report 1.6.0 → 1.7.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: eb26bd22c7b99d601f0eca7648de96e15dc06ac06b405c887cca9c92e96d353f
4
- data.tar.gz: 03bc3e1613cc9bdb6b84d123164ec213051054d5f05b9627ab57394ca9df721f
3
+ metadata.gz: 51abac0022982e8c18d66396b580a4acadcbc14f86fd698f6e551e0d95cd304a
4
+ data.tar.gz: 8f4c5b26c6dd55268206ebe402642a88a287e5339d93a7dcd2532b11093e5564
5
5
  SHA512:
6
- metadata.gz: 4a35e38922d52d49f34d6e4269e76aa1e43820f7c3d22ab569aa92667397cf3a1b9b0bfeed46fbc188bf3fcf9911166c6ec8372f074c033272e378b21a9e3383
7
- data.tar.gz: d841f2ecc4afc0bbefeacc3500be6132e976d82da5705759151527d8be64b03cfdb96083e2819eff1590d725d1f34e59b644c349bb6c08ef09146bf4e893211a
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.
@@ -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 |label, whole_count|
25
- part_count = part_data[label] || 0
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
- { label:, part_count:, whole_count:, percent: }
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, label = line.split(' ')
36
- hash[label] = count.to_i
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[:label], stats[:percent], stats[:part_count], stats[:whole_count]].join(',') }
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
- default_headings = ['Author', 'Percent Flagged', 'Flagged Lines', 'All lines']
50
- static_heading = colspec.keys&.first # Handle just one column for now
51
- all_headings = (default_headings + [static_heading]).compact
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[:label])
59
+ next if skip.include?(stats[:author])
59
60
 
60
- new_row = [
61
- { value: stats[:label], alignment: :left },
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 << new_row
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[:label]
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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module QualityReport
4
- VERSION = '1.6.0'
4
+ VERSION = '1.7.0'
5
5
  end
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.6.0
4
+ version: 1.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Robb Shecter