rubocop / rubocop-ast

RuboCop's AST extensions and NodePattern functionality
https://docs.rubocop.org/rubocop-ast
MIT License
104 stars 52 forks source link

Improve error message for invalid `parser_engine` value #286

Closed Earlopain closed 7 months ago

Earlopain commented 7 months ago

parser doesn't exist, it must be parser_whitequark. In addition, this only accepts symbols.

When passing a string, this would previously print The keyword argument `parser_engine` accepts `parser` or `parser_prism`, but `parser_prism` was passed.. Use inspect to clearly show what you did wrong.

The new error message looks like this: The keyword argument `parser_engine` accepts `:parser_whitequark` or `:parser_prism`, but `"parser_prism"` was passed..

koic commented 7 months ago

It seems to be issues with Layout/LineLength. https://github.com/rubocop/rubocop-ast/actions/runs/8201827148/job/22431355671?pr=286

Earlopain commented 7 months ago

Yes, sorry. I already force-pushed.

bbatsov commented 7 months ago

I wonder if we shouldn't convert strings to keywords automatically here (if passed), as it's not a big deal.

Earlopain commented 7 months ago

That makes sense to me. Reverted most of the error message changes since they are now unnecessary and made it to instead accept strings as well.

marcandre commented 7 months ago

Released in v1.31.2, thanks!

koic commented 7 months ago

I had initially decided to accept only symbol argument, designing it would lead to better performance through consistency. But, currently, I think the convenience of accepting both string and symbol argument might be more beneficial. Let's accept both 👍