Skip to content

Commit

Permalink
improved rubocop config (puma#2152)
Browse files Browse the repository at this point in the history
  • Loading branch information
nateberkopec authored Mar 7, 2020
1 parent 27ed7b1 commit 2cef8dd
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 38 deletions.
23 changes: 23 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ AllCops:
Exclude:
- 'tmp/**/*'
- 'vendor/**/*'
- 'examples/**/*'
- 'pkg/**/*'
- 'Rakefile'

Layout/SpaceAfterColon:
Expand Down Expand Up @@ -53,3 +55,24 @@ Style/TrailingCommaInArguments:

Performance:
Enabled: true

Metrics/ParameterLists:
Max: 7

Performance/RedundantMatch:
Enabled: true

Performance/RedundantBlockCall:
Enabled: true

Performance/StringReplacement:
Enabled: true

Layout/AccessModifierIndentation:
EnforcedStyle: indent

Style/WhileUntilModifier:
Enabled: true

Style/TernaryParentheses:
Enabled: true
30 changes: 1 addition & 29 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,19 +39,7 @@ Layout/EmptyLinesAroundModuleBody:
# 5 offenses
Layout/IndentationWidth:
Enabled: true

# 3 offenses
Layout/AccessModifierIndentation:
EnforcedStyle: indent

# 2 offenses
Style/WhileUntilModifier:
Enabled: true

# 1 offense
Style/TernaryParentheses:
Enabled: true


# >200 offenses for 80
# 58 offenses for 100
# 18 offenses for 120
Expand All @@ -64,19 +52,3 @@ Metrics/LineLength:
- https
IgnoreCopDirectives: false
IgnoredPatterns: []

# 1 offense
Metrics/ParameterLists:
Max: 5

# 1 offense
Performance/RedundantMatch:
Enabled: true

# 1 offense
Performance/RedundantBlockCall:
Enabled: true

# 1 offense
Performance/StringReplacement:
Enabled: true
2 changes: 1 addition & 1 deletion lib/puma/cli.rb
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ def run
@launcher.run
end

private
private
def unsupported(str)
@events.error(str)
raise UnsupportedOption
Expand Down
2 changes: 1 addition & 1 deletion lib/puma/control_cli.rb
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ def run
exit 1
end

private
private
def start
require 'puma/cli'

Expand Down
4 changes: 1 addition & 3 deletions lib/puma/minissl.rb
Original file line number Diff line number Diff line change
Expand Up @@ -141,9 +141,7 @@ def close
# Read any drop any partially initialized sockets and any received bytes during shutdown.
# Don't let this socket hold this loop forever.
# If it can't send more packets within 1s, then give up.
while should_drop_bytes?
return if [:timeout, :eof].include?(read_and_drop(1))
end
return if [:timeout, :eof].include?(read_and_drop(1)) while should_drop_bytes?
rescue IOError, SystemCallError
Thread.current.purge_interrupt_queue if Thread.current.respond_to? :purge_interrupt_queue
# nothing
Expand Down
2 changes: 1 addition & 1 deletion lib/puma/null_io.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def each
# Mimics IO#read with no data.
#
def read(count = nil, _buffer = nil)
(count && count > 0) ? nil : ""
count && count > 0 ? nil : ""
end

def rewind
Expand Down
4 changes: 1 addition & 3 deletions test/test_rack_handler.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,7 @@ def in_handler(app, options = {})

# Wait for launcher to boot
Timeout.timeout(10) do
until @launcher
sleep 1
end
sleep 1 until @launcher
end
sleep 1

Expand Down

0 comments on commit 2cef8dd

Please sign in to comment.