fix rubocop cop Style/NonNilCheck

This commit is contained in:
Pavel Lobashov 2015-06-08 10:29:08 +03:00
parent 37ede3cd61
commit 13658b0586
5 changed files with 6 additions and 12 deletions

View File

@ -112,12 +112,6 @@ Style/MultilineBlockChain:
Style/NilComparison: Style/NilComparison:
Enabled: false Enabled: false
# Offense count: 13
# Cop supports --auto-correct.
# Configuration parameters: IncludeSemanticChanges.
Style/NonNilCheck:
Enabled: false
# Offense count: 3 # Offense count: 3
# Cop supports --auto-correct. # Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SupportedStyles, AllowInnerSlashes. # Configuration parameters: EnforcedStyle, SupportedStyles, AllowInnerSlashes.

View File

@ -189,7 +189,7 @@ module Zip
private :unix_mode_cmp private :unix_mode_cmp
def exists?(fileName) def exists?(fileName)
expand_path(fileName) == '/' || @mappedZip.find_entry(fileName) != nil expand_path(fileName) == '/' || !@mappedZip.find_entry(fileName).nil?
end end
alias exist? exists? alias exist? exists?
@ -234,7 +234,7 @@ module Zip
def directory?(fileName) def directory?(fileName)
entry = @mappedZip.find_entry(fileName) entry = @mappedZip.find_entry(fileName)
expand_path(fileName) == '/' || (entry != nil && entry.directory?) expand_path(fileName) == '/' || (!entry.nil? && entry.directory?)
end end
def open(fileName, openMode = 'r', permissionInt = 0644, &block) def open(fileName, openMode = 'r', permissionInt = 0644, &block)
@ -293,7 +293,7 @@ module Zip
def file?(fileName) def file?(fileName)
entry = @mappedZip.find_entry(fileName) entry = @mappedZip.find_entry(fileName)
entry != nil && entry.file? !entry.nil? && entry.file?
end end
def dirname(fileName) def dirname(fileName)

View File

@ -6,7 +6,7 @@ class ZipFileExtractDirectoryTest < MiniTest::Test
TEST_OUT_NAME = 'test/data/generated/emptyOutDir' TEST_OUT_NAME = 'test/data/generated/emptyOutDir'
def open_zip(&aProc) def open_zip(&aProc)
assert(aProc != nil) assert(!aProc.nil?)
::Zip::File.open(TestZipFile::TEST_ZIP4.zip_name, &aProc) ::Zip::File.open(TestZipFile::TEST_ZIP4.zip_name, &aProc)
end end

View File

@ -18,7 +18,7 @@ class ZipSettingsTest < MiniTest::Test
end end
def open_zip(&aProc) def open_zip(&aProc)
assert(aProc != nil) assert(!aProc.nil?)
::Zip::File.open(TestZipFile::TEST_ZIP4.zip_name, &aProc) ::Zip::File.open(TestZipFile::TEST_ZIP4.zip_name, &aProc)
end end

View File

@ -125,7 +125,7 @@ module AssertEntry
end end
def assert_stream_contents(zis, testZipFile) def assert_stream_contents(zis, testZipFile)
assert(zis != nil) assert(!zis.nil?)
testZipFile.entry_names.each do |entryName| testZipFile.entry_names.each do |entryName|
assert_next_entry(entryName, zis) assert_next_entry(entryName, zis)
end end