M .rubocop.yml => .rubocop.yml +92 -80
@@ 1,123 1,135 @@
AllCops:
- TargetRubyVersion: 2.5
+ TargetRubyVersion: 2.7
+ NewCops: enable
-Metrics/LineLength:
- Max: 80
-
-Style/Tab:
+Gemspec/RequiredRubyVersion:
Enabled: false
-Style/IndentationWidth:
- Width: 1 # one tab
-
-Lint/EndAlignment:
- EnforcedStyleAlignWith: variable
-
-Lint/RescueException:
- Enabled: false
-
-Metrics/AbcSize:
- Max: 134
-
-Metrics/BlockLength:
- Max: 200
-
-Metrics/BlockNesting:
- Max: 5
-
Metrics/ClassLength:
- Max: 200
-
-Metrics/CyclomaticComplexity:
- Max: 22
+ Exclude:
+ - test/*
Metrics/MethodLength:
- Max: 200
+ Exclude:
+ - test/*
-Metrics/ModuleLength:
- Max: 1000
+Metrics/BlockLength:
+ ExcludedMethods:
+ - route
+ - "on"
+ Exclude:
+ - test/*
-Metrics/ParameterLists:
- Max: 7
+Metrics/AbcSize:
+ Exclude:
+ - test/*
-Metrics/PerceivedComplexity:
- Max: 22
+Metrics/ParameterLists:
+ Max: 6
+
+Naming/MethodParameterName:
+ AllowNamesEndingInNumbers: false
+ AllowedNames:
+ - m
+ - e
+ - q
+ - s
+ - k
+ - v
+ - ex
+ - tx
+ - id
+ - iq
+ - ip
+ - db
+
+Layout/IndentationStyle:
+ Enabled: false
+ EnforcedStyle: tabs
+ IndentationWidth: 2
+
+Layout/IndentationWidth:
+ Width: 1 # one tab
-Style/AndOr:
- Enabled: false
+Layout/LineLength:
+ Max: 80
+ Exclude:
+ - Gemfile
-Style/AlignParameters:
- Enabled: false
+Layout/SpaceAroundEqualsInParameterDefault:
+ EnforcedStyle: no_space
-Style/BlockDelimiters:
- Enabled: false
+Layout/AccessModifierIndentation:
+ EnforcedStyle: outdent
-Style/CaseIndentation:
- EnforcedStyle: end
+Layout/FirstParameterIndentation:
+ EnforcedStyle: consistent
-Style/Documentation:
+Style/AccessModifierDeclarations:
Enabled: false
-Style/FormatString:
- EnforcedStyle: percent
-
-# Offense count: 1
-Style/IfInsideElse:
- Exclude:
- - 'sgx-catapult.rb'
-
-Style/LeadingCommentSpace:
+Style/ExplicitBlockArgument:
Enabled: false
-Style/MultilineMethodCallBraceLayout:
- Enabled: false
+Style/StringLiterals:
+ EnforcedStyle: double_quotes
-Style/MultilineOperationIndentation:
+Style/NumericLiterals:
Enabled: false
-Style/MultilineTernaryOperator:
- Enabled: false
+Style/SymbolArray:
+ EnforcedStyle: brackets
-Style/Next:
- Enabled: false
+Style/WordArray:
+ EnforcedStyle: brackets
-Style/Not:
+Style/Documentation:
Enabled: false
-Style/NumericLiterals:
- MinDigits: 20
- Strict: true
-
-Style/NumericPredicate:
+Style/DoubleNegation:
+ EnforcedStyle: allowed_in_returns
Enabled: false
-Style/SpaceAroundOperators:
+Style/PerlBackrefs:
Enabled: false
-Style/SpaceInsideHashLiteralBraces:
- EnforcedStyle: no_space
+Style/SpecialGlobalVars:
+ EnforcedStyle: use_perl_names
-Style/StringLiterals:
- EnforcedStyle: double_quotes
- Enabled: false
+Style/RegexpLiteral:
+ EnforcedStyle: slashes
+ AllowInnerSlashes: true
-Style/NegatedIf:
+Lint/OutOfRangeRegexpRef:
Enabled: false
-Style/RedundantReturn:
+Lint/MissingSuper:
Enabled: false
+Style/BlockDelimiters:
+ EnforcedStyle: semantic
+ AllowBracesOnProceduralOneLiners: true
+ ProceduralMethods:
+ - execute_command
+
Style/MultilineBlockChain:
Enabled: false
-Style/SpaceAroundEqualsInParameterDefault:
- EnforcedStyle: no_space
+Layout/FirstArgumentIndentation:
+ EnforcedStyle: consistent
-Style/IndentArray:
+Layout/FirstArrayElementIndentation:
EnforcedStyle: consistent
-Style/SymbolArray:
- EnforcedStyle: brackets
+Style/FormatString:
+ EnforcedStyle: percent
-Style/FirstParameterIndentation:
- EnforcedStyle: consistent
+Style/FormatStringToken:
+ EnforcedStyle: unannotated
+
+Style/FrozenStringLiteralComment:
+ Exclude:
+ - forms/**/*.rb
+
+Naming/AccessorMethodName:
+ Enabled: false
M em_promise.rb.gemspec => em_promise.rb.gemspec +2 -2
@@ 12,10 12,10 @@ Gem::Specification.new do |spec|
spec.homepage = "https://git.singpolyma.net/em_promise.rb"
spec.files =
- `git ls-files -z`.split("\x00".b).reject do |f|
+ `git ls-files -z`.split("\x00".b).reject { |f|
f.start_with?(".", "test/", "scripts/") ||
f == "Makefile" || f == "Gemfile"
- end
+ }
spec.require_paths = ["lib"]
spec.add_dependency "eventmachine"
M lib/em_promise.rb => lib/em_promise.rb +7 -9
@@ 20,11 20,11 @@ class EMPromise < Promise
def initialize(&initial_blk)
@ready = true
- @fiber = Fiber.new do |blk|
+ @fiber = Fiber.new { |blk|
Thread.current[:_em_promise_trampoline] = self
self.ready = false
Trampoline.yield(blk.call)
- end
+ }
@fiber.resume(&initial_blk) if initial_blk
end
@@ 46,11 46,9 @@ class EMPromise < Promise
tramp&.ready = true
blk = Fiber.yield arg
tramp&.ready = false
- if blk.is_a?(SubmittedBlock)
- arg = blk.call
- else
- return arg
- end
+ return arg unless blk.is_a?(SubmittedBlock)
+
+ arg = blk.call
end
end
end
@@ 74,9 72,9 @@ class EMPromise < Promise
fulfill(deferrable) if deferrable
end
- def fulfill(value, bind_defer=true)
+ def fulfill(value, bind_defer: true)
if bind_defer && value.is_a?(EM::Deferrable)
- value.callback { |x| fulfill(x, false) }
+ value.callback { |x| fulfill(x, bind_defer: false) }
value.errback(&method(:reject))
else
super(value)