rubycritic 4.9.2 → 4.10.0

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: 78f041e961ddd2844538f7fca6622192a8b2a9f64caa540cb8fc4b08f13362e0
4
- data.tar.gz: 1bb52128d47548eb1969869552d26e7ef81940c61aa22b85777652f1a53659f1
3
+ metadata.gz: ffa925049a3ca35743b419abfa744f93b7a4c7f3a5c6ee702703eff959c05177
4
+ data.tar.gz: 1349a8bf0b72de99e5d7415dc3fd59dbacfe93683a20c5e7c25285243a11f28e
5
5
  SHA512:
6
- metadata.gz: 202a4ba45550da029562867c284a941c65666c013fbd75dfa2be0443ce2483149f4c2c751584ff90c10242014a8f630750e6413571304b3927faecb093062b8a
7
- data.tar.gz: 9e4af57d0f10840698a488da7ce77951ef693c022fa16888bc1387fa73d9e3067eab3cd2ee7a690e4640880940426627b3b3089576c21671c408b7af77a41467
6
+ metadata.gz: b7487d521e1c7070d3cb30430e8d5ea023a2baad07a69a2d0e540ba28c014d7caef9b9727585b0731775281cde5a31f1f7a20fb46112e4eb86c6938f2b249fe2
7
+ data.tar.gz: eb343b8c57606946ccc3439275eb829c06cf52c3557f63661c85923a4b1a7babc587ba3bcdabf3297adc69a725ad62fde6c2cc0634890ba24176d89c599e9145
data/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # main [(unreleased)](https://github.com/whitesmith/rubycritic/compare/v4.9.2...main)
2
2
 
3
+ # v4.10.0 / 2025-07-30 [(commits)](https://github.com/whitesmith/rubycritic/compare/v4.9.2...v4.10.0)
4
+
5
+ * [CHANGE] Bump aruba, byebug, cucumber, fakefs, rake, reek dependencies (by [@faisal][])
6
+ * [BUGFIX] Work around issue preventing feature execution on Ruby 3.5.0dev (by [@faisal][])
7
+ * [CHANGE] Add changes or suppress warnings for issues found by newer rubocop (by [@faisal][])
8
+ * [CHANGE] Update CI checkout action to v4 (by [@faisal][])
9
+ * [CHANGE] Run RubyCritic outside of the project without losing the churn value (by [@juanvqz][])
10
+
3
11
  # v4.9.2 / 2025-04-08 [(commits)](https://github.com/whitesmith/rubycritic/compare/v4.9.1...v4.9.2)
4
12
 
5
13
  * [CHANGE] Adds development dependency for gems removed from standard library in Ruby 3.5 -- ostruct, irb, rdoc (by [@faisal][])
@@ -8,6 +8,7 @@ module RubyCritic
8
8
  module Analyser
9
9
  class Attributes
10
10
  include Colorize
11
+
11
12
  def initialize(analysed_modules)
12
13
  @analysed_modules = analysed_modules
13
14
  end
@@ -6,6 +6,7 @@ module RubyCritic
6
6
  module Analyser
7
7
  class Churn
8
8
  include Colorize
9
+
9
10
  attr_writer :source_control_system
10
11
 
11
12
  def initialize(analysed_modules)
@@ -7,6 +7,7 @@ module RubyCritic
7
7
  module Analyser
8
8
  class Complexity
9
9
  include Colorize
10
+
10
11
  def initialize(analysed_modules)
11
12
  @flog = Flog.new
12
13
  @analysed_modules = analysed_modules
@@ -8,6 +8,7 @@ module RubyCritic
8
8
  module Analyser
9
9
  class FlaySmells
10
10
  include Colorize
11
+
11
12
  def initialize(analysed_modules)
12
13
  @analysed_modules = paths_to_analysed_modules(analysed_modules)
13
14
  @flay = Flay.new(@analysed_modules.keys)
@@ -8,6 +8,7 @@ module RubyCritic
8
8
  module Analyser
9
9
  class FlogSmells
10
10
  include Colorize
11
+
11
12
  HIGH_COMPLEXITY_SCORE_THRESHOLD = 25
12
13
  VERY_HIGH_COMPLEXITY_SCORE_THRESHOLD = 60
13
14
 
@@ -8,6 +8,7 @@ module RubyCritic
8
8
  module Analyser
9
9
  class ReekSmells
10
10
  include Colorize
11
+
11
12
  def initialize(analysed_modules)
12
13
  @analysed_modules = analysed_modules
13
14
  end
@@ -24,11 +24,11 @@ module RubyCritic
24
24
  root: root,
25
25
  coverage_path: coverage_path,
26
26
  formats: formats,
27
- deduplicate_symlinks: deduplicate_symlinks,
27
+ deduplicate_symlinks: deduplicate_symlinks?,
28
28
  paths: paths,
29
- suppress_ratings: suppress_ratings,
29
+ suppress_ratings: suppress_ratings?,
30
30
  minimum_score: minimum_score,
31
- no_browser: no_browser,
31
+ no_browser: no_browser?,
32
32
  base_branch: base_branch,
33
33
  feature_branch: feature_branch,
34
34
  threshold_score: threshold_score
@@ -68,16 +68,16 @@ module RubyCritic
68
68
  options['threshold_score']
69
69
  end
70
70
 
71
- def deduplicate_symlinks
72
- value_for(options['deduplicate_symlinks'])
71
+ def deduplicate_symlinks?
72
+ value_for?(options['deduplicate_symlinks'])
73
73
  end
74
74
 
75
- def suppress_ratings
76
- value_for(options['suppress_ratings'])
75
+ def suppress_ratings?
76
+ value_for?(options['suppress_ratings'])
77
77
  end
78
78
 
79
- def no_browser
80
- value_for(options['no_browser'])
79
+ def no_browser?
80
+ value_for?(options['no_browser'])
81
81
  end
82
82
 
83
83
  def formats
@@ -96,7 +96,7 @@ module RubyCritic
96
96
  options['paths']
97
97
  end
98
98
 
99
- def value_for(value)
99
+ def value_for?(value)
100
100
  value = value.to_s
101
101
  value == 'true' unless value.empty?
102
102
  end
@@ -26,10 +26,10 @@ module RubyCritic
26
26
  end
27
27
 
28
28
  def current_status
29
- satisfy_minimum_score_rule ? SUCCESS : SCORE_BELOW_MINIMUM
29
+ satisfy_minimum_score_rule? ? SUCCESS : SCORE_BELOW_MINIMUM
30
30
  end
31
31
 
32
- def satisfy_minimum_score_rule
32
+ def satisfy_minimum_score_rule?
33
33
  score >= @options[:minimum_score].to_f
34
34
  end
35
35
 
@@ -71,7 +71,7 @@ module RubyCritic
71
71
 
72
72
  def print_starting_up_output
73
73
  puts "\n\n!!! Running `#{name}` rake command\n"
74
- puts "!!! Inspecting #{paths} #{options.empty? ? '' : "with options #{options}"}\n\n"
74
+ puts "!!! Inspecting #{paths} #{"with options #{options}" unless options.empty?}\n\n"
75
75
  end
76
76
 
77
77
  def options_as_arguments
@@ -20,12 +20,16 @@ module RubyCritic
20
20
  end
21
21
  end
22
22
 
23
+ # :reek:TooManyInstanceVariables
24
+ # rubocop:disable Metrics/ClassLength
23
25
  class Churn
26
+ # :reek:TooManyStatements
24
27
  def initialize(churn_after: nil, paths: ['.'])
25
28
  @churn_after = churn_after
26
29
  @paths = Array(paths)
27
30
  @date = nil
28
31
  @stats = {}
32
+ @git_root = find_git_root
29
33
 
30
34
  call
31
35
  end
@@ -40,16 +44,32 @@ module RubyCritic
40
44
 
41
45
  private
42
46
 
47
+ # :reek:DuplicateMethodCall
48
+ def find_git_root
49
+ @paths.each do |path|
50
+ current_path = File.expand_path(path)
51
+ while current_path != File.dirname(current_path)
52
+ return current_path if Dir.exist?(File.join(current_path, '.git'))
53
+
54
+ current_path = File.dirname(current_path)
55
+ end
56
+ end
57
+ Dir.pwd
58
+ end
59
+
43
60
  def call
44
61
  git_log_commands.each { |log_command| exec_git_command(log_command) }
45
62
  end
46
63
 
47
64
  def exec_git_command(command)
48
- Git
49
- .git(command)
50
- .split("\n")
51
- .reject(&:empty?)
52
- .each { |line| process_line(line) }
65
+ # Run git command from the git repository root
66
+ Dir.chdir(@git_root) do
67
+ Git
68
+ .git(command)
69
+ .split("\n")
70
+ .reject(&:empty?)
71
+ .each { |line| process_line(line) }
72
+ end
53
73
  end
54
74
 
55
75
  def git_log_commands
@@ -57,7 +77,20 @@ module RubyCritic
57
77
  end
58
78
 
59
79
  def git_log_command(path)
60
- "log --all --date=iso --follow --format='format:date:%x09%ad' --name-status #{after_clause}#{path}"
80
+ # Convert absolute paths to relative paths from git root
81
+ relative_path = make_relative_to_git_root(path)
82
+ "log --all --date=iso --follow --format='format:date:%x09%ad' --name-status #{after_clause}#{relative_path}"
83
+ end
84
+
85
+ def make_relative_to_git_root(path)
86
+ absolute_path = File.expand_path(path)
87
+ if absolute_path.start_with?(@git_root)
88
+ # Convert to relative path from git root
89
+ absolute_path[(@git_root.length + 1)..] || '.'
90
+ else
91
+ # If path is not within git root, use as is
92
+ path
93
+ end
61
94
  end
62
95
 
63
96
  def after_clause
@@ -87,13 +120,18 @@ module RubyCritic
87
120
  process_file(to)
88
121
  end
89
122
 
123
+ # :reek:DuplicateMethodCall
90
124
  def filename_for_subdirectory(filename)
91
- git_path = Git.git('rev-parse --show-toplevel')
92
- cd_path = Dir.pwd
93
- if cd_path.length > git_path.length
94
- filename = filename.sub(/^#{Regexp.escape("#{File.basename(cd_path)}/")}/, '')
125
+ if @git_root == Dir.pwd
126
+ git_path = Git.git('rev-parse --show-toplevel')
127
+ cd_path = Dir.pwd
128
+ if cd_path.length > git_path.length
129
+ filename = filename.sub(/^#{Regexp.escape("#{File.basename(cd_path)}/")}/, '')
130
+ end
131
+ [filename]
132
+ else
133
+ filename
95
134
  end
96
- [filename]
97
135
  end
98
136
 
99
137
  def process_file(filename)
@@ -109,10 +147,32 @@ module RubyCritic
109
147
  @renames ||= Renames.new
110
148
  end
111
149
 
150
+ # :reek:TooManyStatements
151
+ # rubocop:disable Metrics/MethodLength
112
152
  def stats(path)
153
+ # Try the path as-is first
154
+ result = @stats.fetch(path, nil)
155
+ return result if result
156
+
157
+ # If not found, try converting absolute path to relative path from git root
158
+ absolute_path = File.expand_path(path)
159
+ if absolute_path.start_with?(@git_root)
160
+ relative_path = absolute_path[(@git_root.length + 1)..]
161
+ return @stats.fetch(relative_path, Stats.new(0))
162
+ end
163
+
164
+ # If still not found, try converting relative path to absolute path
165
+ unless path.start_with?('/')
166
+ absolute_path = File.expand_path(path, @git_root)
167
+ return @stats.fetch(absolute_path, Stats.new(0))
168
+ end
169
+
170
+ # Default fallback
113
171
  @stats.fetch(path, Stats.new(0))
114
172
  end
173
+ # rubocop:enable Metrics/MethodLength
115
174
  end
175
+ # rubocop:enable Metrics/ClassLength
116
176
  end
117
177
  end
118
178
  end
@@ -21,8 +21,28 @@ module RubyCritic
21
21
  self.class.git(arg)
22
22
  end
23
23
 
24
+ # :reek:DuplicateMethodCall
25
+ # :reek:NilCheck
24
26
  def self.supported?
25
- git('branch 2>&1') && $CHILD_STATUS.success?
27
+ return true if git('branch 2>&1') && $CHILD_STATUS.success?
28
+
29
+ return false if Config.paths.nil? || Config.paths.empty?
30
+
31
+ Config.paths.any? do |path|
32
+ absolute_path = File.expand_path(path)
33
+ check_git_repository?(absolute_path)
34
+ end
35
+ end
36
+
37
+ # :reek:DuplicateMethodCall
38
+ def self.check_git_repository?(path)
39
+ current_path = File.expand_path(path)
40
+ while current_path != File.dirname(current_path)
41
+ return true if Dir.exist?(File.join(current_path, '.git'))
42
+
43
+ current_path = File.dirname(current_path)
44
+ end
45
+ false
26
46
  end
27
47
 
28
48
  def self.to_s
@@ -50,7 +70,7 @@ module RubyCritic
50
70
  end
51
71
 
52
72
  def travel_to_head
53
- stash_successful = stash_changes
73
+ stash_successful = stash_changes?
54
74
  yield
55
75
  ensure
56
76
  travel_to_original_state if stash_successful
@@ -88,7 +108,7 @@ module RubyCritic
88
108
 
89
109
  private
90
110
 
91
- def stash_changes
111
+ def stash_changes?
92
112
  stashes_count_before = stashes_count
93
113
  git('stash')
94
114
  stashes_count_after = stashes_count
@@ -52,9 +52,11 @@ module RubyCritic
52
52
  Time.strptime(perforce_files[Perforce.key_file(path)].last_commit, '%s').strftime('%Y-%m-%d %H:%M:%S %z')
53
53
  end
54
54
 
55
+ # rubocop:disable Style/CollectionQuerying
55
56
  def revision?
56
57
  !perforce_files.values.count(&:opened?).zero?
57
58
  end
59
+ # rubocop:enable Style/CollectionQuerying
58
60
 
59
61
  def head_reference
60
62
  perforce_files.values.map(&:head).max_by(&:to_i)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module RubyCritic
4
- VERSION = '4.9.2'
4
+ VERSION = '4.10.0'
5
5
  end
metadata CHANGED
@@ -1,13 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rubycritic
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.9.2
4
+ version: 4.10.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Guilherme Simoes
8
+ autorequire:
8
9
  bindir: bin
9
10
  cert_chain: []
10
- date: 2025-04-09 00:00:00.000000000 Z
11
+ date: 2025-07-30 00:00:00.000000000 Z
11
12
  dependencies:
12
13
  - !ruby/object:Gem::Dependency
13
14
  name: flay
@@ -85,7 +86,7 @@ dependencies:
85
86
  requirements:
86
87
  - - "~>"
87
88
  - !ruby/object:Gem::Version
88
- version: 6.4.0
89
+ version: 6.5.0
89
90
  - - "<"
90
91
  - !ruby/object:Gem::Version
91
92
  version: '7.0'
@@ -95,7 +96,7 @@ dependencies:
95
96
  requirements:
96
97
  - - "~>"
97
98
  - !ruby/object:Gem::Version
98
- version: 6.4.0
99
+ version: 6.5.0
99
100
  - - "<"
100
101
  - !ruby/object:Gem::Version
101
102
  version: '7.0'
@@ -175,14 +176,20 @@ dependencies:
175
176
  requirements:
176
177
  - - "~>"
177
178
  - !ruby/object:Gem::Version
178
- version: 2.3.0
179
+ version: 2.3.1
180
+ - - ">="
181
+ - !ruby/object:Gem::Version
182
+ version: 2.3.1
179
183
  type: :development
180
184
  prerelease: false
181
185
  version_requirements: !ruby/object:Gem::Requirement
182
186
  requirements:
183
187
  - - "~>"
184
188
  - !ruby/object:Gem::Version
185
- version: 2.3.0
189
+ version: 2.3.1
190
+ - - ">="
191
+ - !ruby/object:Gem::Version
192
+ version: 2.3.1
186
193
  - !ruby/object:Gem::Dependency
187
194
  name: bundler
188
195
  requirement: !ruby/object:Gem::Requirement
@@ -203,7 +210,7 @@ dependencies:
203
210
  requirements:
204
211
  - - "~>"
205
212
  - !ruby/object:Gem::Version
206
- version: '11.0'
213
+ version: '12.0'
207
214
  - - ">="
208
215
  - !ruby/object:Gem::Version
209
216
  version: '10.0'
@@ -213,7 +220,7 @@ dependencies:
213
220
  requirements:
214
221
  - - "~>"
215
222
  - !ruby/object:Gem::Version
216
- version: '11.0'
223
+ version: '12.0'
217
224
  - - ">="
218
225
  - !ruby/object:Gem::Version
219
226
  version: '10.0'
@@ -223,7 +230,7 @@ dependencies:
223
230
  requirements:
224
231
  - - "~>"
225
232
  - !ruby/object:Gem::Version
226
- version: 9.2.1
233
+ version: 10.0.0
227
234
  - - "!="
228
235
  - !ruby/object:Gem::Version
229
236
  version: 9.0.0
@@ -233,7 +240,7 @@ dependencies:
233
240
  requirements:
234
241
  - - "~>"
235
242
  - !ruby/object:Gem::Version
236
- version: 9.2.1
243
+ version: 10.0.0
237
244
  - - "!="
238
245
  - !ruby/object:Gem::Version
239
246
  version: 9.0.0
@@ -257,14 +264,14 @@ dependencies:
257
264
  requirements:
258
265
  - - "~>"
259
266
  - !ruby/object:Gem::Version
260
- version: 2.6.0
267
+ version: 3.0.0
261
268
  type: :development
262
269
  prerelease: false
263
270
  version_requirements: !ruby/object:Gem::Requirement
264
271
  requirements:
265
272
  - - "~>"
266
273
  - !ruby/object:Gem::Version
267
- version: 2.6.0
274
+ version: 3.0.0
268
275
  - !ruby/object:Gem::Dependency
269
276
  name: irb
270
277
  requirement: !ruby/object:Gem::Requirement
@@ -373,7 +380,7 @@ dependencies:
373
380
  requirements:
374
381
  - - "~>"
375
382
  - !ruby/object:Gem::Version
376
- version: 13.2.0
383
+ version: 13.3.0
377
384
  - - ">="
378
385
  - !ruby/object:Gem::Version
379
386
  version: 11.0.0
@@ -383,7 +390,7 @@ dependencies:
383
390
  requirements:
384
391
  - - "~>"
385
392
  - !ruby/object:Gem::Version
386
- version: 13.2.0
393
+ version: 13.3.0
387
394
  - - ">="
388
395
  - !ruby/object:Gem::Version
389
396
  version: 11.0.0
@@ -605,6 +612,7 @@ licenses:
605
612
  - MIT
606
613
  metadata:
607
614
  rubygems_mfa_required: 'true'
615
+ post_install_message:
608
616
  rdoc_options: []
609
617
  require_paths:
610
618
  - lib
@@ -619,7 +627,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
619
627
  - !ruby/object:Gem::Version
620
628
  version: '0'
621
629
  requirements: []
622
- rubygems_version: 3.6.2
630
+ rubygems_version: 3.5.22
631
+ signing_key:
623
632
  specification_version: 4
624
633
  summary: RubyCritic is a Ruby code quality reporter
625
634
  test_files: []