mirror of
https://github.com/samsonjs/grape_logging.git
synced 2026-04-27 14:57:40 +00:00
AutoFix RuboCop Layout/FirstHashElementIndentation
This commit is contained in:
parent
b6833655f5
commit
c9dfc20973
5 changed files with 54 additions and 61 deletions
|
|
@ -29,13 +29,6 @@ Gemspec/RequiredRubyVersion:
|
||||||
Exclude:
|
Exclude:
|
||||||
- 'grape_logging.gemspec'
|
- 'grape_logging.gemspec'
|
||||||
|
|
||||||
# Offense count: 26
|
|
||||||
# This cop supports safe autocorrection (--autocorrect).
|
|
||||||
# Configuration parameters: IndentationWidth.
|
|
||||||
# SupportedStyles: special_inside_parentheses, consistent, align_braces
|
|
||||||
Layout/FirstHashElementIndentation:
|
|
||||||
EnforcedStyle: consistent
|
|
||||||
|
|
||||||
# Offense count: 1
|
# Offense count: 1
|
||||||
# This cop supports safe autocorrection (--autocorrect).
|
# This cop supports safe autocorrection (--autocorrect).
|
||||||
# Configuration parameters: AllowMultipleStyles, EnforcedHashRocketStyle, EnforcedColonStyle, EnforcedLastArgumentHashStyle.
|
# Configuration parameters: AllowMultipleStyles, EnforcedHashRocketStyle, EnforcedColonStyle, EnforcedLastArgumentHashStyle.
|
||||||
|
|
|
||||||
|
|
@ -10,8 +10,8 @@ describe GrapeLogging::Loggers::ClientEnv do
|
||||||
context 'forwarded for' do
|
context 'forwarded for' do
|
||||||
let(:mock_request) do
|
let(:mock_request) do
|
||||||
OpenStruct.new(env: {
|
OpenStruct.new(env: {
|
||||||
"HTTP_X_FORWARDED_FOR" => forwarded_for
|
"HTTP_X_FORWARDED_FOR" => forwarded_for
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'sets the ip key' do
|
it 'sets the ip key' do
|
||||||
|
|
@ -27,8 +27,8 @@ describe GrapeLogging::Loggers::ClientEnv do
|
||||||
context 'remote address' do
|
context 'remote address' do
|
||||||
let(:mock_request) do
|
let(:mock_request) do
|
||||||
OpenStruct.new(env: {
|
OpenStruct.new(env: {
|
||||||
"REMOTE_ADDR" => remote_addr
|
"REMOTE_ADDR" => remote_addr
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'sets the ip key' do
|
it 'sets the ip key' do
|
||||||
|
|
@ -39,8 +39,8 @@ describe GrapeLogging::Loggers::ClientEnv do
|
||||||
context 'user agent' do
|
context 'user agent' do
|
||||||
let(:mock_request) do
|
let(:mock_request) do
|
||||||
OpenStruct.new(env: {
|
OpenStruct.new(env: {
|
||||||
"HTTP_USER_AGENT" => user_agent
|
"HTTP_USER_AGENT" => user_agent
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'sets the ua key' do
|
it 'sets the ua key' do
|
||||||
|
|
|
||||||
|
|
@ -6,13 +6,13 @@ describe GrapeLogging::Loggers::FilterParameters do
|
||||||
|
|
||||||
let(:mock_request) do
|
let(:mock_request) do
|
||||||
OpenStruct.new(params: {
|
OpenStruct.new(params: {
|
||||||
'this_one' => 'this one',
|
'this_one' => 'this one',
|
||||||
'that_one' => 'one',
|
'that_one' => 'one',
|
||||||
'two' => 'two',
|
'two' => 'two',
|
||||||
'three' => 'three',
|
'three' => 'three',
|
||||||
'four' => 'four',
|
'four' => 'four',
|
||||||
"\xff" => 'invalid utf8',
|
"\xff" => 'invalid utf8',
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
let(:mock_request_with_deep_nesting) do
|
let(:mock_request_with_deep_nesting) do
|
||||||
|
|
@ -35,37 +35,37 @@ describe GrapeLogging::Loggers::FilterParameters do
|
||||||
shared_examples 'filtering' do
|
shared_examples 'filtering' do
|
||||||
it 'filters out sensitive parameters' do
|
it 'filters out sensitive parameters' do
|
||||||
expect(subject.parameters(mock_request, nil)).to eq(params: {
|
expect(subject.parameters(mock_request, nil)).to eq(params: {
|
||||||
'this_one' => subject.instance_variable_get('@replacement'),
|
'this_one' => subject.instance_variable_get('@replacement'),
|
||||||
'that_one' => subject.instance_variable_get('@replacement'),
|
'that_one' => subject.instance_variable_get('@replacement'),
|
||||||
'two' => 'two',
|
'two' => 'two',
|
||||||
'three' => 'three',
|
'three' => 'three',
|
||||||
'four' => subject.instance_variable_get('@replacement'),
|
'four' => subject.instance_variable_get('@replacement'),
|
||||||
"\xff" => 'invalid utf8',
|
"\xff" => 'invalid utf8',
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'deeply filters out sensitive parameters' do
|
it 'deeply filters out sensitive parameters' do
|
||||||
expect(subject.parameters(mock_request_with_deep_nesting, nil)).to eq(params: {
|
expect(subject.parameters(mock_request_with_deep_nesting, nil)).to eq(params: {
|
||||||
'this_one' => subject.instance_variable_get('@replacement'),
|
'this_one' => subject.instance_variable_get('@replacement'),
|
||||||
'that_one' => subject.instance_variable_get('@replacement'),
|
'that_one' => subject.instance_variable_get('@replacement'),
|
||||||
'two' => 'two',
|
'two' => 'two',
|
||||||
'three' => 'three',
|
'three' => 'three',
|
||||||
'four' => subject.instance_variable_get('@replacement'),
|
'four' => subject.instance_variable_get('@replacement'),
|
||||||
"\xff" => 'invalid utf8',
|
"\xff" => 'invalid utf8',
|
||||||
'five' => {
|
'five' => {
|
||||||
'this_one' => subject.instance_variable_get('@replacement'),
|
'this_one' => subject.instance_variable_get('@replacement'),
|
||||||
'that_one' => subject.instance_variable_get('@replacement'),
|
'that_one' => subject.instance_variable_get('@replacement'),
|
||||||
'two' => 'two',
|
'two' => 'two',
|
||||||
'three' => 'three',
|
'three' => 'three',
|
||||||
'four' => subject.instance_variable_get('@replacement'),
|
'four' => subject.instance_variable_get('@replacement'),
|
||||||
"\xff" => 'invalid utf8',
|
"\xff" => 'invalid utf8',
|
||||||
'six' => {
|
'six' => {
|
||||||
'seven' => 'seven',
|
'seven' => 'seven',
|
||||||
'eight' => 'eight',
|
'eight' => 'eight',
|
||||||
'one' => subject.instance_variable_get('@replacement'),
|
'one' => subject.instance_variable_get('@replacement'),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -8,33 +8,33 @@ describe GrapeLogging::Loggers::RequestHeaders do
|
||||||
|
|
||||||
let(:mock_request_with_unhandled_headers) do
|
let(:mock_request_with_unhandled_headers) do
|
||||||
OpenStruct.new(env: {
|
OpenStruct.new(env: {
|
||||||
HTTP_REFERER: 'http://example.com',
|
HTTP_REFERER: 'http://example.com',
|
||||||
"PATH_INFO"=>"/api/v1/users"
|
"PATH_INFO"=>"/api/v1/users"
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
let(:mock_request_with_long_headers) do
|
let(:mock_request_with_long_headers) do
|
||||||
OpenStruct.new(env: {
|
OpenStruct.new(env: {
|
||||||
HTTP_REFERER: 'http://example.com',
|
HTTP_REFERER: 'http://example.com',
|
||||||
HTTP_USER_AGENT: "Mozilla/5.0"
|
HTTP_USER_AGENT: "Mozilla/5.0"
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'strips HTTP_ from the parameter' do
|
it 'strips HTTP_ from the parameter' do
|
||||||
expect(subject.parameters(mock_request, nil)).to eq({
|
expect(subject.parameters(mock_request, nil)).to eq({
|
||||||
headers: {'Referer' => 'http://example.com', 'Accept' => 'text/plain'}
|
headers: {'Referer' => 'http://example.com', 'Accept' => 'text/plain'}
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'only handle things which start with HTTP_' do
|
it 'only handle things which start with HTTP_' do
|
||||||
expect(subject.parameters(mock_request_with_unhandled_headers, nil)).to eq({
|
expect(subject.parameters(mock_request_with_unhandled_headers, nil)).to eq({
|
||||||
headers: {'Referer' => 'http://example.com' }
|
headers: {'Referer' => 'http://example.com' }
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'substitutes _ with -' do
|
it 'substitutes _ with -' do
|
||||||
expect(subject.parameters(mock_request_with_long_headers, nil)).to eq({
|
expect(subject.parameters(mock_request_with_long_headers, nil)).to eq({
|
||||||
headers: {'Referer' => 'http://example.com', 'User-Agent' => 'Mozilla/5.0' }
|
headers: {'Referer' => 'http://example.com', 'User-Agent' => 'Mozilla/5.0' }
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -9,8 +9,8 @@ describe GrapeLogging::Loggers::Response do
|
||||||
|
|
||||||
it 'returns an array of parsed JSON objects' do
|
it 'returns an array of parsed JSON objects' do
|
||||||
expect(subject.parameters(nil, response)).to eq({
|
expect(subject.parameters(nil, response)).to eq({
|
||||||
response: [response.body.first],
|
response: [response.body.first],
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
@ -21,8 +21,8 @@ describe GrapeLogging::Loggers::Response do
|
||||||
|
|
||||||
it 'just returns the body' do
|
it 'just returns the body' do
|
||||||
expect(subject.parameters(nil, response)).to eq({
|
expect(subject.parameters(nil, response)).to eq({
|
||||||
response: response.body,
|
response: response.body,
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue