Skip to content

Commit

Permalink
Add Layout/IndentationConsistency to Rubocop config
Browse files Browse the repository at this point in the history
  • Loading branch information
herwinw committed Oct 12, 2024
1 parent 8aae62f commit fabdaac
Show file tree
Hide file tree
Showing 17 changed files with 128 additions and 125 deletions.
3 changes: 3 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ AllCops:
DisabledByDefault: true
NewCops: disable

Layout/IndentationConsistency:
Enabled: true

Layout/TrailingWhitespace:
Enabled: true

Expand Down
20 changes: 10 additions & 10 deletions core/basicobject/instance_exec_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -84,17 +84,17 @@ def foo
end.should raise_error(TypeError)
end

quarantine! do # Not clean, leaves cvars lying around to break other specs
it "scopes class var accesses in the caller when called on an Integer" do
# Integer can take instance vars
Integer.class_eval "@@__tmp_instance_exec_spec = 1"
(defined? @@__tmp_instance_exec_spec).should == nil

@@__tmp_instance_exec_spec = 2
1.instance_exec { @@__tmp_instance_exec_spec }.should == 2
Integer.__send__(:remove_class_variable, :@@__tmp_instance_exec_spec)
quarantine! do # Not clean, leaves cvars lying around to break other specs
it "scopes class var accesses in the caller when called on an Integer" do
# Integer can take instance vars
Integer.class_eval "@@__tmp_instance_exec_spec = 1"
(defined? @@__tmp_instance_exec_spec).should == nil

@@__tmp_instance_exec_spec = 2
1.instance_exec { @@__tmp_instance_exec_spec }.should == 2
Integer.__send__(:remove_class_variable, :@@__tmp_instance_exec_spec)
end
end
end

it "raises a TypeError when defining methods on numerics" do
-> do
Expand Down
16 changes: 8 additions & 8 deletions core/file/chown_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -78,15 +78,15 @@
end

describe "File#chown" do
before :each do
@fname = tmp('file_chown_test')
@file = File.open(@fname, 'w')
end
before :each do
@fname = tmp('file_chown_test')
@file = File.open(@fname, 'w')
end

after :each do
@file.close unless @file.closed?
rm_r @fname
end
after :each do
@file.close unless @file.closed?
rm_r @fname
end

as_superuser do
platform_is :windows do
Expand Down
2 changes: 1 addition & 1 deletion core/hash/hash_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
a = 1
b = 2

eval('{a:, b:}.should == { a: 1, b: 2 }')
eval('{a:, b:}.should == { a: 1, b: 2 }')
end
end
end
8 changes: 4 additions & 4 deletions core/integer/pow_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@
2.pow(61, 5843009213693951).should eql 3697379018277258
2.pow(62, 5843009213693952).should eql 1551748822859776
2.pow(63, 5843009213693953).should eql 3103497645717974
2.pow(64, 5843009213693954).should eql 363986077738838
2.pow(64, 5843009213693954).should eql 363986077738838
end

it "handles sign like #divmod does" do
2.pow(5, 12).should == 8
2.pow(5, -12).should == -4
-2.pow(5, 12).should == 4
2.pow(5, 12).should == 8
2.pow(5, -12).should == -4
-2.pow(5, 12).should == 4
-2.pow(5, -12).should == -8
end

Expand Down
4 changes: 2 additions & 2 deletions core/integer/remainder_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
end

it "keeps sign of self" do
5.remainder( 3).should == 2
5.remainder(-3).should == 2
5.remainder( 3).should == 2
5.remainder(-3).should == 2
-5.remainder( 3).should == -2
-5.remainder(-3).should == -2
end
Expand Down
30 changes: 15 additions & 15 deletions core/io/dup_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,27 +25,27 @@
@i.fileno.should_not == @f.fileno
end

quarantine! do # This does not appear to be consistent across platforms
it "shares the original stream between the two IOs" do
start = @f.pos
@i.pos.should == start
quarantine! do # This does not appear to be consistent across platforms
it "shares the original stream between the two IOs" do
start = @f.pos
@i.pos.should == start

s = "Hello, wo.. wait, where am I?\n"
s2 = "<evil voice> Muhahahaa!"
s = "Hello, wo.. wait, where am I?\n"
s2 = "<evil voice> Muhahahaa!"

@f.write s
@i.pos.should == @f.pos
@f.write s
@i.pos.should == @f.pos

@i.rewind
@i.gets.should == s
@i.rewind
@i.gets.should == s

@i.rewind
@i.write s2
@i.rewind
@i.write s2

@f.rewind
@f.gets.should == "#{s2}\n"
@f.rewind
@f.gets.should == "#{s2}\n"
end
end
end

it "allows closing the new IO without affecting the original" do
@i.close
Expand Down
22 changes: 11 additions & 11 deletions core/io/read_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -217,19 +217,19 @@
end
end

quarantine! do # The process tried to write to a nonexistent pipe.
platform_is :windows do
# TODO: It should raise Errno::ESPIPE on Windows as well
# once https://bugs.ruby-lang.org/issues/12230 is fixed.
it "raises Errno::EINVAL if passed an offset" do
-> {
suppress_warning do # https://bugs.ruby-lang.org/issues/19630
IO.read("|cmd.exe /C echo hello", 1, 1)
end
}.should raise_error(Errno::EINVAL)
quarantine! do # The process tried to write to a nonexistent pipe.
platform_is :windows do
# TODO: It should raise Errno::ESPIPE on Windows as well
# once https://bugs.ruby-lang.org/issues/12230 is fixed.
it "raises Errno::EINVAL if passed an offset" do
-> {
suppress_warning do # https://bugs.ruby-lang.org/issues/19630
IO.read("|cmd.exe /C echo hello", 1, 1)
end
}.should raise_error(Errno::EINVAL)
end
end
end
end

ruby_version_is "3.3" do
# https://bugs.ruby-lang.org/issues/19630
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 @@ -245,7 +245,7 @@ def foo; "foo from singleton class"; end

ruby_version_is ""..."3.2" do
it "looks in the included modules for builtin methods" do
result = ruby_exe(<<-RUBY)
result = ruby_exe(<<-RUBY)
a = Module.new do
def /(other) quo(other) end
end
Expand Down
26 changes: 13 additions & 13 deletions language/fixtures/private.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,17 +43,17 @@ def foo
end
end

class E
include D
end

class G
def foo
"foo"
end
end

class H < A
private :foo
end
class E
include D
end

class G
def foo
"foo"
end
end

class H < A
private :foo
end
end
6 changes: 3 additions & 3 deletions language/fixtures/send.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@ class PrivateSetter
attr_writer :foo
private :foo=

def call_self_foo_equals(value)
self.foo = value
end
def call_self_foo_equals(value)
self.foo = value
end

def call_self_foo_equals_masgn(value)
a, self.foo = 1, value
Expand Down
16 changes: 8 additions & 8 deletions language/precedence_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -294,14 +294,14 @@ class FalseClass; undef_method :=~; end
-> { eval("1...2...3") }.should raise_error(SyntaxError)
end

it ".. ... have higher precedence than ? :" do
# Use variables to avoid warnings
from = 1
to = 2
# These are flip-flop, not Range instances
(from..to ? 3 : 4).should == 3
(from...to ? 3 : 4).should == 3
end
it ".. ... have higher precedence than ? :" do
# Use variables to avoid warnings
from = 1
to = 2
# These are flip-flop, not Range instances
(from..to ? 3 : 4).should == 3
(from...to ? 3 : 4).should == 3
end

it "? : is right-associative" do
(true ? 2 : 3 ? 4 : 5).should == 2
Expand Down
28 changes: 14 additions & 14 deletions library/bigdecimal/fix_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,20 @@
require 'bigdecimal'

describe "BigDecimal#fix" do
before :each do
@zero = BigDecimal("0")
@mixed = BigDecimal("1.23456789")
@pos_int = BigDecimal("2E5555")
@neg_int = BigDecimal("-2E5555")
@pos_frac = BigDecimal("2E-9999")
@neg_frac = BigDecimal("-2E-9999")

@infinity = BigDecimal("Infinity")
@infinity_neg = BigDecimal("-Infinity")
@nan = BigDecimal("NaN")
@zero_pos = BigDecimal("+0")
@zero_neg = BigDecimal("-0")
end
before :each do
@zero = BigDecimal("0")
@mixed = BigDecimal("1.23456789")
@pos_int = BigDecimal("2E5555")
@neg_int = BigDecimal("-2E5555")
@pos_frac = BigDecimal("2E-9999")
@neg_frac = BigDecimal("-2E-9999")

@infinity = BigDecimal("Infinity")
@infinity_neg = BigDecimal("-Infinity")
@nan = BigDecimal("NaN")
@zero_pos = BigDecimal("+0")
@zero_neg = BigDecimal("-0")
end

it "returns a BigDecimal" do
BigDecimal("2E100000000").fix.kind_of?(BigDecimal).should == true
Expand Down
2 changes: 1 addition & 1 deletion library/erb/new_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@
<b><%#= item %></b>
<%# end %>
END
ERBSpecs.new_erb(input).result.should == "\n<b></b>\n\n"
ERBSpecs.new_erb(input).result.should == "\n<b></b>\n\n"
ERBSpecs.new_erb(input, trim_mode: '<>').result.should == "<b></b>\n"
end

Expand Down
26 changes: 13 additions & 13 deletions library/logger/logger/new_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,19 @@
rm_r @file_path
end

it "creates a new logger object" do
l = Logger.new(STDERR)
-> { l.add(Logger::WARN, "Foo") }.should output_to_fd(/Foo/, STDERR)
end

it "receives a logging device as first argument" do
l = Logger.new(@log_file)
l.add(Logger::WARN, "Test message")

@log_file.rewind
LoggerSpecs.strip_date(@log_file.readline).should == "WARN -- : Test message\n"
l.close
end
it "creates a new logger object" do
l = Logger.new(STDERR)
-> { l.add(Logger::WARN, "Foo") }.should output_to_fd(/Foo/, STDERR)
end

it "receives a logging device as first argument" do
l = Logger.new(@log_file)
l.add(Logger::WARN, "Test message")

@log_file.rewind
LoggerSpecs.strip_date(@log_file.readline).should == "WARN -- : Test message\n"
l.close
end

it "receives a frequency rotation as second argument" do
-> { Logger.new(@log_file, "daily") }.should_not raise_error
Expand Down
38 changes: 19 additions & 19 deletions library/socket/basicsocket/send_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,27 +16,27 @@
@socket.close
end

it "sends a message to another socket and returns the number of bytes sent" do
data = +""
t = Thread.new do
client = @server.accept
loop do
got = client.recv(5)
break if got.nil? || got.empty?
data << got
end
client.close
end
Thread.pass while t.status and t.status != "sleep"
t.status.should_not be_nil
it "sends a message to another socket and returns the number of bytes sent" do
data = +""
t = Thread.new do
client = @server.accept
loop do
got = client.recv(5)
break if got.nil? || got.empty?
data << got
end
client.close
end
Thread.pass while t.status and t.status != "sleep"
t.status.should_not be_nil

@socket.send('hello', 0).should == 5
@socket.shutdown(1) # indicate, that we are done sending
@socket.recv(10)
@socket.send('hello', 0).should == 5
@socket.shutdown(1) # indicate, that we are done sending
@socket.recv(10)

t.join
data.should == 'hello'
end
t.join
data.should == 'hello'
end

platform_is_not :solaris, :windows do
it "accepts flags to specify unusual sending behaviour" do
Expand Down
4 changes: 2 additions & 2 deletions library/stringio/fixtures/classes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ class StringSubclass < String; end

module StringIOSpecs
def self.build
str = <<-EOS
str = <<-EOS
each
peach
pear
plum
EOS
EOS
StringIO.new(str)
end
end

0 comments on commit fabdaac

Please sign in to comment.