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

Add Layout/IndentationConsistency to Rubocop config #1180

Merged
merged 5 commits into from
Oct 12, 2024
Merged
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
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -72,5 +72,5 @@ jobs:
- uses: ruby/setup-ruby@v1
with:
ruby-version: '3.0'
- run: gem install rubocop:1.28.2
- run: rubocop --parallel
- run: bundle install
- run: bundle exec rubocop --parallel
15 changes: 15 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,13 @@ AllCops:
DisplayCopNames: true
Exclude:
- command_line/fixtures/bad_syntax.rb
- core/exception/fixtures/syntax_error.rb
DisabledByDefault: true
NewCops: disable

Layout/IndentationConsistency:
Enabled: true

Layout/TrailingWhitespace:
Enabled: true

Expand Down Expand Up @@ -43,6 +47,17 @@ Lint/InterpolationCheck:
Lint/LiteralAsCondition:
Enabled: false

# Required to support Ruby 3.0
Lint/RedundantRequireStatement:
Exclude:
- core/fiber/**/*.rb
- library/fiber/**/*.rb
- optional/capi/fiber_spec.rb

Lint/RedundantSafeNavigation:
Exclude:
- language/safe_navigator_spec.rb

Lint/RedundantSplatExpansion:
Enabled: false

Expand Down
35 changes: 18 additions & 17 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# This configuration was generated by
# `rubocop --auto-gen-config`
# on 2019-12-12 22:16:26 +0900 using RuboCop version 0.77.0.
# on 2024-10-12 16:01:45 UTC using RuboCop version 1.66.1.
# The point is for the user to remove these configuration records
# one by one as the offenses are removed from the code base.
# Note that changes in the inspected code, or installation of new
Expand All @@ -21,6 +21,7 @@ Lint/DuplicateMethods:
- 'fixtures/class.rb'

# Offense count: 8
# This cop supports safe autocorrection (--autocorrect).
Lint/EnsureReturn:
Exclude:
- 'language/fixtures/ensure.rb'
Expand All @@ -39,6 +40,7 @@ Lint/FloatOutOfRange:
- 'core/string/modulo_spec.rb'

# Offense count: 2
# This cop supports safe autocorrection (--autocorrect).
Lint/ImplicitStringConcatenation:
Exclude:
- 'language/string_spec.rb'
Expand All @@ -50,8 +52,8 @@ Lint/IneffectiveAccessModifier:
- 'core/module/fixtures/classes.rb'
- 'language/fixtures/private.rb'

# Offense count: 72
# Cop supports --auto-correct.
# Offense count: 71
# This cop supports safe autocorrection (--autocorrect).
Lint/LiteralInInterpolation:
Exclude:
- 'core/module/refine_spec.rb'
Expand All @@ -65,32 +67,25 @@ Lint/LiteralInInterpolation:
- 'language/undef_spec.rb'

# Offense count: 8
# Cop supports --auto-correct.
# This cop supports safe autocorrection (--autocorrect).
Lint/MultipleComparison:
Exclude:
- 'language/precedence_spec.rb'

# Offense count: 9
# This cop supports safe autocorrection (--autocorrect).
Lint/ParenthesesAsGroupedExpression:
Exclude:
- 'core/string/fixtures/freeze_magic_comment.rb'
- 'language/block_spec.rb'
- 'language/fixtures/send.rb'
- 'language/method_spec.rb'

# Offense count: 2
# Cop supports --auto-correct.
# This cop supports safe autocorrection (--autocorrect).
Lint/RedundantStringCoercion:
Exclude:
- 'core/io/print_spec.rb'

# Offense count: 1
# Cop supports --auto-correct.
Lint/RedundantWithIndex:
Exclude:
- 'core/enumerator/with_index_spec.rb'

# Offense count: 22
# Offense count: 25
Lint/RescueException:
Exclude:
- 'command_line/fixtures/debug_info.rb'
Expand All @@ -107,14 +102,19 @@ Lint/RescueException:
- 'language/rescue_spec.rb'
- 'library/erb/filename_spec.rb'

# Offense count: 1
Lint/SelfAssignment:
Exclude:
- 'core/gc/auto_compact_spec.rb'

# Offense count: 4
# Configuration parameters: IgnoreImplicitReferences.
Lint/ShadowedArgument:
Exclude:
- 'language/fixtures/super.rb'

# Offense count: 39
# Configuration parameters: AllowComments.
# Offense count: 45
# Configuration parameters: AllowComments, AllowNil.
Lint/SuppressedException:
Enabled: false

Expand All @@ -127,7 +127,8 @@ Lint/UnderscorePrefixedVariableName:
- 'language/block_spec.rb'

# Offense count: 7
# Configuration parameters: ContextCreatingMethods, MethodCreatingMethods.
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: AutoCorrect, ContextCreatingMethods, MethodCreatingMethods.
Lint/UselessAccessModifier:
Exclude:
- 'core/module/define_method_spec.rb'
Expand Down
3 changes: 3 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
source 'https://rubygems.org'

gem 'rubocop', '= 1.66.1'
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
herwinw marked this conversation as resolved.
Show resolved Hide resolved

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
herwinw marked this conversation as resolved.
Show resolved Hide resolved
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
Loading