diff --git a/.rubocop.yml b/.rubocop.yml index 0eaf834..4c154f6 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -1,3 +1,6 @@ +AllCops: + TargetRubyVersion: 2.0 + Style/Documentation: Enabled: false @@ -7,5 +10,25 @@ Style/FileName: Style/Semicolon: AllowAsExpressionSeparator: true -Style/TrailingComma: +Style/TrailingCommaInLiteral: EnforcedStyleForMultiline: comma + +Style/TrailingCommaInArguments: + EnforcedStyleForMultiline: comma + +Style/SignalException: + EnforcedStyle: semantic + +Style/ClassAndModuleChildren: + EnforcedStyle: compact + +Style/TrivialAccessors: + AllowPredicates: true + +Style/Alias: + EnforcedStyle: prefer_alias_method + +Lint/ShadowingOuterLocalVariable: + Exclude: + - examples/many_to_one.rb + - examples/one_to_many.rb diff --git a/examples/many_to_one.rb b/examples/many_to_one.rb index 22789a0..257b627 100644 --- a/examples/many_to_one.rb +++ b/examples/many_to_one.rb @@ -5,11 +5,11 @@ require 'channel' c = Channel.new 1.upto(5) do |i| - go(lambda { |i, co| + go(lambda do |i, co| 1.upto(5) do |j| - co << format("hi from %d.%d", i, j) + co << format('hi from %d.%d', i, j) end - }, i, c) + end, i, c) end 25.times { puts c.recv } diff --git a/examples/non_blocking_channel_operations.rb b/examples/non_blocking_channel_operations.rb index dadf5be..3e9a207 100644 --- a/examples/non_blocking_channel_operations.rb +++ b/examples/non_blocking_channel_operations.rb @@ -12,14 +12,14 @@ Channel.select(messages) do |msg, c| end end -msg = 'hi' -messages <- msg -#select { -#case messages <- msg: -# fmt.Println("sent message", msg) -#default: -# fmt.Println("no message sent") -#} +# msg = 'hi' +# messages <- msg +# select { +# case messages <- msg: +# fmt.Println("sent message", msg) +# default: +# fmt.Println("no message sent") +# } Channel.select(messages, signals) do |res, c| case c diff --git a/examples/one_to_many.rb b/examples/one_to_many.rb index fb25daf..4331ad4 100644 --- a/examples/one_to_many.rb +++ b/examples/one_to_many.rb @@ -8,15 +8,15 @@ w = WaitGroup.new w.add(5) 1.upto(5) do |i| - go(lambda { |i, ci| - j = 1 - ci.each { |v| - sleep(0.001) - puts format("%d.%d got %d", i, j, v) - j += 1 - } - w.done - }, i, c) + go(lambda do |i, ci| + j = 1 + ci.each do |v| + sleep(0.001) + puts format('%d.%d got %d', i, j, v) + j += 1 + end + w.done + end, i, c) end 1.upto(25) { |i| c << i } diff --git a/test/test_channel.rb b/test/test_channel.rb index 1254789..c3c1b26 100644 --- a/test/test_channel.rb +++ b/test/test_channel.rb @@ -8,9 +8,9 @@ require 'channel' class TestChannel < Test::Unit::TestCase module Util - def meanwhile(*procs, &blk) + def meanwhile(*procs) threads = procs.map { |p| Thread.new(&p) } - blk.call + yield threads.each(&:join) end end diff --git a/test/test_waitgroup.rb b/test/test_waitgroup.rb index b05922f..822f646 100644 --- a/test/test_waitgroup.rb +++ b/test/test_waitgroup.rb @@ -7,9 +7,9 @@ require 'channel/waitgroup' class TestWaitGroup < Test::Unit::TestCase module Util - def meanwhile(*procs, &blk) + def meanwhile(*procs) threads = procs.map { |p| Thread.new(&p) } - blk.call + yield threads.each(&:join) end end