From 25c2e6b0f9ca965c2575085f09b69b628748d920 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 Closes #704. 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..1c26b83839 --- /dev/null +++ b/lib/rubocop/cop/rails/strip_heredoc.rb @@ -0,0 +1,56 @@ +# 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) + <