skunk 0.5.3 → 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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 816d1842d51cccffa9e5284adc57ab7650bad54ef646e31bf8ac7941cd9dbb96
4
- data.tar.gz: aaa37f4214a723eaacb3ddbae476f084f75e13b2c3fd156ab841ff9d6930739c
3
+ metadata.gz: 0fc5fca985be539efe139317e8c6e94221f322a85ff1425ecb6111ac37a6b08a
4
+ data.tar.gz: 5286ff3133b6f9d3d9a17d117d275db45049f2e82470730f4abc224ae47adf96
5
5
  SHA512:
6
- metadata.gz: ede49233f3739dc19fb14bc2633acc8dbd2fbc87493673ed11eaeb22ecca3e7efa6e53c65b6e41548c8b30e00bb54349372429adc7fe9152fe77b8c12073bde1
7
- data.tar.gz: e22e1e0d5e2bb43f1f7188b7eda3d36613baa6c3e68dd2e63d7664f01b9f7f89cc9ff3be6b72d96d75a667ebf5f836d175df4a379162193865084ad4ec4abd31
6
+ metadata.gz: f4d0ad320ae6ac543bd86dca2beb7deca48a33b3f6ef418492b077460cff45245af9c8f10bb71bb42b5d1962b5e7a6784e2c28fabef83787703b48e2ec296d46
7
+ data.tar.gz: a469d5f01b8c97e68a8a1ce7e7d906a001d8a21a174afe469795b827aca2dfea06ea7a0179e2da533847969202d35343b6c147a8bd14221ffec8ecfb6e316e5c
@@ -4,44 +4,12 @@ name: CI
4
4
  on: [push, pull_request]
5
5
 
6
6
  jobs:
7
- test-ruby-2-4-x:
8
- runs-on: ubuntu-latest
9
- steps:
10
- - uses: actions/checkout@v2
11
- - name: Setup Ruby 2.4
12
- uses: ruby/setup-ruby@v1
13
- with:
14
- ruby-version: 2.4
15
- - name: Build and run tests
16
- env:
17
- BUNDLE_GEMFILE: "Gemfile-Ruby-2-4"
18
- run: |
19
- gem install bundler -v 2.3
20
- bundle install --jobs 4 --retry 3
21
- bundle exec rake
22
-
23
- test-ruby-2-5-x:
24
- runs-on: ubuntu-latest
25
- steps:
26
- - uses: actions/checkout@v2
27
- - name: Setup Ruby 2.5
28
- uses: ruby/setup-ruby@v1
29
- with:
30
- ruby-version: 2.5
31
- - name: Build and run tests
32
- env:
33
- BUNDLE_GEMFILE: "Gemfile-Ruby-2-5"
34
- run: |
35
- gem install bundler -v 2.3.26
36
- bundle install --jobs 4 --retry 3
37
- bundle exec rake
38
-
39
7
  test-ruby:
40
8
  runs-on: ${{ matrix.os }}-latest
41
9
  strategy:
42
10
  matrix:
43
11
  os: [ubuntu]
44
- ruby-version: ["2.6", "2.7", "3.0", "3.1", "3.2"]
12
+ ruby-version: ["2.6", "2.7", "3.0", "3.1", "3.2", "3.3"]
45
13
  steps:
46
14
  - uses: actions/checkout@v2
47
15
  - name: Setup Ruby ${{ matrix.ruby-version }}
@@ -6,11 +6,11 @@ jobs:
6
6
  runs-on: ubuntu-latest
7
7
 
8
8
  steps:
9
- - uses: actions/checkout@v2
9
+ - uses: actions/checkout@v4
10
10
  - name: Setup Ruby
11
11
  uses: ruby/setup-ruby@v1
12
12
  with:
13
- ruby-version: 3.1
13
+ ruby-version: 3.3
14
14
  bundler-cache: true
15
15
  - name: Run test suite with COVERAGE=true
16
16
  run: |
data/.gitignore CHANGED
@@ -11,3 +11,4 @@
11
11
  .byebug_history
12
12
 
13
13
  .ruby-version
14
+ .tool-versions
data/.rubocop_todo.yml CHANGED
@@ -1,6 +1,6 @@
1
1
  # This configuration was generated by
2
2
  # `rubocop --auto-gen-config`
3
- # on 2023-07-22 00:31:00 UTC using RuboCop version 1.54.2.
3
+ # on 2025-05-02 20:16:50 UTC using RuboCop version 1.75.4.
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
@@ -25,12 +25,11 @@ Layout/HeredocIndentation:
25
25
  Exclude:
26
26
  - 'lib/skunk/commands/status_reporter.rb'
27
27
 
28
- # Offense count: 2
28
+ # Offense count: 1
29
29
  # Configuration parameters: AllowedParentClasses.
30
30
  Lint/MissingSuper:
31
31
  Exclude:
32
32
  - 'lib/skunk/cli/application.rb'
33
- - 'lib/skunk/commands/base.rb'
34
33
 
35
34
  # Offense count: 1
36
35
  # Configuration parameters: AllowedMethods, AllowedPatterns, CountRepeatedAttributes.
@@ -51,7 +50,16 @@ Metrics/MethodLength:
51
50
  # Offense count: 1
52
51
  # Configuration parameters: EnforcedStyle, CheckMethodNames, CheckSymbols, AllowedIdentifiers, AllowedPatterns.
53
52
  # SupportedStyles: snake_case, normalcase, non_integer
54
- # AllowedIdentifiers: capture3, iso8601, rfc1123_date, rfc822, rfc2822, rfc3339, x86_64
53
+ # AllowedIdentifiers: TLS1_1, TLS1_2, capture3, iso8601, rfc1123_date, rfc822, rfc2822, rfc3339, x86_64
55
54
  Naming/VariableNumber:
56
55
  Exclude:
57
56
  - 'lib/skunk/commands/status_sharer.rb'
57
+
58
+ # Offense count: 1
59
+ # This cop supports unsafe autocorrection (--autocorrect-all).
60
+ # Configuration parameters: EnforcedStyle.
61
+ # SupportedStyles: always, always_true, never
62
+ Style/FrozenStringLiteralComment:
63
+ Exclude:
64
+ - '**/*.arb'
65
+ - 'bin/console'
data/CHANGELOG.md CHANGED
@@ -5,10 +5,16 @@ 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
- ## main [(unreleased)](https://github.com/fastruby/skunk/compare/v0.5.3...HEAD)
8
+ ## main [(unreleased)](https://github.com/fastruby/skunk/compare/v0.5.4...HEAD)
9
9
 
10
10
  * <INSERT YOUR FEATURE OR BUGFIX HERE>
11
11
 
12
+ ## v0.5.4 / 2025-05-05 [(commits)](https://github.com/fastruby/skunk/compare/v0.5.3...v0.5.4)
13
+
14
+ * [FEATURE: Generate JSON report in background](https://github.com/fastruby/skunk/pull/119)
15
+ * [ENHANCEMENT: Better test suite with more relaxed console output expectation](https://github.com/fastruby/skunk/pull/117)
16
+ * [ENHANCEMENT: Use minitest 5.22.x (also, stop testing with Ruby 2.4 and 2.5)](https://github.com/fastruby/skunk/pull/115)
17
+
12
18
  ## v0.5.3 / 2023-12-01 [(commits)](https://github.com/fastruby/skunk/compare/v0.5.2...v0.5.3)
13
19
 
14
20
  * [BUGFIX: Update reek, rubocop, and terminal-table dependencies](https://github.com/fastruby/skunk/pull/111)
data/README.md CHANGED
@@ -123,6 +123,10 @@ To only run skunk on specific folders, pass a list of directories in the command
123
123
 
124
124
  `skunk app lib`
125
125
 
126
+ ### Generate JSON report in background
127
+
128
+ When the Skunk command is run, it will generate a JSON report file in the `RubyCritic::Config.root` location.
129
+
126
130
  ### Comparing feature branches
127
131
 
128
132
  When working on new features, run skunk against your feature branch to check if the changes are improving or decreasing the code quality of the project.
@@ -10,6 +10,7 @@ module Skunk
10
10
  # reporter object.
11
11
  class Base < RubyCritic::Command::Base
12
12
  def initialize(options)
13
+ super
13
14
  @options = options
14
15
  @status_reporter = Skunk::Command::StatusReporter.new(@options)
15
16
  end
@@ -3,11 +3,10 @@
3
3
  require "rubycritic/commands/default"
4
4
  require "rubycritic/analysers_runner"
5
5
  require "rubycritic/revision_comparator"
6
- require "rubycritic/reporter"
7
6
 
8
- require "skunk/commands/base"
9
7
  require "skunk/commands/shareable"
10
8
  require "skunk/commands/status_reporter"
9
+ require "skunk/reporter"
11
10
 
12
11
  module Skunk
13
12
  module Command
@@ -27,7 +26,7 @@ module Skunk
27
26
  #
28
27
  # @return [Skunk::Command::StatusReporter]
29
28
  def execute
30
- RubyCritic::Config.formats = []
29
+ RubyCritic::Config.formats = [:json]
31
30
 
32
31
  report(critique)
33
32
 
@@ -39,6 +38,8 @@ module Skunk
39
38
  #
40
39
  # @param [RubyCritic::AnalysedModulesCollection] A collection of analysed modules
41
40
  def report(analysed_modules)
41
+ Reporter.generate_report(analysed_modules)
42
+
42
43
  status_reporter.analysed_modules = analysed_modules
43
44
  status_reporter.score = analysed_modules.score
44
45
  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
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.3"
4
+ VERSION = "0.5.4"
5
5
  end
data/skunk.gemspec CHANGED
@@ -43,7 +43,7 @@ Gem::Specification.new do |spec|
43
43
 
44
44
  spec.add_development_dependency "codecov", "~> 0.1.16"
45
45
  spec.add_development_dependency "debug"
46
- spec.add_development_dependency "minitest", "~> 5.8.4"
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"
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.3
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: 2023-12-01 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
@@ -76,16 +76,16 @@ dependencies:
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
@@ -232,8 +232,6 @@ files:
232
232
  - CODE_OF_CONDUCT.md
233
233
  - CONTRIBUTING.md
234
234
  - Gemfile
235
- - Gemfile-Ruby-2-4
236
- - Gemfile-Ruby-2-5
237
235
  - LICENSE.txt
238
236
  - README.md
239
237
  - Rakefile
@@ -254,6 +252,9 @@ files:
254
252
  - lib/skunk/commands/status_reporter.rb
255
253
  - lib/skunk/commands/status_sharer.rb
256
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
257
258
  - lib/skunk/rubycritic/analysed_module.rb
258
259
  - lib/skunk/rubycritic/analysed_modules_collection.rb
259
260
  - lib/skunk/version.rb
@@ -285,7 +286,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
285
286
  - !ruby/object:Gem::Version
286
287
  version: '0'
287
288
  requirements: []
288
- rubygems_version: 3.4.21
289
+ rubygems_version: 3.5.16
289
290
  signing_key:
290
291
  specification_version: 4
291
292
  summary: A library to assess code quality vs. code coverage
data/Gemfile-Ruby-2-4 DELETED
@@ -1,13 +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 "reek", "~> 6.0.0"
11
- gem "rubocop", "~> 1.0"
12
- gem "simplecov", "< 0.19.0"
13
- gem "vcr", "< 6.1.0"
data/Gemfile-Ruby-2-5 DELETED
@@ -1,13 +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 "reek", "~> 6.0.0"
11
- gem "rubocop", "~> 1.0"
12
- gem "simplecov", "< 0.19.0"
13
- gem "vcr", "< 6.1.0"