Skip to content

Commit

Permalink
Use trailing_whitespace where useful
Browse files Browse the repository at this point in the history
  • Loading branch information
marcandre committed Sep 10, 2020
1 parent dbe1c32 commit 6c8b3df
Show file tree
Hide file tree
Showing 13 changed files with 47 additions and 47 deletions.
2 changes: 1 addition & 1 deletion spec/rubocop/cop/layout/empty_line_between_defs_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ def a; end; def b; end
RUBY

expect_correction(<<~RUBY)
def a; end;
def a; end;#{trailing_whitespace}
def b; end
RUBY
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
it 'accepts block body starting with a line with spaces' do
expect_no_offenses(<<~RUBY)
some_method #{open}
#{trailing_whitespace}
do_something
#{close}
RUBY
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@

expect(corrected).to eq(<<~RUBY)
a, b,
c =
c =#{trailing_whitespace}
1,
2, 3
RUBY
Expand All @@ -118,7 +118,7 @@

expect(new_source).to eq(<<~RUBY)
a
.c =
.c =#{trailing_whitespace}
1,
2, 3
RUBY
Expand Down
4 changes: 2 additions & 2 deletions spec/rubocop/cop/layout/first_hash_element_line_break_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
RUBY

expect_correction(<<~RUBY)
a = {
a = {#{trailing_whitespace}
a: 1,
b: 2 }
RUBY
Expand All @@ -25,7 +25,7 @@
RUBY

expect_correction(<<~RUBY)
method({
method({#{trailing_whitespace}
foo: 1,
bar: 2 })
RUBY
Expand Down
18 changes: 9 additions & 9 deletions spec/rubocop/cop/layout/multiline_block_layout_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
RUBY

expect_correction(<<~RUBY)
test do
test do#{trailing_whitespace}
foo
end
RUBY
Expand All @@ -26,7 +26,7 @@
RUBY

expect_correction(<<~RUBY)
test {
test {#{trailing_whitespace}
foo
}
RUBY
Expand All @@ -41,7 +41,7 @@
RUBY

expect_correction(<<~RUBY)
test do |x|
test do |x|#{trailing_whitespace}
foo
end
RUBY
Expand All @@ -56,7 +56,7 @@
RUBY

expect_correction(<<~RUBY)
test { |x|
test { |x|#{trailing_whitespace}
foo
}
RUBY
Expand Down Expand Up @@ -150,7 +150,7 @@
RUBY

expect_correction(<<~RUBY)
-> (x) do
-> (x) do#{trailing_whitespace}
foo
bar
end
Expand All @@ -166,7 +166,7 @@
RUBY

expect_correction(<<~RUBY)
-> x do
-> x do#{trailing_whitespace}
foo
bar
end
Expand Down Expand Up @@ -226,7 +226,7 @@
RUBY

expect_correction(<<~RUBY)
test do |foo|
test do |foo|#{trailing_whitespace}
bar
test
end
Expand All @@ -243,7 +243,7 @@
RUBY

expect_correction(<<~RUBY)
x = -> (y) {
x = -> (y) {#{trailing_whitespace}
foo
bar
}
Expand All @@ -260,7 +260,7 @@
RUBY

expect_correction(<<~RUBY)
foo do |o|
foo do |o|#{trailing_whitespace}
(
bar
)
Expand Down
8 changes: 4 additions & 4 deletions spec/rubocop/cop/lint/literal_in_interpolation_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -202,12 +202,12 @@
^^^^^^ Literal interpolation detected.
RUBY

expect_correction(<<~'RUBY')
"this is
expect_correction(<<~RUBY)
"this is#{trailing_whitespace}
silly"
"this is
"this is#{trailing_whitespace}
silly"
"this is
"this is#{trailing_whitespace}
silly"
RUBY
end
Expand Down
16 changes: 8 additions & 8 deletions spec/rubocop/cop/lint/useless_method_definition_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def initialize(arg1, arg2)

expect_correction(<<~RUBY)
class Foo
#{trailing_whitespace}
end
RUBY
end
Expand Down Expand Up @@ -102,26 +102,26 @@ def useful_instance_method
do_something
end
#{trailing_whitespace}
#{trailing_whitespace}
def self.useful_class_method
do_something
end
#{trailing_whitespace}
#{trailing_whitespace}
class << self
def self.other_useful_class_method
do_something
end
#{trailing_whitespace}
#{trailing_whitespace}
end
end
RUBY
Expand Down Expand Up @@ -189,7 +189,7 @@ def initialize

expect_correction(<<~RUBY)
class Foo
#{trailing_whitespace}
end
RUBY
end
Expand Down
12 changes: 6 additions & 6 deletions spec/rubocop/cop/style/bisected_attr_accessor_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class Foo
expect_correction(<<~RUBY)
class Foo
attr_accessor :bar
#{trailing_whitespace}
other_macro :something
end
RUBY
Expand All @@ -37,7 +37,7 @@ class Foo
expect_correction(<<~RUBY)
class Foo
attr_accessor :bar
#{trailing_whitespace}
other_macro :something
end
RUBY
Expand All @@ -59,7 +59,7 @@ class Foo
class Foo
ATTRIBUTES = %i[foo bar]
attr_accessor *ATTRIBUTES
#{trailing_whitespace}
other_macro :something
end
RUBY
Expand Down Expand Up @@ -106,11 +106,11 @@ class Foo
expect_correction(<<~RUBY)
class Foo
attr_accessor :bar
#{trailing_whitespace}
private
#{trailing_whitespace}
attr_accessor :baz
end
RUBY
Expand Down Expand Up @@ -140,7 +140,7 @@ class Foo
class << self
attr_accessor :baz
#{trailing_whitespace}
private
Expand Down
4 changes: 2 additions & 2 deletions spec/rubocop/cop/style/class_methods_definitions_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def three

expect_correction(<<~RUBY)
class A
#{trailing_whitespace}
def self.three
end
Expand Down Expand Up @@ -49,7 +49,7 @@ def two

expect_correction(<<~RUBY)
class A
#{trailing_whitespace}
# Multiline
# comment.
def self.two
Expand Down
2 changes: 1 addition & 1 deletion spec/rubocop/cop/style/line_end_concatenation_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@
# whitespace in this cop.
it 'autocorrects a + with trailing whitespace to \\' do
expect_offense(<<~RUBY)
top = "test" +
top = "test" +#{trailing_whitespace}
^ Use `\\` instead of `+` or `<<` to concatenate those strings.
"top"
RUBY
Expand Down
2 changes: 1 addition & 1 deletion spec/rubocop/cop/style/method_def_parentheses_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ def func()
RUBY

expect_correction(<<~RUBY)
def func
def func#{trailing_whitespace}
end
RUBY
end
Expand Down
4 changes: 2 additions & 2 deletions spec/rubocop/cop/style/mixin_grouping_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ class Foo
class Foo
prepend Qux, Baz, Bar
do_something_else
#{trailing_whitespace}
end
RUBY
end
Expand All @@ -229,7 +229,7 @@ class Foo
prepend Qux, Bar
Other.prepend Baz
do_something_else
#{trailing_whitespace}
end
RUBY
end
Expand Down
16 changes: 8 additions & 8 deletions spec/rubocop/cop/style/redundant_assignment_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def func
def func
some_preceding_statements
something
#{trailing_whitespace}
end
RUBY
end
Expand All @@ -40,7 +40,7 @@ def func
some_preceding_statements
begin
something
#{trailing_whitespace}
end
end
RUBY
Expand Down Expand Up @@ -69,11 +69,11 @@ def func
def func
1
2
#{trailing_whitespace}
rescue SomeException
3
4
#{trailing_whitespace}
rescue AnotherException
5
end
Expand Down Expand Up @@ -117,12 +117,12 @@ def func
some_preceding_statements
if x
1
#{trailing_whitespace}
elsif y
2
else
3
#{trailing_whitespace}
end
end
RUBY
Expand Down Expand Up @@ -156,13 +156,13 @@ def func
case x
when y
1
#{trailing_whitespace}
when z
2
when q
else
3
#{trailing_whitespace}
end
end
RUBY
Expand Down

0 comments on commit 6c8b3df

Please sign in to comment.