Skip to content

Add rubocop rule for StringLiterals

Description of the proposal

This is a proposal to add the rubocop rule for StringLiterals. In our case, we'd enforce single quotes where possible. An example MR that enables the config and ran --auto-corect can be found here: !23410 (closed).

We already recommend this behaviour in our style guide (see https://github.com/rubocop-hq/ruby-style-guide#consistent-string-literals) and therefore it would be valuable to add it as a linter rule as well.

Bad

"No special symbols"
"No string interpolation"
"Just text"

Good

'No special symbols'
'No string interpolation'
'Just text'
"Wait! What's #{this}!"

How many files are affected

Running rubocop with StringLiterals enabled gives the following result:

13869 files inspected, 25509 offenses detected

Tasks

  • Mention the proposal in the next backend weekly call and the #backend channel to encourage contribution
  • Proceed with the proposal once 50% of the maintainers have weighed in, and 80% of their votes are 👍
  • Once approved, mention it again in the next backend weekly call and the #backend channel

/cc @gitlab-org/maintainers/rails-backend

Edited by 🤖 GitLab Bot 🤖