ruby-syntax-tree / syntax_tree

Interact with the Ruby syntax tree
https://ruby-syntax-tree.github.io/syntax_tree/
MIT License
568 stars 55 forks source link

Plugins expect different arguments for `format` method #313

Open nixme opened 1 year ago

nixme commented 1 year ago

When using syntax_tree-rbs plugin (and it looks like others too), stree check will throw warnings (and error in the check rake task):

[warn] sig/merge_sitemaps.rbs
wrong number of arguments (given 3, expected 1..2)
.../vendor/bundle/ruby/3.2.0/gems/syntax_tree-rbs-0.5.1/lib/syntax_tree/rbs.rb:47:in `format'
.../vendor/bundle/ruby/3.2.0/gems/syntax_tree-6.0.0/lib/syntax_tree/cli.rb:136:in `run'
.../vendor/bundle/ruby/3.2.0/gems/syntax_tree-6.0.0/lib/syntax_tree/cli.rb:580:in `block (2 levels) in process_queue'

I believe this changed with a3c65df07baa42c348ac9a8c17463807b05d7f4e (included in versions 5.0.0 and greater).

The call to each formatter went from format(source, options.print_width) to format(source, options.print_width, options: options.formatter_options)

I'm happy make some PRs, but didn't know if you wanted to fix this is in each plugin, or for compatibility, check arity here in the main project and call appropriately.

kddnewton commented 1 year ago

Oh no! Looks like you're right and I'm depending on an API that I really shouldn't be.

I think I'd like to include all of the various plugins in this project and check that they're working properly.

Thanks for opening the issue!