debride 1.15.0 → 1.15.2

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: 77baff9dbc4bab278d0e6b6fe16772ecdce26b00c4c7b24469e0680f0d608c41
4
- data.tar.gz: 885b6274f63f3d76c6a106543d28be50f177fcc6fa6adad7cf642c0b3ef7f0d8
3
+ metadata.gz: a2a172fbacd06e56a051cb02614afd1abe8f6d58a89e2fbf316e981b7d984ad2
4
+ data.tar.gz: ad77390a37d25f0d3af9d7c8b399151ad653321117020b029b15cd1e587b94eb
5
5
  SHA512:
6
- metadata.gz: 421c0cb4b4aa45ed2e7897254549def50af4f4491a029676bcc7671aa026e8cda45b9774073eef8d3bffa15665f7df0466e1b6a68f236fc0b0c2ee12806461a5
7
- data.tar.gz: 2cc4e04095596764513090fffe356835d3af36c192395dbe7753470801e623f826bf72c54371de30bf1d9006d4cf109809cffc1419e887607914623cc8a1bb82
6
+ metadata.gz: 03610f92787f0dc2e44af469f11582a6a2f4a6463e210b0c79e01c9294c89fe6dd37c2147f6ad1476c6a125a1238efb1c742ac9c29844b2fabad4e27bc60e878
7
+ data.tar.gz: 6c21f8d4c056aff81158115b7a12880537a96e52d40913ffea8a43ab900eed95f58c2a9c7bd200cf721ed32c981cae7b3c6d1df7f9cfbd6cda8ef4a4c418f314
checksums.yaml.gz.sig CHANGED
Binary file
data/History.rdoc CHANGED
@@ -1,3 +1,17 @@
1
+ === 1.15.2 / 2026-04-20
2
+
3
+ * 3 bug fixes:
4
+
5
+ * Fix #process_hash when there's a kwsplat in the middle. (carlos-musetti)
6
+ * Rescue StandardError in .run to handle wider gamut of errors gracefully.
7
+ * Add #process override to handle errors as well.
8
+
9
+ === 1.15.1 / 2026-01-26
10
+
11
+ * 1 bug fix:
12
+
13
+ * Namespace NotRubyParser to avoid problems with bundler's horrid eager loading. (nateberkopec)
14
+
1
15
  === 1.15.0 / 2026-01-02
2
16
 
3
17
  * 1 minor enhancement:
data/lib/debride.rb CHANGED
@@ -11,16 +11,15 @@ require "path_expander"
11
11
  require "prism"
12
12
  require "prism/translation/ruby_parser"
13
13
 
14
- class NotRubyParser < Prism::Translation::RubyParser # compatibility layer
15
- end
16
-
17
14
  ##
18
15
  # A static code analyzer that points out possible dead methods.
19
16
 
20
17
  class Debride < MethodBasedSexpProcessor
21
- VERSION = "1.15.0" # :nodoc:
18
+ VERSION = "1.15.2" # :nodoc:
22
19
  PROJECT = "debride"
23
20
 
21
+ NotRubyParser = Class.new Prism::Translation::RubyParser # compatibility layer :nodoc:
22
+
24
23
  def self.load_plugins proj = PROJECT
25
24
  unless defined? @@plugins then
26
25
  @@plugins = []
@@ -83,12 +82,18 @@ class Debride < MethodBasedSexpProcessor
83
82
 
84
83
  begin
85
84
  process send(msg, file)
86
- rescue RuntimeError, SyntaxError => e
85
+ rescue StandardError, SyntaxError => e
87
86
  warn " skipping #{file}: #{e.message}"
88
87
  end
89
88
  end
90
89
  end
91
90
 
91
+ def process exp # :nodoc:
92
+ super
93
+ rescue => e # override to capture these but move on
94
+ warn " skipping: #{e.message}"
95
+ end
96
+
92
97
  def process_rb path_or_io
93
98
  warn "Processing ruby: #{path_or_io}" if option[:verbose]
94
99
 
@@ -486,6 +491,9 @@ class Debride < MethodBasedSexpProcessor
486
491
  def process_hash sexp
487
492
  _, *pairs = sexp
488
493
 
494
+ # pad kwsplat to survive each_slice 2
495
+ pairs = pairs.flat_map { |s| s && s.sexp_type == :kwsplat ? [s, nil] : [s] }
496
+
489
497
  pairs.each_slice 2 do |k, v|
490
498
  if v.nil? && k.sexp_type == :lit then
491
499
  called << k.last
@@ -536,23 +544,24 @@ class Debride < MethodBasedSexpProcessor
536
544
  def missing_locations
537
545
  focus = option[:focus]
538
546
 
539
- missing.map { |klass, meths|
540
- bad = meths.map { |meth|
541
- location =
542
- method_locations["#{klass}##{meth}"] ||
543
- method_locations["#{klass}::#{meth}"]
547
+ missing
548
+ .map { |klass, meths|
549
+ bad = meths.map { |meth|
550
+ location =
551
+ method_locations["#{klass}##{meth}"] ||
552
+ method_locations["#{klass}::#{meth}"]
544
553
 
545
- if focus then
546
- path = location[/(.+):\d+/, 1]
554
+ if focus then
555
+ path = location[/(.+):\d+/, 1]
547
556
 
548
- next unless File.fnmatch(focus, path)
549
- end
557
+ next unless File.fnmatch(focus, path)
558
+ end
550
559
 
551
- [meth, location]
552
- }.compact
560
+ [meth, location]
561
+ }.compact
553
562
 
554
- [klass, bad]
555
- }
563
+ [klass, bad]
564
+ }
556
565
  .to_h
557
566
  .reject { |k,v| v.empty? }
558
567
  end
data/test/test_debride.rb CHANGED
@@ -425,6 +425,18 @@ class TestDebride < Minitest::Test
425
425
  assert_process [["Seattle", [:raining]]], ruby
426
426
  end
427
427
 
428
+ def test_hash__kwsplat_bug
429
+ ruby = <<~RUBY
430
+ {
431
+ a:,
432
+ **b,
433
+ c:,
434
+ }
435
+ RUBY
436
+
437
+ assert_process [], ruby
438
+ end
439
+
428
440
  def test_safe_navigation_operator
429
441
  ruby = <<-RUBY.strip
430
442
  class Seattle
data.tar.gz.sig CHANGED
Binary file
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: debride
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.15.0
4
+ version: 1.15.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryan Davis
@@ -9,9 +9,9 @@ bindir: bin
9
9
  cert_chain:
10
10
  - |
11
11
  -----BEGIN CERTIFICATE-----
12
- MIIDPjCCAiagAwIBAgIBCTANBgkqhkiG9w0BAQsFADBFMRMwEQYDVQQDDApyeWFu
12
+ MIIDPjCCAiagAwIBAgIBCjANBgkqhkiG9w0BAQsFADBFMRMwEQYDVQQDDApyeWFu
13
13
  ZC1ydWJ5MRkwFwYKCZImiZPyLGQBGRYJemVuc3BpZGVyMRMwEQYKCZImiZPyLGQB
14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bx0
26
+ rQtqonfWTHQ8UbQ7GqCL3gDQ0QDD2B+HUlb4uaCZ2icxqa/eOtxMvHC2tj+h0xKY
27
+ xL84ipM5kr0bHGf9/MRZJWcw51urueNycBXu1Xh+pEN8qBmYsFRR4SIODLClybAO
28
+ 6cbm2PyPQgKNiqE4H+IQrDVHd9bJs1XgLElk3qoaJBWXc/5fy0J1imYb25UqmiHG
29
+ snGe1hrppvBRdcyEzvhfIPjI
30
30
  -----END CERTIFICATE-----
31
31
  date: 1980-01-02 00:00:00.000000000 Z
32
32
  dependencies:
@@ -112,15 +112,29 @@ dependencies:
112
112
  requirements:
113
113
  - - "~>"
114
114
  - !ruby/object:Gem::Version
115
- version: '4.5'
115
+ version: '4.6'
116
116
  type: :development
117
117
  prerelease: false
118
118
  version_requirements: !ruby/object:Gem::Requirement
119
119
  requirements:
120
120
  - - "~>"
121
121
  - !ruby/object:Gem::Version
122
- version: '4.5'
123
- description: Analyze code for potentially uncalled / dead methods, now with auto-removal.
122
+ version: '4.6'
123
+ description: |-
124
+ Analyze code for potentially uncalled / dead methods, now with auto-removal.
125
+
126
+ == Features/Problems:
127
+
128
+ * Static analysis of code. Can be easily hooked up to a CI.
129
+ * As with all static analysis tools of dynamic languages, can't be 100%.
130
+ * Whitelisting known good methods by name or regexp.
131
+ * Use --rails for Rails-specific domain knowledge.
132
+ * Use debride_rm to brazenly remove all unused methods. BE CAREFUL.
133
+ * Use `debride_rails_whitelist` to generate an emperical whitelist from logs.
134
+ * Uses path_expander, so you can use:
135
+ * dir_arg -- expand a directory automatically
136
+ * @file_of_args -- persist arguments in a file
137
+ * -path_to_subtract -- ignore intersecting subsets of files/directories
124
138
  email:
125
139
  - ryand-ruby@zenspider.com
126
140
  executables:
@@ -148,6 +162,7 @@ licenses:
148
162
  - MIT
149
163
  metadata:
150
164
  homepage_uri: https://github.com/seattlerb/debride
165
+ documentation_uri: http://docs.seattlerb.org/debride
151
166
  rdoc_options:
152
167
  - "--main"
153
168
  - README.rdoc
@@ -166,5 +181,5 @@ required_rubygems_version: !ruby/object:Gem::Requirement
166
181
  requirements: []
167
182
  rubygems_version: 3.7.2
168
183
  specification_version: 4
169
- summary: Analyze code for potentially uncalled / dead methods, now with auto-removal.
184
+ summary: Analyze code for potentially uncalled / dead methods, now with auto-removal
170
185
  test_files: []
metadata.gz.sig CHANGED
Binary file