Skip to content

Commit

Permalink
Merge pull request #408 from grosser/grosser/symbols
Browse files Browse the repository at this point in the history
enforce :"foo-bar" over :'foo-bar' to be consistent with other doubl…
  • Loading branch information
searls authored Apr 26, 2022
2 parents e6130ac + 1ec52c6 commit 61f0c0a
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 1 deletion.
3 changes: 2 additions & 1 deletion config/base.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1561,7 +1561,8 @@ Style/Proc:
Enabled: true

Style/QuotedSymbols:
Enabled: false
Enabled: true
EnforcedStyle: same_as_string_literals

Style/RaiseArgs:
Enabled: false
Expand Down
Empty file.
3 changes: 3 additions & 0 deletions test/fixture/quoted_symbols/test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
a = :"good-d"
b = :'bad-d'
puts a + b
8 changes: 8 additions & 0 deletions test/standardrb_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,14 @@ def test_project_with_cwd_in_nested_path
MSG
end

def test_quoted_symbols_are_enforced
stdout, status = run_standardrb("test/fixture/quoted_symbols")
refute status.success?, stdout
assert_equal stdout.scan(/.*\.rb.*/), [
" test.rb:2:5: Style/QuotedSymbols: Prefer double-quoted symbols unless you need single quotes to avoid extra backslashes for escaping."
]
end

private

def run_standardrb(cwd, args = [])
Expand Down

0 comments on commit 61f0c0a

Please sign in to comment.