seattlerb / debride

Analyze code for potentially uncalled / dead methods, now with auto-removal.
https://www.zenspider.com/projects/debride.html
720 stars 19 forks source link

Support newer syntax #46

Closed TSMMark closed 1 year ago

TSMMark commented 1 year ago

Hi thanks for this tool! It's awesome. However, it chokes on "newer" syntax.

Specifically, these are the issues I'm seeing when running on my project:

... all args

def whatever(...)
  whatever_else(...)
end
Parse Error parsing a.rb. Skipping.
  a.rb:55 :: parse error on value "..." (tBDOT3)

oneliner function

def session = @session ||= Session.new
Parse Error parsing b.rb. Skipping.
  b.rb:85 :: parse error on value "=" (tEQL)

What would it take to support newer syntaxes? I could try implementing it if given some initial instructions

zenspider commented 1 year ago

What version of ruby_parser are you using?

TSMMark commented 1 year ago
dev $ bundle info ruby_parser
  * ruby_parser (3.16.0)
TSMMark commented 1 year ago

updating to latest (3.19.2) seems to have solved the issue, thanks!

zenspider commented 1 year ago

Bump it and I think you'll be good:

=== 3.19.2 / 2022-12-03

* 5 bug fixes:

  * Fixed bug parsing array patterns using %w, %i, etc.
  * Fixed dedenting when heredoc has only empty line and interpolation. (mvz)
  * Fixed dsym unescaping. (mvz)
  * Fixed vars in pattern matching that should be lasgn, not lvar.
  * find_pat mid-patterns are now splatted inline, not wrapped in an array_pat.

=== 3.19.1 / 2022-04-05

* 2 bug fixes:

  * Added comments to endless defn and defs. (mvz)
  * Fixed endless method bug handling attrset names.

=== 3.19.0 / 2022-03-29

* 1 major enhancement:

  * Added tentative 3.1 support.

* 7 minor enhancements:

  * 3.1: bare RHS assoc: { y: } => s(:hash, s(:lit, :y), nil)
  * 3.1: calls w/ unnamed block args (bare &)
  * 3.1: endless defn/defs w/ paren-less calls (aka commands)
  * 3.1: pattern capture to nonlocal vars, eg: ^@a, ^$b, ^@@c
  * 3.1: pattern: ^(expr) => expr
  * Improved steps for adding new versions.
  * Improved steps for running gauntlets.

* 2 bug fixes:

  * Bumped 2.6+ cached versions for rake compare.
  * Skip test_regexp_esc_C_slash on ruby 3.1.0 because of MRI bug.

=== 3.18.1 / 2021-11-10

* 1 minor enhancement:

  * All parser tests are now explicitly testing line numbers at every level.

* 3 bug fixes:

  * Fixed endless method with noargs. (mitsuru)
  * Fixed line numbers on some yield forms.
  * Handle and clearly report if unifdef is missing.

=== 3.18.0 / 2021-10-27

Holy crap... 58 commits! 2.7 and 3.0 are feature complete. Strings
& heredocs have been rewritten.

* 9 major enhancements:

  * !!! Rewrote lexer (and friends) for strings, heredocs, and %*[] constructs.
  * Massive overhaul on line numbers.
  * Freeze input! Finally!!! No more modifying the input string for heredocs.
  * Overhauled RPStringScanner. Removed OLD compatibility methods!
  * Removed Sexp methods: value, to_sym, add, add_all, node_type, values.
    * value moved to sexp_processor.
  * Removed String#grep monkey-patch.
  * Removed String#lineno monkey-patch.
  * Removed string_to_pos, charpos, etc hacks for ancient ruby versions.
  * Removed unread_many... NO! NO EDITING THE INPUT STRING!

* 31 minor enhancements:

  * 2.7/3.0: many more pattern edge cases
  * 2.7: Added `mlhs = rhs rescue expr`
  * 2.7: refactored destructured args (`|(k,v)|`) and unfactored(?!) case_body/args.
  * 3.0: excessed_comma
  * 3.0: finished most everything: endless methods, patterns, etc.
  * 3.0: refactored / added new pattern changes
  * Added RubyLexer#in_heredoc? (ie, is there old_ss ?)
  * Added RubyLexer#old_ss and old_lineno and removed much of SSStack(ish).
  * Added Symbol#end_with? when necessary
  * Added TALLY and DEBUG options for ss.getch and ss.scan
  * Added ignore_body_comments to make parser productions more clear.
  * Added support for no_kwarg (eg `def f(**nil)`).
  * Added support for no_kwarg in blocks (eg `f { |**nil| }`).
  * Augmented generated parser files to have frozen_string_literal comments and fixed tests.
  * Broke out 3.0 parser into its own to ease development.
  * Bumped dependencies on sexp_processor and oedipus_lex.
  * Clean generated 3.x files.
  * Extracted all string scanner methods to their own module.
  * Fixed some precedence decls.
  * Implemented most of pattern matching for 2.7+.
  * Improve lex_state= to report location in verbose debug mode.
  * Made it easier to debug with a particular version of ruby via rake.
  * Make sure ripper uses the same version of ruby we specified.
  * Moved all string/heredoc/etc code to ruby_lexer_strings.rb
  * Remove warning from newer bisons.
  * Sprinkled in some frozen_string_literal, but mostly helped by oedipus bump.
  * Switch to comparing against ruby binary since ripper is buggy.
  * bugs task should try both bug*.rb and bad*.rb.
  * endless methods
  * f_any_kwrest refactoring.
  * refactored defn/defs

* 15 bug fixes:

  * Cleaned a bunch of old hacks. Initializing RubyLexer w/ Parser is cleaner now.
  * Corrected some lex_state errors in process_token_keyword.
  * Fixed ancient ruby2 change (use #lines) in ruby_parse_extract_error.
  * Fixed bug where else without rescue only raises on 2.6+
  * Fixed caller for getch and scan when DEBUG=1
  * Fixed comments in the middle of message cascades.
  * Fixed differences w/ symbol productions against ruby 2.7.
  * Fixed dsym to use string_contents production.
  * Fixed error in bdot2/3 in some edge cases. Fixed p_alt line.
  * Fixed heredoc dedenting in the presence of empty lines. (mvz)
  * Fixed some leading whitespace / comment processing
  * Fixed up how class/module/defn/defs comments were collected.
  * Overhauled ripper.rb to deal with buggy ripper w/ yydebug.
  * Removed dsym from literal.
  * Removed tUBANG lexeme but kept it distinct as a method name (eg: `def !@`).

=== 3.17.0 / 2021-08-03

* 1 minor enhancement:

  * Added support for arg forwarding (eg `def f(...); m(...); end`) (presidentbeef)