From 2c4215fa5fc42f4e92184daa52eaa22b56de60b1 Mon Sep 17 00:00:00 2001 From: Koichi ITO Date: Sat, 16 Jul 2022 13:12:54 +0900 Subject: [PATCH] Add new `Style/EmptyHeredoc` cop ## Summary Checks for using empty heredoc to reduce redundancy. ```ruby # bad <<~EOS EOS <<-EOS EOS <>' + Style/EmptyLambdaParameter: Description: 'Omit parens for empty lambda parameters.' Enabled: true diff --git a/lib/rubocop.rb b/lib/rubocop.rb index 126274caeb2..eaac41af88e 100644 --- a/lib/rubocop.rb +++ b/lib/rubocop.rb @@ -481,6 +481,7 @@ require_relative 'rubocop/cop/style/empty_block_parameter' require_relative 'rubocop/cop/style/empty_case_condition' require_relative 'rubocop/cop/style/empty_else' +require_relative 'rubocop/cop/style/empty_heredoc' require_relative 'rubocop/cop/style/empty_lambda_parameter' require_relative 'rubocop/cop/style/empty_literal' require_relative 'rubocop/cop/style/empty_method' diff --git a/lib/rubocop/cop/style/empty_heredoc.rb b/lib/rubocop/cop/style/empty_heredoc.rb new file mode 100644 index 00000000000..2109ecab2cf --- /dev/null +++ b/lib/rubocop/cop/style/empty_heredoc.rb @@ -0,0 +1,59 @@ +# frozen_string_literal: true + +module RuboCop + module Cop + module Style + # Checks for using empty heredoc to reduce redundancy. + # + # @example + # + # # bad + # <<~EOS + # EOS + # + # <<-EOS + # EOS + # + # <