Skip to content

Commit

Permalink
Autocorrect Style/IfUnlessModifier
Browse files Browse the repository at this point in the history
  • Loading branch information
mvz committed Apr 12, 2020
1 parent bf61276 commit 08ea367
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 27 deletions.
9 changes: 0 additions & 9 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -163,15 +163,6 @@ Style/IdenticalConditionalBranches:
Exclude:
- 'lib/aruba/hooks.rb'

# Offense count: 6
# Cop supports --auto-correct.
Style/IfUnlessModifier:
Exclude:
- 'lib/aruba/cucumber/command.rb'
- 'lib/aruba/matchers/collection/include_an_object.rb'
- 'lib/aruba/platforms/unix_environment_variables.rb'
- 'spec/aruba/platform/windows_environment_variables_spec.rb'

# Offense count: 5
Style/MethodMissingSuper:
Exclude:
Expand Down
4 changes: 1 addition & 3 deletions lib/aruba/cucumber/command.rb
Original file line number Diff line number Diff line change
Expand Up @@ -283,9 +283,7 @@
end

Then(/^the exit status should( not)? be (\d+)$/) do |negated, exit_status|
if last_command_stopped.nil?
last_command_started.stop
end
last_command_started.stop if last_command_stopped.nil?

if negated
expect(last_command_stopped).not_to have_exit_status exit_status.to_i
Expand Down
4 changes: 1 addition & 3 deletions lib/aruba/matchers/collection/include_an_object.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,7 @@ def initialize(matcher)
# @api private
# @return [String]
def failure_message
unless iterable?
return "#{improve_hash_formatting(super)}, but was not iterable"
end
return "#{improve_hash_formatting(super)}, but was not iterable" unless iterable?

return failed_objects.first if failed_objects.size == 1

Expand Down
4 changes: 1 addition & 3 deletions lib/aruba/platforms/unix_environment_variables.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,7 @@ class UpdateAction
def initialize(other_env, &block)
@other_env = other_env.to_h.each_with_object({}) { |(k, v), a| a[k] = v.to_s }

@block = if block_given?
block
end
@block = (block if block_given?)
end

def call(env)
Expand Down
12 changes: 3 additions & 9 deletions spec/aruba/platform/windows_environment_variables_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -116,9 +116,7 @@
let(:variable) { 'unknown' }

context 'and no default is given' do
unless defined? KeyError
class KeyError < StandardError; end
end
class KeyError < StandardError; end unless defined? KeyError

it { expect { environment.fetch(variable) }.to raise_error KeyError }
end
Expand Down Expand Up @@ -156,9 +154,7 @@ class KeyError < StandardError; end
let(:variable) { 'unknown' }

context 'and no default is given' do
unless defined? KeyError
class KeyError < StandardError; end
end
class KeyError < StandardError; end unless defined? KeyError

it { expect { environment.fetch(variable) }.to raise_error KeyError }
end
Expand Down Expand Up @@ -196,9 +192,7 @@ class KeyError < StandardError; end
let(:variable) { 'unknown' }

context 'and no default is given' do
unless defined? KeyError
class KeyError < StandardError; end
end
class KeyError < StandardError; end unless defined? KeyError

it { expect { environment.fetch(variable) }.to raise_error KeyError }
end
Expand Down

0 comments on commit 08ea367

Please sign in to comment.