Skip to content

Commit

Permalink
[Fix #11803] Update the doc for Style/RedundantFetchBlock
Browse files Browse the repository at this point in the history
Fixes #11803.

This PR adds a note to the doc for `Style/RedundantFetchBlock` about the difference
in behavior between enabled and disabled frozen string magic literal comment.
  • Loading branch information
koic authored and bbatsov committed Apr 17, 2023
1 parent b5c8dda commit f59711f
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions lib/rubocop/cop/style/redundant_fetch_block.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@
module RuboCop
module Cop
module Style
# Identifies places where `fetch(key) { value }`
# can be replaced by `fetch(key, value)`.
# Identifies places where `fetch(key) { value }` can be replaced by `fetch(key, value)`.
#
# In such cases `fetch(key, value)` method is faster
# than `fetch(key) { value }`.
# In such cases `fetch(key, value)` method is faster than `fetch(key) { value }`.
#
# NOTE: The block string `'value'` in `hash.fetch(:key) { 'value' }` is detected
# when frozen string literal magic comment is enabled (i.e. `# frozen_string_literal: true`),
# but not when disabled.
#
# @safety
# This cop is unsafe because it cannot be guaranteed that the receiver
Expand Down

0 comments on commit f59711f

Please sign in to comment.