Skip to content

Commit

Permalink
Fix Style/SignalException cop.
Browse files Browse the repository at this point in the history
  • Loading branch information
hainesr committed Sep 26, 2019
1 parent b9e6e95 commit 9005351
Show file tree
Hide file tree
Showing 7 changed files with 8 additions and 21 deletions.
13 changes: 0 additions & 13 deletions .rubocop_rubyzip.yml
Original file line number Diff line number Diff line change
Expand Up @@ -181,19 +181,6 @@ Style/SafeNavigation:
- 'test/filesystem/file_stat_test.rb'
- 'test/test_helper.rb'

# Offense count: 8
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle.
# SupportedStyles: only_raise, only_fail, semantic
Style/SignalException:
Exclude:
- 'test/central_directory_entry_test.rb'
- 'test/central_directory_test.rb'
- 'test/filesystem/file_nonmutating_test.rb'
- 'test/ioextras/abstract_input_stream_test.rb'
- 'test/local_entry_test.rb'
- 'test/test_helper.rb'

# Offense count: 30
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle.
Expand Down
2 changes: 1 addition & 1 deletion test/central_directory_entry_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ def test_read_entry_from_truncated_zip_file
fragment.extend(IOizeString)
entry = ::Zip::Entry.new
entry.read_c_dir_entry(fragment)
fail 'ZipError expected'
raise 'ZipError expected'
rescue ::Zip::Error
end
end
4 changes: 2 additions & 2 deletions test/central_directory_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def test_read_from_invalid_stream
cdir = ::Zip::CentralDirectory.new
cdir.read_from_stream(zipFile)
end
fail 'ZipError expected!'
raise 'ZipError expected!'
rescue ::Zip::Error
end

Expand All @@ -33,7 +33,7 @@ def test_read_from_truncated_zip_file
fragment.extend(IOizeString)
entry = ::Zip::CentralDirectory.new
entry.read_from_stream(fragment)
fail 'ZipError expected'
raise 'ZipError expected'
rescue ::Zip::Error
end

Expand Down
2 changes: 1 addition & 1 deletion test/filesystem/file_nonmutating_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ def test_new
end
begin
is = @zip_file.file.new('file1') do
fail 'should not call block'
raise 'should not call block'
end
ensure
is.close if is
Expand Down
2 changes: 1 addition & 1 deletion test/ioextras/abstract_input_stream_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ def test_readline
test_gets
begin
@io.readline
fail 'EOFError expected'
raise 'EOFError expected'
rescue EOFError
end
end
Expand Down
2 changes: 1 addition & 1 deletion test/local_entry_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def test_read_local_entry_from_truncated_zip_file
zipFragment.extend(IOizeString).reset
entry = ::Zip::Entry.new
entry.read_local_entry(zipFragment)
fail 'ZipError expected'
raise 'ZipError expected'
rescue ::Zip::Error
end

Expand Down
4 changes: 2 additions & 2 deletions test/test_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ def assert_entry_contents_for_stream(filename, zis, entryName)
if (expected && actual) && (expected.length > 400 || actual.length > 400)
zipEntryFilename = entryName + '.zipEntry'
File.open(zipEntryFilename, 'wb') { |entryfile| entryfile << actual }
fail("File '#{filename}' is different from '#{zipEntryFilename}'")
raise("File '#{filename}' is different from '#{zipEntryFilename}'")
else
assert_equal(expected, actual)
end
Expand All @@ -122,7 +122,7 @@ def self.assert_contents(filename, aString)
if fileContents.length > 400 || aString.length > 400
stringFile = filename + '.other'
File.open(stringFile, 'wb') { |f| f << aString }
fail("File '#{filename}' is different from contents of string stored in '#{stringFile}'")
raise("File '#{filename}' is different from contents of string stored in '#{stringFile}'")
else
assert_equal(fileContents, aString)
end
Expand Down

0 comments on commit 9005351

Please sign in to comment.