Skip to content

Commit

Permalink
Merge pull request #1339 from Earlopain/compatibility-code
Browse files Browse the repository at this point in the history
Remove RuboCop < 1.52 compatibility code
  • Loading branch information
koic authored Aug 25, 2024
2 parents 8fa6856 + 0909f0e commit ecc1d6d
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 39 deletions.
6 changes: 1 addition & 5 deletions lib/rubocop/cop/rails/action_order.rb
Original file line number Diff line number Diff line change
Expand Up @@ -92,11 +92,7 @@ def add_range(range1, range2)
end

def range_with_comments(node)
# rubocop:todo InternalAffairs/LocationExpression
# Using `RuboCop::Ext::Comment#source_range` requires RuboCop > 1.46,
# which introduces https://github.com/rubocop/rubocop/pull/11630.
ranges = [node, *processed_source.ast_with_comments[node]].map { |comment| comment.loc.expression }
# rubocop:enable InternalAffairs/LocationExpression
ranges = [node, *processed_source.ast_with_comments[node]].map(&:source_range)
ranges.reduce do |result, range|
add_range(result, range)
end
Expand Down
6 changes: 1 addition & 5 deletions lib/rubocop/cop/rails/active_record_callbacks_order.rb
Original file line number Diff line number Diff line change
Expand Up @@ -123,11 +123,7 @@ def begin_pos_with_comment(node)
end

def inline_comment?(comment)
# rubocop:todo InternalAffairs/LocationExpression
# Using `RuboCop::Ext::Comment#source_range` requires RuboCop > 1.46,
# which introduces https://github.com/rubocop/rubocop/pull/11630.
!comment_line?(comment.loc.expression.source_line)
# rubocop:enable InternalAffairs/LocationExpression
!comment_line?(comment.source_range.source_line)
end

def start_line_position(node)
Expand Down
29 changes: 0 additions & 29 deletions lib/rubocop/cop/rails/redundant_active_record_all_method.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,35 +3,6 @@
module RuboCop
module Cop
module Rails
# TODO: In the future, please support only RuboCop 1.52+ and use `RuboCop::Cop::AllowedReceivers`:
# https://github.com/rubocop/rubocop/blob/v1.52.0/lib/rubocop/cop/mixin/allowed_receivers.rb
# At that time, this duplicated module implementation can be removed.
module AllowedReceivers
def allowed_receiver?(receiver)
receiver_name = receiver_name(receiver)

allowed_receivers.include?(receiver_name)
end

def receiver_name(receiver)
return receiver_name(receiver.receiver) if receiver.receiver && !receiver.receiver.const_type?

if receiver.send_type?
if receiver.receiver
"#{receiver_name(receiver.receiver)}.#{receiver.method_name}"
else
receiver.method_name.to_s
end
else
receiver.source
end
end

def allowed_receivers
cop_config.fetch('AllowedReceivers', [])
end
end

# Detect redundant `all` used as a receiver for Active Record query methods.
#
# For the methods `delete_all` and `destroy_all`, this cop will only check cases where the receiver is a model.
Expand Down

0 comments on commit ecc1d6d

Please sign in to comment.