Skip to content

Commit

Permalink
Merge pull request #172 from Shopify/bitwise-aiden/update-redundant-e…
Browse files Browse the repository at this point in the history
…xtend-cop

Update RedundantExtendTSig to trim whole line
  • Loading branch information
bitwise-aiden committed Aug 16, 2023
2 parents 3cf5b67 + 5094122 commit c84fcf2
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 11 deletions.
3 changes: 2 additions & 1 deletion lib/rubocop/cop/sorbet/redundant_extend_t_sig.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ module Sorbet
# end
#
class RedundantExtendTSig < RuboCop::Cop::Base
include RangeHelp
extend AutoCorrector

MSG = "Do not redundantly `extend T::Sig` when it is already included in all modules."
Expand All @@ -40,7 +41,7 @@ def on_send(node)
return unless extend_t_sig?(node)

add_offense(node) do |corrector|
corrector.remove(node)
corrector.remove(range_by_whole_lines(node.source_range, include_final_newline: true))
end
end
end
Expand Down
13 changes: 3 additions & 10 deletions spec/rubocop/cop/sorbet/redundant_extend_t_sig_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@

expect_correction(<<~RUBY)
#{header}
#{trailing_whitespace}
end
RUBY
end
Expand Down Expand Up @@ -43,7 +42,7 @@ module M
^^^^^^^^^^^^^ #{message}
RUBY

expect_correction(a_blank_line)
expect_correction("")
end

it "registers an offense when using `extend ::T::Sig` (fully qualified)" do
Expand All @@ -52,7 +51,7 @@ module M
^^^^^^^^^^^^^^^ #{message}
RUBY

expect_correction(a_blank_line)
expect_correction("")
end

it "registers an offense when using `extend T::Sig` with an explicit receiver" do
Expand All @@ -61,7 +60,7 @@ module M
^^^^^^^^^^^^^^^^^^^^^^^^^ #{message}
RUBY

expect_correction(a_blank_line)
expect_correction("")
end

it "does not register an offense when extending other modules in the T namespace" do
Expand All @@ -71,10 +70,4 @@ module M
end
RUBY
end

private

def a_blank_line
"\n"
end
end

0 comments on commit c84fcf2

Please sign in to comment.