Skip to content

Commit b3561cc

Browse files
RuboCop.
1 parent c5ee45f commit b3561cc

File tree

5 files changed

+12
-11
lines changed

5 files changed

+12
-11
lines changed

context/tasks.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,8 @@ By constructing your program correctly, it's easy to implement concurrent map-re
9999
```ruby
100100
Async do
101101
# Map (create several concurrent tasks)
102-
users_size = Async {User.size}
103-
posts_size = Async {Post.size}
102+
users_size = Async{User.size}
103+
posts_size = Async{Post.size}
104104

105105
# Reduce (wait for and merge the results)
106106
average = posts_size.wait / users_size.wait

guides/tasks/readme.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,8 @@ By constructing your program correctly, it's easy to implement concurrent map-re
9999
```ruby
100100
Async do
101101
# Map (create several concurrent tasks)
102-
users_size = Async {User.size}
103-
posts_size = Async {Post.size}
102+
users_size = Async{User.size}
103+
posts_size = Async{Post.size}
104104

105105
# Reduce (wait for and merge the results)
106106
average = posts_size.wait / users_size.wait

lib/async/task.rb

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,8 @@ def wait
265265
# Access the result of the task without waiting. May be nil if the task is not completed. Does not raise exceptions.
266266
def result
267267
value = @promise.value
268-
# For backward compatibility, return nil for stopped tasks
268+
269+
# For backward compatibility, return nil for stopped tasks:
269270
if @promise.cancelled?
270271
nil
271272
else
@@ -409,20 +410,20 @@ def finish!
409410
# State transition into the completed state.
410411
def completed!(result)
411412
# Resolve the promise with the result:
412-
@promise&.resolve(result)
413+
@promise.resolve(result)
413414
end
414415

415416
# State transition into the failed state.
416417
def failed!(exception = false)
417418
# Reject the promise with the exception:
418-
@promise&.reject(exception)
419+
@promise.reject(exception)
419420
end
420421

421422
def stopped!
422423
# Console.info(self, status:) {"Task #{self} was stopped with #{@children&.size.inspect} children!"}
423424

424425
# Cancel the promise:
425-
@promise&.cancel
426+
@promise.cancel
426427

427428
stopped = false
428429

test/async/promise.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@
184184

185185
expect(results).to be(:empty?)
186186
expect(errors.size).to be == 3
187-
expect(errors).to be(:all?) {|error| error == test_error}
187+
expect(errors).to be(:all?){|error| error == test_error}
188188
expect(promise.waiting?).to be == false
189189
end
190190
end
@@ -281,7 +281,7 @@
281281

282282
expect(results).to be(:empty?)
283283
expect(errors.size).to be == 3
284-
expect(errors).to be(:all?) {|error| error.message =~ /shared cancellation/}
284+
expect(errors).to be(:all?){|error| error.message =~ /shared cancellation/}
285285
expect(promise.waiting?).to be == false
286286
end
287287
end

test/async/task.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -793,7 +793,7 @@ def sleep_forever
793793

794794
with "finished task" do
795795
it "has no backtrace" do
796-
task = Async {}
796+
task = Async{}
797797

798798
expect(task.backtrace).to be_nil
799799
end

0 commit comments

Comments
 (0)