1
0
mirror of https://github.com/meineerde/rackstash.git synced 2026-01-31 17:27:13 +00:00

Fix minor code formatting issues

This commit is contained in:
Holger Just 2017-08-05 23:28:59 +02:00
parent d362b7efaa
commit eab3d16ec5
11 changed files with 27 additions and 33 deletions

View File

@ -23,10 +23,6 @@ Metrics/ClassLength:
Metrics/MethodLength:
Enabled: false
# As long as methods are readable, this should be fine.
# In any case, this shouldn't be a hard error. We try to improve where sensible
# using tools like RubyCritic instead
# rspec uses long blocks by definition
Metrics/BlockLength:
Exclude:
@ -64,6 +60,9 @@ Style/DoubleNegation:
Style/EmptyMethod:
EnforcedStyle: expanded
Style/MultilineMethodCallIndentation:
EnforcedStyle: indented
# Multiline indentation is always tricky. Format it as deemed useful in the
# local method, but try to avoid it at all wherever possible
Style/MultilineOperationIndentation:

View File

@ -90,7 +90,7 @@ module Rackstash
# @return [void]
# @raise NotImplementedHereError
def write_single(log)
raise NotImplementedHereError, 'write_single needs to be implemented ' +
raise NotImplementedHereError, 'write_single needs to be implemented ' \
'in the actual adapter subclass'
end

View File

@ -64,8 +64,8 @@ module Rackstash
next unless filter_class.is_a?(Class)
filter_class_name = const.to_s
.gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2')
.gsub(/([a-z\d])([A-Z])/,'\1_\2')
.gsub(/([A-Z]+)([A-Z][a-z])/, '\1_\2')
.gsub(/([a-z\d])([A-Z])/, '\1_\2')
.downcase
.to_sym

View File

@ -30,7 +30,7 @@ describe Rackstash::Adapters::File do
end
it 'accepts a Pathname' do
expect(described_class.new(Pathname.new logfile.path).filename)
expect(described_class.new(Pathname.new(logfile.path)).filename)
.to eql(logfile.path)
.and be_a String
end
@ -43,13 +43,13 @@ describe Rackstash::Adapters::File do
it 'creates the file and leading directories' do
Dir.mktmpdir do |base|
expect(File.exist? File.join(base, 'dir')).to be false
expect(File.exist?(File.join(base, 'dir'))).to be false
adapter = described_class.new File.join(base, 'dir', 'sub', 'test.log')
expect(adapter.filename).to eql File.join(base, 'dir', 'sub', 'test.log')
expect(File.directory? File.join(base, 'dir')).to be true
expect(File.file? File.join(base, 'dir', 'sub', 'test.log')).to be true
expect(File.directory?(File.join(base, 'dir'))).to be true
expect(File.file?(File.join(base, 'dir', 'sub', 'test.log'))).to be true
end
end
end

View File

@ -400,7 +400,7 @@ describe Rackstash::Buffer do
end
it 'merges fields and tags as values' do
fields = {foo: :bar}
fields = { foo: :bar }
tags = ['default_tag']
expect(buffer.fields).to receive(:deep_merge).with(fields, force: false)
@ -410,8 +410,8 @@ describe Rackstash::Buffer do
end
it 'merges fields and tags as Procs' do
fields = ->{}
tags = ->{}
fields = -> {}
tags = -> {}
expect(buffer.fields).to receive(:deep_merge).with(fields, force: false)
expect(buffer.tags).to receive(:merge).with(tags)

View File

@ -474,7 +474,7 @@ describe Rackstash::Fields::AbstractCollection do
it 'returns the inspected proc on errors' do
error = -> { raise 'Oh, no!' }
expected_arguments = ->(arg1, args, arg3) { 'cherio' }
expected_arguments = ->(_arg1, _args, _arg3) { 'cherio' }
ok = -> { :ok }
outer = -> { [ok, error, expected_arguments] }

View File

@ -339,7 +339,7 @@ describe Rackstash::Fields::Array do
describe '#push' do
it 'can append multiple values' do
expect(array.push 'value', 'value2').to equal array
expect(array.push('value', 'value2')).to equal array
expect(array[0]).to eql 'value'
expect(array[1]).to eql 'value2'
end
@ -353,7 +353,7 @@ describe Rackstash::Fields::Array do
end
it 'can use append as an alias' do
expect(array.append 'foo').to equal array
expect(array.append('foo')).to equal array
expect(array[0]).to eql 'foo'
end
end

View File

@ -24,9 +24,7 @@ describe Rackstash::Fields::Hash do
expect(hash.forbidden_keys)
.to be_a(Set)
.and be_frozen
.and all(
be_frozen.and be_a String
)
.and all be_frozen.and be_a String
end
it 'accepts forbidden_keys as a Set' do
@ -36,9 +34,7 @@ describe Rackstash::Fields::Hash do
expect(hash.forbidden_keys)
.to be_a(Set)
.and be_frozen
.and all(
be_frozen.and be_a String
)
.and all be_frozen.and be_a String
# We create a new set without affecting the passed one
expect(hash.forbidden_keys).not_to equal forbidden_keys

View File

@ -20,13 +20,13 @@ describe Rackstash::Filters::SkipEvent do
end
it 'accepts a block' do
expect { described_class.new { } }.not_to raise_error
expect { described_class.new {} }.not_to raise_error
end
end
describe '#call' do
it 'returns the event if the condition is falsey' do
event = {'foo' => 'bar'}
event = { 'foo' => 'bar' }
expect(described_class.new(->(_event) { false }).call(event)).to equal event
expect(described_class.new(->(_event) { nil }).call(event)).to equal event
@ -35,7 +35,7 @@ describe Rackstash::Filters::SkipEvent do
end
it 'returns false if the condition is truethy' do
event = {'foo' => 'bar'}
event = { 'foo' => 'bar' }
expect(described_class.new(->(_event) { true }).call(event)).to be false
expect(described_class.new(->(_event) { event }).call(event)).to be false

View File

@ -124,7 +124,7 @@ describe Rackstash::Flow do
expect { flow.encoder 23 }.to raise_error TypeError
expect { flow.encoder true }.to raise_error TypeError
expect { flow.encoder false }.to raise_error TypeError
expect { flow.encoder ->{} }.to raise_error TypeError
expect { flow.encoder -> {} }.to raise_error TypeError
end
end
@ -173,7 +173,7 @@ describe Rackstash::Flow do
it 'calls FilterChain#append' do
expect(flow.filter_chain).to receive(:append).twice.and_call_original
expect(flow.filter_append ->(event) { event }).to equal flow
expect(flow.filter_append(->(event) { event })).to equal flow
expect(flow.filter_append { |event| event }).to equal flow
expect(flow.filter_chain.size).to eql 2
@ -184,7 +184,6 @@ describe Rackstash::Flow do
end
end
describe '#filter_delete' do
before(:each) do
flow.filter_chain << ->(event) {}
@ -217,7 +216,7 @@ describe Rackstash::Flow do
it 'calls FilterChain#unshift' do
expect(flow.filter_chain).to receive(:unshift).twice.and_call_original
expect(flow.filter_unshift ->(event) { event }).to equal flow
expect(flow.filter_unshift(->(event) { event })).to equal flow
expect(flow.filter_unshift { |event| event }).to equal flow
expect(flow.filter_chain.size).to eql 2

View File

@ -33,7 +33,7 @@ describe Rackstash::Logger do
end
it 'allows to set #formatter' do
logger = described_class.new('output.log', formatter: ->{})
logger = described_class.new('output.log', formatter: -> {})
expect(logger.formatter).to be_a Proc
end
end
@ -80,7 +80,7 @@ describe Rackstash::Logger do
describe '#default_fields=' do
it 'forwards to the sink' do
expect(logger.sink).to receive(:default_fields=).with({ 'key' => 'value' })
expect(logger.sink).to receive(:default_fields=).with('key' => 'value')
logger.default_fields = { 'key' => 'value' }
end
end
@ -421,7 +421,7 @@ describe Rackstash::Logger do
expect(buffer).not_to receive(:add_message)
expect(logger.add(0, { foo: 'bar' })).to eql(foo: 'bar')
expect(logger.add(0, foo: 'bar')).to eql(foo: 'bar')
end
it 'can use debug shortcut' do