skunk 0.5.2 → 0.5.4

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.
Files changed (40) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/main.yml +12 -92
  3. data/.github/workflows/skunk.yml +4 -3
  4. data/.gitignore +1 -0
  5. data/.reek.yml +4 -3
  6. data/.rubocop_todo.yml +25 -17
  7. data/CHANGELOG.md +18 -1
  8. data/CONTRIBUTING.md +84 -0
  9. data/Gemfile +4 -0
  10. data/README.md +108 -156
  11. data/lib/skunk/cli/application.rb +3 -3
  12. data/lib/skunk/cli/options/argv.rb +1 -1
  13. data/lib/skunk/command_factory.rb +25 -0
  14. data/lib/skunk/commands/base.rb +21 -0
  15. data/lib/skunk/commands/compare.rb +64 -0
  16. data/lib/skunk/commands/compare_score.rb +39 -0
  17. data/lib/skunk/commands/default.rb +48 -0
  18. data/lib/skunk/commands/help.rb +25 -0
  19. data/lib/skunk/commands/shareable.rb +25 -0
  20. data/lib/skunk/{cli/commands → commands}/status_reporter.rb +1 -1
  21. data/lib/skunk/{cli/commands → commands}/status_sharer.rb +1 -3
  22. data/lib/skunk/commands/version.rb +20 -0
  23. data/lib/skunk/generators/json/simple.rb +58 -0
  24. data/lib/skunk/generators/json_report.rb +23 -0
  25. data/lib/skunk/reporter.rb +25 -0
  26. data/lib/skunk/rubycritic/analysed_module.rb +15 -9
  27. data/lib/skunk/version.rb +1 -1
  28. data/skunk.gemspec +6 -7
  29. metadata +40 -55
  30. data/CODEOWNERS +0 -5
  31. data/Gemfile-Ruby-2-4 +0 -10
  32. data/lib/skunk/cli/command_factory.rb +0 -27
  33. data/lib/skunk/cli/commands/base.rb +0 -22
  34. data/lib/skunk/cli/commands/compare.rb +0 -66
  35. data/lib/skunk/cli/commands/compare_score.rb +0 -41
  36. data/lib/skunk/cli/commands/default.rb +0 -49
  37. data/lib/skunk/cli/commands/help.rb +0 -27
  38. data/lib/skunk/cli/commands/shareable.rb +0 -27
  39. data/lib/skunk/cli/commands/version.rb +0 -22
  40. /data/lib/skunk/{cli/commands → commands}/output.rb +0 -0
@@ -4,7 +4,7 @@ require "net/http"
4
4
  require "net/https"
5
5
  require "json"
6
6
 
7
- require "skunk/cli/commands/status_reporter"
7
+ require "skunk/commands/status_reporter"
8
8
 
9
9
  module Skunk
10
10
  module Command
@@ -38,7 +38,6 @@ module Skunk
38
38
  ENV["SHARE_URL"] || DEFAULT_URL
39
39
  end
40
40
 
41
- # rubocop:disable Style/HashSyntax
42
41
  def json_summary
43
42
  result = {
44
43
  total_skunk_score: total_skunk_score,
@@ -56,7 +55,6 @@ module Skunk
56
55
 
57
56
  result
58
57
  end
59
- # rubocop:enable Style/HashSyntax
60
58
 
61
59
  def json_results
62
60
  sorted_modules.map(&:to_hash)
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "rubycritic/commands/version"
4
+
5
+ # nodoc #
6
+ module Skunk
7
+ module Command
8
+ # Shows skunk version
9
+ class Version < RubyCritic::Command::Version
10
+ def execute
11
+ print Skunk::VERSION
12
+ status_reporter
13
+ end
14
+
15
+ def sharing?
16
+ false
17
+ end
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,58 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "rubycritic/generators/json/simple"
4
+
5
+ module Skunk
6
+ module Generator
7
+ module Json
8
+ # Generates a JSON report for the analysed modules.
9
+ class Simple < RubyCritic::Generator::Json::Simple
10
+ def data
11
+ {
12
+ analysed_modules_count: analysed_modules_count,
13
+ skunk_score_average: skunk_score_average,
14
+ skunk_score_total: skunk_score_total,
15
+ worst_pathname: worst&.pathname,
16
+ worst_score: worst&.skunk_score,
17
+ files: files
18
+ }
19
+ end
20
+
21
+ private
22
+
23
+ def analysed_modules_count
24
+ @analysed_modules_count ||= non_test_modules.count
25
+ end
26
+
27
+ def skunk_score_average
28
+ return 0 if analysed_modules_count.zero?
29
+
30
+ (skunk_score_total.to_d / analysed_modules_count).to_f.round(2)
31
+ end
32
+
33
+ def skunk_score_total
34
+ @skunk_score_total ||= non_test_modules.sum(&:skunk_score)
35
+ end
36
+
37
+ def non_test_modules
38
+ @non_test_modules ||= @analysed_modules.reject do |a_module|
39
+ module_path = a_module.pathname.dirname.to_s
40
+ module_path.start_with?("test", "spec") || module_path.end_with?("test", "spec")
41
+ end
42
+ end
43
+
44
+ def worst
45
+ @worst ||= sorted_modules.first
46
+ end
47
+
48
+ def sorted_modules
49
+ @sorted_modules ||= non_test_modules.sort_by(&:skunk_score).reverse!
50
+ end
51
+
52
+ def files
53
+ @files ||= sorted_modules.map(&:to_hash)
54
+ end
55
+ end
56
+ end
57
+ end
58
+ end
@@ -0,0 +1,23 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "rubycritic/generators/json_report"
4
+
5
+ require "skunk/generators/json/simple"
6
+
7
+ module Skunk
8
+ module Generator
9
+ # Generates a JSON report for the analysed modules.
10
+ class JsonReport < RubyCritic::Generator::JsonReport
11
+ def initialize(analysed_modules)
12
+ super
13
+ @analysed_modules = analysed_modules
14
+ end
15
+
16
+ private
17
+
18
+ def generator
19
+ Skunk::Generator::Json::Simple.new(@analysed_modules)
20
+ end
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,25 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Skunk
4
+ # Pick the right report generator based on the format specified in the
5
+ # configuration. If the format is not supported, it will default to ConsoleReport.
6
+ module Reporter
7
+ REPORT_GENERATOR_CLASS_FORMATS = %i[json].freeze
8
+
9
+ def self.generate_report(analysed_modules)
10
+ RubyCritic::Config.formats.uniq.each do |format|
11
+ report_generator_class(format).new(analysed_modules).generate_report
12
+ end
13
+ end
14
+
15
+ def self.report_generator_class(config_format)
16
+ if REPORT_GENERATOR_CLASS_FORMATS.include? config_format
17
+ require "skunk/generators/#{config_format}_report"
18
+ Generator.const_get("#{config_format.capitalize}Report")
19
+ else
20
+ require "skunk/generators/console_report"
21
+ Generator::ConsoleReport
22
+ end
23
+ end
24
+ end
25
+ end
@@ -10,30 +10,38 @@ module RubyCritic
10
10
  # Returns a numeric value that represents the skunk_score of a module:
11
11
  #
12
12
  # If module is perfectly covered, skunk score is the same as the
13
- # `churn_times_cost`
13
+ # `cost`
14
14
  #
15
15
  # If module has no coverage, skunk score is a penalized value of
16
- # `churn_times_cost`
16
+ # `cost`
17
17
  #
18
- # For now the skunk_score is calculated by multiplying `churn_times_cost`
18
+ # For now the skunk_score is calculated by multiplying `cost`
19
19
  # times the lack of coverage.
20
20
  #
21
21
  # For example:
22
22
  #
23
- # When `churn_times_cost` is 100 and module is perfectly covered:
23
+ # When `cost` is 100 and module is perfectly covered:
24
24
  # skunk_score => 100
25
25
  #
26
- # When `churn_times_cost` is 100 and module is not covered at all:
26
+ # When `cost` is 100 and module is not covered at all:
27
27
  # skunk_score => 100 * 100 = 10_000
28
28
  #
29
- # When `churn_times_cost` is 100 and module is covered at 75%:
29
+ # When `cost` is 100 and module is covered at 75%:
30
30
  # skunk_score => 100 * 25 (percentage uncovered) = 2_500
31
31
  #
32
32
  # @return [Float]
33
33
  def skunk_score
34
34
  return cost.round(2) if coverage == PERFECT_COVERAGE
35
35
 
36
- (cost * (PERFECT_COVERAGE - coverage.to_i)).round(2)
36
+ (cost * penalty_factor).round(2)
37
+ end
38
+
39
+ # Returns a numeric value that represents the penalty factor based
40
+ # on the lack of code coverage (not enough test cases for this module)
41
+ #
42
+ # @return [Integer]
43
+ def penalty_factor
44
+ PERFECT_COVERAGE - coverage.to_i
37
45
  end
38
46
 
39
47
  # Returns the value of churn times cost.
@@ -53,7 +61,6 @@ module RubyCritic
53
61
  # - coverage
54
62
  #
55
63
  # @return [Hash]
56
- # rubocop:disable Style/HashSyntax
57
64
  def to_hash
58
65
  {
59
66
  file: pathname.to_s,
@@ -64,6 +71,5 @@ module RubyCritic
64
71
  coverage: coverage.round(2)
65
72
  }
66
73
  end
67
- # rubocop:enable Style/HashSyntax
68
74
  end
69
75
  end
data/lib/skunk/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Skunk
4
- VERSION = "0.5.2"
4
+ VERSION = "0.5.4"
5
5
  end
data/skunk.gemspec CHANGED
@@ -14,7 +14,7 @@ Gem::Specification.new do |spec|
14
14
  spec.description = "Knows how to calculate the SkunkScore for a set of Ruby modules"
15
15
  spec.homepage = "https://github.com/fastruby/skunk"
16
16
 
17
- spec.required_ruby_version = [">= 2.4.0", "< 3.2"]
17
+ spec.required_ruby_version = [">= 2.4.0"]
18
18
 
19
19
  # Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
20
20
  # to allow pushing to a single host or delete this section to allow pushing to any host.
@@ -39,19 +39,18 @@ Gem::Specification.new do |spec|
39
39
  spec.require_paths = ["lib"]
40
40
 
41
41
  spec.add_dependency "rubycritic", ">= 4.5.2", "< 5.0"
42
- spec.add_dependency "terminal-table", "~> 1.8.0"
42
+ spec.add_dependency "terminal-table", "~> 3.0"
43
43
 
44
- spec.add_development_dependency "byebug", "~> 11"
45
44
  spec.add_development_dependency "codecov", "~> 0.1.16"
46
- spec.add_development_dependency "minitest", "~> 5.8.4"
45
+ spec.add_development_dependency "debug"
46
+ spec.add_development_dependency "minitest", "< 6"
47
47
  spec.add_development_dependency "minitest-around", "~> 0.5.0"
48
48
  spec.add_development_dependency "minitest-stub_any_instance", "~> 1.0.2"
49
49
  spec.add_development_dependency "minitest-stub-const", "~> 0.6"
50
50
  spec.add_development_dependency "rake", "~> 13.0"
51
- spec.add_development_dependency "reek", "~> 6.0.0"
52
- spec.add_development_dependency "rubocop", "~> 1.0"
51
+ spec.add_development_dependency "reek"
52
+ spec.add_development_dependency "rubocop"
53
53
  spec.add_development_dependency "simplecov", "~> 0.18"
54
54
  spec.add_development_dependency "simplecov-console", "0.5.0"
55
- spec.add_development_dependency "vcr", "~> 6.0.0"
56
55
  spec.add_development_dependency "webmock", "~> 3.10.0"
57
56
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: skunk
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.2
4
+ version: 0.5.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ernesto Tagwerker
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-04-27 00:00:00.000000000 Z
11
+ date: 2025-05-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rubycritic
@@ -36,56 +36,56 @@ dependencies:
36
36
  requirements:
37
37
  - - "~>"
38
38
  - !ruby/object:Gem::Version
39
- version: 1.8.0
39
+ version: '3.0'
40
40
  type: :runtime
41
41
  prerelease: false
42
42
  version_requirements: !ruby/object:Gem::Requirement
43
43
  requirements:
44
44
  - - "~>"
45
45
  - !ruby/object:Gem::Version
46
- version: 1.8.0
46
+ version: '3.0'
47
47
  - !ruby/object:Gem::Dependency
48
- name: byebug
48
+ name: codecov
49
49
  requirement: !ruby/object:Gem::Requirement
50
50
  requirements:
51
51
  - - "~>"
52
52
  - !ruby/object:Gem::Version
53
- version: '11'
53
+ version: 0.1.16
54
54
  type: :development
55
55
  prerelease: false
56
56
  version_requirements: !ruby/object:Gem::Requirement
57
57
  requirements:
58
58
  - - "~>"
59
59
  - !ruby/object:Gem::Version
60
- version: '11'
60
+ version: 0.1.16
61
61
  - !ruby/object:Gem::Dependency
62
- name: codecov
62
+ name: debug
63
63
  requirement: !ruby/object:Gem::Requirement
64
64
  requirements:
65
- - - "~>"
65
+ - - ">="
66
66
  - !ruby/object:Gem::Version
67
- version: 0.1.16
67
+ version: '0'
68
68
  type: :development
69
69
  prerelease: false
70
70
  version_requirements: !ruby/object:Gem::Requirement
71
71
  requirements:
72
- - - "~>"
72
+ - - ">="
73
73
  - !ruby/object:Gem::Version
74
- version: 0.1.16
74
+ version: '0'
75
75
  - !ruby/object:Gem::Dependency
76
76
  name: minitest
77
77
  requirement: !ruby/object:Gem::Requirement
78
78
  requirements:
79
- - - "~>"
79
+ - - "<"
80
80
  - !ruby/object:Gem::Version
81
- version: 5.8.4
81
+ version: '6'
82
82
  type: :development
83
83
  prerelease: false
84
84
  version_requirements: !ruby/object:Gem::Requirement
85
85
  requirements:
86
- - - "~>"
86
+ - - "<"
87
87
  - !ruby/object:Gem::Version
88
- version: 5.8.4
88
+ version: '6'
89
89
  - !ruby/object:Gem::Dependency
90
90
  name: minitest-around
91
91
  requirement: !ruby/object:Gem::Requirement
@@ -146,30 +146,30 @@ dependencies:
146
146
  name: reek
147
147
  requirement: !ruby/object:Gem::Requirement
148
148
  requirements:
149
- - - "~>"
149
+ - - ">="
150
150
  - !ruby/object:Gem::Version
151
- version: 6.0.0
151
+ version: '0'
152
152
  type: :development
153
153
  prerelease: false
154
154
  version_requirements: !ruby/object:Gem::Requirement
155
155
  requirements:
156
- - - "~>"
156
+ - - ">="
157
157
  - !ruby/object:Gem::Version
158
- version: 6.0.0
158
+ version: '0'
159
159
  - !ruby/object:Gem::Dependency
160
160
  name: rubocop
161
161
  requirement: !ruby/object:Gem::Requirement
162
162
  requirements:
163
- - - "~>"
163
+ - - ">="
164
164
  - !ruby/object:Gem::Version
165
- version: '1.0'
165
+ version: '0'
166
166
  type: :development
167
167
  prerelease: false
168
168
  version_requirements: !ruby/object:Gem::Requirement
169
169
  requirements:
170
- - - "~>"
170
+ - - ">="
171
171
  - !ruby/object:Gem::Version
172
- version: '1.0'
172
+ version: '0'
173
173
  - !ruby/object:Gem::Dependency
174
174
  name: simplecov
175
175
  requirement: !ruby/object:Gem::Requirement
@@ -198,20 +198,6 @@ dependencies:
198
198
  - - '='
199
199
  - !ruby/object:Gem::Version
200
200
  version: 0.5.0
201
- - !ruby/object:Gem::Dependency
202
- name: vcr
203
- requirement: !ruby/object:Gem::Requirement
204
- requirements:
205
- - - "~>"
206
- - !ruby/object:Gem::Version
207
- version: 6.0.0
208
- type: :development
209
- prerelease: false
210
- version_requirements: !ruby/object:Gem::Requirement
211
- requirements:
212
- - - "~>"
213
- - !ruby/object:Gem::Version
214
- version: 6.0.0
215
201
  - !ruby/object:Gem::Dependency
216
202
  name: webmock
217
203
  requirement: !ruby/object:Gem::Requirement
@@ -243,10 +229,9 @@ files:
243
229
  - ".rubocop.yml"
244
230
  - ".rubocop_todo.yml"
245
231
  - CHANGELOG.md
246
- - CODEOWNERS
247
232
  - CODE_OF_CONDUCT.md
233
+ - CONTRIBUTING.md
248
234
  - Gemfile
249
- - Gemfile-Ruby-2-4
250
235
  - LICENSE.txt
251
236
  - README.md
252
237
  - Rakefile
@@ -254,19 +239,22 @@ files:
254
239
  - fastruby-logo.png
255
240
  - lib/skunk.rb
256
241
  - lib/skunk/cli/application.rb
257
- - lib/skunk/cli/command_factory.rb
258
- - lib/skunk/cli/commands/base.rb
259
- - lib/skunk/cli/commands/compare.rb
260
- - lib/skunk/cli/commands/compare_score.rb
261
- - lib/skunk/cli/commands/default.rb
262
- - lib/skunk/cli/commands/help.rb
263
- - lib/skunk/cli/commands/output.rb
264
- - lib/skunk/cli/commands/shareable.rb
265
- - lib/skunk/cli/commands/status_reporter.rb
266
- - lib/skunk/cli/commands/status_sharer.rb
267
- - lib/skunk/cli/commands/version.rb
268
242
  - lib/skunk/cli/options.rb
269
243
  - lib/skunk/cli/options/argv.rb
244
+ - lib/skunk/command_factory.rb
245
+ - lib/skunk/commands/base.rb
246
+ - lib/skunk/commands/compare.rb
247
+ - lib/skunk/commands/compare_score.rb
248
+ - lib/skunk/commands/default.rb
249
+ - lib/skunk/commands/help.rb
250
+ - lib/skunk/commands/output.rb
251
+ - lib/skunk/commands/shareable.rb
252
+ - lib/skunk/commands/status_reporter.rb
253
+ - lib/skunk/commands/status_sharer.rb
254
+ - lib/skunk/commands/version.rb
255
+ - lib/skunk/generators/json/simple.rb
256
+ - lib/skunk/generators/json_report.rb
257
+ - lib/skunk/reporter.rb
270
258
  - lib/skunk/rubycritic/analysed_module.rb
271
259
  - lib/skunk/rubycritic/analysed_modules_collection.rb
272
260
  - lib/skunk/version.rb
@@ -292,16 +280,13 @@ required_ruby_version: !ruby/object:Gem::Requirement
292
280
  - - ">="
293
281
  - !ruby/object:Gem::Version
294
282
  version: 2.4.0
295
- - - "<"
296
- - !ruby/object:Gem::Version
297
- version: '3.2'
298
283
  required_rubygems_version: !ruby/object:Gem::Requirement
299
284
  requirements:
300
285
  - - ">="
301
286
  - !ruby/object:Gem::Version
302
287
  version: '0'
303
288
  requirements: []
304
- rubygems_version: 3.3.3
289
+ rubygems_version: 3.5.16
305
290
  signing_key:
306
291
  specification_version: 4
307
292
  summary: A library to assess code quality vs. code coverage
data/CODEOWNERS DELETED
@@ -1,5 +0,0 @@
1
-
2
- # These code owners will be the default owners to everything in the repository.
3
- # Unless a posterior rule has precedence, they will be automatically requested
4
- # for review when a pull request is opened.
5
- * @fastruby/black-bunny-brigade
data/Gemfile-Ruby-2-4 DELETED
@@ -1,10 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- source "https://rubygems.org"
4
-
5
- git_source(:github) { |repo_name| "https://github.com/#{repo_name}" }
6
-
7
- # Specify your gem's dependencies in skunk.gemspec
8
- gemspec
9
-
10
- gem "simplecov", "< 0.19.0"
@@ -1,27 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "rubycritic/command_factory"
4
-
5
- module Skunk
6
- module Cli
7
- # Knows how to calculate the command that was request by the CLI user
8
- class CommandFactory < RubyCritic::CommandFactory
9
- COMMAND_CLASS_MODES = %i[version help default compare].freeze
10
-
11
- # Returns the command class based on the command that was executed
12
- #
13
- # @param mode
14
- # @return [Class]
15
- def self.command_class(mode)
16
- mode = mode.to_s.split("_").first.to_sym
17
- if COMMAND_CLASS_MODES.include? mode
18
- require "skunk/cli/commands/#{mode}"
19
- Command.const_get(mode.capitalize)
20
- else
21
- require "skunk/cli/commands/default"
22
- Command::Default
23
- end
24
- end
25
- end
26
- end
27
- end
@@ -1,22 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "rubycritic/commands/base"
4
- require "skunk/cli/commands/status_reporter"
5
-
6
- module Skunk
7
- module Cli
8
- module Command
9
- # Base class for `Skunk` commands. It knows how to build a command with
10
- # options. It always uses a [Skunk::Command::StatusReporter] as its
11
- # reporter object.
12
- class Base < RubyCritic::Command::Base
13
- def initialize(options)
14
- @options = options
15
- @status_reporter = Skunk::Command::StatusReporter.new(@options)
16
- end
17
-
18
- def share(_); end
19
- end
20
- end
21
- end
22
- end
@@ -1,66 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "rubycritic/commands/compare"
4
- require "skunk/rubycritic/analysed_modules_collection"
5
- require "skunk/cli/commands/output"
6
- require "skunk/cli/commands/shareable"
7
- require "skunk/cli/commands/compare_score"
8
-
9
- # nodoc #
10
- module Skunk
11
- module Cli
12
- module Command
13
- # Knows how to compare two branches and their skunk score average
14
- class Compare < RubyCritic::Command::Compare
15
- include Skunk::Cli::Command::Shareable
16
-
17
- def initialize(options)
18
- super
19
- @options = options
20
- @status_reporter = Skunk::Command::StatusReporter.new(options)
21
- end
22
-
23
- def execute
24
- compare_branches
25
- status_reporter
26
- end
27
-
28
- # switch branch and analyse files but don't generate a report
29
- def analyse_branch(branch)
30
- ::RubyCritic::SourceControlSystem::Git.switch_branch(::RubyCritic::Config.send(branch))
31
- critic = critique(branch)
32
- ::RubyCritic::Config.send(:"#{branch}_score=", critic.skunk_score_average)
33
- ::RubyCritic::Config.root = branch_directory(branch)
34
- end
35
-
36
- # generate report only for modified files but don't report it
37
- def analyse_modified_files
38
- modified_files = ::RubyCritic::Config
39
- .feature_branch_collection
40
- .where(::RubyCritic::SourceControlSystem::Git.modified_files)
41
- ::RubyCritic::AnalysedModulesCollection.new(modified_files.map(&:path),
42
- modified_files)
43
- ::RubyCritic::Config.root = "#{::RubyCritic::Config.root}/compare"
44
- end
45
-
46
- # create a txt file with the branch score details
47
- def build_details
48
- details = CompareScore.new(
49
- ::RubyCritic::Config.base_branch,
50
- ::RubyCritic::Config.feature_branch,
51
- ::RubyCritic::Config.base_branch_score.to_f.round(2),
52
- ::RubyCritic::Config.feature_branch_score.to_f.round(2)
53
- ).message
54
-
55
- Skunk::Command::Output.create_directory(::RubyCritic::Config.compare_root_directory)
56
- File.open(build_details_path, "w") { |file| file.write(details) }
57
- puts details
58
- end
59
-
60
- def build_details_path
61
- "#{::RubyCritic::Config.compare_root_directory}/build_details.txt"
62
- end
63
- end
64
- end
65
- end
66
- end
@@ -1,41 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # nodoc #
4
- module Skunk
5
- module Cli
6
- module Command
7
- # Knows how to describe score evolution between two branches
8
- class CompareScore
9
- def initialize(base_branch, feature_branch, base_branch_score, feature_branch_score)
10
- @base_branch = base_branch
11
- @feature_branch = feature_branch
12
- @base_branch_score = base_branch_score
13
- @feature_branch_score = feature_branch_score
14
- end
15
-
16
- def message
17
- "Base branch (#{@base_branch}) "\
18
- "average skunk score: #{@base_branch_score} \n"\
19
- "Feature branch (#{@feature_branch}) "\
20
- "average skunk score: #{@feature_branch_score} \n"\
21
- "#{score_evolution_message}"
22
- end
23
-
24
- def score_evolution_message
25
- "Skunk score average is #{score_evolution} #{score_evolution_appreciation} \n"
26
- end
27
-
28
- def score_evolution_appreciation
29
- @feature_branch_score > @base_branch_score ? "worse" : "better"
30
- end
31
-
32
- def score_evolution
33
- return "Infinitely" if @base_branch_score.zero?
34
-
35
- precentage = (100 * (@base_branch_score - @feature_branch_score) / @base_branch_score)
36
- "#{precentage.round(0).abs}%"
37
- end
38
- end
39
- end
40
- end
41
- end