Skip to content

Commit 5a405d5

Browse files
dvandersluisbbatsov
authored andcommitted
Update documentation for Style/FormatStringToken for clarity
1 parent 5695986 commit 5a405d5

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

lib/rubocop/cop/style/format_string_token.rb

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,21 @@
33
module RuboCop
44
module Cop
55
module Style
6-
# Use a consistent style for named format string tokens.
6+
# Use a consistent style for tokens within a format string.
77
#
8-
# NOTE: `unannotated` style cop only works for strings
9-
# which are passed as arguments to those methods:
10-
# `printf`, `sprintf`, `format`, `%`.
11-
# The reason is that _unannotated_ format is very similar
12-
# to encoded URLs or Date/Time formatting strings.
8+
# All strings are evaluated. In some cases, this may be undesirable,
9+
# as they could be used as arguments to a method that does not consider
10+
# them to be tokens, but rather other identifiers or just part of the string.
11+
# In these cases, `AllowedMethods` or `AllowedPatterns` can be used to mark the
12+
# method as allowed, thereby avoiding an offense from the cop.
1313
#
14-
# This cop's allowed methods can be customized with `AllowedMethods`.
1514
# By default, there are no allowed methods.
1615
#
16+
# NOTE: Tokens in the `unannotated` style (eg. `%s`) are only considered if used
17+
# in the format string argument to the methods `printf`, `sprintf`, `format` and
18+
# `%`. This is done in order to prevent false positives, because this format is
19+
# very similar to encoded URLs or Date/Time formatting strings.
20+
#
1721
# @example EnforcedStyle: annotated (default)
1822
#
1923
# # bad

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy