Class: RuboCop::Cop::StringLiteralCorrector
Relationships & Source Files | |
Super Chains via Extension / Inclusion / Inheritance | |
Class Chain:
self,
Util ,
::RuboCop::PathUtil
|
|
Inherits: | Object |
Defined in: | lib/rubocop/cop/correctors/string_literal_corrector.rb |
Overview
This autocorrects string literals
Class Method Summary
Util
- Extended
add_parentheses | Metrics/MethodLength. |
any_descendant? | Metrics/MethodLength. |
args_begin, args_end, begins_its_line?, | |
comment_line? | This is a bad API. |
comment_lines?, compatible_external_encoding_for?, | |
double_quotes_required? | If converting a string to Ruby string literal source code, must double quotes be used? |
escape_string, | |
first_part_of_call_chain | Returns, for example, a bare |
include_or_equal?, indent, interpret_string_escapes, line, line_range, needs_escaping?, on_node, parentheses?, parse_regexp, same_line?, to_string_literal, to_supported_styles, trim_string_interpolation_escape_character |
::RuboCop::PathUtil
- Included
absolute? | Returns true for an absolute Unix or Windows path. |
glob? | Returns true for a glob. |
hidden_dir?, hidden_file?, hidden_file_in_not_hidden_dir?, | |
match_path? | Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity. |
maybe_hidden_file? | Loose check to reduce memory allocations. |
relative_path, smart_path |
Class Method Details
.correct(corrector, node, style)
[ GitHub ]# File 'lib/rubocop/cop/correctors/string_literal_corrector.rb', line 10
def correct(corrector, node, style) return if node.dstr_type? str = node.str_content if style == :single_quotes corrector.replace(node, to_string_literal(str)) else corrector.replace(node, str.inspect) end end