Skip to content

Commit d91ec17

Browse files
committed
Run Rubocop on Truffle specs and update to RuboCop 0.66
PullRequest: truffleruby/710
2 parents 6081d43 + ff5ca1c commit d91ec17

File tree

90 files changed

+736
-742
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

90 files changed

+736
-742
lines changed

.rubocop.yml

Lines changed: 16 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
AllCops:
2-
TargetRubyVersion: 2.3
2+
TargetRubyVersion: 2.6
33
DisabledByDefault: true
44
DisplayCopNames: true
55
ExtraDetails: true
@@ -9,9 +9,9 @@ AllCops:
99
- 'lib/truffle/socket/mri.rb' # taken from MRI
1010
- 'lib/truffle/ffi/library.rb' # taken from FFI gem
1111

12-
# Type 'Style' (166):
12+
# Type 'Layout' (166):
1313
# Supports --auto-correct
14-
Style/TrailingBlankLines:
14+
Layout/TrailingBlankLines:
1515
Description: Checks trailing blank lines and final newline.
1616
StyleGuide: "#newline-eof"
1717
Enabled: true
@@ -21,7 +21,7 @@ Style/TrailingBlankLines:
2121
- final_blank_line
2222

2323
# Supports --auto-correct
24-
Style/TrailingWhitespace:
24+
Layout/TrailingWhitespace:
2525
Description: Avoid trailing whitespace.
2626
StyleGuide: "#no-trailing-whitespace"
2727
Enabled: true
@@ -44,7 +44,7 @@ Lint/AmbiguousRegexpLiteral:
4444
Enabled: true
4545

4646
# Supports --auto-correct
47-
Lint/BlockAlignment:
47+
Layout/BlockAlignment:
4848
Description: Align block ends correctly.
4949
Enabled: true
5050
EnforcedStyleAlignWith: either
@@ -58,7 +58,7 @@ Lint/CircularArgumentReference:
5858
should not refer back to the name of the argument.
5959
Enabled: true
6060

61-
Lint/ConditionPosition:
61+
Layout/ConditionPosition:
6262
Description: Checks for condition placed in a confusing position relative to the keyword.
6363
StyleGuide: "#same-line-condition"
6464
Enabled: true
@@ -69,7 +69,7 @@ Lint/Debugger:
6969
Enabled: true
7070

7171
# Supports --auto-correct
72-
Lint/DefEndAlignment:
72+
Layout/DefEndAlignment:
7373
Description: Align ends corresponding to defs correctly.
7474
Enabled: true
7575
EnforcedStyleAlignWith: start_of_line
@@ -122,7 +122,7 @@ Lint/EmptyWhen:
122122
Enabled: false
123123

124124
# Supports --auto-correct
125-
Lint/EndAlignment:
125+
Layout/EndAlignment:
126126
Description: Align ends correctly.
127127
Enabled: true
128128
EnforcedStyleAlignWith: keyword
@@ -175,15 +175,11 @@ Lint/InheritException:
175175
Exclude:
176176
- src/main/ruby/core/exception.rb
177177

178-
Lint/InvalidCharacterLiteral:
179-
Description: Checks for invalid character literals with a non-escaped whitespace character.
180-
Enabled: true
181-
182-
Lint/LiteralInCondition:
178+
Lint/LiteralAsCondition:
183179
Description: Checks of literals used in conditions.
184180
Details: >-
185181
Pattern `while true` is allowed, disable the cop with
186-
`while true # rubocop:disable Lint/LiteralInCondition` in this case.
182+
`while true # rubocop:disable Lint/LiteralAsCondition` in this case.
187183
Enabled: true
188184

189185
# Supports --auto-correct
@@ -277,7 +273,7 @@ Lint/UnifiedInteger:
277273
Enabled: false
278274

279275
# Supports --auto-correct
280-
Lint/UnneededDisable:
276+
Lint/UnneededCopDisableDirective:
281277
Description: 'Checks for rubocop:disable comments that can be removed. Note: this
282278
cop is not disabled when disabling all cops. It must be explicitly disabled.'
283279
Enabled: true
@@ -333,22 +329,22 @@ Lint/UselessSetterCall:
333329

334330
Lint/Void:
335331
Description: Possible use of operator/literal/variable in void context.
336-
Enabled: true
332+
Enabled: false # Triggers for any return value for #initialize and #[]=
337333

338-
#################### Style ###########################
334+
#################### Layout ###########################
339335

340336
# Supports --auto-correct
341337
Style/BlockDelimiters:
342338
Enabled: true
343339

344-
Style/CaseIndentation:
340+
Layout/CaseIndentation:
345341
Enabled: true
346342
EnforcedStyle: 'end'
347343

348-
Style/IndentationConsistency:
344+
Layout/IndentationConsistency:
349345
Enabled: true
350346

351-
Style/IndentationWidth:
347+
Layout/IndentationWidth:
352348
Enabled: true
353349

354350
# Supports --auto-correct

lib/truffle/java/java.rb

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,7 @@ def hash
4141
def eql?(another)
4242
Truffle::Interop::Java.java_eql?(@value, @value)
4343
end
44-
45-
alias_method :eql?, :==
44+
alias_method :==, :eql?
4645

4746
def equal?(another)
4847
nil != @value and JavaObject === another and @value.equals(another.value)

lib/truffle/java/java_utilities.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -367,7 +367,7 @@ def toString
367367
a_proxy = Module.new do
368368
define_singleton_method(:included, included_method)
369369
class << self
370-
attr_accessor :java_class
370+
attr_writer :java_class
371371
def java_class
372372
JavaUtilities::wrap_java_value(@java_class)
373373
end

lib/truffle/java/method_selector.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -334,7 +334,7 @@ def initialize(value_class, boxed_class, wide_type=nil)
334334
class Parameters
335335
def initialize(params, var_args)
336336
@params = params.map { |t| Parameter.for_type(t) }
337-
@var_args
337+
@var_args = var_args
338338
end
339339

340340
def [](index)

lib/truffle/socket/socket.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ def self.unpack_sockaddr_in(sockaddr)
238238
_, address, port = Truffle::Socket::Foreign
239239
.unpack_sockaddr_in(sockaddr, false)
240240

241-
return port, address
241+
[port, address]
242242
rescue SocketError => e
243243
if e.message =~ /ai_family not supported/
244244
raise ArgumentError, 'not an AF_INET/AF_INET6 sockaddr'

lib/truffle/socket/truffle/foreign.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ def self.getaddrinfo(host, service = nil, family = nil, socktype = nil,
166166
res = Addrinfo.new(res[:ai_next])
167167
end
168168

169-
return addrinfos
169+
addrinfos
170170
ensure
171171
hints.free if hints
172172

@@ -282,7 +282,7 @@ def self.pack_sockaddr_in(host, port, family = ::Socket::AF_UNSPEC,
282282

283283
res = Addrinfo.new(res_p.read_pointer)
284284

285-
return res[:ai_addr].read_string(res[:ai_addrlen])
285+
res[:ai_addr].read_string(res[:ai_addrlen])
286286
ensure
287287
hints.free if hints
288288

spec/truffle/.rubocop.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
inherit_from: ../../.rubocop.yml
2+
3+
Style/StringLiterals:
4+
Enabled: false
500 Bytes
Binary file not shown.

spec/truffle/array/new_spec.rb

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ def capacity(ary)
3333

3434
it "creates arrays with the requested capacity with a value block" do
3535
a = Array.new(17) { 1 }
36-
capacity(a).should == 17
36+
capacity(a).should == 17
3737
end
3838
end
39-

spec/truffle/array/pack_spec.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,14 @@ def check_pack_equal_bytes(expected, actual)
2222
it "should pack expressions with loops" do
2323
([1] * 1024).pack('l' * 1024).sum.should == 1024
2424
end
25-
25+
2626
it "should be able to pack a tarball entry" do
2727
ary = ["metadata.gz", "0000444", "0000000", "0000000", "00000001244", "00000000044", " ", " ", "0", nil,
2828
"ustar", "00", "wheel", "wheel", "0000000", "0000000", ""]
2929
pack_format = "a100a8a8a8a12a12a7aaa100a6a2a32a32a8a8a155"
3030
packed = ary.pack(pack_format)
31-
expected = "metadata.gz\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x000000444\x000000000\x000000000\x0000000001244\x0000000000044\x00 0\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00ustar\x0000wheel\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00wheel\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x000000000\x000000000\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
32-
packed.should == expected
31+
path = fixture __FILE__, "tarball_entry.tar"
32+
packed.should == File.binread(path)
3333
end
3434

3535
# Real-world usage of Array#pack, gathered by Brandon Fish, not designed

0 commit comments

Comments
 (0)