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

Improve code formatting and fix Rubocop issues

This commit is contained in:
Holger Just 2018-01-23 23:21:58 +01:00
parent 3a8371e1b8
commit c194b00b34
7 changed files with 30 additions and 33 deletions

View File

@ -297,11 +297,13 @@ module Rackstash
}
buffer.fields.merge!(fields, force: false)
buffer.fields.deep_merge!(
@response_fields,
scope: headers,
force: false
) unless @response_fields.nil?
unless @response_fields.nil?
buffer.fields.deep_merge!(
@response_fields,
scope: headers,
force: false
)
end
buffer.tag(@response_tags, scope: headers) unless @response_tags.nil?
end

View File

@ -11,7 +11,7 @@ require 'rackstash/class_registry'
describe Rackstash::ClassRegistry do
let(:registry) { described_class.new('value') }
let(:klass) { Class.new}
let(:klass) { Class.new }
describe '#initialize' do
it 'sets the object_type' do

View File

@ -496,8 +496,19 @@ describe Rackstash::Fields::Hash do
hash['key'] = 'value'
called_with = []
expect(hash.fetch('key') { |key| called_with << key; :default }).to eql 'value'
expect(hash.fetch('missing') { |key| called_with << key; :default }).to eql :default
expect(
hash.fetch('key') { |key|
called_with << key
:default
}
).to eql 'value'
expect(
hash.fetch('missing') { |key|
called_with << key;
:default
}
).to eql :default
expect(called_with).to eql ['missing']
end

View File

@ -87,7 +87,6 @@ describe Rackstash::Filter::AnonymizeIPMask do
expect(event).not_to include 'ignored'
end
it 'anonymizes arrays' do
filter_spec['array'] = 'anonymized'
filter.call(event)

View File

@ -15,7 +15,7 @@ describe Rackstash::Filter do
let(:filter_class) {
Class.new do
def call(event)
def call(_event)
'filtered'
end
end
@ -87,7 +87,7 @@ describe Rackstash::Filter do
end
it 'keeps the class hierarchy unchanged' do
filter = described_class.build(filter_name, only_if: ->(event){ false })
filter = described_class.build(filter_name, only_if: ->(_event) { false })
expect(filter).to be_instance_of(filter_class)
end
@ -113,7 +113,7 @@ describe Rackstash::Filter do
attr_reader :mandatory
end
filter = described_class.build(filter_name, only_if: ->{}, mandatory: 'foo')
filter = described_class.build(filter_name, only_if: -> {}, mandatory: 'foo')
expect(filter.mandatory).to eql 'foo'
end
end
@ -160,7 +160,8 @@ describe Rackstash::Filter do
describe '.register' do
let(:filter_class) {
Class.new do
def call; end
def call
end
end
}

View File

@ -94,10 +94,8 @@ describe Rackstash::Flow do
'error' => 'RuntimeError',
'error_message' => 'ERROR',
'error_trace' => instance_of(String),
'tags' => [],
'message' => [instance_of(Rackstash::Message)],
'@timestamp' => instance_of(Time)
)
expect(flow).to receive(:error_flow).and_return(error_flow)
@ -128,10 +126,8 @@ describe Rackstash::Flow do
'error' => 'RuntimeError',
'error_message' => 'ERROR',
'error_trace' => instance_of(String),
'tags' => [],
'message' => [instance_of(Rackstash::Message)],
'@timestamp' => instance_of(Time)
)
expect(flow).to receive(:error_flow).and_return(error_flow)
@ -302,19 +298,19 @@ describe Rackstash::Flow do
end
it 'can set to true or false' do
expect(flow.raise_on_error 'something').to eql true
expect(flow.raise_on_error('something')).to eql true
expect(flow.raise_on_error).to eql true
expect(flow.raise_on_error?).to eql true
expect(flow.raise_on_error nil).to eql false
expect(flow.raise_on_error(nil)).to eql false
expect(flow.raise_on_error).to eql false
expect(flow.raise_on_error?).to eql false
expect(flow.raise_on_error true).to eql true
expect(flow.raise_on_error(true)).to eql true
expect(flow.raise_on_error).to eql true
expect(flow.raise_on_error?).to eql true
expect(flow.raise_on_error false).to eql false
expect(flow.raise_on_error(false)).to eql false
expect(flow.raise_on_error).to eql false
expect(flow.raise_on_error?).to eql false
end
@ -345,10 +341,8 @@ describe Rackstash::Flow do
'error' => 'RuntimeError',
'error_message' => 'ERROR',
'error_trace' => instance_of(String),
'tags' => [],
'message' => [instance_of(Rackstash::Message)],
'@timestamp' => instance_of(Time)
)
expect(flow).to receive(:error_flow).and_return(error_flow)
@ -379,10 +373,8 @@ describe Rackstash::Flow do
'error' => 'RuntimeError',
'error_message' => 'ERROR',
'error_trace' => instance_of(String),
'tags' => [],
'message' => [instance_of(Rackstash::Message)],
'@timestamp' => instance_of(Time)
)
expect(flow).to receive(:error_flow).and_return(error_flow)
@ -454,10 +446,8 @@ describe Rackstash::Flow do
'error' => 'RuntimeError',
'error_message' => 'ERROR',
'error_trace' => instance_of(String),
'tags' => [],
'message' => [instance_of(Rackstash::Message)],
'@timestamp' => instance_of(Time)
)
expect(flow).to receive(:error_flow).and_return(error_flow)
@ -488,10 +478,8 @@ describe Rackstash::Flow do
'error' => 'RuntimeError',
'error_message' => 'ERROR',
'error_trace' => instance_of(String),
'tags' => [],
'message' => [instance_of(Rackstash::Message)],
'@timestamp' => instance_of(Time)
)
expect(flow).to receive(:error_flow).and_return(error_flow)

View File

@ -113,9 +113,7 @@ describe Rackstash::Rack::Middleware do
'path' => '/demo',
'status' => 200,
'duration' => be_a(Float).and(be > 0),
'message' => "Request started\nNothing to do...\n",
'@timestamp' => /\d{4}-\d\d-\d\dT\d\d:\d\d:\d\d.\d{6}Z/,
'tags' => []
)
@ -247,10 +245,8 @@ describe Rackstash::Rack::Middleware do
'error' => 'RuntimeError',
'error_message' => 'kaputt',
'error_trace' => %r{\A#{__FILE__}:#{__LINE__ - 8}:in},
# The app did its thing
'message' => "Request started\nNothing to do...\n",
# We explicitly override the logged status, even if the app returned a
# successful response earlier
'status' => 500