From 92dfb4ef1f507117edf193d1eeac45935422e65c Mon Sep 17 00:00:00 2001 From: Koichi ITO Date: Sat, 28 May 2022 01:58:02 +0900 Subject: [PATCH] [Fix #704] Add new `Rails/StripHeredoc` cop Enforces the use of squiggly heredoc over `strip_heredoc`. ```ruby # bad <>' + Rails/TableNameAssignment: Description: >- Do not use `self.table_name =`. Use Inflections or `table_name_prefix` instead. diff --git a/lib/rubocop/cop/rails/strip_heredoc.rb b/lib/rubocop/cop/rails/strip_heredoc.rb new file mode 100644 index 0000000000..9384e23d0a --- /dev/null +++ b/lib/rubocop/cop/rails/strip_heredoc.rb @@ -0,0 +1,55 @@ +# frozen_string_literal: true + +module RuboCop + module Cop + module Rails + # Enforces the use of squiggly heredoc over `strip_heredoc`. + # + # @example + # + # # bad + # <= 2.3', :ruby23 do + it 'registers an offense when using `strip_heredoc` with `<<`' do + expect_offense(<<~RUBY) + <