Skip to content

Commit

Permalink
Enable Layout/LineEndStringConcatenationIndentation
Browse files Browse the repository at this point in the history
...and fix offenses.
  • Loading branch information
bquorning committed Oct 13, 2022
1 parent adbc170 commit 45cd9bd
Show file tree
Hide file tree
Showing 16 changed files with 48 additions and 46 deletions.
2 changes: 2 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,8 @@ Style/FormatStringToken:

Layout/LineContinuationSpacing:
Enabled: true
Layout/LineEndStringConcatenationIndentation:
Enabled: true

# Enable our own pending cops.

Expand Down
2 changes: 1 addition & 1 deletion lib/rubocop/cop/rspec/change_by_zero.rb
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ class ChangeByZero < Base
extend AutoCorrector
MSG = 'Prefer `not_to change` over `to change.by(0)`.'
MSG_COMPOUND = 'Prefer %<preferred>s with compound expectations ' \
'over `change.by(0)`.'
'over `change.by(0)`.'
RESTRICT_ON_SEND = %i[change].freeze

# @!method expect_change_with_arguments(node)
Expand Down
4 changes: 2 additions & 2 deletions lib/rubocop/cop/rspec/factory_bot/create_list.rb
Original file line number Diff line number Diff line change
Expand Up @@ -238,8 +238,8 @@ def format_multiline_block(node)
indent = ' ' * node.body.loc.column
indent_end = ' ' * node.parent.loc.column
" do #{node.arguments.source}\n" \
"#{indent}#{node.body.source}\n" \
"#{indent_end}end"
"#{indent}#{node.body.source}\n" \
"#{indent_end}end"
end

def format_singleline_block(node)
Expand Down
2 changes: 1 addition & 1 deletion lib/rubocop/cop/rspec/repeated_include_example.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ module RSpec
#
class RepeatedIncludeExample < Base
MSG = 'Repeated include of shared_examples %<name>s ' \
'on line(s) %<repeat>s'
'on line(s) %<repeat>s'

# @!method several_include_examples?(node)
def_node_matcher :several_include_examples?, <<-PATTERN
Expand Down
2 changes: 1 addition & 1 deletion spec/rubocop/cli/autocorrect_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
include_context 'when cli spec behavior'

context 'when corrects `RSpec/Capybara/CurrentPathExpectation` with ' \
'`Style/TrailingCommaInArguments`' do
'`Style/TrailingCommaInArguments`' do
before do
RuboCop::ConfigLoader
.default_configuration
Expand Down
6 changes: 3 additions & 3 deletions spec/rubocop/cop/rspec/before_after_all_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
RSpec.describe RuboCop::Cop::RSpec::BeforeAfterAll do
def message(hook)
"Beware of using `#{hook}` as it may cause state to leak between tests. " \
'If you are using `rspec-rails`, and `use_transactional_fixtures` is ' \
"enabled, then records created in `#{hook}` are not automatically rolled " \
'back.'
'If you are using `rspec-rails`, and `use_transactional_fixtures` is ' \
"enabled, then records created in `#{hook}` are not automatically " \
'rolled back.'
end

context 'when using before all' do
Expand Down
14 changes: 7 additions & 7 deletions spec/rubocop/cop/rspec/capybara/specific_finders_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
end

it 'registers an offense when using `find` and other args ' \
'with no parentheses' do
'with no parentheses' do
expect_offense(<<~RUBY)
find '#some-id', exact_text: 'foo'
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Prefer `find_by` over `find`.
Expand All @@ -60,7 +60,7 @@
end

it 'registers an offense when using `find ' \
'with argument is attribute specified id' do
'with argument is attribute specified id' do
expect_offense(<<~RUBY)
find('[id=some-id]')
^^^^^^^^^^^^^^^^^^^^ Prefer `find_by` over `find`.
Expand All @@ -78,29 +78,29 @@
end

it 'does not register an offense when using `find ' \
'with argument is attribute not specified id' do
'with argument is attribute not specified id' do
expect_no_offenses(<<~RUBY)
find('[visible]')
find('[class=some-cls][visible]')
RUBY
end

it 'does not register an offense when using `find ' \
'with argument is element with id' do
'with argument is element with id' do
expect_no_offenses(<<~RUBY)
find('h1#some-id')
RUBY
end

it 'does not register an offense when using `find ' \
'with argument is element with attribute specified id' do
'with argument is element with attribute specified id' do
expect_no_offenses(<<~RUBY)
find('h1[id=some-id]')
RUBY
end

it 'does not register an offense when using `find` ' \
'with argument is not id' do
'with argument is not id' do
expect_no_offenses(<<~RUBY)
find('a.some-id')
find('.some-id')
Expand All @@ -114,7 +114,7 @@
end

it 'does not register an offense when using `find` ' \
'with argument is id with multiple matcher' do
'with argument is id with multiple matcher' do
expect_no_offenses(<<~RUBY)
find('#some-id body')
find('#some-id>h1')
Expand Down
22 changes: 11 additions & 11 deletions spec/rubocop/cop/rspec/capybara/specific_matcher_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

RSpec.describe RuboCop::Cop::RSpec::Capybara::SpecificMatcher do
it 'does not register an offense for abstract matcher when ' \
'first argument is not a replaceable element' do
'first argument is not a replaceable element' do
expect_no_offenses(<<-RUBY)
expect(page).to have_selector('article')
expect(page).to have_no_selector('body')
Expand All @@ -11,7 +11,7 @@
end

it 'does not register an offense for abstract matcher when ' \
'first argument is not an element' do
'first argument is not an element' do
expect_no_offenses(<<-RUBY)
expect(page).to have_no_css('.a')
expect(page).to have_selector('#button')
Expand Down Expand Up @@ -206,7 +206,7 @@ class style visible obscured exact exact_text normalize_ws match wait
end

it 'registers an offense when using abstract matcher with ' \
'first argument is element with replaceable pseudo-classes' do
'first argument is element with replaceable pseudo-classes' do
expect_offense(<<-RUBY)
expect(page).to have_css('button:not([disabled])', exact_text: 'bar')
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Prefer `have_button` over `have_css`.
Expand All @@ -216,7 +216,7 @@ class style visible obscured exact exact_text normalize_ws match wait
end

it 'registers an offense when using abstract matcher with ' \
'first argument is element with multiple replaceable pseudo-classes' do
'first argument is element with multiple replaceable pseudo-classes' do
expect_offense(<<-RUBY)
expect(page).to have_css('button:not([disabled]):enabled')
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Prefer `have_button` over `have_css`.
Expand All @@ -234,22 +234,22 @@ class style visible obscured exact exact_text normalize_ws match wait
end

it 'does not register an offense when using abstract matcher with ' \
'first argument is element with replaceable pseudo-classes' \
'and not boolean attributes' do
'first argument is element with replaceable pseudo-classes' \
'and not boolean attributes' do
expect_no_offenses(<<-RUBY)
expect(page).to have_css('button:not([name="foo"][disabled])')
RUBY
end

it 'does not register an offense when using abstract matcher with ' \
'first argument is element with multiple nonreplaceable pseudo-classes' do
'first argument is element with multiple nonreplaceable pseudo-classes' do
expect_no_offenses(<<-RUBY)
expect(page).to have_css('button:first-of-type:not([disabled])')
RUBY
end

it 'does not register an offense for abstract matcher when ' \
'first argument is element with nonreplaceable attributes' do
'first argument is element with nonreplaceable attributes' do
expect_no_offenses(<<-RUBY)
expect(page).to have_css('button[data-disabled]')
expect(page).to have_css('button[foo=bar]')
Expand All @@ -258,7 +258,7 @@ class style visible obscured exact exact_text normalize_ws match wait
end

it 'does not register an offense for abstract matcher when ' \
'first argument is element with multiple nonreplaceable attributes' do
'first argument is element with multiple nonreplaceable attributes' do
expect_no_offenses(<<-RUBY)
expect(page).to have_css('button[disabled][foo]')
expect(page).to have_css('button[foo][disabled]')
Expand All @@ -269,7 +269,7 @@ class style visible obscured exact exact_text normalize_ws match wait
end

it 'does not register an offense for abstract matcher when ' \
'first argument is element with sub matcher' do
'first argument is element with sub matcher' do
expect_no_offenses(<<-RUBY)
expect(page).to have_css('button body')
expect(page).to have_css('a,h1')
Expand All @@ -279,7 +279,7 @@ class style visible obscured exact exact_text normalize_ws match wait
end

it 'does not register an offense for abstract matcher when ' \
'first argument is dstr' do
'first argument is dstr' do
expect_no_offenses(<<-'RUBY')
expect(page).to have_css(%{a[href="#{foo}"]}, text: "bar")
RUBY
Expand Down
22 changes: 11 additions & 11 deletions spec/rubocop/cop/rspec/change_by_zero_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@

context 'when `NegatedMatcher` is not defined (default)' do
it 'registers an offense when the argument to `by` is zero ' \
'with compound expectations by `and`' do
'with compound expectations by `and`' do
expect_offense(<<-RUBY)
it do
expect { foo }.to change(Foo, :bar).by(0).and change(Foo, :baz).by(0)
Expand All @@ -43,7 +43,7 @@
end

it 'registers an offense when the argument to `by` is zero ' \
'with compound expectations by `&`' do
'with compound expectations by `&`' do
expect_offense(<<-RUBY)
it do
expect { foo }.to change(Foo, :bar).by(0) & change(Foo, :baz).by(0)
Expand All @@ -59,7 +59,7 @@
end

it 'registers an offense when the argument to `by` is zero ' \
'with compound expectations by `or`' do
'with compound expectations by `or`' do
expect_offense(<<-RUBY)
it do
expect { foo }.to change(Foo, :bar).by(0).or change(Foo, :baz).by(0)
Expand All @@ -75,7 +75,7 @@
end

it 'registers an offense when the argument to `by` is zero ' \
'with compound expectations by `|`' do
'with compound expectations by `|`' do
expect_offense(<<-RUBY)
it do
expect { foo }.to change(Foo, :bar).by(0) | change(Foo, :baz).by(0)
Expand All @@ -92,7 +92,7 @@

context 'when with a line break' do
it 'registers an offense when the argument to `by` is zero ' \
'with compound expectations by `and`' do
'with compound expectations by `and`' do
expect_offense(<<-RUBY)
it do
expect { foo }
Expand All @@ -112,7 +112,7 @@
end

it 'registers an offense when the argument to `by` is zero ' \
'with compound expectations by `&`' do
'with compound expectations by `&`' do
expect_offense(<<-RUBY)
it do
expect { foo }
Expand All @@ -132,7 +132,7 @@
end

it 'registers an offense when the argument to `by` is zero ' \
'with compound expectations by `or`' do
'with compound expectations by `or`' do
expect_offense(<<-RUBY)
it do
expect { foo }
Expand All @@ -152,7 +152,7 @@
end

it 'registers an offense when the argument to `by` is zero ' \
'with compound expectations by `|`' do
'with compound expectations by `|`' do
expect_offense(<<-RUBY)
it do
expect { foo }
Expand All @@ -177,7 +177,7 @@
let(:cop_config) { { 'NegatedMatcher' => 'not_change' } }

it 'registers an offense and autocorrect when ' \
'the argument to `by` is zero with compound expectations' do
'the argument to `by` is zero with compound expectations' do
expect_offense(<<-RUBY)
it do
expect { foo }.to change(Foo, :bar).by(0).and change(Foo, :baz).by(0)
Expand All @@ -198,8 +198,8 @@
end

it 'registers an offense and autocorrect when ' \
'the argument to `by` is zero with compound expectations ' \
'with line break' do
'the argument to `by` is zero with compound expectations ' \
'with line break' do
expect_offense(<<-RUBY)
it do
expect { foo }
Expand Down
2 changes: 1 addition & 1 deletion spec/rubocop/cop/rspec/empty_example_group_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@
end

it 'flags an empty example group with no examples defined in `case`' \
'branches' do
'branches' do
expect_offense(<<~RUBY)
describe Foo do
^^^^^^^^^^^^ Empty example group detected.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@
end

it 'flags a missing empty line after a `rubocop:enable` directive ' \
'when it is followed by a `rubocop:disable` directive' do
'when it is followed by a `rubocop:disable` directive' do
expect_offense(<<-RUBY)
RSpec.describe Foo do
# rubocop:disable RSpec/Foo
Expand Down
2 changes: 1 addition & 1 deletion spec/rubocop/cop/rspec/empty_line_after_example_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@
end

it 'flags a missing empty line after a `rubocop:enable` directive ' \
'when it is followed by a `rubocop:disable` directive' do
'when it is followed by a `rubocop:disable` directive' do
expect_offense(<<-RUBY)
RSpec.describe Foo do
# rubocop:disable RSpec/Foo
Expand Down
2 changes: 1 addition & 1 deletion spec/rubocop/cop/rspec/empty_line_after_final_let_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@
end

it 'flags a missing empty line after a `rubocop:enable` directive ' \
'when it is followed by a `rubocop:disable` directive' do
'when it is followed by a `rubocop:disable` directive' do
expect_offense(<<-RUBY)
RSpec.describe User do
# rubocop:disable RSpec/Foo
Expand Down
2 changes: 1 addition & 1 deletion spec/rubocop/cop/rspec/empty_line_after_hook_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@
end

it 'flags a missing empty line after a `rubocop:enable` directive ' \
'when it is followed by a `rubocop:disable` directive' do
'when it is followed by a `rubocop:disable` directive' do
expect_offense(<<-RUBY)
RSpec.describe User do
# rubocop:disable RSpec/Foo
Expand Down
2 changes: 1 addition & 1 deletion spec/rubocop/cop/rspec/empty_line_after_subject_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@
end

it 'flags a missing empty line after a `rubocop:enable` directive ' \
'when it is followed by a `rubocop:disable` directive' do
'when it is followed by a `rubocop:disable` directive' do
expect_offense(<<-RUBY)
RSpec.describe User do
# rubocop:disable RSpec/Foo
Expand Down
6 changes: 3 additions & 3 deletions spec/rubocop/cop/rspec/repeated_include_example_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
end

it "registers an offense for repeated #{include_method} " \
'with parentheses' do
'with parentheses' do
expect_offense(<<~RUBY, include_method: include_method)
describe 'foo' do
%{include_method}('an x')
Expand Down Expand Up @@ -70,7 +70,7 @@
end

it "registers an offense for repeated #{include_method} " \
'with parentheses' do
'with parentheses' do
expect_offense(<<~RUBY, include_method: include_method)
describe 'foo' do
%{include_method}('an x', 'y')
Expand Down Expand Up @@ -107,7 +107,7 @@
end

it "accepts repeated #{include_method} with different parameters " \
'with parentheses' do
'with parentheses' do
expect_no_offenses(<<~RUBY)
describe 'foo' do
#{include_method}('an x', 'y')
Expand Down

0 comments on commit 45cd9bd

Please sign in to comment.