[ruby/prism] Remove deprecated lib/prism/translation/parser/rubocop.rb file

Follow up https://github.com/ruby/prism/pull/2558.

This PR removes deprecated lib/prism/translation/parser/rubocop.rb file.

The file was a workaround to allow setting `TargetRubyVersion: 80_82_73_83_77.xx` until Prism (`Prism::Translation::Parser`) is integrated into RuboCop.
RuboCop already supports Prism (`Prism::Translation::Parser`) as of https://github.com/rubocop/rubocop/pull/12724.

It has been several months since the file was deprecated in ruby/prism#2558.
And, yesterday, Prism 1.0.0 was released, but perhaps the file should have been removed before then.

Although this might be seen as incompatible with semver 1.0.0, I think there is no longer a reason to keep the file.

https://github.com/ruby/prism/commit/646a10270e
This commit is contained in:
Koichi ITO 2024-08-21 02:56:21 +09:00 committed by git
parent 22d9260f05
commit af65b41e07
2 changed files with 0 additions and 74 deletions

View File

@ -95,7 +95,6 @@ Gem::Specification.new do |spec|
"lib/prism/translation/parser34.rb",
"lib/prism/translation/parser/compiler.rb",
"lib/prism/translation/parser/lexer.rb",
"lib/prism/translation/parser/rubocop.rb",
"lib/prism/translation/ripper.rb",
"lib/prism/translation/ripper/sexp.rb",
"lib/prism/translation/ripper/shim.rb",

View File

@ -1,73 +0,0 @@
# 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"
require_relative "../../prism"
require_relative "../parser"
module Prism
module Translation
class Parser
# This is the special version numbers that should be used in RuboCop
# configuration files to trigger using prism.
# For Ruby 3.3
VERSION_3_3 = 80_82_73_83_77.33
# For Ruby 3.4
VERSION_3_4 = 80_82_73_83_77.34
# This module gets prepended into RuboCop::AST::ProcessedSource.
module ProcessedSource
# This condition is compatible with rubocop-ast versions up to 1.30.0.
if RuboCop::AST::ProcessedSource.instance_method(:parser_class).arity == 1
# Redefine parser_class so that we can inject the prism parser into the
# 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_relative "../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_relative "../parser34"
Prism::Translation::Parser34
else
super
end
end
else
# Redefine parser_class so that we can inject the prism parser into the
# 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_relative "../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_relative "../parser34"
Prism::Translation::Parser34
else
super
end
end
end
end
end
end
end
# :stopdoc:
RuboCop::AST::ProcessedSource.prepend(Prism::Translation::Parser::ProcessedSource)
known_rubies = RuboCop::TargetRuby.const_get(:KNOWN_RUBIES)
RuboCop::TargetRuby.send(:remove_const, :KNOWN_RUBIES)
RuboCop::TargetRuby::KNOWN_RUBIES = [*known_rubies, Prism::Translation::Parser::VERSION_3_3].freeze