Ruby on Rails, convert projectwide single quotes to double quotes
Asked Answered
H

1

7

I wonder if anyone has come up with a shortcut to correctly convert ALL single quotes to double quotes in a new rails project. Thank you in advance. I would do that at the end of generating new project with a template.rb

Hairsplitter answered 25/3, 2019 at 10:26 Comment(3)
I would use Rubocop. Configure it to use the quotes you prefer and then run rubocop -a to automatically fix all issues.Trueblue
@AlekseiMatiushkin Indeed, I trust Rubocop more to cover all these encodings, escaping and edge cases. I prefer spending the time to review Rubocop's changes instead of building a correct regexp in sed.Trueblue
rubocop it is, I didn't remember it had auto fix capabilityHairsplitter
O
12

I would also use rubocop for that:

rubocop --safe-auto-correct --only "Style/StringLiterals" .

As spickermann suggested

Outcross answered 25/3, 2019 at 12:25 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.