skunk 0.5.2 → 0.5.3
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/.github/workflows/main.yml +21 -69
- data/.github/workflows/skunk.yml +4 -3
- data/.reek.yml +4 -3
- data/.rubocop_todo.yml +16 -16
- data/CHANGELOG.md +12 -1
- data/CONTRIBUTING.md +84 -0
- data/Gemfile +4 -0
- data/Gemfile-Ruby-2-4 +3 -0
- data/Gemfile-Ruby-2-5 +13 -0
- data/README.md +104 -156
- data/lib/skunk/cli/application.rb +3 -3
- data/lib/skunk/cli/options/argv.rb +1 -1
- data/lib/skunk/command_factory.rb +25 -0
- data/lib/skunk/commands/base.rb +20 -0
- data/lib/skunk/commands/compare.rb +64 -0
- data/lib/skunk/commands/compare_score.rb +39 -0
- data/lib/skunk/commands/default.rb +47 -0
- data/lib/skunk/commands/help.rb +25 -0
- data/lib/skunk/commands/shareable.rb +25 -0
- data/lib/skunk/{cli/commands → commands}/status_reporter.rb +1 -1
- data/lib/skunk/{cli/commands → commands}/status_sharer.rb +1 -3
- data/lib/skunk/commands/version.rb +20 -0
- data/lib/skunk/rubycritic/analysed_module.rb +15 -9
- data/lib/skunk/version.rb +1 -1
- data/skunk.gemspec +5 -6
- metadata +34 -50
- data/CODEOWNERS +0 -5
- data/lib/skunk/cli/command_factory.rb +0 -27
- data/lib/skunk/cli/commands/base.rb +0 -22
- data/lib/skunk/cli/commands/compare.rb +0 -66
- data/lib/skunk/cli/commands/compare_score.rb +0 -41
- data/lib/skunk/cli/commands/default.rb +0 -49
- data/lib/skunk/cli/commands/help.rb +0 -27
- data/lib/skunk/cli/commands/shareable.rb +0 -27
- data/lib/skunk/cli/commands/version.rb +0 -22
- /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/
|
|
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
|
|
@@ -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
|
-
# `
|
|
13
|
+
# `cost`
|
|
14
14
|
#
|
|
15
15
|
# If module has no coverage, skunk score is a penalized value of
|
|
16
|
-
# `
|
|
16
|
+
# `cost`
|
|
17
17
|
#
|
|
18
|
-
# For now the skunk_score is calculated by multiplying `
|
|
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 `
|
|
23
|
+
# When `cost` is 100 and module is perfectly covered:
|
|
24
24
|
# skunk_score => 100
|
|
25
25
|
#
|
|
26
|
-
# When `
|
|
26
|
+
# When `cost` is 100 and module is not covered at all:
|
|
27
27
|
# skunk_score => 100 * 100 = 10_000
|
|
28
28
|
#
|
|
29
|
-
# When `
|
|
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 *
|
|
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
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"
|
|
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", "~>
|
|
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"
|
|
45
|
+
spec.add_development_dependency "debug"
|
|
46
46
|
spec.add_development_dependency "minitest", "~> 5.8.4"
|
|
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"
|
|
52
|
-
spec.add_development_dependency "rubocop"
|
|
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.
|
|
4
|
+
version: 0.5.3
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Ernesto Tagwerker
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2023-12-01 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: rubycritic
|
|
@@ -36,42 +36,42 @@ dependencies:
|
|
|
36
36
|
requirements:
|
|
37
37
|
- - "~>"
|
|
38
38
|
- !ruby/object:Gem::Version
|
|
39
|
-
version:
|
|
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:
|
|
46
|
+
version: '3.0'
|
|
47
47
|
- !ruby/object:Gem::Dependency
|
|
48
|
-
name:
|
|
48
|
+
name: codecov
|
|
49
49
|
requirement: !ruby/object:Gem::Requirement
|
|
50
50
|
requirements:
|
|
51
51
|
- - "~>"
|
|
52
52
|
- !ruby/object:Gem::Version
|
|
53
|
-
version:
|
|
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:
|
|
60
|
+
version: 0.1.16
|
|
61
61
|
- !ruby/object:Gem::Dependency
|
|
62
|
-
name:
|
|
62
|
+
name: debug
|
|
63
63
|
requirement: !ruby/object:Gem::Requirement
|
|
64
64
|
requirements:
|
|
65
|
-
- - "
|
|
65
|
+
- - ">="
|
|
66
66
|
- !ruby/object:Gem::Version
|
|
67
|
-
version: 0
|
|
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
|
|
74
|
+
version: '0'
|
|
75
75
|
- !ruby/object:Gem::Dependency
|
|
76
76
|
name: minitest
|
|
77
77
|
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:
|
|
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:
|
|
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: '
|
|
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: '
|
|
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,11 @@ 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
235
|
- Gemfile-Ruby-2-4
|
|
236
|
+
- Gemfile-Ruby-2-5
|
|
250
237
|
- LICENSE.txt
|
|
251
238
|
- README.md
|
|
252
239
|
- Rakefile
|
|
@@ -254,19 +241,19 @@ files:
|
|
|
254
241
|
- fastruby-logo.png
|
|
255
242
|
- lib/skunk.rb
|
|
256
243
|
- 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
244
|
- lib/skunk/cli/options.rb
|
|
269
245
|
- lib/skunk/cli/options/argv.rb
|
|
246
|
+
- lib/skunk/command_factory.rb
|
|
247
|
+
- lib/skunk/commands/base.rb
|
|
248
|
+
- lib/skunk/commands/compare.rb
|
|
249
|
+
- lib/skunk/commands/compare_score.rb
|
|
250
|
+
- lib/skunk/commands/default.rb
|
|
251
|
+
- lib/skunk/commands/help.rb
|
|
252
|
+
- lib/skunk/commands/output.rb
|
|
253
|
+
- lib/skunk/commands/shareable.rb
|
|
254
|
+
- lib/skunk/commands/status_reporter.rb
|
|
255
|
+
- lib/skunk/commands/status_sharer.rb
|
|
256
|
+
- lib/skunk/commands/version.rb
|
|
270
257
|
- lib/skunk/rubycritic/analysed_module.rb
|
|
271
258
|
- lib/skunk/rubycritic/analysed_modules_collection.rb
|
|
272
259
|
- lib/skunk/version.rb
|
|
@@ -292,16 +279,13 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
292
279
|
- - ">="
|
|
293
280
|
- !ruby/object:Gem::Version
|
|
294
281
|
version: 2.4.0
|
|
295
|
-
- - "<"
|
|
296
|
-
- !ruby/object:Gem::Version
|
|
297
|
-
version: '3.2'
|
|
298
282
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
299
283
|
requirements:
|
|
300
284
|
- - ">="
|
|
301
285
|
- !ruby/object:Gem::Version
|
|
302
286
|
version: '0'
|
|
303
287
|
requirements: []
|
|
304
|
-
rubygems_version: 3.
|
|
288
|
+
rubygems_version: 3.4.21
|
|
305
289
|
signing_key:
|
|
306
290
|
specification_version: 4
|
|
307
291
|
summary: A library to assess code quality vs. code coverage
|
data/CODEOWNERS
DELETED
|
@@ -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
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
require "rubycritic/commands/default"
|
|
4
|
-
require "rubycritic/analysers_runner"
|
|
5
|
-
require "rubycritic/revision_comparator"
|
|
6
|
-
require "rubycritic/reporter"
|
|
7
|
-
|
|
8
|
-
require "skunk/cli/commands/base"
|
|
9
|
-
require "skunk/cli/commands/shareable"
|
|
10
|
-
require "skunk/cli/commands/status_reporter"
|
|
11
|
-
|
|
12
|
-
module Skunk
|
|
13
|
-
module Cli
|
|
14
|
-
module Command
|
|
15
|
-
# Default command runs a critique using RubyCritic and uses
|
|
16
|
-
# Skunk::Command::StatusReporter to report status
|
|
17
|
-
class Default < RubyCritic::Command::Default
|
|
18
|
-
include Skunk::Cli::Command::Shareable
|
|
19
|
-
|
|
20
|
-
def initialize(options)
|
|
21
|
-
super
|
|
22
|
-
@options = options
|
|
23
|
-
@status_reporter = Skunk::Command::StatusReporter.new(options)
|
|
24
|
-
end
|
|
25
|
-
|
|
26
|
-
# It generates a report and it returns an instance of
|
|
27
|
-
# Skunk::Command::StatusReporter
|
|
28
|
-
#
|
|
29
|
-
# @return [Skunk::Command::StatusReporter]
|
|
30
|
-
def execute
|
|
31
|
-
RubyCritic::Config.formats = []
|
|
32
|
-
|
|
33
|
-
report(critique)
|
|
34
|
-
|
|
35
|
-
status_reporter
|
|
36
|
-
end
|
|
37
|
-
|
|
38
|
-
# It connects the Skunk::Command::StatusReporter with the collection
|
|
39
|
-
# of analysed modules.
|
|
40
|
-
#
|
|
41
|
-
# @param [RubyCritic::AnalysedModulesCollection] A collection of analysed modules
|
|
42
|
-
def report(analysed_modules)
|
|
43
|
-
status_reporter.analysed_modules = analysed_modules
|
|
44
|
-
status_reporter.score = analysed_modules.score
|
|
45
|
-
end
|
|
46
|
-
end
|
|
47
|
-
end
|
|
48
|
-
end
|
|
49
|
-
end
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
require "skunk/cli/commands/base"
|
|
4
|
-
require "rubycritic/commands/help"
|
|
5
|
-
|
|
6
|
-
module Skunk
|
|
7
|
-
module Cli
|
|
8
|
-
module Command
|
|
9
|
-
# Knows how to guide user into using `skunk` properly
|
|
10
|
-
class Help < Skunk::Cli::Command::Base
|
|
11
|
-
# Outputs a help message
|
|
12
|
-
def execute
|
|
13
|
-
puts options[:help_text]
|
|
14
|
-
status_reporter
|
|
15
|
-
end
|
|
16
|
-
|
|
17
|
-
def sharing?
|
|
18
|
-
false
|
|
19
|
-
end
|
|
20
|
-
|
|
21
|
-
private
|
|
22
|
-
|
|
23
|
-
attr_reader :options, :status_reporter
|
|
24
|
-
end
|
|
25
|
-
end
|
|
26
|
-
end
|
|
27
|
-
end
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module Skunk
|
|
4
|
-
module Cli
|
|
5
|
-
module Command
|
|
6
|
-
# This is a module that will be used for sharing reports to a server
|
|
7
|
-
module Shareable
|
|
8
|
-
# It shares the report using SHARE_URL or https://skunk.fastruby.io. It
|
|
9
|
-
# will post all results in JSON format and return a status message.
|
|
10
|
-
#
|
|
11
|
-
# @param [Skunk::Command::StatusReporter] A status reporter with analysed modules
|
|
12
|
-
# :reek:FeatureEnvy
|
|
13
|
-
def share(reporter)
|
|
14
|
-
sharer = Skunk::Command::StatusSharer.new(@options)
|
|
15
|
-
sharer.status_reporter = reporter
|
|
16
|
-
sharer.share
|
|
17
|
-
end
|
|
18
|
-
|
|
19
|
-
# @return [Boolean] If the environment is set to share to an external
|
|
20
|
-
# service
|
|
21
|
-
def sharing?
|
|
22
|
-
ENV["SHARE"] == "true"
|
|
23
|
-
end
|
|
24
|
-
end
|
|
25
|
-
end
|
|
26
|
-
end
|
|
27
|
-
end
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
require "rubycritic/commands/version"
|
|
4
|
-
|
|
5
|
-
# nodoc #
|
|
6
|
-
module Skunk
|
|
7
|
-
module Cli
|
|
8
|
-
module Command
|
|
9
|
-
# Shows skunk version
|
|
10
|
-
class Version < RubyCritic::Command::Version
|
|
11
|
-
def execute
|
|
12
|
-
print Skunk::VERSION
|
|
13
|
-
status_reporter
|
|
14
|
-
end
|
|
15
|
-
|
|
16
|
-
def sharing?
|
|
17
|
-
false
|
|
18
|
-
end
|
|
19
|
-
end
|
|
20
|
-
end
|
|
21
|
-
end
|
|
22
|
-
end
|
|
File without changes
|