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/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
|
||||
# Cop supports --auto-correct.
|
||||
# Configuration parameters: IgnoredMethods.
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
require 'English'
|
||||
require 'delegate'
|
||||
require 'singleton'
|
||||
require 'tempfile'
|
||||
|
|
|
@ -401,7 +401,7 @@ module Zip
|
|||
::File.popen(*args, &aProc)
|
||||
end
|
||||
|
||||
def foreach(fileName, aSep = $/, &aProc)
|
||||
def foreach(fileName, aSep = $INPUT_RECORD_SEPARATOR, &aProc)
|
||||
self.open(fileName) { |is| is.each_line(aSep, &aProc) }
|
||||
end
|
||||
|
||||
|
|
|
@ -49,13 +49,13 @@ module Zip
|
|||
buf
|
||||
end
|
||||
|
||||
def readlines(a_sep_string = $/)
|
||||
def readlines(a_sep_string = $INPUT_RECORD_SEPARATOR)
|
||||
ret_val = []
|
||||
each_line(a_sep_string) { |line| ret_val << line }
|
||||
ret_val
|
||||
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
|
||||
|
||||
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
|
||||
elsif a_sep_string.respond_to?(:to_int)
|
||||
number_of_bytes = a_sep_string.to_int
|
||||
a_sep_string = $/
|
||||
a_sep_string = $INPUT_RECORD_SEPARATOR
|
||||
else
|
||||
number_of_bytes = nil
|
||||
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?
|
||||
|
||||
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
|
||||
over_limit = (number_of_bytes && @output_buffer.bytesize >= number_of_bytes)
|
||||
|
@ -97,14 +97,14 @@ module Zip
|
|||
ret_val
|
||||
end
|
||||
|
||||
def readline(a_sep_string = $/)
|
||||
def readline(a_sep_string = $INPUT_RECORD_SEPARATOR)
|
||||
ret_val = gets(a_sep_string)
|
||||
raise EOFError unless ret_val
|
||||
|
||||
ret_val
|
||||
end
|
||||
|
||||
def each_line(a_sep_string = $/)
|
||||
def each_line(a_sep_string = $INPUT_RECORD_SEPARATOR)
|
||||
loop { yield readline(a_sep_string) }
|
||||
rescue EOFError
|
||||
# We just need to catch this; we don't need to handle it.
|
||||
|
|
|
@ -11,7 +11,7 @@ module Zip
|
|||
end
|
||||
|
||||
def print(*params)
|
||||
self << params.join($,) << $\.to_s
|
||||
self << params.join($OUTPUT_FIELD_SEPARATOR) << $OUTPUT_RECORD_SEPARATOR.to_s
|
||||
end
|
||||
|
||||
def printf(a_format_string, *params)
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#!/usr/bin/env ruby
|
||||
|
||||
$: << '../lib'
|
||||
$LOAD_PATH << '../lib'
|
||||
system('zip example.zip example.rb gtk_ruby_zip.rb')
|
||||
|
||||
require 'zip'
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#!/usr/bin/env ruby
|
||||
|
||||
$: << '../lib'
|
||||
$LOAD_PATH << '../lib'
|
||||
|
||||
require 'zip/filesystem'
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#!/usr/bin/env ruby
|
||||
|
||||
$: << '../lib'
|
||||
$LOAD_PATH << '../lib'
|
||||
|
||||
$VERBOSE = true
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
$VERBOSE = true
|
||||
|
||||
$: << '../lib'
|
||||
$LOAD_PATH << '../lib'
|
||||
|
||||
require 'Qt'
|
||||
system('rbuic -o zipdialogui.rb zipdialogui.ui')
|
||||
|
@ -80,7 +80,7 @@ class ZipDialog < ZipDialogUI
|
|||
end
|
||||
|
||||
unless ARGV[0]
|
||||
puts "usage: #{$0} zipname"
|
||||
puts "usage: #{$PROGRAM_NAME} zipname"
|
||||
exit
|
||||
end
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#!/usr/bin/env ruby
|
||||
|
||||
$: << '../lib'
|
||||
$LOAD_PATH << '../lib'
|
||||
|
||||
require 'zip'
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
$VERBOSE = true
|
||||
|
||||
$: << '../lib'
|
||||
$LOAD_PATH << '../lib'
|
||||
|
||||
require 'zip'
|
||||
require 'find'
|
||||
|
@ -32,7 +32,7 @@ module Zip
|
|||
end
|
||||
end
|
||||
|
||||
if $0 == __FILE__
|
||||
if $PROGRAM_NAME == __FILE__
|
||||
module ZipFindConsoleRunner
|
||||
PATH_ARG_INDEX = 0
|
||||
FILENAME_PATTERN_ARG_INDEX = 1
|
||||
|
@ -55,7 +55,7 @@ if $0 == __FILE__
|
|||
end
|
||||
|
||||
def self.usage
|
||||
puts "Usage: #{$0} PATH ZIPFILENAME_PATTERN FILNAME_PATTERN"
|
||||
puts "Usage: #{$PROGRAM_NAME} PATH ZIPFILENAME_PATTERN FILNAME_PATTERN"
|
||||
end
|
||||
|
||||
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
|
||||
# http://stahlworks.com/dev/index.php?tool=zipunzip
|
||||
# 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" \
|
||||
"to create test data. If you don't have it you can download\n" \
|
||||
'the necessary test files at http://sf.net/projects/rubyzip.'
|
||||
|
|
|
@ -4,8 +4,8 @@ require 'zip/ioextras'
|
|||
class AbstractInputStreamTest < MiniTest::Test
|
||||
# AbstractInputStream subclass that provides a read method
|
||||
|
||||
TEST_LINES = ["Hello world#{$/}",
|
||||
"this is the second line#{$/}",
|
||||
TEST_LINES = ["Hello world#{$INPUT_RECORD_SEPARATOR}",
|
||||
"this is the second line#{$INPUT_RECORD_SEPARATOR}",
|
||||
'this is the last line']
|
||||
TEST_STRING = TEST_LINES.join
|
||||
class TestAbstractInputStream
|
||||
|
@ -50,7 +50,7 @@ class AbstractInputStreamTest < MiniTest::Test
|
|||
|
||||
def test_gets_multi_char_seperator
|
||||
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
|
||||
|
||||
LONG_LINES = [
|
||||
|
|
|
@ -20,8 +20,8 @@ class AbstractOutputStreamTest < MiniTest::Test
|
|||
def setup
|
||||
@output_stream = TestOutputStream.new
|
||||
|
||||
@origCommaSep = $,
|
||||
@origOutputSep = $\
|
||||
@origCommaSep = $OUTPUT_FIELD_SEPARATOR
|
||||
@origOutputSep = $OUTPUT_RECORD_SEPARATOR
|
||||
end
|
||||
|
||||
def teardown
|
||||
|
|
|
@ -58,10 +58,10 @@ class ZipOutputStreamTest < MiniTest::Test
|
|||
begin
|
||||
::Zip::OutputStream.open(name)
|
||||
rescue SystemCallError
|
||||
assert($!.kind_of?(Errno::EISDIR) || # Linux
|
||||
$!.kind_of?(Errno::EEXIST) || # Windows/cygwin
|
||||
$!.kind_of?(Errno::EACCES), # Windows
|
||||
"Expected Errno::EISDIR (or on win/cygwin: Errno::EEXIST), but was: #{$!.class}")
|
||||
assert($ERROR_INFO.kind_of?(Errno::EISDIR) || # Linux
|
||||
$ERROR_INFO.kind_of?(Errno::EEXIST) || # Windows/cygwin
|
||||
$ERROR_INFO.kind_of?(Errno::EACCES), # Windows
|
||||
"Expected Errno::EISDIR (or on win/cygwin: Errno::EEXIST), but was: #{$ERROR_INFO.class}")
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -61,7 +61,7 @@ module DecompressorTests
|
|||
def setup
|
||||
@refText = ''
|
||||
File.open(TEST_FILE) { |f| @refText = f.read }
|
||||
@refLines = @refText.split($/)
|
||||
@refLines = @refText.split($INPUT_RECORD_SEPARATOR)
|
||||
end
|
||||
|
||||
def test_read_everything
|
||||
|
|
Loading…
Reference in New Issue