Project

General

Profile

Actions

Feature #10168

open

Native Object#inspect method should single quote strings that don't need to be double quoted

Added by pghalliday (Peter Halliday) over 9 years ago. Updated over 8 years ago.

Status:
Open
Assignee:
-
Target version:
-
[ruby-core:64551]

Description

When these strings get printed, copied and pasted into source code, RuboCop will complain, eg:

spec/recipes/default_spec.rb:23:24: C: Prefer single-quoted strings when you don't need string interpolation or special symbols.
    stub_data_bag_item("jenkins-cluster", "default").and_return(
                       ^^^^^^^^^^^^^^^^^

which resulted from the following code

signature = "#{type}(#{options[:args].map(&:inspect).join(', ')})"

If we believe that the default rules for RuboCop are good then it seems to me that they should be applied by Ruby where appropriate. In this case the strings should be single quoted.

From my point of view this is a suggestion to increase overall productivity as I use tools that use this method to print things that I then copy and paste quite a bit - not having to then replace the quotes will save me time. Not using or always changing the defaults for RuboCop seems to be the wrong approach

Actions

Also available in: Atom PDF

Like0
Like0