Rubocop gets angry when I try to fill zeros (fill 0s) with Ruby

problem

rubocop got angry ... scary ...

C: Style/FormatStringToken: Prefer annotated tokens (like %<foo>s) over unannotated tokens (like %s).
        format('number: %03d', 1)
                        ^^^^

Solution

In format, you can set the argument specification using hash, so avoid it there.

format("number: %03<number>d", number: 1)
#=> "number: 001"

reference

Recommended Posts

Rubocop gets angry when I try to fill zeros (fill 0s) with Ruby
When I push to Heroku, I get angry with Precompiling assets failed.
I get a Ruby version error when I try to start Rails.
When I try to use the AWS SDK with Ruby + Lambda, `sam local` is messed up.
When I try to sign up with devise, it automatically redirects to root_path
I get an error when I try to use "^" or "$" in ruby ​​regular expression
Try to link Ruby and Java with Dapr
Try to get redmine API key with ruby
I tried what I wanted to try with Stream softly.
What happens to instance variables when copying an instance with ruby
I tried to automate LibreOffice Calc with Ruby + PyCall.rb (Ubuntu 18.04)
I was angry with proc_open (): fork failed when trying to composer update inside a Docker container
I tried DI with Ruby
I tried to solve the problem of "multi-stage selection" with Ruby
When I try to put centos in VMware, pane is dead
I want to add a browsing function with ruby on rails
I want to avoid OutOfMemory when outputting large files with POI
I got an IllegalAccessError when trying to use PowerMock with JUnit
What I was addicted to when implementing google authentication with rails
I tried to reimplement Ruby Float (arg, exception: true) with builtin
[Rails] I want to add data to Params when transitioning with link_to
When I try to install gempg it says I don't have libpq-fe.h