Skip to content
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

Indentation fixup #1209

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
3 changes: 3 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ AllCops:
Layout/IndentationConsistency:
Enabled: true

Layout/IndentationWidth:
Enabled: true

Layout/TrailingWhitespace:
Enabled: true

Expand Down
9 changes: 9 additions & 0 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,15 @@
# Note that changes in the inspected code, or installation of new
# versions of RuboCop, may require this file to be generated again.

# Offense count: 4
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: Width, AllowedPatterns.
Layout/IndentationWidth:
Exclude:
- 'core/method/to_proc_spec.rb'
- 'library/socket/socket/bind_spec.rb'
- 'optional/capi/string_spec.rb'

# Offense count: 2
Lint/DuplicateCaseCondition:
Exclude:
Expand Down
24 changes: 12 additions & 12 deletions command_line/dash_upper_u_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

describe "ruby -U" do
it "sets Encoding.default_internal to UTF-8" do
ruby_exe('print Encoding.default_internal.name',
options: '-U').should == 'UTF-8'
ruby_exe('print Encoding.default_internal.name',
options: '-U').should == 'UTF-8'
end

it "sets Encoding.default_internal to UTF-8 when RUBYOPT is empty or only spaces" do
Expand All @@ -14,25 +14,25 @@
end

it "does nothing different if specified multiple times" do
ruby_exe('print Encoding.default_internal.name',
options: '-U -U').should == 'UTF-8'
ruby_exe('print Encoding.default_internal.name',
options: '-U -U').should == 'UTF-8'
end

it "is overruled by Encoding.default_internal=" do
ruby_exe('Encoding.default_internal="ascii"; print Encoding.default_internal.name',
options: '-U').should == 'US-ASCII'
ruby_exe('Encoding.default_internal="ascii"; print Encoding.default_internal.name',
options: '-U').should == 'US-ASCII'
end

it "does not affect the default external encoding" do
ruby_exe('Encoding.default_external="ascii"; print Encoding.default_external.name',
options: '-U').should == 'US-ASCII'
ruby_exe('Encoding.default_external="ascii"; print Encoding.default_external.name',
options: '-U').should == 'US-ASCII'
end

it "does not affect the source encoding" do
ruby_exe("print __ENCODING__.name",
options: '-U -KE').should == 'EUC-JP'
ruby_exe("print __ENCODING__.name",
options: '-KE -U').should == 'EUC-JP'
ruby_exe("print __ENCODING__.name",
options: '-U -KE').should == 'EUC-JP'
ruby_exe("print __ENCODING__.name",
options: '-KE -U').should == 'EUC-JP'
end

# I assume IO redirection will break on Windows...
Expand Down
2 changes: 1 addition & 1 deletion core/array/drop_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
end

it "raises an ArgumentError if the number of elements specified is negative" do
-> { [1, 2].drop(-3) }.should raise_error(ArgumentError)
-> { [1, 2].drop(-3) }.should raise_error(ArgumentError)
end

it "returns an empty Array if all elements are dropped" do
Expand Down
12 changes: 6 additions & 6 deletions core/complex/shared/rect.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,15 @@
end

it "returns the real part of self as the first element" do
@numbers.each do |number|
number.send(@method).first.should == number.real
end
@numbers.each do |number|
number.send(@method).first.should == number.real
end
end

it "returns the imaginary part of self as the last element" do
@numbers.each do |number|
number.send(@method).last.should == number.imaginary
end
@numbers.each do |number|
number.send(@method).last.should == number.imaginary
end
end

it "raises an ArgumentError if given any arguments" do
Expand Down
4 changes: 2 additions & 2 deletions core/encoding/converter/finish_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
end

it "returns the last part of the converted String if it hasn't already" do
@ec.convert("\u{9999}").should == "\e$B9a".dup.force_encoding('iso-2022-jp')
@ec.finish.should == "\e(B".dup.force_encoding('iso-2022-jp')
@ec.convert("\u{9999}").should == "\e$B9a".dup.force_encoding('iso-2022-jp')
@ec.finish.should == "\e(B".dup.force_encoding('iso-2022-jp')
end

it "returns a String in the destination encoding" do
Expand Down
6 changes: 3 additions & 3 deletions core/encoding/converter/search_convpath_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
end

it "raises an Encoding::ConverterNotFoundError if no conversion path exists" do
-> do
Encoding::Converter.search_convpath(Encoding::BINARY, Encoding::Emacs_Mule)
end.should raise_error(Encoding::ConverterNotFoundError)
-> do
Encoding::Converter.search_convpath(Encoding::BINARY, Encoding::Emacs_Mule)
end.should raise_error(Encoding::ConverterNotFoundError)
end
end
2 changes: 1 addition & 1 deletion core/env/fetch_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@

it "warns on block and default parameter given" do
-> do
ENV.fetch("foo", "default") { "bar" }.should == "bar"
ENV.fetch("foo", "default") { "bar" }.should == "bar"
end.should complain(/block supersedes default value argument/)
end

Expand Down
2 changes: 1 addition & 1 deletion core/env/length_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
require_relative 'shared/length'

describe "ENV.length" do
it_behaves_like :env_length, :length
it_behaves_like :env_length, :length
end
2 changes: 1 addition & 1 deletion core/env/size_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
require_relative 'shared/length'

describe "ENV.size" do
it_behaves_like :env_length, :size
it_behaves_like :env_length, :size
end
26 changes: 13 additions & 13 deletions core/file/dirname_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -65,19 +65,19 @@ def object.to_int; 2; end
end

it "returns all the components of filename except the last one (edge cases on all platforms)" do
File.dirname("").should == "."
File.dirname(".").should == "."
File.dirname("./").should == "."
File.dirname("./b/./").should == "./b"
File.dirname("..").should == "."
File.dirname("../").should == "."
File.dirname("/").should == "/"
File.dirname("/.").should == "/"
File.dirname("/foo/").should == "/"
File.dirname("/foo/.").should == "/foo"
File.dirname("/foo/./").should == "/foo"
File.dirname("/foo/../.").should == "/foo/.."
File.dirname("foo/../").should == "foo"
File.dirname("").should == "."
File.dirname(".").should == "."
File.dirname("./").should == "."
File.dirname("./b/./").should == "./b"
File.dirname("..").should == "."
File.dirname("../").should == "."
File.dirname("/").should == "/"
File.dirname("/.").should == "/"
File.dirname("/foo/").should == "/"
File.dirname("/foo/.").should == "/foo"
File.dirname("/foo/./").should == "/foo"
File.dirname("/foo/../.").should == "/foo/.."
File.dirname("foo/../").should == "foo"
end

platform_is_not :windows do
Expand Down
2 changes: 1 addition & 1 deletion core/float/comparison_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ def obj.infinite?
it "returns 1 when self is Infinity and other is infinite?=nil (which means finite)" do
obj = Object.new
def obj.infinite?
nil
nil
end
(infinity_value <=> obj).should == 1
end
Expand Down
6 changes: 3 additions & 3 deletions core/hash/shared/store.rb
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,9 @@ def key.reverse() "bar" end
end

it "does not raise an exception if changing the value of an existing key during iteration" do
hash = {1 => 2, 3 => 4, 5 => 6}
hash.each { hash.send(@method, 1, :foo) }
hash.should == {1 => :foo, 3 => 4, 5 => 6}
hash = {1 => 2, 3 => 4, 5 => 6}
hash.each { hash.send(@method, 1, :foo) }
hash.should == {1 => :foo, 3 => 4, 5 => 6}
end

it "does not dispatch to hash for Boolean, Integer, Float, String, or Symbol" do
Expand Down
2 changes: 1 addition & 1 deletion core/hash/transform_keys_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@
end

it "raises a FrozenError on hash argument" do
->{ @hash.transform_keys!({ a: :A, b: :B, c: :C }) }.should raise_error(FrozenError)
->{ @hash.transform_keys!({ a: :A, b: :B, c: :C }) }.should raise_error(FrozenError)
end

context "when no block is given" do
Expand Down
2 changes: 1 addition & 1 deletion core/io/write_nonblock_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@

it "checks if the file is writable if writing zero bytes" do
-> {
@readonly_file.write_nonblock("")
@readonly_file.write_nonblock("")
}.should raise_error(IOError)
end
end
Expand Down
2 changes: 1 addition & 1 deletion core/module/const_get_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@
end

it "does read private constants" do
ConstantSpecs.const_get(:CS_PRIVATE).should == :cs_private
ConstantSpecs.const_get(:CS_PRIVATE).should == :cs_private
end

it 'does autoload a constant' do
Expand Down
2 changes: 1 addition & 1 deletion core/module/const_source_location_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@
end

it "does search private constants path" do
ConstantSpecs.const_source_location(:CS_PRIVATE).should == [@constants_fixture_path, ConstantSpecs::CS_PRIVATE_LINE]
ConstantSpecs.const_source_location(:CS_PRIVATE).should == [@constants_fixture_path, ConstantSpecs::CS_PRIVATE_LINE]
end

it "works for eval with a given line" do
Expand Down
2 changes: 1 addition & 1 deletion core/module/refine_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ def /(other) quo(other) end
it "looks in later included modules of the refined module first" do
a = Module.new do
def foo
"foo from A"
"foo from A"
end
end

Expand Down
6 changes: 3 additions & 3 deletions core/numeric/shared/imag.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
end

it "raises an ArgumentError if given any arguments" do
@numbers.each do |number|
-> { number.send(@method, number) }.should raise_error(ArgumentError)
end
@numbers.each do |number|
-> { number.send(@method, number) }.should raise_error(ArgumentError)
end
end
end
26 changes: 13 additions & 13 deletions core/numeric/shared/rect.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,24 +25,24 @@
end

it "returns self as the first element" do
@numbers.each do |number|
if Float === number and number.nan?
number.send(@method).first.nan?.should be_true
else
number.send(@method).first.should == number
end
end
@numbers.each do |number|
if Float === number and number.nan?
number.send(@method).first.nan?.should be_true
else
number.send(@method).first.should == number
end
end
end

it "returns 0 as the last element" do
@numbers.each do |number|
number.send(@method).last.should == 0
end
@numbers.each do |number|
number.send(@method).last.should == 0
end
end

it "raises an ArgumentError if given any arguments" do
@numbers.each do |number|
-> { number.send(@method, number) }.should raise_error(ArgumentError)
end
@numbers.each do |number|
-> { number.send(@method, number) }.should raise_error(ArgumentError)
end
end
end
4 changes: 2 additions & 2 deletions core/process/gid_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
describe "Process.gid" do
platform_is_not :windows do
it "returns the correct gid for the user executing this process" do
current_gid_according_to_unix = `id -gr`.to_i
Process.gid.should == current_gid_according_to_unix
current_gid_according_to_unix = `id -gr`.to_i
Process.gid.should == current_gid_according_to_unix
end
end

Expand Down
4 changes: 2 additions & 2 deletions core/string/byterindex_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -352,8 +352,8 @@ def obj.method_missing(*args); 5; end
end

it "returns the character index before the finish" do
"ありがりがとう".byterindex("が", 9).should == 6
"ありがりがとう".byterindex(/が/, 9).should == 6
"ありがりがとう".byterindex("が", 9).should == 6
"ありがりがとう".byterindex(/が/, 9).should == 6
end
end
end
2 changes: 1 addition & 1 deletion core/string/chilled_string_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
input.freeze
-> {
-> {
input << "mutated"
input << "mutated"
}.should raise_error(FrozenError)
}.should_not complain(/literal string will be frozen in the future/)
end
Expand Down
14 changes: 7 additions & 7 deletions core/string/lstrip_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@
it_behaves_like :string_strip, :lstrip

it "returns a copy of self with leading whitespace removed" do
" hello ".lstrip.should == "hello "
" hello world ".lstrip.should == "hello world "
"\n\r\t\n\v\r hello world ".lstrip.should == "hello world "
"hello".lstrip.should == "hello"
" こにちわ".lstrip.should == "こにちわ"
" hello ".lstrip.should == "hello "
" hello world ".lstrip.should == "hello world "
"\n\r\t\n\v\r hello world ".lstrip.should == "hello world "
"hello".lstrip.should == "hello"
" こにちわ".lstrip.should == "こにちわ"
end

it "works with lazy substrings" do
Expand All @@ -22,8 +22,8 @@
end

it "strips leading \\0" do
"\x00hello".lstrip.should == "hello"
"\000 \000hello\000 \000".lstrip.should == "hello\000 \000"
"\x00hello".lstrip.should == "hello"
"\000 \000hello\000 \000".lstrip.should == "hello\000 \000"
end
end

Expand Down
4 changes: 2 additions & 2 deletions core/string/rindex_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -371,8 +371,8 @@ def obj.method_missing(*args); 5; end
end

it "returns the character index before the finish" do
"ありがりがとう".rindex("が", 3).should == 2
"ありがりがとう".rindex(/が/, 3).should == 2
"ありがりがとう".rindex("が", 3).should == 2
"ありがりがとう".rindex(/が/, 3).should == 2
end

it "raises an Encoding::CompatibilityError if the encodings are incompatible" do
Expand Down
Loading