skunk 0.5.0 → 0.5.1
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/.reek.yml +2 -7
- data/.rubocop_todo.yml +8 -7
- data/CHANGELOG.md +6 -1
- data/lib/skunk/cli/commands/compare.rb +50 -34
- data/lib/skunk/cli/commands/compare_score.rb +28 -26
- data/lib/skunk/cli/commands/default.rb +3 -11
- data/lib/skunk/cli/commands/shareable.rb +21 -0
- data/lib/skunk/cli/commands/status_sharer.rb +0 -1
- data/lib/skunk/version.rb +1 -1
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a8741b921c9257b475b2bae0741cc039e8afef0556312667e57ba7986f10f7fa
|
4
|
+
data.tar.gz: 79cc09d05f4a7ac2de50461e3ec1c9351ab68803fd33c7d9166b0d1046051891
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 29cd83b1f165c6e52c0196495428c80f388fd7ca7b633fe01455665632337a8a07b4bcfa26c8d29c34a23101d69ccadf858cb1615aa66812aac603850899c6df
|
7
|
+
data.tar.gz: 6b22ce77d18d98dc8f53275dfde28453a5b877a9b6e30b30fe6393321daad3ae655f13502924ba42991efe4876765e0e0317dc1e1fa3c2e4b1a769ea10f01304
|
data/.reek.yml
CHANGED
@@ -9,14 +9,10 @@ detectors:
|
|
9
9
|
- Skunk::Command::StatusReporter#table
|
10
10
|
InstanceVariableAssumption:
|
11
11
|
exclude:
|
12
|
-
- Skunk::Cli::Command::Default
|
13
12
|
- Skunk::Cli::Options::Argv
|
14
13
|
- RubyCritic::AnalysedModulesCollection
|
15
14
|
IrresponsibleModule:
|
16
15
|
exclude:
|
17
|
-
- Skunk::Cli::Command::Help
|
18
|
-
- Skunk::Cli::Options::Argv
|
19
|
-
- Skunk::Cli::Options
|
20
16
|
- RubyCritic::AnalysedModulesCollection
|
21
17
|
NestedIterators:
|
22
18
|
exclude:
|
@@ -28,6 +24,5 @@ detectors:
|
|
28
24
|
- Skunk::Cli::Options::Argv#parse
|
29
25
|
UtilityFunction:
|
30
26
|
exclude:
|
31
|
-
-
|
32
|
-
- Skunk::Command::Compare#
|
33
|
-
- Skunk::Command::Compare#build_details_path
|
27
|
+
- Skunk::Cli::Command::Compare#analyse_modified_files
|
28
|
+
- Skunk::Cli::Command::Compare#build_details_path
|
data/.rubocop_todo.yml
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# This configuration was generated by
|
2
2
|
# `rubocop --auto-gen-config`
|
3
|
-
# on
|
3
|
+
# on 2021-02-12 01:27:25 UTC using RuboCop version 1.9.1.
|
4
4
|
# The point is for the user to remove these configuration records
|
5
5
|
# one by one as the offenses are removed from the code base.
|
6
6
|
# Note that changes in the inspected code, or installation of new
|
@@ -40,24 +40,25 @@ Lint/MissingSuper:
|
|
40
40
|
- 'lib/skunk/cli/commands/base.rb'
|
41
41
|
|
42
42
|
# Offense count: 1
|
43
|
-
# Configuration parameters: IgnoredMethods.
|
43
|
+
# Configuration parameters: IgnoredMethods, CountRepeatedAttributes.
|
44
44
|
Metrics/AbcSize:
|
45
45
|
Max: 18
|
46
46
|
|
47
|
-
# Offense count:
|
48
|
-
# Configuration parameters: CountComments, CountAsOne, ExcludedMethods.
|
49
|
-
#
|
47
|
+
# Offense count: 7
|
48
|
+
# Configuration parameters: CountComments, CountAsOne, ExcludedMethods, IgnoredMethods.
|
49
|
+
# IgnoredMethods: refine
|
50
50
|
Metrics/BlockLength:
|
51
|
-
Max:
|
51
|
+
Max: 72
|
52
52
|
|
53
53
|
# Offense count: 2
|
54
|
-
# Configuration parameters: CountComments, CountAsOne, ExcludedMethods.
|
54
|
+
# Configuration parameters: CountComments, CountAsOne, ExcludedMethods, IgnoredMethods.
|
55
55
|
Metrics/MethodLength:
|
56
56
|
Max: 13
|
57
57
|
|
58
58
|
# Offense count: 1
|
59
59
|
# Configuration parameters: EnforcedStyle, CheckMethodNames, CheckSymbols, AllowedIdentifiers.
|
60
60
|
# SupportedStyles: snake_case, normalcase, non_integer
|
61
|
+
# AllowedIdentifiers: capture3, iso8601, rfc1123_date, rfc822, rfc2822, rfc3339
|
61
62
|
Naming/VariableNumber:
|
62
63
|
Exclude:
|
63
64
|
- 'lib/skunk/cli/commands/status_sharer.rb'
|
data/CHANGELOG.md
CHANGED
@@ -5,7 +5,12 @@ All notable changes to this project will be documented in this file.
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
7
7
|
|
8
|
-
## [Unreleased] [(commits)](https://github.com/fastruby/skunk/compare/v0.5.
|
8
|
+
## [Unreleased] [(commits)](https://github.com/fastruby/skunk/compare/v0.5.1...HEAD)
|
9
|
+
|
10
|
+
## [0.5.1] [(commits)](https://github.com/fastruby/skunk/compare/v0.5.0...v0.5.1)
|
11
|
+
|
12
|
+
* [BUGFIX] Fix bug related to compare plus share code (by [@etagwerker]())
|
13
|
+
|
9
14
|
## [0.5.0] [(commits)](https://github.com/fastruby/skunk/compare/v0.4.2...v0.5.0)
|
10
15
|
|
11
16
|
* [FEATURE] Share your results using an environment variable (by [@rahulpuroht]() and [@etagwerker]())
|
@@ -3,47 +3,63 @@
|
|
3
3
|
require "rubycritic/commands/compare"
|
4
4
|
require "skunk/rubycritic/analysed_modules_collection"
|
5
5
|
require "skunk/cli/commands/output"
|
6
|
+
require "skunk/cli/commands/shareable"
|
6
7
|
require "skunk/cli/commands/compare_score"
|
7
8
|
|
8
9
|
# nodoc #
|
9
10
|
module Skunk
|
10
|
-
module
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
::RubyCritic::SourceControlSystem::Git.switch_branch(::RubyCritic::Config.send(branch))
|
16
|
-
critic = critique(branch)
|
17
|
-
::RubyCritic::Config.send(:"#{branch}_score=", critic.skunk_score_average)
|
18
|
-
::RubyCritic::Config.root = branch_directory(branch)
|
19
|
-
end
|
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
|
20
16
|
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
::RubyCritic::AnalysedModulesCollection.new(modified_files.map(&:path),
|
27
|
-
modified_files)
|
28
|
-
::RubyCritic::Config.root = "#{::RubyCritic::Config.root}/compare"
|
29
|
-
end
|
17
|
+
def initialize(options)
|
18
|
+
super
|
19
|
+
@options = options
|
20
|
+
@status_reporter = Skunk::Command::StatusReporter.new(options)
|
21
|
+
end
|
30
22
|
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
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
|
44
59
|
|
45
|
-
|
46
|
-
|
60
|
+
def build_details_path
|
61
|
+
"#{::RubyCritic::Config.compare_root_directory}/build_details.txt"
|
62
|
+
end
|
47
63
|
end
|
48
64
|
end
|
49
65
|
end
|
@@ -2,37 +2,39 @@
|
|
2
2
|
|
3
3
|
# nodoc #
|
4
4
|
module Skunk
|
5
|
-
module
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
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
|
14
15
|
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
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
|
22
23
|
|
23
|
-
|
24
|
-
|
25
|
-
|
24
|
+
def score_evolution_message
|
25
|
+
"Skunk score average is #{score_evolution} #{score_evolution_appreciation} \n"
|
26
|
+
end
|
26
27
|
|
27
|
-
|
28
|
-
|
29
|
-
|
28
|
+
def score_evolution_appreciation
|
29
|
+
@feature_branch_score > @base_branch_score ? "worse" : "better"
|
30
|
+
end
|
30
31
|
|
31
|
-
|
32
|
-
|
32
|
+
def score_evolution
|
33
|
+
return "Infinitely" if @base_branch_score.zero?
|
33
34
|
|
34
|
-
|
35
|
-
|
35
|
+
precentage = (100 * (@base_branch_score - @feature_branch_score) / @base_branch_score)
|
36
|
+
"#{precentage.round(0).abs}%"
|
37
|
+
end
|
36
38
|
end
|
37
39
|
end
|
38
40
|
end
|
@@ -6,6 +6,7 @@ require "rubycritic/revision_comparator"
|
|
6
6
|
require "rubycritic/reporter"
|
7
7
|
|
8
8
|
require "skunk/cli/commands/base"
|
9
|
+
require "skunk/cli/commands/shareable"
|
9
10
|
require "skunk/cli/commands/status_reporter"
|
10
11
|
|
11
12
|
module Skunk
|
@@ -14,6 +15,8 @@ module Skunk
|
|
14
15
|
# Default command runs a critique using RubyCritic and uses
|
15
16
|
# Skunk::Command::StatusReporter to report status
|
16
17
|
class Default < RubyCritic::Command::Default
|
18
|
+
include Skunk::Cli::Command::Shareable
|
19
|
+
|
17
20
|
def initialize(options)
|
18
21
|
super
|
19
22
|
@options = options
|
@@ -40,17 +43,6 @@ module Skunk
|
|
40
43
|
status_reporter.analysed_modules = analysed_modules
|
41
44
|
status_reporter.score = analysed_modules.score
|
42
45
|
end
|
43
|
-
|
44
|
-
# It shares the report using SHARE_URL or https://skunk.fastruby.io. It
|
45
|
-
# will post all results in JSON format and return a status message.
|
46
|
-
#
|
47
|
-
# @param [Skunk::Command::StatusReporter] A status reporter with analysed modules
|
48
|
-
# :reek:FeatureEnvy
|
49
|
-
def share(reporter)
|
50
|
-
sharer = Skunk::Command::StatusSharer.new(@options)
|
51
|
-
sharer.status_reporter = reporter
|
52
|
-
sharer.share
|
53
|
-
end
|
54
46
|
end
|
55
47
|
end
|
56
48
|
end
|
@@ -0,0 +1,21 @@
|
|
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
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
data/lib/skunk/version.rb
CHANGED
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.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ernesto Tagwerker
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-02-
|
11
|
+
date: 2021-02-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rubycritic
|
@@ -261,6 +261,7 @@ files:
|
|
261
261
|
- lib/skunk/cli/commands/default.rb
|
262
262
|
- lib/skunk/cli/commands/help.rb
|
263
263
|
- lib/skunk/cli/commands/output.rb
|
264
|
+
- lib/skunk/cli/commands/shareable.rb
|
264
265
|
- lib/skunk/cli/commands/status_reporter.rb
|
265
266
|
- lib/skunk/cli/commands/status_sharer.rb
|
266
267
|
- lib/skunk/cli/commands/version.rb
|
@@ -299,7 +300,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
299
300
|
- !ruby/object:Gem::Version
|
300
301
|
version: '0'
|
301
302
|
requirements: []
|
302
|
-
rubygems_version: 3.
|
303
|
+
rubygems_version: 3.0.9
|
303
304
|
signing_key:
|
304
305
|
specification_version: 4
|
305
306
|
summary: A library to assess code quality vs. code coverage
|