Skip to content

Commit 4d04e1b

Browse files
koicmatzbot
authored andcommitted
[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. ruby/prism@0e4bc31463
1 parent 7d3304e commit 4d04e1b

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

lib/prism/translation/parser/rubocop.rb

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
# frozen_string_literal: true
22
# typed: ignore
33

4+
warn "WARN: Prism is directly supported since RuboCop 1.62. The `prism/translation/parser/rubocop` file is deprecated."
5+
46
require "parser"
57
require "rubocop"
68

@@ -27,9 +29,13 @@ module ProcessedSource
2729
# list of known parsers.
2830
def parser_class(ruby_version)
2931
if ruby_version == Prism::Translation::Parser::VERSION_3_3
32+
warn "WARN: Setting `TargetRubyVersion: 80_82_73_83_77.33` is deprecated. " \
33+
"Set to `ParserEngine: parser_prism` and `TargetRubyVersion: 3.3` instead."
3034
require "prism/translation/parser33"
3135
Prism::Translation::Parser33
3236
elsif ruby_version == Prism::Translation::Parser::VERSION_3_4
37+
warn "WARN: Setting `TargetRubyVersion: 80_82_73_83_77.34` is deprecated. " \
38+
"Set to `ParserEngine: parser_prism` and `TargetRubyVersion: 3.4` instead."
3339
require "prism/translation/parser34"
3440
Prism::Translation::Parser34
3541
else
@@ -41,9 +47,13 @@ def parser_class(ruby_version)
4147
# list of known parsers.
4248
def parser_class(ruby_version, _parser_engine)
4349
if ruby_version == Prism::Translation::Parser::VERSION_3_3
50+
warn "WARN: Setting `TargetRubyVersion: 80_82_73_83_77.33` is deprecated. " \
51+
"Set to `ParserEngine: parser_prism` and `TargetRubyVersion: 3.3` instead."
4452
require "prism/translation/parser33"
4553
Prism::Translation::Parser33
4654
elsif ruby_version == Prism::Translation::Parser::VERSION_3_4
55+
warn "WARN: Setting `TargetRubyVersion: 80_82_73_83_77.34` is deprecated. " \
56+
"Set to `ParserEngine: parser_prism` and `TargetRubyVersion: 3.4` instead."
4757
require "prism/translation/parser34"
4858
Prism::Translation::Parser34
4959
else

0 commit comments

Comments
 (0)