Skip to content

Commit

Permalink
Fix Naming/VariableName cop in the library code.
Browse files Browse the repository at this point in the history
  • Loading branch information
hainesr committed Feb 19, 2020
1 parent 892ac81 commit 8d65a9b
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 21 deletions.
7 changes: 0 additions & 7 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,6 @@ Naming/AccessorMethodName:
- 'lib/zip/streamable_stream.rb'
- 'test/file_permissions_test.rb'

# Offense count: 721
# Configuration parameters: EnforcedStyle.
# SupportedStyles: snake_case, camelCase
Naming/VariableName:
Exclude:
- 'lib/**/*.rb'

# Offense count: 7
# Configuration parameters: EnforcedStyle.
# SupportedStyles: inline, group
Expand Down
16 changes: 8 additions & 8 deletions lib/zip/file.rb
Original file line number Diff line number Diff line change
Expand Up @@ -319,11 +319,11 @@ def remove(entry)

# Renames the specified entry.
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')
@entry_set.delete(foundEntry)
foundEntry.name = new_name
@entry_set << foundEntry
@entry_set.delete(found_entry)
found_entry.name = new_name
@entry_set << found_entry
end

# Replaces the specified entry with the contents of src_path (from
Expand Down Expand Up @@ -420,15 +420,15 @@ def mkdir(entry_name, permission = 0o755)
private

def directory?(new_entry, src_path)
srcPathIsDirectory = ::File.directory?(src_path)
if new_entry.directory? && !srcPathIsDirectory
path_is_directory = ::File.directory?(src_path)
if new_entry.directory? && !path_is_directory
raise ArgumentError,
"entry name '#{new_entry}' indicates directory entry, but " \
"'#{src_path}' is not a directory"
elsif !new_entry.directory? && srcPathIsDirectory
elsif !new_entry.directory? && path_is_directory
new_entry.name += '/'
end
new_entry.directory? && srcPathIsDirectory
new_entry.directory? && path_is_directory
end

def check_entry_exists(entry_name, continue_on_exists_proc, proc_name)
Expand Down
12 changes: 6 additions & 6 deletions lib/zip/filesystem.rb
Original file line number Diff line number Diff line change
Expand Up @@ -444,16 +444,16 @@ def new(directory_name)
end

def open(directory_name)
dirIt = new(directory_name)
dir_iter = new(directory_name)
if block_given?
begin
yield(dirIt)
yield(dir_iter)
return nil
ensure
dirIt.close
dir_iter.close
end
end
dirIt
dir_iter
end

def pwd
Expand Down Expand Up @@ -487,9 +487,9 @@ def foreach(directory_name)
path = @file.expand_path(directory_name)
path << '/' unless path.end_with?('/')
path = Regexp.escape(path)
subDirEntriesRegex = Regexp.new("^#{path}([^/]+)$")
subdir_entry_regex = Regexp.new("^#{path}([^/]+)$")
@mapped_zip.each do |filename|
match = subDirEntriesRegex.match(filename)
match = subdir_entry_regex.match(filename)
yield(match[1]) unless match.nil?
end
end
Expand Down

0 comments on commit 8d65a9b

Please sign in to comment.