Fix Style/SpecialGlobalVars cop.
This commit is contained in:
parent
2cbdbf110b
commit
bb3b4474fa
|
@ -209,27 +209,6 @@ Style/SafeNavigation:
|
||||||
- 'test/filesystem/file_stat_test.rb'
|
- 'test/filesystem/file_stat_test.rb'
|
||||||
- 'test/test_helper.rb'
|
- 'test/test_helper.rb'
|
||||||
|
|
||||||
# Offense count: 30
|
|
||||||
# Cop supports --auto-correct.
|
|
||||||
# Configuration parameters: EnforcedStyle.
|
|
||||||
# SupportedStyles: use_perl_names, use_english_names
|
|
||||||
Style/SpecialGlobalVars:
|
|
||||||
Exclude:
|
|
||||||
- 'lib/zip/filesystem.rb'
|
|
||||||
- 'lib/zip/ioextras/abstract_input_stream.rb'
|
|
||||||
- 'lib/zip/ioextras/abstract_output_stream.rb'
|
|
||||||
- 'samples/example.rb'
|
|
||||||
- 'samples/example_filesystem.rb'
|
|
||||||
- 'samples/gtk_ruby_zip.rb'
|
|
||||||
- 'samples/qtzip.rb'
|
|
||||||
- 'samples/write_simple.rb'
|
|
||||||
- 'samples/zipfind.rb'
|
|
||||||
- 'test/gentestfiles.rb'
|
|
||||||
- 'test/ioextras/abstract_input_stream_test.rb'
|
|
||||||
- 'test/ioextras/abstract_output_stream_test.rb'
|
|
||||||
- 'test/output_stream_test.rb'
|
|
||||||
- 'test/test_helper.rb'
|
|
||||||
|
|
||||||
# Offense count: 42
|
# Offense count: 42
|
||||||
# Cop supports --auto-correct.
|
# Cop supports --auto-correct.
|
||||||
# Configuration parameters: IgnoredMethods.
|
# Configuration parameters: IgnoredMethods.
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
require 'English'
|
||||||
require 'delegate'
|
require 'delegate'
|
||||||
require 'singleton'
|
require 'singleton'
|
||||||
require 'tempfile'
|
require 'tempfile'
|
||||||
|
|
|
@ -401,7 +401,7 @@ module Zip
|
||||||
::File.popen(*args, &aProc)
|
::File.popen(*args, &aProc)
|
||||||
end
|
end
|
||||||
|
|
||||||
def foreach(fileName, aSep = $/, &aProc)
|
def foreach(fileName, aSep = $INPUT_RECORD_SEPARATOR, &aProc)
|
||||||
self.open(fileName) { |is| is.each_line(aSep, &aProc) }
|
self.open(fileName) { |is| is.each_line(aSep, &aProc) }
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -49,13 +49,13 @@ module Zip
|
||||||
buf
|
buf
|
||||||
end
|
end
|
||||||
|
|
||||||
def readlines(a_sep_string = $/)
|
def readlines(a_sep_string = $INPUT_RECORD_SEPARATOR)
|
||||||
ret_val = []
|
ret_val = []
|
||||||
each_line(a_sep_string) { |line| ret_val << line }
|
each_line(a_sep_string) { |line| ret_val << line }
|
||||||
ret_val
|
ret_val
|
||||||
end
|
end
|
||||||
|
|
||||||
def gets(a_sep_string = $/, number_of_bytes = nil)
|
def gets(a_sep_string = $INPUT_RECORD_SEPARATOR, number_of_bytes = nil)
|
||||||
@lineno = @lineno.next
|
@lineno = @lineno.next
|
||||||
|
|
||||||
if number_of_bytes.respond_to?(:to_int)
|
if number_of_bytes.respond_to?(:to_int)
|
||||||
|
@ -63,7 +63,7 @@ module Zip
|
||||||
a_sep_string = a_sep_string.to_str if a_sep_string
|
a_sep_string = a_sep_string.to_str if a_sep_string
|
||||||
elsif a_sep_string.respond_to?(:to_int)
|
elsif a_sep_string.respond_to?(:to_int)
|
||||||
number_of_bytes = a_sep_string.to_int
|
number_of_bytes = a_sep_string.to_int
|
||||||
a_sep_string = $/
|
a_sep_string = $INPUT_RECORD_SEPARATOR
|
||||||
else
|
else
|
||||||
number_of_bytes = nil
|
number_of_bytes = nil
|
||||||
a_sep_string = a_sep_string.to_str if a_sep_string
|
a_sep_string = a_sep_string.to_str if a_sep_string
|
||||||
|
@ -71,7 +71,7 @@ module Zip
|
||||||
|
|
||||||
return read(number_of_bytes) if a_sep_string.nil?
|
return read(number_of_bytes) if a_sep_string.nil?
|
||||||
|
|
||||||
a_sep_string = "#{$/}#{$/}" if a_sep_string.empty?
|
a_sep_string = "#{$INPUT_RECORD_SEPARATOR}#{$INPUT_RECORD_SEPARATOR}" if a_sep_string.empty?
|
||||||
|
|
||||||
buffer_index = 0
|
buffer_index = 0
|
||||||
over_limit = (number_of_bytes && @output_buffer.bytesize >= number_of_bytes)
|
over_limit = (number_of_bytes && @output_buffer.bytesize >= number_of_bytes)
|
||||||
|
@ -97,14 +97,14 @@ module Zip
|
||||||
ret_val
|
ret_val
|
||||||
end
|
end
|
||||||
|
|
||||||
def readline(a_sep_string = $/)
|
def readline(a_sep_string = $INPUT_RECORD_SEPARATOR)
|
||||||
ret_val = gets(a_sep_string)
|
ret_val = gets(a_sep_string)
|
||||||
raise EOFError unless ret_val
|
raise EOFError unless ret_val
|
||||||
|
|
||||||
ret_val
|
ret_val
|
||||||
end
|
end
|
||||||
|
|
||||||
def each_line(a_sep_string = $/)
|
def each_line(a_sep_string = $INPUT_RECORD_SEPARATOR)
|
||||||
loop { yield readline(a_sep_string) }
|
loop { yield readline(a_sep_string) }
|
||||||
rescue EOFError
|
rescue EOFError
|
||||||
# We just need to catch this; we don't need to handle it.
|
# We just need to catch this; we don't need to handle it.
|
||||||
|
|
|
@ -11,7 +11,7 @@ module Zip
|
||||||
end
|
end
|
||||||
|
|
||||||
def print(*params)
|
def print(*params)
|
||||||
self << params.join($,) << $\.to_s
|
self << params.join($OUTPUT_FIELD_SEPARATOR) << $OUTPUT_RECORD_SEPARATOR.to_s
|
||||||
end
|
end
|
||||||
|
|
||||||
def printf(a_format_string, *params)
|
def printf(a_format_string, *params)
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
#!/usr/bin/env ruby
|
#!/usr/bin/env ruby
|
||||||
|
|
||||||
$: << '../lib'
|
$LOAD_PATH << '../lib'
|
||||||
system('zip example.zip example.rb gtk_ruby_zip.rb')
|
system('zip example.zip example.rb gtk_ruby_zip.rb')
|
||||||
|
|
||||||
require 'zip'
|
require 'zip'
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
#!/usr/bin/env ruby
|
#!/usr/bin/env ruby
|
||||||
|
|
||||||
$: << '../lib'
|
$LOAD_PATH << '../lib'
|
||||||
|
|
||||||
require 'zip/filesystem'
|
require 'zip/filesystem'
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
#!/usr/bin/env ruby
|
#!/usr/bin/env ruby
|
||||||
|
|
||||||
$: << '../lib'
|
$LOAD_PATH << '../lib'
|
||||||
|
|
||||||
$VERBOSE = true
|
$VERBOSE = true
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
$VERBOSE = true
|
$VERBOSE = true
|
||||||
|
|
||||||
$: << '../lib'
|
$LOAD_PATH << '../lib'
|
||||||
|
|
||||||
require 'Qt'
|
require 'Qt'
|
||||||
system('rbuic -o zipdialogui.rb zipdialogui.ui')
|
system('rbuic -o zipdialogui.rb zipdialogui.ui')
|
||||||
|
@ -80,7 +80,7 @@ class ZipDialog < ZipDialogUI
|
||||||
end
|
end
|
||||||
|
|
||||||
unless ARGV[0]
|
unless ARGV[0]
|
||||||
puts "usage: #{$0} zipname"
|
puts "usage: #{$PROGRAM_NAME} zipname"
|
||||||
exit
|
exit
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
#!/usr/bin/env ruby
|
#!/usr/bin/env ruby
|
||||||
|
|
||||||
$: << '../lib'
|
$LOAD_PATH << '../lib'
|
||||||
|
|
||||||
require 'zip'
|
require 'zip'
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
$VERBOSE = true
|
$VERBOSE = true
|
||||||
|
|
||||||
$: << '../lib'
|
$LOAD_PATH << '../lib'
|
||||||
|
|
||||||
require 'zip'
|
require 'zip'
|
||||||
require 'find'
|
require 'find'
|
||||||
|
@ -32,7 +32,7 @@ module Zip
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if $0 == __FILE__
|
if $PROGRAM_NAME == __FILE__
|
||||||
module ZipFindConsoleRunner
|
module ZipFindConsoleRunner
|
||||||
PATH_ARG_INDEX = 0
|
PATH_ARG_INDEX = 0
|
||||||
FILENAME_PATTERN_ARG_INDEX = 1
|
FILENAME_PATTERN_ARG_INDEX = 1
|
||||||
|
@ -55,7 +55,7 @@ if $0 == __FILE__
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.usage
|
def self.usage
|
||||||
puts "Usage: #{$0} PATH ZIPFILENAME_PATTERN FILNAME_PATTERN"
|
puts "Usage: #{$PROGRAM_NAME} PATH ZIPFILENAME_PATTERN FILNAME_PATTERN"
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.report_entry_found(fileName)
|
def self.report_entry_found(fileName)
|
||||||
|
|
|
@ -112,7 +112,7 @@ class TestZipFile
|
||||||
# to help create the following files, there's a free one available from
|
# to help create the following files, there's a free one available from
|
||||||
# http://stahlworks.com/dev/index.php?tool=zipunzip
|
# http://stahlworks.com/dev/index.php?tool=zipunzip
|
||||||
# that works with the above code
|
# that works with the above code
|
||||||
raise $!.to_s +
|
raise $ERROR_INFO.to_s +
|
||||||
"\n\nziptest.rb requires the Info-ZIP program 'zip' in the path\n" \
|
"\n\nziptest.rb requires the Info-ZIP program 'zip' in the path\n" \
|
||||||
"to create test data. If you don't have it you can download\n" \
|
"to create test data. If you don't have it you can download\n" \
|
||||||
'the necessary test files at http://sf.net/projects/rubyzip.'
|
'the necessary test files at http://sf.net/projects/rubyzip.'
|
||||||
|
|
|
@ -4,8 +4,8 @@ require 'zip/ioextras'
|
||||||
class AbstractInputStreamTest < MiniTest::Test
|
class AbstractInputStreamTest < MiniTest::Test
|
||||||
# AbstractInputStream subclass that provides a read method
|
# AbstractInputStream subclass that provides a read method
|
||||||
|
|
||||||
TEST_LINES = ["Hello world#{$/}",
|
TEST_LINES = ["Hello world#{$INPUT_RECORD_SEPARATOR}",
|
||||||
"this is the second line#{$/}",
|
"this is the second line#{$INPUT_RECORD_SEPARATOR}",
|
||||||
'this is the last line']
|
'this is the last line']
|
||||||
TEST_STRING = TEST_LINES.join
|
TEST_STRING = TEST_LINES.join
|
||||||
class TestAbstractInputStream
|
class TestAbstractInputStream
|
||||||
|
@ -50,7 +50,7 @@ class AbstractInputStreamTest < MiniTest::Test
|
||||||
|
|
||||||
def test_gets_multi_char_seperator
|
def test_gets_multi_char_seperator
|
||||||
assert_equal('Hell', @io.gets('ll'))
|
assert_equal('Hell', @io.gets('ll'))
|
||||||
assert_equal("o world#{$/}this is the second l", @io.gets('d l'))
|
assert_equal("o world#{$INPUT_RECORD_SEPARATOR}this is the second l", @io.gets('d l'))
|
||||||
end
|
end
|
||||||
|
|
||||||
LONG_LINES = [
|
LONG_LINES = [
|
||||||
|
|
|
@ -20,8 +20,8 @@ class AbstractOutputStreamTest < MiniTest::Test
|
||||||
def setup
|
def setup
|
||||||
@output_stream = TestOutputStream.new
|
@output_stream = TestOutputStream.new
|
||||||
|
|
||||||
@origCommaSep = $,
|
@origCommaSep = $OUTPUT_FIELD_SEPARATOR
|
||||||
@origOutputSep = $\
|
@origOutputSep = $OUTPUT_RECORD_SEPARATOR
|
||||||
end
|
end
|
||||||
|
|
||||||
def teardown
|
def teardown
|
||||||
|
|
|
@ -58,10 +58,10 @@ class ZipOutputStreamTest < MiniTest::Test
|
||||||
begin
|
begin
|
||||||
::Zip::OutputStream.open(name)
|
::Zip::OutputStream.open(name)
|
||||||
rescue SystemCallError
|
rescue SystemCallError
|
||||||
assert($!.kind_of?(Errno::EISDIR) || # Linux
|
assert($ERROR_INFO.kind_of?(Errno::EISDIR) || # Linux
|
||||||
$!.kind_of?(Errno::EEXIST) || # Windows/cygwin
|
$ERROR_INFO.kind_of?(Errno::EEXIST) || # Windows/cygwin
|
||||||
$!.kind_of?(Errno::EACCES), # Windows
|
$ERROR_INFO.kind_of?(Errno::EACCES), # Windows
|
||||||
"Expected Errno::EISDIR (or on win/cygwin: Errno::EEXIST), but was: #{$!.class}")
|
"Expected Errno::EISDIR (or on win/cygwin: Errno::EEXIST), but was: #{$ERROR_INFO.class}")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -61,7 +61,7 @@ module DecompressorTests
|
||||||
def setup
|
def setup
|
||||||
@refText = ''
|
@refText = ''
|
||||||
File.open(TEST_FILE) { |f| @refText = f.read }
|
File.open(TEST_FILE) { |f| @refText = f.read }
|
||||||
@refLines = @refText.split($/)
|
@refLines = @refText.split($INPUT_RECORD_SEPARATOR)
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_read_everything
|
def test_read_everything
|
||||||
|
|
Loading…
Reference in New Issue