Skip to content

Instantly share code, notes, and snippets.

@glasnt
Last active August 29, 2015 14:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save glasnt/ee9aff3d62ddeb306194 to your computer and use it in GitHub Desktop.
Save glasnt/ee9aff3d62ddeb306194 to your computer and use it in GitHub Desktop.
Rubocop in SPAACCEE

Rubocop doesn't appear to be correcting spaces within braces denoting variables within strings.

Attempting an automatic correction does not fix this.

Running the auto-gen-correct command does not suggest any configurations to correct this.

variable = "hi"
string = "#{ variable} #{variable} #{variable }"
puts string
# line 1: should be single spaces
# line 2: should consolidate to one form
# line 3: no problems
$ rubocop -a
Inspecting 1 file
C
Offenses:
testing_rubocop.rb:1:12: C: [Corrected] Prefer single-quoted strings when you don't need string interpolation or special symbols.
variable = "hi"
^^^^
1 file inspected, 1 offense detected, 1 offense corrected
variable = 'hi'
string = "#{ variable} #{variable} #{variable }"
puts string
# line 1: auto corrected
# line 2: not altered.
# line 3: no change.
$ rubocop --auto-gen-config
Inspecting 1 file
C
Offenses:
testing_rubocop.rb:1:12: C: Prefer single-quoted strings when you don't need string interpolation or special symbols.
variable = "hi"
^^^^
1 file inspected, 1 offense detected
Created .rubocop_todo.yml.
Run `rubocop --config .rubocop_todo.yml`, or
add inherit_from: .rubocop_todo.yml in a .rubocop.yml file.
@glasnt
Copy link
Author

glasnt commented May 13, 2015

This is totally a thing.
rubocop/rubocop#1836

The Bible now says "#{v}" is good, "#{ v }" is bad. I'm making a PR to create a cop to fix this now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment