Skip to content

Commit 2b5e5b2

Browse files
committed
Update Status Sharer to use skunk analysis from the collection module
1 parent 3985c8d commit 2b5e5b2

File tree

4 files changed

+17
-8
lines changed

4 files changed

+17
-8
lines changed

lib/skunk/commands/default.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ def execute
3737
# @param [RubyCritic::AnalysedModulesCollection] A collection of analysed modules
3838
def report(analysed_modules)
3939
Reporter.generate_report(analysed_modules)
40+
41+
status_reporter.analysed_modules = analysed_modules
4042
end
4143
end
4244
end

lib/skunk/commands/status_reporter.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ module Skunk
66
module Command
77
# Extends RubyCritic::Command::StatusReporter to silence the status message
88
class StatusReporter < RubyCritic::Command::StatusReporter
9+
attr_accessor :analysed_modules
10+
911
def initialize(options = {})
1012
super(options)
1113
end

lib/skunk/commands/status_sharer.rb

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,15 +40,16 @@ def base_url
4040

4141
def json_summary
4242
result = {
43-
total_skunk_score: total_skunk_score,
44-
analysed_modules_count: analysed_modules_count,
45-
skunk_score_average: skunk_score_average,
43+
total_skunk_score: analysed_modules.skunk_score_total,
44+
analysed_modules_count: analysed_modules.analysed_modules_count,
45+
skunk_score_average: analysed_modules.skunk_score_average,
4646
skunk_version: Skunk::VERSION
4747
}
4848

49-
if worst
49+
if analysed_modules&.worst_module
50+
worst = analysed_modules.worst_module
5051
result[:worst_skunk_score] = {
51-
file: worst.pathname.to_s,
52+
file: worst.pathname,
5253
skunk_score: worst.skunk_score
5354
}
5455
end
@@ -57,7 +58,7 @@ def json_summary
5758
end
5859

5960
def json_results
60-
sorted_modules.map(&:to_hash)
61+
analysed_modules.sorted_modules.map(&:to_hash)
6162
end
6263

6364
# :reek:UtilityFunction

lib/skunk/generators/json_report.rb

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ def initialize(analysed_modules)
1212

1313
def generate_report
1414
FileUtils.mkdir_p(generator.file_directory)
15-
puts "#{report_name} generated at #{generator.file_pathname}"
16-
File.write(generator.file_pathname, generator.render)
15+
puts "#{report_name} generated at #{file_path}"
16+
File.write(file_path, generator.render)
1717
end
1818

1919
private
@@ -28,6 +28,10 @@ def report_name
2828
.downcase
2929
.capitalize
3030
end
31+
32+
def file_path
33+
generator.file_pathname
34+
end
3135
end
3236
end
3337
end

0 commit comments

Comments
 (0)