debride 1.8.0 → 1.9.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 +5 -5
- checksums.yaml.gz.sig +1 -2
- data/History.rdoc +30 -0
- data/README.rdoc +15 -0
- data/Rakefile +4 -3
- data/lib/debride.rb +113 -54
- data/test/test_debride.rb +97 -16
- data.tar.gz.sig +2 -2
- metadata +28 -23
- metadata.gz.sig +0 -0
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 | 
            -
             | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 2 | 
            +
            SHA256:
         | 
| 3 | 
            +
              metadata.gz: 1c2b2a4fb03bd2f6f8a5406f0b413e3159b49ac6a9b0c3641bedc7a6e724a548
         | 
| 4 | 
            +
              data.tar.gz: cdeb2dc596fe5e496ed940a989fe84f482480c2a2cc7436228e1c4b07755ccbf
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: a11b67c7d6a82313be67dbb1680c54ab9f9db3e0f769ab2ce96980ebfb696cc5dd607d6107cb0cc00c9a5c966553439deea89fa0acd13be83707e6393b52070b
         | 
| 7 | 
            +
              data.tar.gz: f2f4eb04d9c348109b88fcca245233554bae0febe496ead9c08622653add4a2cdd10bb4405b7bff9cc308972d5cc46f46241aa56162976d2f89cf03c4ba9e2d4
         | 
    
        checksums.yaml.gz.sig
    CHANGED
    
    | @@ -1,2 +1 @@ | |
| 1 | 
            -
             | 
| 2 | 
            -
            �ߖ�t�!N��
         | 
| 1 | 
            +
            �1��oLoϩ}�
         | 
    
        data/History.rdoc
    CHANGED
    
    | @@ -1,3 +1,33 @@ | |
| 1 | 
            +
            === 1.9.0 / 2022-05-23
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            * 3 minor enhancements:
         | 
| 4 | 
            +
             | 
| 5 | 
            +
              * Added --json and --yaml output options.
         | 
| 6 | 
            +
              * Added io argument to #report, added tests for #report.
         | 
| 7 | 
            +
              * Improved processing of --exclude with directories (adds trailing slash).
         | 
| 8 | 
            +
             | 
| 9 | 
            +
            * 1 bug fix:
         | 
| 10 | 
            +
             | 
| 11 | 
            +
              * Fixed exception thrown in #report when using --focus. (cbillen)
         | 
| 12 | 
            +
             | 
| 13 | 
            +
            === 1.8.2 / 2019-09-24
         | 
| 14 | 
            +
             | 
| 15 | 
            +
            * 1 bug fix:
         | 
| 16 | 
            +
             | 
| 17 | 
            +
              * Fixed some sexp access under STRICT_SEXP=1.
         | 
| 18 | 
            +
             | 
| 19 | 
            +
            === 1.8.1 / 2017-11-29
         | 
| 20 | 
            +
             | 
| 21 | 
            +
            * 2 minor enhancements:
         | 
| 22 | 
            +
             | 
| 23 | 
            +
              * Add basic support for jbuilder files. (d-mato)
         | 
| 24 | 
            +
              * Added rails & whitelist example to readme. (TheRusskiy)
         | 
| 25 | 
            +
             | 
| 26 | 
            +
            * 2 bug fixes:
         | 
| 27 | 
            +
             | 
| 28 | 
            +
              * Capture RegexpError and skip file. (mrdShinse)
         | 
| 29 | 
            +
              * Fixed reporting of cdecl+const2 (eg X::Y = 42). (herwinw)
         | 
| 30 | 
            +
             | 
| 1 31 | 
             
            === 1.8.0 / 2017-05-09
         | 
| 2 32 |  | 
| 3 33 | 
             
            * 1 minor enhancement:
         | 
    
        data/README.rdoc
    CHANGED
    
    | @@ -42,6 +42,21 @@ API), then you can whitelist it: | |
| 42 42 | 
             
              MyClass
         | 
| 43 43 | 
             
                bad_method                          lib/some/file.rb:20
         | 
| 44 44 | 
             
              ...
         | 
| 45 | 
            +
              
         | 
| 46 | 
            +
            Usage example for a typical rails application:
         | 
| 47 | 
            +
              # dump rake routes into a file
         | 
| 48 | 
            +
              % rake routes > routes.txt
         | 
| 49 | 
            +
              # generate whitelist based on routes and usages from production log
         | 
| 50 | 
            +
              % debride_rails_whitelist routes.txt log/production.log | sort -u > whitelist.txt
         | 
| 51 | 
            +
              # add migration methods
         | 
| 52 | 
            +
              % echo up >> whitelist.txt
         | 
| 53 | 
            +
              % echo down >> whitelist.txt
         | 
| 54 | 
            +
              % echo change >> whitelist.txt
         | 
| 55 | 
            +
              # output debride report co standard output with the following options:
         | 
| 56 | 
            +
              # ignore typical rails methods, 
         | 
| 57 | 
            +
              # specify generated whitelist,
         | 
| 58 | 
            +
              # run in current directory (".")
         | 
| 59 | 
            +
              % debride --rails --whitelist whitelist.txt .
         | 
| 45 60 |  | 
| 46 61 | 
             
            You can also use regexps in your whitelist by delimiting them with //'s.
         | 
| 47 62 |  | 
    
        data/Rakefile
    CHANGED
    
    | @@ -26,15 +26,16 @@ end | |
| 26 26 | 
             
            def run dir, whitelist
         | 
| 27 27 | 
             
              abort "Specify dir to scan with D=<path>" unless dir
         | 
| 28 28 |  | 
| 29 | 
            -
              ENV["GEM_HOME"] = "tmp/isolate | 
| 30 | 
            -
              ENV["GEM_PATH"] = "../../debride-erb/dev/tmp/isolate | 
| 29 | 
            +
              ENV["GEM_HOME"] = "tmp/isolate"
         | 
| 30 | 
            +
              ENV["GEM_PATH"] = "../../debride-erb/dev/tmp/isolate"
         | 
| 31 31 |  | 
| 32 32 | 
             
              whitelist = whitelist && ["--whitelist", whitelist]
         | 
| 33 33 | 
             
              verbose   = ENV["V"]  && "-v"
         | 
| 34 | 
            +
              exclude   = ENV["E"]  && ["--exclude", ENV["E"]]
         | 
| 34 35 |  | 
| 35 36 | 
             
              require "debride"
         | 
| 36 37 |  | 
| 37 | 
            -
              args = ["--rails", verbose, whitelist, dir].flatten.compact
         | 
| 38 | 
            +
              args = ["--rails", verbose, whitelist, exclude, dir].flatten.compact
         | 
| 38 39 |  | 
| 39 40 | 
             
              Debride.run(args).report
         | 
| 40 41 | 
             
            end
         | 
    
        data/lib/debride.rb
    CHANGED
    
    | @@ -8,21 +8,11 @@ require "ruby_parser" | |
| 8 8 | 
             
            require "sexp_processor"
         | 
| 9 9 | 
             
            require "path_expander"
         | 
| 10 10 |  | 
| 11 | 
            -
            # :stopdoc:
         | 
| 12 | 
            -
            class File
         | 
| 13 | 
            -
              RUBY19 = "<3".respond_to? :encoding unless defined? RUBY19 # :nodoc:
         | 
| 14 | 
            -
             | 
| 15 | 
            -
              class << self
         | 
| 16 | 
            -
                alias :binread :read unless RUBY19
         | 
| 17 | 
            -
              end
         | 
| 18 | 
            -
            end
         | 
| 19 | 
            -
            # :startdoc:
         | 
| 20 | 
            -
             | 
| 21 11 | 
             
            ##
         | 
| 22 12 | 
             
            # A static code analyzer that points out possible dead methods.
         | 
| 23 13 |  | 
| 24 14 | 
             
            class Debride < MethodBasedSexpProcessor
         | 
| 25 | 
            -
              VERSION = "1. | 
| 15 | 
            +
              VERSION = "1.9.0" # :nodoc:
         | 
| 26 16 | 
             
              PROJECT = "debride"
         | 
| 27 17 |  | 
| 28 18 | 
             
              def self.load_plugins proj = PROJECT
         | 
| @@ -50,7 +40,7 @@ class Debride < MethodBasedSexpProcessor | |
| 50 40 | 
             
              end
         | 
| 51 41 |  | 
| 52 42 | 
             
              def self.file_extensions
         | 
| 53 | 
            -
                %w[rb rake] + load_plugins
         | 
| 43 | 
            +
                %w[rb rake jbuilder] + load_plugins
         | 
| 54 44 | 
             
              end
         | 
| 55 45 |  | 
| 56 46 | 
             
              ##
         | 
| @@ -66,6 +56,8 @@ class Debride < MethodBasedSexpProcessor | |
| 66 56 | 
             
                expander = PathExpander.new(args, glob)
         | 
| 67 57 | 
             
                files = expander.process
         | 
| 68 58 | 
             
                excl  = debride.option[:exclude]
         | 
| 59 | 
            +
                excl.map! { |fd| File.directory?(fd) ? "#{fd}/" : fd } if excl
         | 
| 60 | 
            +
             | 
| 69 61 | 
             
                files = expander.filter_files files, StringIO.new(excl.join "\n") if excl
         | 
| 70 62 |  | 
| 71 63 | 
             
                debride.run(files)
         | 
| @@ -94,33 +86,34 @@ class Debride < MethodBasedSexpProcessor | |
| 94 86 | 
             
              end
         | 
| 95 87 |  | 
| 96 88 | 
             
              def process_rb path_or_io
         | 
| 97 | 
            -
                 | 
| 98 | 
            -
             | 
| 99 | 
            -
             | 
| 100 | 
            -
             | 
| 101 | 
            -
                   | 
| 102 | 
            -
             | 
| 103 | 
            -
                   | 
| 104 | 
            -
             | 
| 105 | 
            -
                   | 
| 106 | 
            -
                    raise "Unhandled type: #{path_or_io.class}:#{path_or_io.inspect}"
         | 
| 107 | 
            -
                  end
         | 
| 108 | 
            -
             | 
| 109 | 
            -
                  rp = RubyParser.for_current_ruby rescue RubyParser.new
         | 
| 110 | 
            -
                  rp.process(file, path, option[:timeout])
         | 
| 111 | 
            -
                rescue Racc::ParseError => e
         | 
| 112 | 
            -
                  warn "Parse Error parsing #{path}. Skipping."
         | 
| 113 | 
            -
                  warn "  #{e.message}"
         | 
| 114 | 
            -
                rescue Timeout::Error
         | 
| 115 | 
            -
                  warn "TIMEOUT parsing #{path}. Skipping."
         | 
| 89 | 
            +
                warn "Processing ruby: #{path_or_io}" if option[:verbose]
         | 
| 90 | 
            +
             | 
| 91 | 
            +
                case path_or_io
         | 
| 92 | 
            +
                when String then
         | 
| 93 | 
            +
                  path, file = path_or_io, File.binread(path_or_io)
         | 
| 94 | 
            +
                when IO, StringIO then
         | 
| 95 | 
            +
                  path, file = "(io)", path_or_io.read
         | 
| 96 | 
            +
                else
         | 
| 97 | 
            +
                  raise "Unhandled type: #{path_or_io.class}:#{path_or_io.inspect}"
         | 
| 116 98 | 
             
                end
         | 
| 99 | 
            +
             | 
| 100 | 
            +
                rp = RubyParser.for_current_ruby rescue RubyParser.new
         | 
| 101 | 
            +
                rp.process(file, path, option[:timeout])
         | 
| 102 | 
            +
              rescue Racc::ParseError, RegexpError => e
         | 
| 103 | 
            +
                warn "Parse Error parsing #{path}. Skipping."
         | 
| 104 | 
            +
                warn "  #{e.message}"
         | 
| 105 | 
            +
              rescue Timeout::Error
         | 
| 106 | 
            +
                warn "TIMEOUT parsing #{path}. Skipping."
         | 
| 117 107 | 
             
              end
         | 
| 118 108 |  | 
| 119 109 | 
             
              ##
         | 
| 120 110 | 
             
              # Parse command line options and return a hash of parsed option values.
         | 
| 121 111 |  | 
| 122 112 | 
             
              def self.parse_options args
         | 
| 123 | 
            -
                options = { | 
| 113 | 
            +
                options = {
         | 
| 114 | 
            +
                  :whitelist => [],
         | 
| 115 | 
            +
                  :format => :text,
         | 
| 116 | 
            +
                }
         | 
| 124 117 |  | 
| 125 118 | 
             
                op = OptionParser.new do |opts|
         | 
| 126 119 | 
             
                  opts.banner  = "debride [options] files_or_dirs"
         | 
| @@ -160,6 +153,14 @@ class Debride < MethodBasedSexpProcessor | |
| 160 153 | 
             
                  opts.on("-v", "--verbose", "Verbose. Show progress processing files.") do
         | 
| 161 154 | 
             
                    options[:verbose] = true
         | 
| 162 155 | 
             
                  end
         | 
| 156 | 
            +
             | 
| 157 | 
            +
                  opts.on "--json" do
         | 
| 158 | 
            +
                    options[:format] = :json
         | 
| 159 | 
            +
                  end
         | 
| 160 | 
            +
             | 
| 161 | 
            +
                  opts.on "--yaml" do
         | 
| 162 | 
            +
                    options[:format] = :yaml
         | 
| 163 | 
            +
                  end
         | 
| 163 164 | 
             
                end
         | 
| 164 165 |  | 
| 165 166 | 
             
                op.parse! args
         | 
| @@ -208,7 +209,7 @@ class Debride < MethodBasedSexpProcessor | |
| 208 209 | 
             
              end
         | 
| 209 210 |  | 
| 210 211 | 
             
              def process_attrasgn(sexp)
         | 
| 211 | 
            -
                method_name = sexp | 
| 212 | 
            +
                _, _, method_name, * = sexp
         | 
| 212 213 | 
             
                method_name = method_name.last if Sexp === method_name
         | 
| 213 214 | 
             
                called << method_name
         | 
| 214 215 | 
             
                process_until_empty sexp
         | 
| @@ -222,7 +223,7 @@ class Debride < MethodBasedSexpProcessor | |
| 222 223 | 
             
              end
         | 
| 223 224 |  | 
| 224 225 | 
             
              def process_call sexp # :nodoc:
         | 
| 225 | 
            -
                method_name = sexp | 
| 226 | 
            +
                _, _, method_name, * = sexp
         | 
| 226 227 |  | 
| 227 228 | 
             
                case method_name
         | 
| 228 229 | 
             
                when :new then
         | 
| @@ -273,8 +274,8 @@ class Debride < MethodBasedSexpProcessor | |
| 273 274 | 
             
                    if Sexp === possible_hash && possible_hash.sexp_type == :hash
         | 
| 274 275 | 
             
                      possible_hash.sexp_body.each_slice(2) do |key, val|
         | 
| 275 276 | 
             
                        next unless Sexp === val
         | 
| 276 | 
            -
                        called << val.last        if val. | 
| 277 | 
            -
                        called << val.last.to_sym if val. | 
| 277 | 
            +
                        called << val.last        if val.sexp_type == :lit
         | 
| 278 | 
            +
                        called << val.last.to_sym if val.sexp_type == :str
         | 
| 278 279 | 
             
                      end
         | 
| 279 280 | 
             
                    end
         | 
| 280 281 | 
             
                  end
         | 
| @@ -296,6 +297,9 @@ class Debride < MethodBasedSexpProcessor | |
| 296 297 |  | 
| 297 298 | 
             
              def process_cdecl exp # :nodoc:
         | 
| 298 299 | 
             
                _, name, val = exp
         | 
| 300 | 
            +
             | 
| 301 | 
            +
                name = name_to_string process name if Sexp === name
         | 
| 302 | 
            +
             | 
| 299 303 | 
             
                process val
         | 
| 300 304 |  | 
| 301 305 | 
             
                signature = "#{klass_name}::#{name}"
         | 
| @@ -307,6 +311,19 @@ class Debride < MethodBasedSexpProcessor | |
| 307 311 | 
             
                exp
         | 
| 308 312 | 
             
              end
         | 
| 309 313 |  | 
| 314 | 
            +
              def name_to_string exp
         | 
| 315 | 
            +
                case exp.sexp_type
         | 
| 316 | 
            +
                when :colon2 then
         | 
| 317 | 
            +
                  _, (_, lhs), rhs = exp
         | 
| 318 | 
            +
                  "#{lhs}::#{rhs}"
         | 
| 319 | 
            +
                when :colon3 then
         | 
| 320 | 
            +
                  _, rhs = exp
         | 
| 321 | 
            +
                  "::#{rhs}"
         | 
| 322 | 
            +
                else
         | 
| 323 | 
            +
                  raise "Not handled: #{exp.inspect}"
         | 
| 324 | 
            +
                end
         | 
| 325 | 
            +
              end
         | 
| 326 | 
            +
             | 
| 310 327 | 
             
              def process_colon2 exp # :nodoc:
         | 
| 311 328 | 
             
                _, lhs, name = exp
         | 
| 312 329 | 
             
                process lhs
         | 
| @@ -381,37 +398,79 @@ class Debride < MethodBasedSexpProcessor | |
| 381 398 | 
             
                by_class.sort_by { |k,v| k }
         | 
| 382 399 | 
             
              end
         | 
| 383 400 |  | 
| 401 | 
            +
              def missing_locations
         | 
| 402 | 
            +
                focus = option[:focus]
         | 
| 403 | 
            +
             | 
| 404 | 
            +
                missing.map { |klass, meths|
         | 
| 405 | 
            +
                  bad = meths.map { |meth|
         | 
| 406 | 
            +
                    location =
         | 
| 407 | 
            +
                      method_locations["#{klass}##{meth}"] ||
         | 
| 408 | 
            +
                      method_locations["#{klass}::#{meth}"]
         | 
| 409 | 
            +
             | 
| 410 | 
            +
                    if focus then
         | 
| 411 | 
            +
                      path = location[/(.+):\d+/, 1]
         | 
| 412 | 
            +
             | 
| 413 | 
            +
                      next unless File.fnmatch(focus, path)
         | 
| 414 | 
            +
                    end
         | 
| 415 | 
            +
             | 
| 416 | 
            +
                    [meth, location]
         | 
| 417 | 
            +
                  }.compact
         | 
| 418 | 
            +
             | 
| 419 | 
            +
                  [klass, bad]
         | 
| 420 | 
            +
                }
         | 
| 421 | 
            +
                  .to_h
         | 
| 422 | 
            +
                  .reject { |k,v| v.empty? }
         | 
| 423 | 
            +
              end
         | 
| 424 | 
            +
             | 
| 384 425 | 
             
              ##
         | 
| 385 426 | 
             
              # Print out a report of suspects.
         | 
| 386 427 |  | 
| 387 | 
            -
              def report
         | 
| 428 | 
            +
              def report io = $stdout
         | 
| 388 429 | 
             
                focus = option[:focus]
         | 
| 430 | 
            +
                type  = option[:format] || :text
         | 
| 431 | 
            +
             | 
| 432 | 
            +
                send "report_#{type}", io, focus, missing_locations
         | 
| 433 | 
            +
              end
         | 
| 389 434 |  | 
| 435 | 
            +
              def report_text io, focus, missing
         | 
| 390 436 | 
             
                if focus then
         | 
| 391 | 
            -
                  puts "Focusing on #{focus}"
         | 
| 392 | 
            -
                  puts
         | 
| 437 | 
            +
                  io.puts "Focusing on #{focus}"
         | 
| 438 | 
            +
                  io.puts
         | 
| 393 439 | 
             
                end
         | 
| 394 440 |  | 
| 395 | 
            -
                puts "These methods MIGHT not be called:"
         | 
| 441 | 
            +
                io.puts "These methods MIGHT not be called:"
         | 
| 396 442 |  | 
| 397 443 | 
             
                missing.each do |klass, meths|
         | 
| 398 | 
            -
                  bad = meths.map { |meth|
         | 
| 399 | 
            -
             | 
| 400 | 
            -
             | 
| 401 | 
            -
             | 
| 402 | 
            -
             | 
| 444 | 
            +
                  bad = meths.map { |(meth, location)| "  %-35s %s" % [meth, location] }
         | 
| 445 | 
            +
             | 
| 446 | 
            +
                  io.puts
         | 
| 447 | 
            +
                  io.puts klass
         | 
| 448 | 
            +
                  io.puts bad.join "\n"
         | 
| 449 | 
            +
                end
         | 
| 450 | 
            +
              end
         | 
| 403 451 |  | 
| 404 | 
            -
             | 
| 452 | 
            +
              def report_json io, focus, missing
         | 
| 453 | 
            +
                require "json"
         | 
| 405 454 |  | 
| 406 | 
            -
             | 
| 407 | 
            -
                   | 
| 408 | 
            -
             | 
| 409 | 
            -
                  next if bad.empty?
         | 
| 455 | 
            +
                data = {
         | 
| 456 | 
            +
                  :missing => missing
         | 
| 457 | 
            +
                }
         | 
| 410 458 |  | 
| 411 | 
            -
             | 
| 412 | 
            -
             | 
| 413 | 
            -
             | 
| 414 | 
            -
             | 
| 459 | 
            +
                data[:focus] = focus if focus
         | 
| 460 | 
            +
             | 
| 461 | 
            +
                JSON.dump data, io
         | 
| 462 | 
            +
              end
         | 
| 463 | 
            +
             | 
| 464 | 
            +
              def report_yaml io, focus, missing
         | 
| 465 | 
            +
                require "yaml"
         | 
| 466 | 
            +
             | 
| 467 | 
            +
                data = {
         | 
| 468 | 
            +
                  :missing => missing
         | 
| 469 | 
            +
                }
         | 
| 470 | 
            +
             | 
| 471 | 
            +
                data[:focus] = focus if focus
         | 
| 472 | 
            +
             | 
| 473 | 
            +
                YAML.dump data, io
         | 
| 415 474 | 
             
              end
         | 
| 416 475 |  | 
| 417 476 | 
             
              ##
         | 
    
        data/test/test_debride.rb
    CHANGED
    
    | @@ -8,10 +8,31 @@ class SafeDebride < Debride | |
| 8 8 | 
             
            end
         | 
| 9 9 |  | 
| 10 10 | 
             
            class TestDebride < Minitest::Test
         | 
| 11 | 
            +
              EXP_LIST = [["Debride",
         | 
| 12 | 
            +
                           [:process_attrasgn,
         | 
| 13 | 
            +
                            :process_call,
         | 
| 14 | 
            +
                            :process_cdecl,
         | 
| 15 | 
            +
                            :process_colon2,
         | 
| 16 | 
            +
                            :process_colon3,
         | 
| 17 | 
            +
                            :process_const,
         | 
| 18 | 
            +
                            :process_defn,
         | 
| 19 | 
            +
                            :process_defs,
         | 
| 20 | 
            +
                            :process_rb,
         | 
| 21 | 
            +
                            :report,
         | 
| 22 | 
            +
                            :report_json,
         | 
| 23 | 
            +
                            :report_text,
         | 
| 24 | 
            +
                            :report_yaml]]]
         | 
| 25 | 
            +
             | 
| 26 | 
            +
              formatted_vals = EXP_LIST.map { |k,vs|
         | 
| 27 | 
            +
                [k, vs.map { |v| [v, "lib/debride.rb:###"] } ]
         | 
| 28 | 
            +
              }.to_h
         | 
| 29 | 
            +
             | 
| 30 | 
            +
              EXP_FORMATTED = { :missing => formatted_vals }
         | 
| 31 | 
            +
             | 
| 11 32 | 
             
              def assert_option arg, exp_arg, exp_opt
         | 
| 12 33 | 
             
                opt = SafeDebride.parse_options arg
         | 
| 13 34 |  | 
| 14 | 
            -
                exp_opt = {:whitelist => []}.merge exp_opt
         | 
| 35 | 
            +
                exp_opt = {:whitelist => [], :format => :text}.merge exp_opt
         | 
| 15 36 | 
             
                assert_equal exp_opt, opt
         | 
| 16 37 | 
             
                assert_equal exp_arg, arg
         | 
| 17 38 | 
             
              end
         | 
| @@ -27,20 +48,13 @@ class TestDebride < Minitest::Test | |
| 27 48 | 
             
              end
         | 
| 28 49 |  | 
| 29 50 | 
             
              def test_sanity
         | 
| 30 | 
            -
                skip "This is slow" unless ENV["SLOW"]
         | 
| 31 | 
            -
             | 
| 32 51 | 
             
                debride = nil
         | 
| 33 52 |  | 
| 34 53 | 
             
                assert_silent do
         | 
| 35 54 | 
             
                  debride = Debride.run %w[lib]
         | 
| 36 55 | 
             
                end
         | 
| 37 56 |  | 
| 38 | 
            -
                 | 
| 39 | 
            -
                        [:process_attrasgn, :process_call, :process_cdecl, :process_colon2,
         | 
| 40 | 
            -
                         :process_colon3, :process_const, :process_defn, :process_defs,
         | 
| 41 | 
            -
                         :process_rb, :report]]]
         | 
| 42 | 
            -
             | 
| 43 | 
            -
                assert_equal exp, debride.missing
         | 
| 57 | 
            +
                assert_equal EXP_LIST, debride.missing
         | 
| 44 58 | 
             
              end
         | 
| 45 59 |  | 
| 46 60 | 
             
              def test_parse_options
         | 
| @@ -85,16 +99,63 @@ class TestDebride < Minitest::Test | |
| 85 99 | 
             
              end
         | 
| 86 100 |  | 
| 87 101 | 
             
              def test_exclude_files
         | 
| 88 | 
            -
                 | 
| 102 | 
            +
                debride = Debride.run %w[--exclude test/ lib test]
         | 
| 103 | 
            +
             | 
| 104 | 
            +
                assert_equal EXP_LIST, debride.missing
         | 
| 105 | 
            +
              end
         | 
| 89 106 |  | 
| 90 | 
            -
             | 
| 107 | 
            +
              def test_exclude_files__multiple
         | 
| 108 | 
            +
                debride = Debride.run %w[--exclude test,lib lib test]
         | 
| 91 109 |  | 
| 92 | 
            -
                 | 
| 93 | 
            -
             | 
| 94 | 
            -
                         :process_colon3, :process_const, :process_defn, :process_defs,
         | 
| 95 | 
            -
                         :process_rb, :report]]]
         | 
| 110 | 
            +
                assert_empty debride.missing
         | 
| 111 | 
            +
              end
         | 
| 96 112 |  | 
| 97 | 
            -
             | 
| 113 | 
            +
              def test_exclude_files__dir_without_slash
         | 
| 114 | 
            +
                debride = Debride.run %w[--exclude test lib test]
         | 
| 115 | 
            +
             | 
| 116 | 
            +
                assert_equal EXP_LIST, debride.missing
         | 
| 117 | 
            +
              end
         | 
| 118 | 
            +
             | 
| 119 | 
            +
              def test_focus
         | 
| 120 | 
            +
                debride = Debride.run %w[--focus lib/debride.rb lib test]
         | 
| 121 | 
            +
                io      = StringIO.new
         | 
| 122 | 
            +
             | 
| 123 | 
            +
                debride.report(io)
         | 
| 124 | 
            +
             | 
| 125 | 
            +
                assert_includes io.string, "Focusing on lib/debride.rb"
         | 
| 126 | 
            +
              end
         | 
| 127 | 
            +
             | 
| 128 | 
            +
              def test_format__plain
         | 
| 129 | 
            +
                debride = Debride.run %w[lib]
         | 
| 130 | 
            +
                io      = StringIO.new
         | 
| 131 | 
            +
             | 
| 132 | 
            +
                debride.report(io)
         | 
| 133 | 
            +
             | 
| 134 | 
            +
                assert_match %r%process_attrasgn\s+lib/debride.rb:\d+-\d+%, io.string
         | 
| 135 | 
            +
              end
         | 
| 136 | 
            +
             | 
| 137 | 
            +
              def test_format__json
         | 
| 138 | 
            +
                debride = Debride.run %w[lib --json]
         | 
| 139 | 
            +
                io      = StringIO.new
         | 
| 140 | 
            +
             | 
| 141 | 
            +
                debride.report(io)
         | 
| 142 | 
            +
             | 
| 143 | 
            +
                exp  = JSON.load JSON.dump EXP_FORMATTED # force stringify
         | 
| 144 | 
            +
                data = JSON.load io.string.gsub(/\d+-\d+/, "###")
         | 
| 145 | 
            +
             | 
| 146 | 
            +
                assert_equal exp, data
         | 
| 147 | 
            +
              end
         | 
| 148 | 
            +
             | 
| 149 | 
            +
              def test_format__yaml
         | 
| 150 | 
            +
                debride = Debride.run %w[lib --yaml]
         | 
| 151 | 
            +
                io      = StringIO.new
         | 
| 152 | 
            +
             | 
| 153 | 
            +
                debride.report(io)
         | 
| 154 | 
            +
             | 
| 155 | 
            +
                exp  = EXP_FORMATTED
         | 
| 156 | 
            +
                data = YAML.load io.string.gsub(/\d+-\d+/, "###")
         | 
| 157 | 
            +
             | 
| 158 | 
            +
                assert_equal exp, data
         | 
| 98 159 | 
             
              end
         | 
| 99 160 |  | 
| 100 161 | 
             
              def test_whitelist
         | 
| @@ -186,6 +247,26 @@ class TestDebride < Minitest::Test | |
| 186 247 | 
             
                assert_process exp, ruby, :rails => true
         | 
| 187 248 | 
             
              end
         | 
| 188 249 |  | 
| 250 | 
            +
              def test_cdecl_const2
         | 
| 251 | 
            +
                ruby = <<-RUBY.strip
         | 
| 252 | 
            +
                  class Z
         | 
| 253 | 
            +
                    X::Y = 42
         | 
| 254 | 
            +
                  end
         | 
| 255 | 
            +
                RUBY
         | 
| 256 | 
            +
             | 
| 257 | 
            +
                assert_process [["Z", ["X::Y"]]], ruby
         | 
| 258 | 
            +
              end
         | 
| 259 | 
            +
             | 
| 260 | 
            +
              def test_cdecl_const3
         | 
| 261 | 
            +
                ruby = <<-RUBY.strip
         | 
| 262 | 
            +
                  class Z
         | 
| 263 | 
            +
                    ::Y = 42
         | 
| 264 | 
            +
                  end
         | 
| 265 | 
            +
                RUBY
         | 
| 266 | 
            +
             | 
| 267 | 
            +
                assert_process [["Z", ["::Y"]]], ruby
         | 
| 268 | 
            +
              end
         | 
| 269 | 
            +
             | 
| 189 270 | 
             
              def test_method_send
         | 
| 190 271 | 
             
                ruby = <<-RUBY.strip
         | 
| 191 272 | 
             
                  class Seattle
         | 
    
        data.tar.gz.sig
    CHANGED
    
    | @@ -1,2 +1,2 @@ | |
| 1 | 
            -
             | 
| 2 | 
            -
             | 
| 1 | 
            +
            ^$	ߦ��jhB>��!F"Bvu�m���f�*��:�\q�Ӫ�bjF�<����]2�Iv��� �_��J<c�U�P�J<�lq��ФŮ�G�[�҄�&��tÆ��Q�z�̌c���6Ey�`Vșa�Ƅ��"
         | 
| 2 | 
            +
            :��6������C��{��[�ݿ}�IYš�|��Y���8��w.d���9�z�$��~u�l𝋀�E���s;)�Z��Q+��w($��<m�Qq����PZ%�e$�\Nx�Nrn�Z
         | 
    
        metadata
    CHANGED
    
    | @@ -1,18 +1,18 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: debride
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 1. | 
| 4 | 
            +
              version: 1.9.0
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors:
         | 
| 7 7 | 
             
            - Ryan Davis
         | 
| 8 | 
            -
            autorequire: | 
| 8 | 
            +
            autorequire:
         | 
| 9 9 | 
             
            bindir: bin
         | 
| 10 10 | 
             
            cert_chain:
         | 
| 11 11 | 
             
            - |
         | 
| 12 12 | 
             
              -----BEGIN CERTIFICATE-----
         | 
| 13 | 
            -
               | 
| 13 | 
            +
              MIIDPjCCAiagAwIBAgIBBjANBgkqhkiG9w0BAQsFADBFMRMwEQYDVQQDDApyeWFu
         | 
| 14 14 | 
             
              ZC1ydWJ5MRkwFwYKCZImiZPyLGQBGRYJemVuc3BpZGVyMRMwEQYKCZImiZPyLGQB
         | 
| 15 | 
            -
               | 
| 15 | 
            +
              GRYDY29tMB4XDTIxMTIyMzIzMTkwNFoXDTIyMTIyMzIzMTkwNFowRTETMBEGA1UE
         | 
| 16 16 | 
             
              AwwKcnlhbmQtcnVieTEZMBcGCgmSJomT8ixkARkWCXplbnNwaWRlcjETMBEGCgmS
         | 
| 17 17 | 
             
              JomT8ixkARkWA2NvbTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBALda
         | 
| 18 18 | 
             
              b9DCgK+627gPJkB6XfjZ1itoOQvpqH1EXScSaba9/S2VF22VYQbXU1xQXL/WzCkx
         | 
| @@ -20,17 +20,16 @@ cert_chain: | |
| 20 20 | 
             
              oOvjtt5P8+GSK9zLzxQP0gVLS/D0FmoE44XuDr3iQkVS2ujU5zZL84mMNqNB1znh
         | 
| 21 21 | 
             
              GiadM9GHRaDiaxuX0cIUBj19T01mVE2iymf9I6bEsiayK/n6QujtyCbTWsAS9Rqt
         | 
| 22 22 | 
             
              qhtV7HJxNKuPj/JFH0D2cswvzznE/a5FOYO68g+YCuFi5L8wZuuM8zzdwjrWHqSV
         | 
| 23 | 
            -
              gBEfoTEGr7Zii72cx+ | 
| 24 | 
            -
               | 
| 25 | 
            -
               | 
| 26 | 
            -
               | 
| 27 | 
            -
               | 
| 28 | 
            -
               | 
| 29 | 
            -
               | 
| 30 | 
            -
               | 
| 31 | 
            -
              fO6tdKQc/5RfA8oQEkg8hrxA5PQSz4TOFJGLpFvIapEk6tMruQ0bHgkhr9auXg==
         | 
| 23 | 
            +
              gBEfoTEGr7Zii72cx+sCAwEAAaM5MDcwCQYDVR0TBAIwADALBgNVHQ8EBAMCBLAw
         | 
| 24 | 
            +
              HQYDVR0OBBYEFEfFe9md/r/tj/Wmwpy+MI8d9k/hMA0GCSqGSIb3DQEBCwUAA4IB
         | 
| 25 | 
            +
              AQCKB5jfsuSnKb+t/Wrh3UpdkmX7TrEsjVmERC0pPqzQ5GQJgmEXDD7oMgaKXaAq
         | 
| 26 | 
            +
              x2m+KSZDrqk7c8uho5OX6YMqg4KdxehfSLqqTZGoeV78qwf/jpPQZKTf+W9gUSJh
         | 
| 27 | 
            +
              zsWpo4K50MP+QtdSbKXZwjAafpQ8hK0MnnZ/aeCsW9ov5vdXpYbf3dpg6ADXRGE7
         | 
| 28 | 
            +
              lQY2y1tJ5/chqu6h7dQmnm2ABUqx9O+JcN9hbCYoA5i/EeubUEtFIh2w3SpO6YfB
         | 
| 29 | 
            +
              JFmxn4h9YO/pVdB962BdBNNDia0kgIjI3ENnkLq0dKpYU3+F3KhEuTksLO0L6X/V
         | 
| 30 | 
            +
              YsuyUzsMz6GQA4khyaMgKNSD
         | 
| 32 31 | 
             
              -----END CERTIFICATE-----
         | 
| 33 | 
            -
            date:  | 
| 32 | 
            +
            date: 2022-05-23 00:00:00.000000000 Z
         | 
| 34 33 | 
             
            dependencies:
         | 
| 35 34 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 36 35 | 
             
              name: sexp_processor
         | 
| @@ -78,30 +77,36 @@ dependencies: | |
| 78 77 | 
             
              name: rdoc
         | 
| 79 78 | 
             
              requirement: !ruby/object:Gem::Requirement
         | 
| 80 79 | 
             
                requirements:
         | 
| 81 | 
            -
                - - " | 
| 80 | 
            +
                - - ">="
         | 
| 82 81 | 
             
                  - !ruby/object:Gem::Version
         | 
| 83 82 | 
             
                    version: '4.0'
         | 
| 83 | 
            +
                - - "<"
         | 
| 84 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 85 | 
            +
                    version: '7'
         | 
| 84 86 | 
             
              type: :development
         | 
| 85 87 | 
             
              prerelease: false
         | 
| 86 88 | 
             
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 87 89 | 
             
                requirements:
         | 
| 88 | 
            -
                - - " | 
| 90 | 
            +
                - - ">="
         | 
| 89 91 | 
             
                  - !ruby/object:Gem::Version
         | 
| 90 92 | 
             
                    version: '4.0'
         | 
| 93 | 
            +
                - - "<"
         | 
| 94 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 95 | 
            +
                    version: '7'
         | 
| 91 96 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 92 97 | 
             
              name: hoe
         | 
| 93 98 | 
             
              requirement: !ruby/object:Gem::Requirement
         | 
| 94 99 | 
             
                requirements:
         | 
| 95 100 | 
             
                - - "~>"
         | 
| 96 101 | 
             
                  - !ruby/object:Gem::Version
         | 
| 97 | 
            -
                    version: '3. | 
| 102 | 
            +
                    version: '3.23'
         | 
| 98 103 | 
             
              type: :development
         | 
| 99 104 | 
             
              prerelease: false
         | 
| 100 105 | 
             
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 101 106 | 
             
                requirements:
         | 
| 102 107 | 
             
                - - "~>"
         | 
| 103 108 | 
             
                  - !ruby/object:Gem::Version
         | 
| 104 | 
            -
                    version: '3. | 
| 109 | 
            +
                    version: '3.23'
         | 
| 105 110 | 
             
            description: Analyze code for potentially uncalled / dead methods, now with auto-removal.
         | 
| 106 111 | 
             
            email:
         | 
| 107 112 | 
             
            - ryand-ruby@zenspider.com
         | 
| @@ -128,8 +133,9 @@ files: | |
| 128 133 | 
             
            homepage: https://github.com/seattlerb/debride
         | 
| 129 134 | 
             
            licenses:
         | 
| 130 135 | 
             
            - MIT
         | 
| 131 | 
            -
            metadata: | 
| 132 | 
            -
             | 
| 136 | 
            +
            metadata:
         | 
| 137 | 
            +
              homepage_uri: https://github.com/seattlerb/debride
         | 
| 138 | 
            +
            post_install_message:
         | 
| 133 139 | 
             
            rdoc_options:
         | 
| 134 140 | 
             
            - "--main"
         | 
| 135 141 | 
             
            - README.rdoc
         | 
| @@ -146,9 +152,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement | |
| 146 152 | 
             
                - !ruby/object:Gem::Version
         | 
| 147 153 | 
             
                  version: '0'
         | 
| 148 154 | 
             
            requirements: []
         | 
| 149 | 
            -
             | 
| 150 | 
            -
             | 
| 151 | 
            -
            signing_key: 
         | 
| 155 | 
            +
            rubygems_version: 3.3.12
         | 
| 156 | 
            +
            signing_key:
         | 
| 152 157 | 
             
            specification_version: 4
         | 
| 153 158 | 
             
            summary: Analyze code for potentially uncalled / dead methods, now with auto-removal.
         | 
| 154 159 | 
             
            test_files: []
         | 
    
        metadata.gz.sig
    CHANGED
    
    | Binary file |