diff --git a/.rubocop.yml b/.rubocop.yml index 5a902e0f01..caa166288d 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -8,6 +8,9 @@ AllCops: DisabledByDefault: true NewCops: disable +Layout/IndentationConsistency: + Enabled: true + Layout/TrailingWhitespace: Enabled: true diff --git a/core/basicobject/instance_exec_spec.rb b/core/basicobject/instance_exec_spec.rb index 289fdd889b..370f03d33c 100644 --- a/core/basicobject/instance_exec_spec.rb +++ b/core/basicobject/instance_exec_spec.rb @@ -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 diff --git a/core/file/chown_spec.rb b/core/file/chown_spec.rb index 8cc8f0d04b..4db0e3712c 100644 --- a/core/file/chown_spec.rb +++ b/core/file/chown_spec.rb @@ -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 diff --git a/core/hash/hash_spec.rb b/core/hash/hash_spec.rb index 19eb806dc4..9b47d4b2bf 100644 --- a/core/hash/hash_spec.rb +++ b/core/hash/hash_spec.rb @@ -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 diff --git a/core/integer/pow_spec.rb b/core/integer/pow_spec.rb index 4712911095..ecaca01eff 100644 --- a/core/integer/pow_spec.rb +++ b/core/integer/pow_spec.rb @@ -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 diff --git a/core/integer/remainder_spec.rb b/core/integer/remainder_spec.rb index 96268b3af5..757e42fbe8 100644 --- a/core/integer/remainder_spec.rb +++ b/core/integer/remainder_spec.rb @@ -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 diff --git a/core/io/dup_spec.rb b/core/io/dup_spec.rb index 68d538377f..564e007438 100644 --- a/core/io/dup_spec.rb +++ b/core/io/dup_spec.rb @@ -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 = " Muhahahaa!" + s = "Hello, wo.. wait, where am I?\n" + s2 = " 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 diff --git a/core/io/read_spec.rb b/core/io/read_spec.rb index 8741d9f017..567daa55df 100644 --- a/core/io/read_spec.rb +++ b/core/io/read_spec.rb @@ -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 diff --git a/core/module/refine_spec.rb b/core/module/refine_spec.rb index 11085c325b..8b9ea5eca8 100644 --- a/core/module/refine_spec.rb +++ b/core/module/refine_spec.rb @@ -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 diff --git a/language/fixtures/private.rb b/language/fixtures/private.rb index 96f73cea3f..da3e0a97f9 100644 --- a/language/fixtures/private.rb +++ b/language/fixtures/private.rb @@ -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 diff --git a/language/fixtures/send.rb b/language/fixtures/send.rb index 918241e171..5d1d9da214 100644 --- a/language/fixtures/send.rb +++ b/language/fixtures/send.rb @@ -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 diff --git a/language/precedence_spec.rb b/language/precedence_spec.rb index c5adcca2c0..5e606c16d8 100644 --- a/language/precedence_spec.rb +++ b/language/precedence_spec.rb @@ -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 diff --git a/library/bigdecimal/fix_spec.rb b/library/bigdecimal/fix_spec.rb index 231c9a587e..2c6276899e 100644 --- a/library/bigdecimal/fix_spec.rb +++ b/library/bigdecimal/fix_spec.rb @@ -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 diff --git a/library/erb/new_spec.rb b/library/erb/new_spec.rb index a5aeeaeed1..f721529ab0 100644 --- a/library/erb/new_spec.rb +++ b/library/erb/new_spec.rb @@ -130,7 +130,7 @@ <%#= item %> <%# end %> END - ERBSpecs.new_erb(input).result.should == "\n\n\n" + ERBSpecs.new_erb(input).result.should == "\n\n\n" ERBSpecs.new_erb(input, trim_mode: '<>').result.should == "\n" end diff --git a/library/logger/logger/new_spec.rb b/library/logger/logger/new_spec.rb index d3100ee2d1..6dcb030ae1 100644 --- a/library/logger/logger/new_spec.rb +++ b/library/logger/logger/new_spec.rb @@ -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 diff --git a/library/socket/basicsocket/send_spec.rb b/library/socket/basicsocket/send_spec.rb index 86b5567026..1c028480e3 100644 --- a/library/socket/basicsocket/send_spec.rb +++ b/library/socket/basicsocket/send_spec.rb @@ -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 diff --git a/library/stringio/fixtures/classes.rb b/library/stringio/fixtures/classes.rb index bb8dc354cc..832c5457d7 100644 --- a/library/stringio/fixtures/classes.rb +++ b/library/stringio/fixtures/classes.rb @@ -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