Fix Naming/VariableName cop in the library code.

This commit is contained in:
Robert Haines 2020-02-19 17:07:32 +00:00
parent e6f414f539
commit f9b161eb32
3 changed files with 14 additions and 21 deletions

View File

@ -38,13 +38,6 @@ Naming/AccessorMethodName:
- 'lib/zip/streamable_stream.rb' - 'lib/zip/streamable_stream.rb'
- 'test/file_permissions_test.rb' - 'test/file_permissions_test.rb'
# Offense count: 721
# Configuration parameters: EnforcedStyle.
# SupportedStyles: snake_case, camelCase
Naming/VariableName:
Exclude:
- 'lib/**/*.rb'
# Offense count: 7 # Offense count: 7
# Configuration parameters: EnforcedStyle. # Configuration parameters: EnforcedStyle.
# SupportedStyles: inline, group # SupportedStyles: inline, group

View File

@ -319,11 +319,11 @@ module Zip
# Renames the specified entry. # Renames the specified entry.
def rename(entry, new_name, &continue_on_exists_proc) def rename(entry, new_name, &continue_on_exists_proc)
foundEntry = get_entry(entry) found_entry = get_entry(entry)
check_entry_exists(new_name, continue_on_exists_proc, 'rename') check_entry_exists(new_name, continue_on_exists_proc, 'rename')
@entry_set.delete(foundEntry) @entry_set.delete(found_entry)
foundEntry.name = new_name found_entry.name = new_name
@entry_set << foundEntry @entry_set << found_entry
end end
# Replaces the specified entry with the contents of src_path (from # Replaces the specified entry with the contents of src_path (from
@ -420,15 +420,15 @@ module Zip
private private
def directory?(new_entry, src_path) def directory?(new_entry, src_path)
srcPathIsDirectory = ::File.directory?(src_path) path_is_directory = ::File.directory?(src_path)
if new_entry.directory? && !srcPathIsDirectory if new_entry.directory? && !path_is_directory
raise ArgumentError, raise ArgumentError,
"entry name '#{new_entry}' indicates directory entry, but " \ "entry name '#{new_entry}' indicates directory entry, but " \
"'#{src_path}' is not a directory" "'#{src_path}' is not a directory"
elsif !new_entry.directory? && srcPathIsDirectory elsif !new_entry.directory? && path_is_directory
new_entry.name += '/' new_entry.name += '/'
end end
new_entry.directory? && srcPathIsDirectory new_entry.directory? && path_is_directory
end end
def check_entry_exists(entry_name, continue_on_exists_proc, proc_name) def check_entry_exists(entry_name, continue_on_exists_proc, proc_name)

View File

@ -444,16 +444,16 @@ module Zip
end end
def open(directory_name) def open(directory_name)
dirIt = new(directory_name) dir_iter = new(directory_name)
if block_given? if block_given?
begin begin
yield(dirIt) yield(dir_iter)
return nil return nil
ensure ensure
dirIt.close dir_iter.close
end end
end end
dirIt dir_iter
end end
def pwd def pwd
@ -487,9 +487,9 @@ module Zip
path = @file.expand_path(directory_name) path = @file.expand_path(directory_name)
path << '/' unless path.end_with?('/') path << '/' unless path.end_with?('/')
path = Regexp.escape(path) path = Regexp.escape(path)
subDirEntriesRegex = Regexp.new("^#{path}([^/]+)$") subdir_entry_regex = Regexp.new("^#{path}([^/]+)$")
@mapped_zip.each do |filename| @mapped_zip.each do |filename|
match = subDirEntriesRegex.match(filename) match = subdir_entry_regex.match(filename)
yield(match[1]) unless match.nil? yield(match[1]) unless match.nil?
end end
end end