Skip to content

Conversation

@r7kamura
Copy link
Contributor

@r7kamura r7kamura commented Nov 22, 2025

This is not a significant change, just minor refactoring.

requires_gem was added in rubocop 1.63.0.

rubocop-rails currently requires rubocop 1.75.0 or higher.

s.add_dependency 'rubocop', '>= 1.75.0', '< 2.0'

Therefore, the code to maintain compatibility with rubocop versions below 1.63.0 is likely no longer necessary.

@r7kamura
Copy link
Contributor Author

r7kamura commented Nov 23, 2025

Or, perhaps it would be better to make more aggressive changes as follows:

diff --git a/lib/rubocop/cop/mixin/target_rails_version.rb b/lib/rubocop/cop/mixin/target_rails_version.rb
index b4240f5b2..606344144 100644
--- a/lib/rubocop/cop/mixin/target_rails_version.rb
+++ b/lib/rubocop/cop/mixin/target_rails_version.rb
@@ -4,9 +4,6 @@ module RuboCop
   module Cop
     # Common functionality for checking target rails version.
     module TargetRailsVersion
-      # Informs the base RuboCop gem that it the Rails version is checked via `requires_gem` API,
-      # without needing to call this `#support_target_rails_version` method.
-      USES_REQUIRES_GEM_API = true
       # Look for `railties` instead of `rails`, to support apps that only use a subset of `rails`
       # See https://github.com/rubocop/rubocop/pull/11289
       TARGET_GEM_NAME = 'railties' # :nodoc:
@@ -17,15 +14,6 @@ module RuboCop
         when String then requires_gem(TARGET_GEM_NAME, version)
         end
       end
-
-      def support_target_rails_version?(version)
-        return false unless gem_requirements
-
-        gem_requirement = gem_requirements[TARGET_GEM_NAME]
-        return true unless gem_requirement # If we have no requirement, then we support all versions
-
-        gem_requirement.satisfied_by?(Gem::Version.new(version))
-      end
     end
   end
 end

If so, please let me know and I will make the changes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant