Skip to content

Commit

Permalink
Remove unnecessary RuboCop disables
Browse files Browse the repository at this point in the history
This includes fixing a `Naming/PredicateName` offense, and one
`Style/GuardClause` offense.

Not sure why Lint/RedundantCopDisableDirective didn't find these.
  • Loading branch information
bquorning committed Feb 11, 2025
1 parent e40c361 commit c8b14c1
Show file tree
Hide file tree
Showing 6 changed files with 7 additions and 14 deletions.
1 change: 0 additions & 1 deletion .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ AllCops:
- 'tmp/**/*'
- 'spec/smoke_tests/**/*.rb'


# Enable when we require rubocop >= 1.71.1 or rubocop-ast >= 1.38.0
InternalAffairs/NodePatternGroups:
Enabled: false
Expand Down
4 changes: 2 additions & 2 deletions lib/rubocop/cop/rspec/implicit_expect.rb
Original file line number Diff line number Diff line change
Expand Up @@ -69,13 +69,13 @@ def on_send(node) # rubocop:disable Metrics/MethodLength
def offending_expect(node)
case implicit_expect(node)
when :is_expected
is_expected_range(node.loc)
range_for_is_expected(node.loc)
when :should, :should_not
node.loc.selector
end
end

def is_expected_range(source_map) # rubocop:disable Naming/PredicateName
def range_for_is_expected(source_map)
Parser::Source::Range.new(
source_map.expression.source_buffer,
source_map.expression.begin_pos,
Expand Down
8 changes: 4 additions & 4 deletions lib/rubocop/cop/rspec/return_from_stub.rb
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,10 @@ def check_and_return_call(node)

def check_block_body(block)
body = block.body
unless dynamic?(body) # rubocop:disable Style/GuardClause
add_offense(block.loc.begin, message: MSG_AND_RETURN) do |corrector|
BlockBodyCorrector.new(block).call(corrector)
end
return if dynamic?(body)

add_offense(block.loc.begin, message: MSG_AND_RETURN) do |corrector|
BlockBodyCorrector.new(block).call(corrector)
end
end

Expand Down
2 changes: 0 additions & 2 deletions spec/rubocop/cop/rspec/align_left_let_brace_spec.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# frozen_string_literal: true

RSpec.describe RuboCop::Cop::RSpec::AlignLeftLetBrace do
# rubocop:disable RSpec/ExampleLength
it 'registers offense for unaligned braces' do
expect_offense(<<~RUBY)
let(:foo) { bar }
Expand Down Expand Up @@ -41,7 +40,6 @@
end
RUBY
end
# rubocop:enable RSpec/ExampleLength

it 'does not register an offense for let with proc argument' do
expect_no_offenses(<<~RUBY)
Expand Down
2 changes: 0 additions & 2 deletions spec/rubocop/cop/rspec/align_right_let_brace_spec.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# frozen_string_literal: true

RSpec.describe RuboCop::Cop::RSpec::AlignRightLetBrace do
# rubocop:disable RSpec/ExampleLength
it 'registers offense for unaligned braces' do
expect_offense(<<~RUBY)
let(:foo) { a }
Expand Down Expand Up @@ -41,7 +40,6 @@
end
RUBY
end
# rubocop:enable RSpec/ExampleLength

it 'does not register an offense for let with proc argument' do
expect_no_offenses(<<~RUBY)
Expand Down
4 changes: 1 addition & 3 deletions spec/rubocop/cop/rspec/focus_spec.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# frozen_string_literal: true

RSpec.describe RuboCop::Cop::RSpec::Focus do
# rubocop:disable RSpec/ExampleLength
it 'flags all rspec example blocks with that include `focus: true`' do
expect_offense(<<~RUBY)
example 'test', meta: true, focus: true do; end
Expand Down Expand Up @@ -131,7 +130,6 @@
shared_context 'test' do; end
RUBY
end
# rubocop:enable RSpec/ExampleLength

it 'does not flag unfocused specs' do
expect_no_offenses(<<~RUBY)
Expand Down Expand Up @@ -175,7 +173,7 @@
RUBY
end

it 'flags focused block types' do # rubocop:disable RSpec/ExampleLength
it 'flags focused block types' do
expect_offense(<<~RUBY)
fdescribe 'test' do; end
^^^^^^^^^^^^^^^^ Focused spec found.
Expand Down

0 comments on commit c8b14c1

Please sign in to comment.