Fix Style/SignalException cop.

This commit is contained in:
Robert Haines 2019-09-26 13:58:43 +01:00
parent 2f993221c0
commit 2cbdbf110b
7 changed files with 8 additions and 21 deletions

View File

@ -209,19 +209,6 @@ Style/SafeNavigation:
- 'test/filesystem/file_stat_test.rb' - 'test/filesystem/file_stat_test.rb'
- 'test/test_helper.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 # Offense count: 30
# Cop supports --auto-correct. # Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle. # Configuration parameters: EnforcedStyle.

View File

@ -63,7 +63,7 @@ class ZipCentralDirectoryEntryTest < MiniTest::Test
fragment.extend(IOizeString) fragment.extend(IOizeString)
entry = ::Zip::Entry.new entry = ::Zip::Entry.new
entry.read_c_dir_entry(fragment) entry.read_c_dir_entry(fragment)
fail 'ZipError expected' raise 'ZipError expected'
rescue ::Zip::Error rescue ::Zip::Error
end end
end end

View File

@ -22,7 +22,7 @@ class ZipCentralDirectoryTest < MiniTest::Test
cdir = ::Zip::CentralDirectory.new cdir = ::Zip::CentralDirectory.new
cdir.read_from_stream(zipFile) cdir.read_from_stream(zipFile)
end end
fail 'ZipError expected!' raise 'ZipError expected!'
rescue ::Zip::Error rescue ::Zip::Error
end end
@ -33,7 +33,7 @@ class ZipCentralDirectoryTest < MiniTest::Test
fragment.extend(IOizeString) fragment.extend(IOizeString)
entry = ::Zip::CentralDirectory.new entry = ::Zip::CentralDirectory.new
entry.read_from_stream(fragment) entry.read_from_stream(fragment)
fail 'ZipError expected' raise 'ZipError expected'
rescue ::Zip::Error rescue ::Zip::Error
end end

View File

@ -80,7 +80,7 @@ class ZipFsFileNonmutatingTest < MiniTest::Test
end end
begin begin
is = @zip_file.file.new('file1') do is = @zip_file.file.new('file1') do
fail 'should not call block' raise 'should not call block'
end end
ensure ensure
is.close if is is.close if is

View File

@ -95,7 +95,7 @@ class AbstractInputStreamTest < MiniTest::Test
test_gets test_gets
begin begin
@io.readline @io.readline
fail 'EOFError expected' raise 'EOFError expected'
rescue EOFError rescue EOFError
end end
end end

View File

@ -46,7 +46,7 @@ class ZipLocalEntryTest < MiniTest::Test
zipFragment.extend(IOizeString).reset zipFragment.extend(IOizeString).reset
entry = ::Zip::Entry.new entry = ::Zip::Entry.new
entry.read_local_entry(zipFragment) entry.read_local_entry(zipFragment)
fail 'ZipError expected' raise 'ZipError expected'
rescue ::Zip::Error rescue ::Zip::Error
end end

View File

@ -95,7 +95,7 @@ module AssertEntry
if (expected && actual) && (expected.length > 400 || actual.length > 400) if (expected && actual) && (expected.length > 400 || actual.length > 400)
zipEntryFilename = entryName + '.zipEntry' zipEntryFilename = entryName + '.zipEntry'
File.open(zipEntryFilename, 'wb') { |entryfile| entryfile << actual } File.open(zipEntryFilename, 'wb') { |entryfile| entryfile << actual }
fail("File '#{filename}' is different from '#{zipEntryFilename}'") raise("File '#{filename}' is different from '#{zipEntryFilename}'")
else else
assert_equal(expected, actual) assert_equal(expected, actual)
end end
@ -111,7 +111,7 @@ module AssertEntry
if fileContents.length > 400 || aString.length > 400 if fileContents.length > 400 || aString.length > 400
stringFile = filename + '.other' stringFile = filename + '.other'
File.open(stringFile, 'wb') { |f| f << aString } 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 else
assert_equal(fileContents, aString) assert_equal(fileContents, aString)
end end