Fix Naming/BlockParameterName cop.
This commit is contained in:
parent
8d91d001fd
commit
846e704048
|
@ -38,19 +38,6 @@ Naming/AccessorMethodName:
|
|||
- 'lib/zip/streamable_stream.rb'
|
||||
- 'test/file_permissions_test.rb'
|
||||
|
||||
# Offense count: 18
|
||||
# Configuration parameters: MinNameLength, AllowNamesEndingInNumbers, AllowedNames, ForbiddenNames.
|
||||
Naming/BlockParameterName:
|
||||
Exclude:
|
||||
- 'lib/zip/file.rb'
|
||||
- 'lib/zip/filesystem.rb'
|
||||
- 'samples/zipfind.rb'
|
||||
- 'test/central_directory_test.rb'
|
||||
- 'test/file_extract_directory_test.rb'
|
||||
- 'test/file_extract_test.rb'
|
||||
- 'test/output_stream_test.rb'
|
||||
- 'test/test_helper.rb'
|
||||
|
||||
# Offense count: 140
|
||||
# Configuration parameters: MinNameLength, AllowNamesEndingInNumbers, AllowedNames, ForbiddenNames.
|
||||
# AllowedNames: io, id, to, by, on, in, at, ip, db, os
|
||||
|
|
|
@ -169,8 +169,8 @@ module Zip
|
|||
# local entry headers (which contain the same information as the
|
||||
# central directory).
|
||||
def foreach(aZipFileName, &block)
|
||||
::Zip::File.open(aZipFileName) do |zipFile|
|
||||
zipFile.each(&block)
|
||||
::Zip::File.open(aZipFileName) do |zip_file|
|
||||
zip_file.each(&block)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -265,8 +265,8 @@ module Zip
|
|||
end
|
||||
|
||||
def chown(ownerInt, groupInt, *filenames)
|
||||
filenames.each do |fileName|
|
||||
e = get_entry(fileName)
|
||||
filenames.each do |filename|
|
||||
e = get_entry(filename)
|
||||
e.extra.create('IUnix') unless e.extra.member?('IUnix')
|
||||
e.extra['IUnix'].uid = ownerInt
|
||||
e.extra['IUnix'].gid = groupInt
|
||||
|
@ -275,8 +275,8 @@ module Zip
|
|||
end
|
||||
|
||||
def chmod(modeInt, *filenames)
|
||||
filenames.each do |fileName|
|
||||
e = get_entry(fileName)
|
||||
filenames.each do |filename|
|
||||
e = get_entry(filename)
|
||||
e.fstype = 3 # force convertion filesystem type to unix
|
||||
e.unix_perms = modeInt
|
||||
e.external_file_attributes = modeInt << 16
|
||||
|
@ -314,8 +314,8 @@ module Zip
|
|||
end
|
||||
|
||||
def utime(modifiedTime, *fileNames)
|
||||
fileNames.each do |fileName|
|
||||
get_entry(fileName).time = modifiedTime
|
||||
fileNames.each do |filename|
|
||||
get_entry(filename).time = modifiedTime
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -406,12 +406,12 @@ module Zip
|
|||
end
|
||||
|
||||
def delete(*args)
|
||||
args.each do |fileName|
|
||||
if directory?(fileName)
|
||||
raise Errno::EISDIR, "Is a directory - \"#{fileName}\""
|
||||
args.each do |filename|
|
||||
if directory?(filename)
|
||||
raise Errno::EISDIR, "Is a directory - \"#{filename}\""
|
||||
end
|
||||
|
||||
@mappedZip.remove(fileName)
|
||||
@mappedZip.remove(filename)
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -488,8 +488,8 @@ module Zip
|
|||
path << '/' unless path.end_with?('/')
|
||||
path = Regexp.escape(path)
|
||||
subDirEntriesRegex = Regexp.new("^#{path}([^/]+)$")
|
||||
@mappedZip.each do |fileName|
|
||||
match = subDirEntriesRegex.match(fileName)
|
||||
@mappedZip.each do |filename|
|
||||
match = subDirEntriesRegex.match(filename)
|
||||
yield(match[1]) unless match.nil?
|
||||
end
|
||||
end
|
||||
|
|
|
@ -10,13 +10,13 @@ require 'find'
|
|||
module Zip
|
||||
module ZipFind
|
||||
def self.find(path, zipFilePattern = /\.zip$/i)
|
||||
Find.find(path) do |fileName|
|
||||
yield(fileName)
|
||||
next unless zipFilePattern.match(fileName) && File.file?(fileName)
|
||||
Find.find(path) do |filename|
|
||||
yield(filename)
|
||||
next unless zipFilePattern.match(filename) && File.file?(filename)
|
||||
|
||||
begin
|
||||
Zip::File.foreach(fileName) do |zipEntry|
|
||||
yield(fileName + File::SEPARATOR + zipEntry.to_s)
|
||||
Zip::File.foreach(filename) do |entry|
|
||||
yield(filename + File::SEPARATOR + entry.to_s)
|
||||
end
|
||||
rescue Errno::EACCES => e
|
||||
puts e
|
||||
|
@ -25,8 +25,8 @@ module Zip
|
|||
end
|
||||
|
||||
def self.find_file(path, fileNamePattern, zipFilePattern = /\.zip$/i)
|
||||
find(path, zipFilePattern) do |fileName|
|
||||
yield(fileName) if fileNamePattern.match(fileName)
|
||||
find(path, zipFilePattern) do |filename|
|
||||
yield(filename) if fileNamePattern.match(filename)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -42,8 +42,8 @@ if $PROGRAM_NAME == __FILE__
|
|||
check_args(args)
|
||||
Zip::ZipFind.find_file(args[PATH_ARG_INDEX],
|
||||
args[FILENAME_PATTERN_ARG_INDEX],
|
||||
args[ZIPFILE_PATTERN_ARG_INDEX]) do |fileName|
|
||||
report_entry_found fileName
|
||||
args[ZIPFILE_PATTERN_ARG_INDEX]) do |filename|
|
||||
report_entry_found filename
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -6,21 +6,21 @@ class ZipCentralDirectoryTest < MiniTest::Test
|
|||
end
|
||||
|
||||
def test_read_from_stream
|
||||
::File.open(TestZipFile::TEST_ZIP2.zip_name, 'rb') do |zipFile|
|
||||
cdir = ::Zip::CentralDirectory.read_from_stream(zipFile)
|
||||
::File.open(TestZipFile::TEST_ZIP2.zip_name, 'rb') do |zip_file|
|
||||
cdir = ::Zip::CentralDirectory.read_from_stream(zip_file)
|
||||
|
||||
assert_equal(TestZipFile::TEST_ZIP2.entry_names.size, cdir.size)
|
||||
assert(cdir.entries.sort.compare_enumerables(TestZipFile::TEST_ZIP2.entry_names.sort) do |cdirEntry, testEntryName|
|
||||
cdirEntry.name == testEntryName
|
||||
assert(cdir.entries.sort.compare_enumerables(TestZipFile::TEST_ZIP2.entry_names.sort) do |cdir_entry, test_entry_name|
|
||||
cdir_entry.name == test_entry_name
|
||||
end)
|
||||
assert_equal(TestZipFile::TEST_ZIP2.comment, cdir.comment)
|
||||
end
|
||||
end
|
||||
|
||||
def test_read_from_invalid_stream
|
||||
File.open('test/data/file2.txt', 'rb') do |zipFile|
|
||||
File.open('test/data/file2.txt', 'rb') do |zip_file|
|
||||
cdir = ::Zip::CentralDirectory.new
|
||||
cdir.read_from_stream(zipFile)
|
||||
cdir.read_from_stream(zip_file)
|
||||
end
|
||||
raise 'ZipError expected!'
|
||||
rescue ::Zip::Error
|
||||
|
|
|
@ -42,9 +42,9 @@ class ZipFileExtractDirectoryTest < MiniTest::Test
|
|||
def test_extract_directory_exists_as_file_overwrite
|
||||
File.open(TEST_OUT_NAME, 'w') { |f| f.puts 'something' }
|
||||
gotCalled = false
|
||||
extract_test_dir do |entry, destPath|
|
||||
extract_test_dir do |entry, dest_path|
|
||||
gotCalled = true
|
||||
assert_equal(TEST_OUT_NAME, destPath)
|
||||
assert_equal(TEST_OUT_NAME, dest_path)
|
||||
assert(entry.directory?)
|
||||
true
|
||||
end
|
||||
|
|
|
@ -53,9 +53,9 @@ class ZipFileExtractTest < MiniTest::Test
|
|||
|
||||
gotCalledCorrectly = false
|
||||
::Zip::File.open(TEST_ZIP.zip_name) do |zf|
|
||||
zf.extract(zf.entries.first, EXTRACTED_FILENAME) do |entry, extractLoc|
|
||||
zf.extract(zf.entries.first, EXTRACTED_FILENAME) do |entry, extract_loc|
|
||||
gotCalledCorrectly = zf.entries.first == entry &&
|
||||
extractLoc == EXTRACTED_FILENAME
|
||||
extract_loc == EXTRACTED_FILENAME
|
||||
true
|
||||
end
|
||||
end
|
||||
|
|
|
@ -121,9 +121,9 @@ class ZipOutputStreamTest < MiniTest::Test
|
|||
end
|
||||
|
||||
def write_test_zip(zos)
|
||||
TEST_ZIP.entry_names.each do |entryName|
|
||||
zos.put_next_entry(entryName)
|
||||
File.open(entryName, 'rb') { |f| zos.write(f.read) }
|
||||
TEST_ZIP.entry_names.each do |entry_name|
|
||||
zos.put_next_entry(entry_name)
|
||||
File.open(entry_name, 'rb') { |f| zos.write(f.read) }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -119,8 +119,8 @@ module AssertEntry
|
|||
|
||||
def assert_stream_contents(zis, testZipFile)
|
||||
assert(!zis.nil?)
|
||||
testZipFile.entry_names.each do |entryName|
|
||||
assert_next_entry(entryName, zis)
|
||||
testZipFile.entry_names.each do |entry_name|
|
||||
assert_next_entry(entry_name, zis)
|
||||
end
|
||||
assert_nil(zis.get_next_entry)
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue