From 4d04e1bbef617cdee6bf15fc3c87b42da7080aea Mon Sep 17 00:00:00 2001 From: Koichi ITO Date: Thu, 7 Mar 2024 00:20:00 +0900 Subject: [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 --- lib/prism/translation/parser/rubocop.rb | 10 ++++++++++ 1 file changed, 10 insertions(+) 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 -- cgit v1.2.3