debride 1.9.0 → 1.10.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data/History.rdoc +19 -0
- data/Rakefile +3 -1
- data/lib/debride.rb +66 -7
- data.tar.gz.sig +1 -2
- metadata +18 -4
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6967abff5ba6b28f0e9883d615830a93e7fcb2dbeb2eaafa665ececa1fed39ce
|
4
|
+
data.tar.gz: b52412f613a2149775cd552e08f44f616ad1c5c89d0ae3fa1dca6f3ce0ffabeb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fc77db06b93e7401cb6a723b1db1532e6c75fba1216301bb4037ae5c6516fcc577931186f1a9ebc9a4fb452403b92f984ab7dca1abcb312cfb0c921d400f32fd
|
7
|
+
data.tar.gz: 48a62586d3131f682447f5855276ab43e9de334ea791c8d2afa6e9bd49e3ff77007b3be10c00c03f934648f97f62a71871db69169060be3b4a92d432d364495b
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data/History.rdoc
CHANGED
@@ -1,3 +1,22 @@
|
|
1
|
+
=== 1.10.1 / 2022-12-03
|
2
|
+
|
3
|
+
* 4 minor enhancements:
|
4
|
+
|
5
|
+
* Added --minimum <Nloc> flag to filter out smaller suspects.
|
6
|
+
* Added line count to suspects in report and total line count to end of report.
|
7
|
+
* Added processing of `delegate xs to: target` as a call to target.
|
8
|
+
* Added processing of rails deliver_X -> X calls.
|
9
|
+
|
10
|
+
* 3 bug fixes:
|
11
|
+
|
12
|
+
* Fixed processing of colon2 (X::Y::Z) names.
|
13
|
+
* Fixed processing of var splatted attr_* methods.
|
14
|
+
* Possibly fixed conflation between rails route scopes and model scopes.
|
15
|
+
|
16
|
+
=== 1.10.0 / 2022-12-03
|
17
|
+
|
18
|
+
* See above... something went wrong with the release process.
|
19
|
+
|
1
20
|
=== 1.9.0 / 2022-05-23
|
2
21
|
|
3
22
|
* 3 minor enhancements:
|
data/Rakefile
CHANGED
@@ -13,6 +13,7 @@ Hoe::add_include_dirs("../../sexp_processor/dev/lib",
|
|
13
13
|
Hoe.plugin :isolate
|
14
14
|
Hoe.plugin :seattlerb
|
15
15
|
Hoe.plugin :rdoc
|
16
|
+
Hoe.plugin :cov
|
16
17
|
|
17
18
|
Hoe.spec "debride" do
|
18
19
|
developer "Ryan Davis", "ryand-ruby@zenspider.com"
|
@@ -32,10 +33,11 @@ def run dir, whitelist
|
|
32
33
|
whitelist = whitelist && ["--whitelist", whitelist]
|
33
34
|
verbose = ENV["V"] && "-v"
|
34
35
|
exclude = ENV["E"] && ["--exclude", ENV["E"]]
|
36
|
+
minimum = ENV["M"] && ["--minimum", ENV["M"]]
|
35
37
|
|
36
38
|
require "debride"
|
37
39
|
|
38
|
-
args = ["--rails", verbose, whitelist, exclude, dir].flatten.compact
|
40
|
+
args = ["--rails", verbose, minimum, whitelist, exclude, dir].flatten.compact
|
39
41
|
|
40
42
|
Debride.run(args).report
|
41
43
|
end
|
data/lib/debride.rb
CHANGED
@@ -12,7 +12,7 @@ require "path_expander"
|
|
12
12
|
# A static code analyzer that points out possible dead methods.
|
13
13
|
|
14
14
|
class Debride < MethodBasedSexpProcessor
|
15
|
-
VERSION = "1.
|
15
|
+
VERSION = "1.10.1" # :nodoc:
|
16
16
|
PROJECT = "debride"
|
17
17
|
|
18
18
|
def self.load_plugins proj = PROJECT
|
@@ -150,6 +150,10 @@ class Debride < MethodBasedSexpProcessor
|
|
150
150
|
options[:rails] = true
|
151
151
|
end
|
152
152
|
|
153
|
+
opts.on("-m", "--minimum N", Integer, "Don't show hits less than N locs.") do |n|
|
154
|
+
options[:minimum] = n
|
155
|
+
end
|
156
|
+
|
153
157
|
opts.on("-v", "--verbose", "Verbose. Show progress processing files.") do
|
154
158
|
options[:verbose] = true
|
155
159
|
end
|
@@ -240,6 +244,10 @@ class Debride < MethodBasedSexpProcessor
|
|
240
244
|
_, _, _, *args = sexp
|
241
245
|
file, line = sexp.file, sexp.line
|
242
246
|
args.each do |(_, name)|
|
247
|
+
if Sexp === name then
|
248
|
+
process name
|
249
|
+
next
|
250
|
+
end
|
243
251
|
record_method name, file, line
|
244
252
|
record_method "#{name}=".to_sym, file, line
|
245
253
|
end
|
@@ -248,6 +256,10 @@ class Debride < MethodBasedSexpProcessor
|
|
248
256
|
_, _, _, *args = sexp
|
249
257
|
file, line = sexp.file, sexp.line
|
250
258
|
args.each do |(_, name)|
|
259
|
+
if Sexp === name then
|
260
|
+
process name
|
261
|
+
next
|
262
|
+
end
|
251
263
|
record_method "#{name}=".to_sym, file, line
|
252
264
|
end
|
253
265
|
when :attr_reader then
|
@@ -255,6 +267,10 @@ class Debride < MethodBasedSexpProcessor
|
|
255
267
|
_, _, _, *args = sexp
|
256
268
|
file, line = sexp.file, sexp.line
|
257
269
|
args.each do |(_, name)|
|
270
|
+
if Sexp === name then
|
271
|
+
process name
|
272
|
+
next
|
273
|
+
end
|
258
274
|
record_method name, file, line
|
259
275
|
end
|
260
276
|
when :send, :public_send, :__send__ then
|
@@ -263,6 +279,18 @@ class Debride < MethodBasedSexpProcessor
|
|
263
279
|
if Sexp === msg_arg && [:lit, :str].include?(msg_arg.sexp_type) then
|
264
280
|
called << msg_arg.last.to_sym
|
265
281
|
end
|
282
|
+
when :delegate then
|
283
|
+
# s(:call, nil, :delegate, ..., s(:hash, s(:lit, :to), s(:lit, :delegator)))
|
284
|
+
possible_hash = sexp.last
|
285
|
+
if Sexp === possible_hash && possible_hash.sexp_type == :hash
|
286
|
+
possible_hash.sexp_body.each_slice(2) do |key, val|
|
287
|
+
next unless key == s(:lit, :to)
|
288
|
+
next unless Sexp === val
|
289
|
+
|
290
|
+
called << val.last if val.sexp_type == :lit
|
291
|
+
called << val.last.to_sym if val.sexp_type == :str
|
292
|
+
end
|
293
|
+
end
|
266
294
|
when *RAILS_DSL_METHODS, *RAILS_VALIDATION_METHODS then
|
267
295
|
if option[:rails]
|
268
296
|
# s(:call, nil, :before_save, s(:lit, :save_callback), s(:hash, ...))
|
@@ -282,10 +310,16 @@ class Debride < MethodBasedSexpProcessor
|
|
282
310
|
when *RAILS_MACRO_METHODS
|
283
311
|
# s(:call, nil, :has_one, s(:lit, :has_one_relation), ...)
|
284
312
|
_, _, _, (_, name), * = sexp
|
285
|
-
|
286
|
-
|
313
|
+
|
314
|
+
# try to detect route scope vs model scope
|
315
|
+
if context.include? :module or context.include? :class then
|
316
|
+
file, line = sexp.file, sexp.line
|
317
|
+
record_method name, file, line
|
318
|
+
end
|
287
319
|
when /_path$/ then
|
288
|
-
method_name = method_name.to_s
|
320
|
+
method_name = method_name.to_s.delete_suffix("_path").to_sym if option[:rails]
|
321
|
+
when /^deliver_/ then
|
322
|
+
method_name = method_name.to_s.delete_prefix("deliver_").to_sym if option[:rails]
|
289
323
|
end
|
290
324
|
|
291
325
|
called << method_name
|
@@ -303,6 +337,7 @@ class Debride < MethodBasedSexpProcessor
|
|
303
337
|
process val
|
304
338
|
|
305
339
|
signature = "#{klass_name}::#{name}"
|
340
|
+
|
306
341
|
known[name] << klass_name
|
307
342
|
|
308
343
|
file, line = exp.file, exp.line
|
@@ -313,12 +348,16 @@ class Debride < MethodBasedSexpProcessor
|
|
313
348
|
|
314
349
|
def name_to_string exp
|
315
350
|
case exp.sexp_type
|
351
|
+
when :const then
|
352
|
+
exp.last.to_s
|
316
353
|
when :colon2 then
|
317
|
-
_,
|
318
|
-
"#{lhs}::#{rhs}"
|
354
|
+
_, lhs, rhs = exp
|
355
|
+
"#{name_to_string lhs}::#{rhs}"
|
319
356
|
when :colon3 then
|
320
357
|
_, rhs = exp
|
321
358
|
"::#{rhs}"
|
359
|
+
when :self then # wtf?
|
360
|
+
"self"
|
322
361
|
else
|
323
362
|
raise "Not handled: #{exp.inspect}"
|
324
363
|
end
|
@@ -440,13 +479,33 @@ class Debride < MethodBasedSexpProcessor
|
|
440
479
|
|
441
480
|
io.puts "These methods MIGHT not be called:"
|
442
481
|
|
482
|
+
total = 0
|
483
|
+
|
443
484
|
missing.each do |klass, meths|
|
444
|
-
bad = meths.map { |(meth, location)|
|
485
|
+
bad = meths.map { |(meth, location)|
|
486
|
+
loc = if location then
|
487
|
+
l0, l1 = location.split(/:/).last.scan(/\d+/).flatten.map(&:to_i)
|
488
|
+
l1 ||= l0
|
489
|
+
l1 - l0 + 1
|
490
|
+
else
|
491
|
+
1
|
492
|
+
end
|
493
|
+
|
494
|
+
next if option[:minimum] && loc < option[:minimum]
|
495
|
+
|
496
|
+
total += loc
|
497
|
+
|
498
|
+
" %-35s %s (%d)" % [meth, location, loc]
|
499
|
+
}.compact
|
500
|
+
|
501
|
+
next if bad.empty?
|
445
502
|
|
446
503
|
io.puts
|
447
504
|
io.puts klass
|
448
505
|
io.puts bad.join "\n"
|
449
506
|
end
|
507
|
+
io.puts
|
508
|
+
io.puts "Total suspect LOC: %d" % [total]
|
450
509
|
end
|
451
510
|
|
452
511
|
def report_json io, focus, missing
|
data.tar.gz.sig
CHANGED
@@ -1,2 +1 @@
|
|
1
|
-
|
2
|
-
:��6������C��{��[�ݿ}�IYš�|��Y���8��w.d���9�z�$��~u�l𝋀�E���s;)�Z��Q+��w($��<m�Qq����PZ%�e$�\Nx�Nrn�Z
|
1
|
+
\�0��M�$3�T�)����Ô��2����@T�qc�� p�g�N��]��)��}i��l��FB��/�������Ⱦ�Uzd,�c�b�*�6d�q��߄�{���k��D>SɁ���u`�"TWg5�Y+���ȑ��/D���;v�%��} �U'�z����{���z�7ht��LJ��bU�V)��qA��GC���\�D�ȊD�a�F��6fk�G����U�~*�(]��j�xci7�j���A���9���
|
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.
|
4
|
+
version: 1.10.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ryan Davis
|
@@ -29,7 +29,7 @@ cert_chain:
|
|
29
29
|
JFmxn4h9YO/pVdB962BdBNNDia0kgIjI3ENnkLq0dKpYU3+F3KhEuTksLO0L6X/V
|
30
30
|
YsuyUzsMz6GQA4khyaMgKNSD
|
31
31
|
-----END CERTIFICATE-----
|
32
|
-
date: 2022-
|
32
|
+
date: 2022-12-03 00:00:00.000000000 Z
|
33
33
|
dependencies:
|
34
34
|
- !ruby/object:Gem::Dependency
|
35
35
|
name: sexp_processor
|
@@ -93,20 +93,34 @@ dependencies:
|
|
93
93
|
- - "<"
|
94
94
|
- !ruby/object:Gem::Version
|
95
95
|
version: '7'
|
96
|
+
- !ruby/object:Gem::Dependency
|
97
|
+
name: simplecov
|
98
|
+
requirement: !ruby/object:Gem::Requirement
|
99
|
+
requirements:
|
100
|
+
- - "~>"
|
101
|
+
- !ruby/object:Gem::Version
|
102
|
+
version: '0.21'
|
103
|
+
type: :development
|
104
|
+
prerelease: false
|
105
|
+
version_requirements: !ruby/object:Gem::Requirement
|
106
|
+
requirements:
|
107
|
+
- - "~>"
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: '0.21'
|
96
110
|
- !ruby/object:Gem::Dependency
|
97
111
|
name: hoe
|
98
112
|
requirement: !ruby/object:Gem::Requirement
|
99
113
|
requirements:
|
100
114
|
- - "~>"
|
101
115
|
- !ruby/object:Gem::Version
|
102
|
-
version: '3.
|
116
|
+
version: '3.25'
|
103
117
|
type: :development
|
104
118
|
prerelease: false
|
105
119
|
version_requirements: !ruby/object:Gem::Requirement
|
106
120
|
requirements:
|
107
121
|
- - "~>"
|
108
122
|
- !ruby/object:Gem::Version
|
109
|
-
version: '3.
|
123
|
+
version: '3.25'
|
110
124
|
description: Analyze code for potentially uncalled / dead methods, now with auto-removal.
|
111
125
|
email:
|
112
126
|
- ryand-ruby@zenspider.com
|
metadata.gz.sig
CHANGED
Binary file
|