From f9b161eb32d6f63f7840838612c20f087f64da5f Mon Sep 17 00:00:00 2001 From: Robert Haines Date: Wed, 19 Feb 2020 17:07:32 +0000 Subject: [PATCH] Fix Naming/VariableName cop in the library code. --- .rubocop_todo.yml | 7 ------- lib/zip/file.rb | 16 ++++++++-------- lib/zip/filesystem.rb | 12 ++++++------ 3 files changed, 14 insertions(+), 21 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 67bd081..ae1fe05 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -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 diff --git a/lib/zip/file.rb b/lib/zip/file.rb index 0e7d4a9..999d972 100644 --- a/lib/zip/file.rb +++ b/lib/zip/file.rb @@ -319,11 +319,11 @@ module Zip # 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 @@ -420,15 +420,15 @@ module Zip 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) diff --git a/lib/zip/filesystem.rb b/lib/zip/filesystem.rb index 28ebad4..d9928d4 100644 --- a/lib/zip/filesystem.rb +++ b/lib/zip/filesystem.rb @@ -444,16 +444,16 @@ module Zip 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 @@ -487,9 +487,9 @@ module Zip 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