diff options
author | Koichi ITO <koic.ito@gmail.com> | 2024-03-07 00:20:00 +0900 |
---|---|---|
committer | git <svn-admin@ruby-lang.org> | 2024-03-06 16:11:07 +0000 |
commit | 4d04e1bbef617cdee6bf15fc3c87b42da7080aea (patch) | |
tree | 0782031a0435d0d7049de80715a15f3d0b8342d6 /lib/prism/translation/parser/rubocop.rb | |
parent | 7d3304ec5faed961c9e9e1f08451a2169703f056 (diff) |
[ruby/prism] Deprecate `TargetRubyVersion: 80_82_73_83_77.xx`
Prism has been directly supported as a parser engine since RuboCop 1.62:
https://github.com/rubocop/rubocop/releases/tag/v1.62.0
This makes specifying `TargetRubyVersion` with special values like `80_82_73_83_77.33`
using the `prism/translation/parser/rubocop` file unnecessary.
As a result, it would be possible to deprecate this approach.
OTOH, early users might be surprised if `prism/translation/parser/rubocop` were to be suddenly removed.
Therefore, this PR deprecates the parameters related to `prism/translation/parser/rubocop`.
```console
$ bundle exec ruby -rrubocop -rprism/translation/parser/rubocop -e "RuboCop::AST::ProcessedSource.new('42', 80_82_73_83_77.33).ast"
WARN: Prism is directly supported since RuboCop 1.62. The `prism/translation/parser/rubocop` file is deprecated.
WARN: Setting `TargetRubyVersion: 80_82_73_83_77.33` is deprecated. Set to `ParserEngine: parser_prism` and `TargetRubyVersion: 3.3` instead.
$ bundle exec ruby -rrubocop -rprism/translation/parser/rubocop -e "RuboCop::AST::ProcessedSource.new('42', 80_82_73_83_77.34).ast"
WARN: Prism is directly supported since RuboCop 1.62. The `prism/translation/parser/rubocop` file is deprecated.
WARN: Setting `TargetRubyVersion: 80_82_73_83_77.34` is deprecated. Set to `ParserEngine: parser_prism` and `TargetRubyVersion: 3.4` instead.
```
Eventually, it will be possible to remove it at some point.
Regarding documentation, it has been updated to not show the old, discouraged usage but rather
the new way of specifying it in RuboCop.
https://github.com/ruby/prism/commit/0e4bc31463
Diffstat (limited to 'lib/prism/translation/parser/rubocop.rb')
-rw-r--r-- | lib/prism/translation/parser/rubocop.rb | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/lib/prism/translation/parser/rubocop.rb b/lib/prism/translation/parser/rubocop.rb index e6fd8db290..91602d16ef 100644 --- a/lib/prism/translation/parser/rubocop.rb +++ b/lib/prism/translation/parser/rubocop.rb @@ -1,6 +1,8 @@ # frozen_string_literal: true # typed: ignore +warn "WARN: Prism is directly supported since RuboCop 1.62. The `prism/translation/parser/rubocop` file is deprecated." + require "parser" require "rubocop" @@ -27,9 +29,13 @@ module Prism # list of known parsers. def parser_class(ruby_version) if ruby_version == Prism::Translation::Parser::VERSION_3_3 + warn "WARN: Setting `TargetRubyVersion: 80_82_73_83_77.33` is deprecated. " \ + "Set to `ParserEngine: parser_prism` and `TargetRubyVersion: 3.3` instead." require "prism/translation/parser33" Prism::Translation::Parser33 elsif ruby_version == Prism::Translation::Parser::VERSION_3_4 + warn "WARN: Setting `TargetRubyVersion: 80_82_73_83_77.34` is deprecated. " \ + "Set to `ParserEngine: parser_prism` and `TargetRubyVersion: 3.4` instead." require "prism/translation/parser34" Prism::Translation::Parser34 else @@ -41,9 +47,13 @@ module Prism # list of known parsers. def parser_class(ruby_version, _parser_engine) if ruby_version == Prism::Translation::Parser::VERSION_3_3 + warn "WARN: Setting `TargetRubyVersion: 80_82_73_83_77.33` is deprecated. " \ + "Set to `ParserEngine: parser_prism` and `TargetRubyVersion: 3.3` instead." require "prism/translation/parser33" Prism::Translation::Parser33 elsif ruby_version == Prism::Translation::Parser::VERSION_3_4 + warn "WARN: Setting `TargetRubyVersion: 80_82_73_83_77.34` is deprecated. " \ + "Set to `ParserEngine: parser_prism` and `TargetRubyVersion: 3.4` instead." require "prism/translation/parser34" Prism::Translation::Parser34 else |