Rubocop 0.52.0 introduced check for unannotated style, and now it throws error on every timestamp expression with default configuration. It makes sense for sting interpolation, but it does not for string to date conversion pattern.
... not to warn about '%Y-%m-%dT%H:%M:%S.%L%z'
It throws Style/FormatStringToken: Prefer annotated tokens (like %<foo>s) over unannotated tokens (like %s).
Code that causes warning:
Time.strptime('2017-10-13T12:56:33.000Z', '%Y-%m-%dT%H:%M:%S.%L%z')
$ rubocop -V
0.52.0 (using Parser 2.4.0.2, running on ruby 2.4.2 x86_64-darwin17)
@nattfodd it's not just date strings, it's _any_ string that contains a percent sign. Unless the string is being used via % or printf or something like that, the string should be ignored.
Example of a current false positive:
class Foo
def foo
my_var = '%something%'
end
end
Hey guys. I can see that it was merged into 0.52.1
Locally I still get Style/FormatStringToken: Prefer annotated tokens (like %<foo>s) over unannotated tokens (like %s) when calling:
Time.strptime("04:30-14/01/2018", "%H:%M-%d/%m/%Y")
Am I missing something?
bundle show rubocop
=> .bundle/gems/rubocop-0.52.1
@vinagrito #5398
@AlexWayfer I knew I was missing something :). Thx!
Most helpful comment
@nattfodd it's not just date strings, it's _any_ string that contains a percent sign. Unless the string is being used via
%orprintfor something like that, the string should be ignored.Example of a current false positive: