Skip to content

Commit b4ddecc

Browse files
authored
Merge pull request #2175 from koic/enable_performance_string_replacement_cop
Enable `Performance/StringReplacement` cop
2 parents 4ac1155 + 53a5041 commit b4ddecc

File tree

4 files changed

+6
-3
lines changed

4 files changed

+6
-3
lines changed

.rubocop.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,9 @@ Performance/RegexpMatch:
241241
Performance/ReverseEach:
242242
Enabled: true
243243

244+
Performance/StringReplacement:
245+
Enabled: true
246+
244247
# Use unary plus to get an unfrozen string literal.
245248
Performance/UnfreezeString:
246249
Enabled: true

lib/active_record/connection_adapters/oracle_enhanced/quoting.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ def quote_column_name(name) #:nodoc:
1414
"\"#{name.upcase}\""
1515
else
1616
# remove double quotes which cannot be used inside quoted identifier
17-
"\"#{name.gsub('"', '')}\""
17+
"\"#{name.delete('"')}\""
1818
end
1919
end
2020

lib/active_record/connection_adapters/oracle_enhanced/structure_dump.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ def structure_dump_column(column) #:nodoc:
7676
end
7777

7878
def structure_dump_virtual_column(column, data_default) #:nodoc:
79-
data_default = data_default.gsub(/"/, "")
79+
data_default = data_default.delete('"')
8080
col = +"\"#{column['column_name']}\" #{column['data_type']}"
8181
if (column["data_type"] == "NUMBER") && !column["data_precision"].nil?
8282
col << "(#{column['data_precision'].to_i}"

spec/active_record/connection_adapters/oracle_enhanced/context_index_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -375,7 +375,7 @@ def verify_logged_statements
375375
sub_query = "SELECT comments.author AS comment_author, comments.body AS comment_body\nFROM comments\nWHERE comments.post_id = :id"
376376
@conn.add_context_index :posts, [:title, :body, sub_query], options
377377
output = dump_table_schema "posts"
378-
expect(output).to match(/add_context_index "posts", \[:title, :body, "#{sub_query.gsub(/\n/, ' ')}"\], #{options.inspect[1..-2]}$/)
378+
expect(output).to match(/add_context_index "posts", \[:title, :body, "#{sub_query.tr("\n", ' ')}"\], #{options.inspect[1..-2]}$/)
379379
@conn.remove_context_index :posts, name: "post_and_comments_index"
380380
end
381381
end

0 commit comments

Comments
 (0)