Skip to content

Commit

Permalink
Suppress new RuboCop offenses
Browse files Browse the repository at this point in the history
Follow up rubocop/rubocop#13242

This commit removes the following redundant `source_range` to suppress new RuboCop offenses:

```console
$ bundle exec rake
(snip)

Offenses:

lib/rubocop/cop/rails/redundant_foreign_key.rb:43:44: C: [Corrected] InternalAffairs/RedundantSourceRange: Remove the redundant source_range.
              add_offense(foreign_key_pair.source_range) do |corrector|
                                           ^^^^^^^^^^^^
lib/rubocop/cop/rails/redundant_receiver_in_with_options.rb:81:34: C: [Corrected] InternalAffairs/RedundantSourceRange: Remove the redundant source_range.
            add_offense(receiver.source_range) do |corrector|
                                 ^^^^^^^^^^^^
lib/rubocop/cop/rails/reflection_class_name.rb:46:47: C: [Corrected] InternalAffairs/RedundantSourceRange: Remove the redundant source_range.
            add_offense(reflection_class_name.source_range) do |corrector|
                                              ^^^^^^^^^^^^
lib/rubocop/cop/rails/request_referer.rb:37:30: C: [Corrected] InternalAffairs/RedundantSourceRange: Remove the redundant source_range.
            add_offense(node.source_range) do |corrector|
                             ^^^^^^^^^^^^

296 files inspected, 4 offenses detected, 4 offenses corrected
```
  • Loading branch information
koic committed Sep 17, 2024
1 parent 4a00257 commit f935a0b
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion lib/rubocop/cop/rails/redundant_foreign_key.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class RedundantForeignKey < Base
def on_send(node)
association_with_foreign_key(node) do |type, name, options, foreign_key_pair, foreign_key|
if redundant?(node, type, name, options, foreign_key)
add_offense(foreign_key_pair.source_range) do |corrector|
add_offense(foreign_key_pair) do |corrector|
range = range_with_surrounding_space(foreign_key_pair.source_range, side: :left)
range = range_with_surrounding_comma(range, :left)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ def on_block(node)

send_nodes.each do |send_node|
receiver = send_node.receiver
add_offense(receiver.source_range) do |corrector|
add_offense(receiver) do |corrector|
autocorrect(corrector, send_node, node)
end
end
Expand Down
2 changes: 1 addition & 1 deletion lib/rubocop/cop/rails/reflection_class_name.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def on_send(node)
return if reflection_class_name.value.send_type? && reflection_class_name.value.receiver.nil?
return if reflection_class_name.value.lvar_type? && str_assigned?(reflection_class_name)

add_offense(reflection_class_name.source_range) do |corrector|
add_offense(reflection_class_name) do |corrector|
autocorrect(corrector, reflection_class_name)
end
end
Expand Down
2 changes: 1 addition & 1 deletion lib/rubocop/cop/rails/request_referer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def on_send(node)
referer?(node) do
return unless node.method?(wrong_method_name)

add_offense(node.source_range) do |corrector|
add_offense(node) do |corrector|
corrector.replace(node, "request.#{style}")
end
end
Expand Down

0 comments on commit f935a0b

Please sign in to comment.