Skip to content

Commit 3b0ab4d

Browse files
kpumukJens-G
authored andcommitted
Enforce consistent whitespaces around blocks, equal signs, and in parameters in Ruby code
1 parent dfeab8d commit 3b0ab4d

61 files changed

Lines changed: 128 additions & 151 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

lib/rb/.rubocop.yml

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,33 @@ AllCops:
99
Exclude:
1010
- "**/vendor/**/*"
1111

12+
Layout/EmptyLines:
13+
Enabled: true
14+
15+
Layout/EmptyLinesAroundBlockBody:
16+
Enabled: true
17+
18+
Layout/ExtraSpacing:
19+
Enabled: true
20+
1221
Layout/IndentationConsistency:
1322
Enabled: true
1423

15-
Layout/EmptyLines:
24+
Layout/LeadingCommentSpace:
1625
Enabled: true
1726

1827
Layout/LeadingEmptyLines:
1928
Enabled: true
2029

30+
Layout/SpaceAfterComma:
31+
Enabled: true
32+
33+
Layout/SpaceAroundEqualsInParameterDefault:
34+
Enabled: true
35+
36+
Layout/SpaceInsideBlockBraces:
37+
Enabled: true
38+
2139
Layout/TrailingEmptyLines:
2240
Enabled: true
2341

lib/rb/Rakefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,5 +135,5 @@ end
135135
CLEAN.include [
136136
'.bundle', 'benchmark/gen-rb', 'coverage', 'ext/*.{o,bundle,so,dll}', 'ext/mkmf.log',
137137
'ext/Makefile', 'ext/conftest.dSYM', 'ext/thrift_native.bundle.dSYM', 'mkmf.log',
138-
'pkg', 'spec/gen-rb', 'test/debug_proto/gen-rb', 'thrift-*.gem'
138+
'pkg', 'spec/gen-rb', 'test/debug_proto/gen-rb', 'thrift-*.gem'
139139
]

lib/rb/benchmark/benchmark.rb

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ def socket_class
116116
def collect_output
117117
puts "Collecting output..."
118118
# read from @pool until all sockets are closed
119-
@buffers = Hash.new { |h,k| h[k] = '' }
119+
@buffers = Hash.new { |h, k| h[k] = '' }
120120
until @pool.empty?
121121
rd, = select(@pool)
122122
next if rd.nil?
@@ -184,9 +184,9 @@ def analyze_output
184184
end
185185
end
186186
@report = {}
187-
@report[:total_calls] = call_times.inject(0.0) { |a,t| a += t }
187+
@report[:total_calls] = call_times.inject(0.0) { |a, t| a += t }
188188
@report[:avg_calls] = @report[:total_calls] / call_times.size
189-
@report[:total_clients] = client_times.inject(0.0) { |a,t| a += t }
189+
@report[:total_clients] = client_times.inject(0.0) { |a, t| a += t }
190190
@report[:avg_clients] = @report[:total_clients] / client_times.size
191191
@report[:connection_failures] = connection_failures.size
192192
@report[:connection_errors] = connection_errors.size
@@ -241,8 +241,8 @@ def report_output
241241

242242
def tabulate(fmt, *labels_and_values)
243243
labels = labels_and_values.map { |l| Array === l ? l.first : l }
244-
label_width = labels.inject(0) { |w,l| l.size > w ? l.size : w }
245-
labels_and_values.each do |(l,v)|
244+
label_width = labels.inject(0) { |w, l| l.size > w ? l.size : w }
245+
labels_and_values.each do |(l, v)|
246246
f = fmt
247247
l, f, c = l if Array === l
248248
fmtstr = "%-#{label_width+1}s #{f}"
@@ -255,7 +255,7 @@ def tabulate(fmt, *labels_and_values)
255255
end
256256

257257
def resolve_const(const)
258-
const and const.split('::').inject(Object) { |k,c| k.const_get(c) }
258+
const and const.split('::').inject(Object) { |k, c| k.const_get(c) }
259259
end
260260

261261
puts "Starting server..."

lib/rb/benchmark/server.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ def self.shutdown
101101
end
102102

103103
def resolve_const(const)
104-
const and const.split('::').inject(Object) { |k,c| k.const_get(c) }
104+
const and const.split('::').inject(Object) { |k, c| k.const_get(c) }
105105
end
106106

107107
tls = true if ARGV[0] == '-tls' and ARGV.shift

lib/rb/ext/extconf.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
#
1919

2020
if defined?(RUBY_ENGINE) && RUBY_ENGINE =~ /jruby/
21-
File.open('Makefile', 'w'){|f| f.puts "all:\n\ninstall:\n" }
21+
File.open('Makefile', 'w'){ |f| f.puts "all:\n\ninstall:\n" }
2222
else
2323
require 'mkmf'
2424

lib/rb/lib/thrift/client.rb

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

2020
module Thrift
2121
module Client
22-
def initialize(iprot, oprot=nil)
22+
def initialize(iprot, oprot = nil)
2323
@iprot = iprot
2424
@oprot = oprot || iprot
2525
@seqid = 0

lib/rb/lib/thrift/exceptions.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ class ApplicationException < Exception
4343

4444
attr_reader :type
4545

46-
def initialize(type=UNKNOWN, message=nil)
46+
def initialize(type = UNKNOWN, message = nil)
4747
super(message)
4848
@type = type
4949
end

lib/rb/lib/thrift/processor.rb

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

2222
module Thrift
2323
module Processor
24-
def initialize(handler, logger=nil)
24+
def initialize(handler, logger = nil)
2525
@handler = handler
2626
if logger.nil?
2727
@logger = Logger.new(STDERR)
@@ -32,7 +32,7 @@ def initialize(handler, logger=nil)
3232
end
3333

3434
def process(iprot, oprot)
35-
name, type, seqid = iprot.read_message_begin
35+
name, type, seqid = iprot.read_message_begin
3636
if respond_to?("process_#{name}")
3737
begin
3838
send("process_#{name}", seqid, iprot, oprot)

lib/rb/lib/thrift/protocol/base_protocol.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ class ProtocolException < Exception
3333

3434
attr_reader :type
3535

36-
def initialize(type=UNKNOWN, message=nil)
36+
def initialize(type = UNKNOWN, message = nil)
3737
super(message)
3838
@type = type
3939
end

lib/rb/lib/thrift/protocol/binary_protocol.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ class BinaryProtocol < BaseProtocol
2525

2626
attr_reader :strict_read, :strict_write
2727

28-
def initialize(trans, strict_read=true, strict_write=true)
28+
def initialize(trans, strict_read = true, strict_write = true)
2929
super(trans)
3030
@strict_read = strict_read
3131
@strict_write = strict_write

0 commit comments

Comments
 (0)