Skip to content

Commit 6097e17

Browse files
committed
Apply ReplaceWithPrimitiveObjectClass to lib/truffle as well
1 parent 72f1c7e commit 6097e17

24 files changed

+56
-55
lines changed

.rubocop.yml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -401,24 +401,25 @@ Layout/SpaceAroundEqualsInParameterDefault:
401401
# Supports --auto-correct
402402
TruffleRuby/ReplaceWithPrimitiveNil:
403403
Enabled: true
404-
Include: # inspect *only* this directory
404+
Include: # inspect *only* these files
405405
- lib/truffle/**/*.rb
406406
- src/main/ruby/**/*.rb
407407

408408
# Supports --auto-correct
409409
TruffleRuby/ReplaceWithPrimitiveObjectClass:
410410
Enabled: true
411-
Include: # inspect *only* this directory
411+
Include: # inspect *only* these files
412+
- lib/truffle/**/*.rb
412413
- src/main/ruby/**/*.rb
413414

414415
# Supports --auto-correct
415416
TruffleRuby/ReplaceWithPrimitiveObjectEqual:
416417
Enabled: true
417-
Include: # inspect *only* this directory
418+
Include: # inspect *only* these files
418419
- src/main/ruby/**/*.rb
419420

420421
# Supports --auto-correct
421422
TruffleRuby/ReplaceWithPrimitiveObjectKindOf:
422423
Enabled: true
423-
Include: # inspect *only* this directory
424+
Include: # inspect *only* these files
424425
- src/main/ruby/**/*.rb

lib/truffle/digest.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -83,16 +83,16 @@ def new
8383
end
8484

8585
def block_length
86-
raise RuntimeError, "#{self.class.name} does not implement block_length()"
86+
raise RuntimeError, "#{Primitive.class(self).name} does not implement block_length()"
8787
end
8888

8989
def update(message)
90-
raise RuntimeError, "#{self.class.name} does not implement update()"
90+
raise RuntimeError, "#{Primitive.class(self).name} does not implement update()"
9191
end
9292
alias_method :<<, :update
9393

9494
def reset
95-
raise RuntimeError, "#{self.class.name} does not implement reset()"
95+
raise RuntimeError, "#{Primitive.class(self).name} does not implement reset()"
9696
end
9797

9898
def digest(message = NO_MESSAGE)
@@ -150,7 +150,7 @@ def ==(other)
150150
end
151151

152152
def inspect
153-
"#<#{self.class.name}: #{hexdigest}>"
153+
"#<#{Primitive.class(self).name}: #{hexdigest}>"
154154
end
155155
end
156156

lib/truffle/socket/ancillary_data.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ def self.int(family, level, type, integer)
3737
def self.unix_rights(*ios)
3838
descriptors = ios.map do |io|
3939
unless io.is_a?(IO)
40-
raise TypeError, "IO expected, got #{io.class} instead"
40+
raise TypeError, "IO expected, got #{Primitive.class(io)} instead"
4141
end
4242

4343
io.fileno

lib/truffle/socket/option.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ def unpack(template)
6363
end
6464

6565
def inspect
66-
"#<#{self.class}: #@family_name #@level_name #@opt_name #{@data.inspect}>"
66+
"#<#{Primitive.class(self)}: #@family_name #@level_name #@opt_name #{@data.inspect}>"
6767
end
6868

6969
def bool

lib/truffle/socket/socket.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,7 @@ class << self
307307
end
308308

309309
def initialize(family, socket_type, protocol = 0)
310-
@no_reverse_lookup = self.class.do_not_reverse_lookup
310+
@no_reverse_lookup = Primitive.class(self).do_not_reverse_lookup
311311

312312
@family = Truffle::Socket.protocol_family(family)
313313
socket_type = Truffle::Socket.socket_type(socket_type)

lib/truffle/socket/tcp_server.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828

2929
class TCPServer < TCPSocket
3030
def initialize(host = nil, service)
31-
@no_reverse_lookup = self.class.do_not_reverse_lookup
31+
@no_reverse_lookup = Primitive.class(self).do_not_reverse_lookup
3232

3333
remote_addrs = Socket
3434
.getaddrinfo(host, service, :UNSPEC, :STREAM, 0, Socket::AI_PASSIVE)

lib/truffle/socket/tcp_socket.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ def self.gethostbyname(hostname)
4444
end
4545

4646
def initialize(host, service, local_host = nil, local_service = nil)
47-
@no_reverse_lookup = self.class.do_not_reverse_lookup
47+
@no_reverse_lookup = Primitive.class(self).do_not_reverse_lookup
4848

4949
if host
5050
host = Truffle::Socket.coerce_to_string(host)

lib/truffle/socket/truffle.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -375,7 +375,7 @@ def self.shutdown_option(how)
375375
shutdown_option(coerce_to_string(how))
376376
else
377377
raise TypeError,
378-
"no implicit conversion of #{how.class} into Integer"
378+
"no implicit conversion of #{Primitive.class(how)} into Integer"
379379
end
380380
end
381381
end

lib/truffle/socket/truffle/ancillary_data.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ def self.type(family, level, raw_type)
7575
end
7676
else
7777
raise TypeError,
78-
"no implicit conversion of #{type.class} into Integer"
78+
"no implicit conversion of #{Primitive.class(type)} into Integer"
7979
end
8080
end
8181
end

lib/truffle/socket/truffle/foreign/ifaddrs.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ def each_address
9696
next_pointer = self.next
9797

9898
until next_pointer.null?
99-
struct = self.class.new(next_pointer)
99+
struct = Primitive.class(self).new(next_pointer)
100100

101101
yield struct
102102

0 commit comments

Comments
 (0)