Closed
Description
PR #8042 Introduced a change that flagged mismatched format as an offense, but I believe it doesn't take into account the escaped %. Something like %% %{foo}s
should be valid as it has a named component, but the first part is just escaping a % sign.
Expected behavior
No offense when pairing a named format with an escaped %. Other combinations with an escaped % may need to be checked.
Actual behavior
Offense flagged with Lint/FormatParameterMismatch: Format string is invalid because formatting sequence types (numbered, named or unnumbered) are mixed
Steps to reproduce the problem
Something like format('%%%<hex>02X', hex: 10)
-> %0A should be valid. This format string does not throw errors when run.
RuboCop version
$ rubocop -V
0.85.1 (using Parser 2.7.1.3, rubocop-ast 0.0.3, running on ruby 2.6.4 x86_64-darwin18)
Activity
Lint/FormatParameterMismatch
#8126s-mage commentedon Jun 9, 2020
Got another false positive for this cop:
"%{code} - %{message}" % { code: 42, message: "wut" }
. If I understood correctly, this string has only named sequences.[Fix #8124] Fix a false positive for `Lint/FormatParameterMismatch`