skunk 0.5.0 → 0.5.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5df324d3763ea965d25b6eb21bb3b97969d5bb51ea89e64c198d05c81c9afd09
4
- data.tar.gz: 98e25d9fc2d2224a286a103bd74f98c97709a6004d785638b43ed08a68302da6
3
+ metadata.gz: a8741b921c9257b475b2bae0741cc039e8afef0556312667e57ba7986f10f7fa
4
+ data.tar.gz: 79cc09d05f4a7ac2de50461e3ec1c9351ab68803fd33c7d9166b0d1046051891
5
5
  SHA512:
6
- metadata.gz: 7ba5745cb720777d96ece4a927132cfea50eac70eee257a6f24bca3da94e91643a2ee5aaef5bd5bc7b50da00b2da20b024c2789ae26f5ef6297af1cb8d1bd352
7
- data.tar.gz: ae78c2425cc2d0ffa2b43ed0774fe3a4ae408d42784e7d1fcb7bc7ae76341cded3266f82c55bb6d814eabc0318378278c2a51b469cd8e097757516650588f0bb
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
- - capture_output_streams
32
- - Skunk::Command::Compare#analyse_modified_files
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 2020-11-18 21:57:13 UTC using RuboCop version 1.3.1.
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: 5
48
- # Configuration parameters: CountComments, CountAsOne, ExcludedMethods.
49
- # ExcludedMethods: refine
47
+ # Offense count: 7
48
+ # Configuration parameters: CountComments, CountAsOne, ExcludedMethods, IgnoredMethods.
49
+ # IgnoredMethods: refine
50
50
  Metrics/BlockLength:
51
- Max: 64
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.0...HEAD)
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 Command
11
- # Knows how to compare two branches and their skunk score average
12
- class Compare < RubyCritic::Command::Compare
13
- # switch branch and analyse files but don't generate a report
14
- def analyse_branch(branch)
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
- # generate report only for modified files but don't report it
22
- def analyse_modified_files
23
- modified_files = ::RubyCritic::Config
24
- .feature_branch_collection
25
- .where(::RubyCritic::SourceControlSystem::Git.modified_files)
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
- # create a txt file with the branch score details
32
- def build_details
33
- details = CompareScore.new(
34
- ::RubyCritic::Config.base_branch,
35
- ::RubyCritic::Config.feature_branch,
36
- ::RubyCritic::Config.base_branch_score.to_f.round(2),
37
- ::RubyCritic::Config.feature_branch_score.to_f.round(2)
38
- ).message
39
-
40
- Skunk::Command::Output.create_directory(::RubyCritic::Config.compare_root_directory)
41
- File.open(build_details_path, "w") { |file| file.write(details) }
42
- puts details
43
- end
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
- def build_details_path
46
- "#{::RubyCritic::Config.compare_root_directory}/build_details.txt"
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 Command
6
- # Knows how to describe score evolution between two branches
7
- class CompareScore
8
- def initialize(base_branch, feature_branch, base_branch_score, feature_branch_score)
9
- @base_branch = base_branch
10
- @feature_branch = feature_branch
11
- @base_branch_score = base_branch_score
12
- @feature_branch_score = feature_branch_score
13
- end
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
- def message
16
- "Base branch (#{@base_branch}) "\
17
- "average skunk score: #{@base_branch_score} \n"\
18
- "Feature branch (#{@feature_branch}) "\
19
- "average skunk score: #{@feature_branch_score} \n"\
20
- "#{score_evolution_message}"
21
- end
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
- def score_evolution_message
24
- "Skunk score average is #{score_evolution} #{score_evolution_appreciation} \n"
25
- end
24
+ def score_evolution_message
25
+ "Skunk score average is #{score_evolution} #{score_evolution_appreciation} \n"
26
+ end
26
27
 
27
- def score_evolution_appreciation
28
- @feature_branch_score > @base_branch_score ? "worse" : "better"
29
- end
28
+ def score_evolution_appreciation
29
+ @feature_branch_score > @base_branch_score ? "worse" : "better"
30
+ end
30
31
 
31
- def score_evolution
32
- return "Infinitely" if @base_branch_score.zero?
32
+ def score_evolution
33
+ return "Infinitely" if @base_branch_score.zero?
33
34
 
34
- precentage = (100 * (@base_branch_score - @feature_branch_score) / @base_branch_score)
35
- "#{precentage.round(0).abs}%"
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
@@ -15,7 +15,6 @@ module Skunk
15
15
  DEFAULT_URL = "https://skunk.fastruby.io"
16
16
  def status_reporter=(status_reporter)
17
17
  self.analysed_modules = status_reporter.analysed_modules
18
- self.score = analysed_modules.score
19
18
  end
20
19
 
21
20
  def share
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.0"
4
+ VERSION = "0.5.1"
5
5
  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.0
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-09 00:00:00.000000000 Z
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.2.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