8000 Rubocop 0.79 by hainesr · Pull Request #437 · rubyzip/rubyzip · GitHub
[go: up one dir, main page]

Skip to content

Rubocop 0.79 #437

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 56 commits into from
Feb 16, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
56 commits
Select commit Hold shift + click to select a range
c8bfd14
Update rubocop version and the config files.
hainesr Sep 14, 2019
a3245ac
Add Rubocop tasks to the Rakefile.
hainesr Sep 15, 2019
aa40035
Fix Gemspec/OrderedDependencies cop.
hainesr Feb 8, 2020
73e405a
Fix Security/Open cop errors.
hainesr Sep 14, 2019
f1154c2
Fix Style/OrAssignment cop.
hainesr Feb 9, 2020
3a3ac6f
Fix Style/Semicolon cop.
hainesr Sep 14, 2019
e7275da
Fix Style/BlockDelimiters cop errors.
hainesr Sep 14, 2019
98c6969
Fix Layout/SpaceA 8000 roundOperators cop.
hainesr Feb 9, 2020
20743a5
Fix Lint/AmbiguousBlockAssociation cop.
hainesr Feb 9, 2020
b528cae
Fix Lint/LiteralAsCondition cop.
hainesr Feb 9, 2020
cd065d0
Fix Lint/UnusedBlockArgument cop.
hainesr Feb 9, 2020
e361a47
Configure Lint/UselessComparison cop.
hainesr Feb 9, 2020
23ba1af
Fix Lint/RescueException cop.
hainesr Feb 9, 2020
0d49421
Fix Lint/UselessAccessModifier cop.
hainesr Feb 9, 2020
fff2c41
Configure Lint/SuppressedException cop.
hainesr Feb 9, 2020
cfe4972
Fix Layout/EmptyLineAfterGuardClause cop.
hainesr Feb 9, 2020
61c83b2
Configure Layout/HashAlignment cop.
hainesr Feb 9, 2020
68259ed
Fix Style/Encoding cop.
hainesr Feb 9, 2020
70d036b
Fix Style/ExpandPathArguments cop.
hainesr Sep 15, 2019
6544563
Configure Style/ZeroLengthPredicate so it doesn't misfire.
hainesr Feb 9, 2020
19aa7e8
Fix Style/RescueStandardError cop.
hainesr Sep 15, 2019
5a1baf4
Fix Style/RedundantReturn cop.
hainesr Sep 15, 2019
b3c4c37
Fix Style/NonNilCheck cop.
hainesr Sep 15, 2019
b3f2413
Fix Style/CommentedKeyword cop.
hainesr Feb 9, 2020
468a80c
Fix Style/IfInsideElse cop.
hainesr Sep 21, 2019
3121ad0
Fix Style/Alias cop.
hainesr Feb 9, 2020
1b8f1a6
Fix Naming/RescuedExceptionsVariableName cop.
hainesr Sep 21, 2019
bce8416
Fix Style/MixinUsage cop.
hainesr Sep 21, 2019
45f4c2d
Fix Style/GuardClause cop.
hainesr Feb 9, 2020
2e11a88
Fix Style/StringLiterals cop.
hainesr Feb 9, 2020
cc0e372
Configure Style/SymbolArray cop.
hainesr Feb 9, 2020
4e1b679
Fix Style/TrailingCommaInArrayLiteral cop.
hainesr Sep 22, 2019
2dfe092
Fix Style/UnpackFirst cop.
hainesr Sep 22, 2019
41f2359
Configure Style/RegexpLiteral cop.
hainesr Feb 9, 2020
5e32204
Configure Style/MultilineBlockChain cop.
hainesr Feb 9, 2020
172ab4b
Fix Style/FloatDivision cop.
hainesr Sep 22, 2019
d42c66c
Fix Style/MultilineWhenThen cop.
hainesr Sep 22, 2019
2dc9b49
Fix Style/EvalWithLocation cop.
hainesr Sep 22, 2019
835843d
Fix Naming/HeredocDelimiterCase cop.
hainesr Sep 22, 2019
7978abb
Configure Naming/MemoizedInstanceVariableName cop.
hainesr Sep 22, 2019
2f99322
Fix Style/Next cop.
hainesr Sep 25, 2019
2cbdbf1
Fix Style/SignalException cop.
hainesr Sep 26, 2019
bb3b447
Fix Style/SpecialGlobalVars cop.
hainesr Sep 26, 2019
0df6cb3
Fix Style/SymbolProc cop.
hainesr Sep 26, 2019
6cab592
Configure and fix Metrics/LineLength cop.
hainesr Sep 26, 2019
0e25e63
Turn off Metrics/BlockLength for the tests.
hainesr Sep 29, 2019
c97d560
Configure Metrics/AbcSize and turn off for the tests.
hainesr Sep 29, 2019
5ce4e13
Configure and fix Style/ClassCheck cop.
hainesr Sep 30, 2019
a9adfa2
Configure Metrics/ClassLength and turn off for the tests.
hainesr Feb 9, 2020
a187ec0
Configure Metrics/MethodLength and turn off for the tests.
hainesr Feb 9, 2020
4b8f740
Fix Layout/EmptyLinesAroundClassBody cop.
hainesr Feb 9, 2020
fae95e3
Fix Style/NumericLiteralPrefix cop.
hainesr Feb 9, 2020
d07b36b
Fix Style/TernaryParentheses cop.
hainesr Feb 9, 2020
989a565
Fix Style/TrailingCommaInHashLiteral cop.
hainesr Feb 9, 2020
c31ab81
Fix Style/NumericLiterals cop.
hainesr Feb 9, 2020
87a63e0
Set TargetRubyVersion to match that in the gemspec.
hainesr Feb 15, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev 8000 Previous commit
Next Next commit
Fix Style/SymbolProc cop.
  • Loading branch information
hainesr committed Feb 15, 2020
commit 0df6cb3059a9d770ac4fd800ad3fdb45872192cb
16 changes: 0 additions & 16 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -209,22 +209,6 @@ Style/SafeNavigation:
- 'test/filesystem/file_stat_test.rb'
- 'test/test_helper.rb'

# Offense count: 42
# Cop supports --auto-correct.
# Configuration parameters: IgnoredMethods.
# IgnoredMethods: respond_to, define_method
Style/SymbolProc:
Exclude:
- 'lib/zip/file.rb'
- 'lib/zip/filesystem.rb'
- 'test/basic_zip_file_test.rb'
- 'test/case_sensitivity_test.rb'
- 'test/deflater_test.rb'
- 'test/file_extract_test.rb'
- 'test/file_split_test.rb'
- 'test/file_test.rb'
- 'test/filesystem/file_nonmutating_test.rb'

# Offense count: 3
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, AllowSafeAssignment.
Expand Down
2 changes: 1 addition & 1 deletion lib/zip/file.rb
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ def to_s

# Returns a string containing the contents of the specified entry
def read(entry)
get_input_stream(entry) { |is| is.read }
get_input_stream(entry, &:read)
end

# Convenience method for adding the contents of a file to the archive
Expand Down
2 changes: 1 addition & 1 deletion lib/zip/filesystem.rb
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,7 @@ def stat(fileName)
alias lstat stat

def readlines(fileName)
self.open(fileName) { |is| is.readlines }
self.open(fileName, &:readlines)
end

def read(fileName)
Expand Down
2 changes: 1 addition & 1 deletion test/basic_zip_file_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ def setup

def test_entries
assert_equal(TestZipFile::TEST_ZIP2.entry_names.sort,
@zip_file.entries.entries.sort.map { |e| e.name })
@zip_file.entries.entries.sort.map(&:name))
end

def test_each
Expand Down
7 changes: 4 additions & 3 deletions test/case_sensitivity_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def test_add_case_sensitive
SRC_FILES.each_with_index do |a, i|
assert_equal(a.last, zfRead.entries[i].name)
AssertEntry.assert_contents(a.first,
zfRead.get_input_stream(a.last) { |zis| zis.read })
zfRead.get_input_stream(a.last, &:read))
end
end

Expand Down Expand Up @@ -56,8 +56,9 @@ def test_add_case_sensitive_read_case_insensitive
zfRead = ::Zip::File.new(EMPTY_FILENAME)
assert_equal(SRC_FILES.collect { |_fn, en| en.downcase }.uniq.size, zfRead.entries.length)
assert_equal(SRC_FILES.last.last.downcase, zfRead.entries.first.name.downcase)
AssertEntry.assert_contents(SRC_FILES.last.first,
zfRead.get_input_stream(SRC_FILES.last.last) { |zis| zis.read })
AssertEntry.assert_contents(
SRC_FILES.last.first, zfRead.get_input_stream(SRC_FILES.last.last, &:read)
)
end

private
Expand Down
2 changes: 1 addition & 1 deletion test/deflater_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def test_data_error
private

def load_file(fileName)
File.open(fileName, 'rb') { |f| f.read }
File.open(fileName, 'rb', &:read)
end

def deflate(data, fileName)
Expand Down
4 changes: 2 additions & 2 deletions test/file_extract_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def test_extract

assert(File.exist?(EXTRACTED_FILENAME))
AssertEntry.assert_contents(EXTRACTED_FILENAME,
zf.get_input_stream(ENTRY_TO_EXTRACT) { |is| is.read })
zf.get_input_stream(ENTRY_TO_EXTRACT, &:read))

::File.unlink(EXTRACTED_FILENAME)

Expand All @@ -29,7 +29,7 @@ def test_extract

assert(File.exist?(EXTRACTED_FILENAME))
AssertEntry.assert_contents(EXTRACTED_FILENAME,
entry.get_input_stream { |is| is.read })
entry.get_input_stream(&:read))
end
end

Expand Down
4 changes: 2 additions & 2 deletions test/file_split_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def test_split

assert(File.exist?(EXTRACTED_FILENAME))
AssertEntry.assert_contents(EXTRACTED_FILENAME,
zf.get_input_stream(ENTRY_TO_EXTRACT) { |is| is.read })
zf.get_input_stream(ENTRY_TO_EXTRACT, &:read))

File.unlink(EXTRACTED_FILENAME)

Expand All @@ -52,7 +52,7 @@ def test_split

assert(File.exist?(EXTRACTED_FILENAME))
AssertEntry.assert_contents(EXTRACTED_FILENAME,
entry.get_input_stream { |is| is.read })
entry.get_input_stream(&:read))
end
end
end
57 changes: 30 additions & 27 deletions test/file_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -106,14 +106,14 @@ def test_get_output_stream
def test_open_buffer_with_string
string = File.read('test/data/rubycode.zip')
::Zip::File.open_buffer string do |zf|
assert zf.entries.map { |e| e.name }.include?('zippedruby1.rb')
assert zf.entries.map(&:name).include?('zippedruby1.rb')
end
end

def test_open_buffer_with_stringio
string_io = StringIO.new File.read('test/data/rubycode.zip')
::Zip::File.open_buffer string_io do |zf|
assert zf.entries.map { |e| e.name }.include?('zippedruby1.rb')
assert zf.entries.map(&:name).include?('zippedruby1.rb')
end
end

Expand Down Expand Up @@ -171,7 +171,7 @@ def test_open_buffer_with_io_and_block
def test_open_buffer_without_block
string_io = StringIO.new File.read('test/data/rubycode.zip')
zf = ::Zip::File.open_buffer string_io
assert zf.entries.map { |e| e.name }.include?('zippedruby1.rb')
assert zf.entries.map(&:name).include?('zippedruby1.rb')
end

def test_cleans_up_tempfiles_after_close
Expand Down Expand Up @@ -201,7 +201,7 @@ def test_add
assert_equal(1, zfRead.entries.length)
assert_equal(entryName, zfRead.entries.first.name)
AssertEntry.assert_contents(srcFile,
zfRead.get_input_stream(entryName) { |zis| zis.read })
zfRead.get_input_stream(entryName, &:read))
end

def test_add_stored
Expand All @@ -221,7 +221,7 @@ def test_add_stored
assert_equal(entry.size, entry.compressed_size)
assert_equal(::Zip::Entry::STORED, entry.compression_method)
AssertEntry.assert_contents(srcFile,
zfRead.get_input_stream(entryName) { |zis| zis.read })
zfRead.get_input_stream(entryName, &:read))
end

def test_recover_permissions_after_add_files_to_archive
Expand Down Expand Up @@ -277,37 +277,37 @@ def test_remove
FileUtils.cp(TestZipFile::TEST_ZIP2.zip_name, TEST_ZIP.zip_name)

zf = ::Zip::File.new(TEST_ZIP.zip_name)
assert(zf.entries.map { |e| e.name }.include?(entryToRemove))
assert(zf.entries.map(&:name).include?(entryToRemove))
zf.remove(entryToRemove)
assert(!zf.entries.map { |e| e.name }.include?(entryToRemove))
assert_equal(zf.entries.map { |x| x.name }.sort, remainingEntries.sort)
assert(!zf.entries.map(&:name).include?(entryToRemove))
assert_equal(zf.entries.map(&:name).sort, remainingEntries.sort)
zf.close

zfRead = ::Zip::File.new(TEST_ZIP.zip_name)
assert(!zfRead.entries.map { |e| e.name }.include?(entryToRemove))
assert_equal(zfRead.entries.map { |x| x.name }.sort, remainingEntries.sort)
assert(!zfRead.entries.map(&:name).include?(entryToRemove))
assert_equal(zfRead.entries.map(&:name).sort, remainingEntries.sort)
zfRead.close
end

def test_rename
entryToRename, * = TEST_ZIP.entry_names

zf = ::Zip::File.new(TEST_ZIP.zip_name)
assert(zf.entries.map { |e| e.name }.include?(entryToRename))
assert(zf.entries.map(&:name).include?(entryToRename))

contents = zf.read(entryToRename)
newName = 'changed entry name'
assert(!zf.entries.map { |e| e.name }.include?(newName))
assert(!zf.entries.map(&:name).include?(newName))

zf.rename(entryToRename, newName)
assert(zf.entries.map { |e| e.name }.include?(newName))
assert(zf.entries.map(&:name).include?(newName))

assert_equal(contents, zf.read(newName))

zf.close

zfRead = ::Zip::File.new(TEST_ZIP.zip_name)
assert(zfRead.entries.map { |e| e.name }.include?(newName))
assert(zfRead.entries.map(&:name).include?(newName))
assert_equal(contents, zfRead.read(newName))
zfRead.close
end
Expand Down Expand Up @@ -352,7 +352,7 @@ def test_rename_to_existing_entry
end

::Zip::File.open(TEST_ZIP.zip_name) do |zf|
assert_equal(oldEntries.sort.map { |e| e.name }, zf.entries.sort.map { |e| e.name })
assert_equal(oldEntries.sort.map(&:name), zf.entries.sort.map(&:name))
end
end

Expand All @@ -373,8 +373,8 @@ def test_rename_to_existing_entry_overwrite
assert(gotCalled)
oldEntries.delete_if { |e| e.name == renamedEntryName }
::Zip::File.open(TEST_ZIP.zip_name) do |zf|
assert_equal(oldEntries.sort.map { |e| e.name },
zf.entries.sort.map { |e| e.name })
assert_equal(oldEntries.sort.map(&:name),
zf.entries.sort.map(&:name))
end
end

Expand Down Expand Up @@ -407,13 +407,16 @@ def test_replace
zf.close
zfRead = ::Zip::File.new(TEST_ZIP.zip_name)
AssertEntry.assert_contents(newEntrySrcFilename,
zfRead.get_input_stream(entryToReplace) { |is| is.read })
zfRead.get_input_stream(entryToReplace, &:read))
AssertEntry.assert_contents(TEST_ZIP.entry_names[0],
zfRead.get_input_stream(TEST_ZIP.entry_names[0]) { |is| is.read })
zfRead.get_input_stream(TEST_ZIP.entry_names[0],
&:read))
AssertEntry.assert_contents(TEST_ZIP.entry_names[1],
zfRead.get_input_stream(TEST_ZIP.entry_names[1]) { |is| is.read })
zfRead.get_input_stream(TEST_ZIP.entry_names[1],
&:read))
AssertEntry.assert_contents(TEST_ZIP.entry_names[3],
zfRead.get_input_stream(TEST_ZIP.entry_names[3]) { |is| is.read })
zfRead.get_input_stream(TEST_ZIP.entry_names[3],
&:read))
zfRead.close
end

Expand Down Expand Up @@ -555,7 +558,7 @@ def test_compound2
zf.add(filename, filename)
assert_contains(zf, filename)
end
assert_equal(zf.entries.sort.map { |e| e.name }, TestFiles::ASCII_TEST_FILES)
assert_equal(zf.entries.sort.map(&:name), TestFiles::ASCII_TEST_FILES)

zf.rename(TestFiles::ASCII_TEST_FILES[0], 'newName')
assert_not_contains(zf, TestFiles::ASCII_TEST_FILES[0])
Expand Down Expand Up @@ -588,24 +591,24 @@ def test_change_comment
def test_preserve_file_order
entryNames = nil
::Zip::File.open(TEST_ZIP.zip_name) do |zf|
entryNames = zf.entries.map { |e| e.to_s }
entryNames = zf.entries.map(&:to_s)
zf.get_output_stream('a.txt') { |os| os.write 'this is a.txt' }
zf.get_output_stream('z.txt') { |os| os.write 'this is z.txt' }
zf.get_output_stream('k.txt') { |os| os.write 'this is k.txt' }
entryNames << 'a.txt' << 'z.txt' << 'k.txt'
end

::Zip::File.open(TEST_ZIP.zip_name) do |zf|
assert_equal(entryNames, zf.entries.map { |e| e.to_s })
entries = zf.entries.sort_by { |e| e.name }.reverse
assert_equal(entryNames, zf.entries.map(&:to_s))
entries = zf.entries.sort_by(&:name).reverse
entries.each do |e|
zf.remove e
zf.get_output_stream(e) { |os| os.write 'foo' }
end
entryNames = entries.map { |e| e.to_s }
entryNames = entries.map(&:to_s)
end
::Zip::File.open(TEST_ZIP.zip_name) do |zf|
assert_equal(entryNames, zf.entries.map { |e| e.to_s })
assert_equal(entryNames, zf.entries.map(&:to_s))
end
end

Expand Down
8 changes: 4 additions & 4 deletions test/filesystem/file_nonmutating_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -468,12 +468,12 @@ def test_popen
if Zip::RUNNING_ON_WINDOWS
# This is pretty much projectile vomit but it allows the test to be
# run on windows also
system_dir = ::File.popen('dir') { |f| f.read }.gsub(/Dir\(s\).*$/, '')
zipfile_dir = @zip_file.file.popen('dir') { |f| f.read }.gsub(/Dir\(s\).*$/, '')
system_dir = ::File.popen('dir', &:read).gsub(/Dir\(s\).*$/, '')
zipfile_dir = @zip_file.file.popen('dir', &:read).gsub(/Dir\(s\).*$/, '')
assert_equal(system_dir, zipfile_dir)
else
assert_equal(::File.popen('ls') { |f| f.read },
@zip_file.file.popen('ls') { |f| f.read })
assert_equal(::File.popen('ls', &:read),
@zip_file.file.popen('ls', &:read))
end
end

Expand Down
0