mirror of
https://github.com/samsonjs/grape_logging.git
synced 2026-04-04 10:35:47 +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:
|
||||
- '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
|
||||
# This cop supports safe autocorrection (--autocorrect).
|
||||
# Configuration parameters: AllowMultipleStyles, EnforcedHashRocketStyle, EnforcedColonStyle, EnforcedLastArgumentHashStyle.
|
||||
|
|
|
|||
|
|
@ -10,8 +10,8 @@ describe GrapeLogging::Loggers::ClientEnv do
|
|||
context 'forwarded for' do
|
||||
let(:mock_request) do
|
||||
OpenStruct.new(env: {
|
||||
"HTTP_X_FORWARDED_FOR" => forwarded_for
|
||||
})
|
||||
"HTTP_X_FORWARDED_FOR" => forwarded_for
|
||||
})
|
||||
end
|
||||
|
||||
it 'sets the ip key' do
|
||||
|
|
@ -27,8 +27,8 @@ describe GrapeLogging::Loggers::ClientEnv do
|
|||
context 'remote address' do
|
||||
let(:mock_request) do
|
||||
OpenStruct.new(env: {
|
||||
"REMOTE_ADDR" => remote_addr
|
||||
})
|
||||
"REMOTE_ADDR" => remote_addr
|
||||
})
|
||||
end
|
||||
|
||||
it 'sets the ip key' do
|
||||
|
|
@ -39,8 +39,8 @@ describe GrapeLogging::Loggers::ClientEnv do
|
|||
context 'user agent' do
|
||||
let(:mock_request) do
|
||||
OpenStruct.new(env: {
|
||||
"HTTP_USER_AGENT" => user_agent
|
||||
})
|
||||
"HTTP_USER_AGENT" => user_agent
|
||||
})
|
||||
end
|
||||
|
||||
it 'sets the ua key' do
|
||||
|
|
|
|||
|
|
@ -6,13 +6,13 @@ describe GrapeLogging::Loggers::FilterParameters do
|
|||
|
||||
let(:mock_request) do
|
||||
OpenStruct.new(params: {
|
||||
'this_one' => 'this one',
|
||||
'that_one' => 'one',
|
||||
'two' => 'two',
|
||||
'three' => 'three',
|
||||
'four' => 'four',
|
||||
"\xff" => 'invalid utf8',
|
||||
})
|
||||
'this_one' => 'this one',
|
||||
'that_one' => 'one',
|
||||
'two' => 'two',
|
||||
'three' => 'three',
|
||||
'four' => 'four',
|
||||
"\xff" => 'invalid utf8',
|
||||
})
|
||||
end
|
||||
|
||||
let(:mock_request_with_deep_nesting) do
|
||||
|
|
@ -35,37 +35,37 @@ describe GrapeLogging::Loggers::FilterParameters do
|
|||
shared_examples 'filtering' do
|
||||
it 'filters out sensitive parameters' do
|
||||
expect(subject.parameters(mock_request, nil)).to eq(params: {
|
||||
'this_one' => subject.instance_variable_get('@replacement'),
|
||||
'that_one' => subject.instance_variable_get('@replacement'),
|
||||
'two' => 'two',
|
||||
'three' => 'three',
|
||||
'four' => subject.instance_variable_get('@replacement'),
|
||||
"\xff" => 'invalid utf8',
|
||||
})
|
||||
'this_one' => subject.instance_variable_get('@replacement'),
|
||||
'that_one' => subject.instance_variable_get('@replacement'),
|
||||
'two' => 'two',
|
||||
'three' => 'three',
|
||||
'four' => subject.instance_variable_get('@replacement'),
|
||||
"\xff" => 'invalid utf8',
|
||||
})
|
||||
end
|
||||
|
||||
it 'deeply filters out sensitive parameters' do
|
||||
expect(subject.parameters(mock_request_with_deep_nesting, nil)).to eq(params: {
|
||||
'this_one' => subject.instance_variable_get('@replacement'),
|
||||
'that_one' => subject.instance_variable_get('@replacement'),
|
||||
'two' => 'two',
|
||||
'three' => 'three',
|
||||
'four' => subject.instance_variable_get('@replacement'),
|
||||
"\xff" => 'invalid utf8',
|
||||
'five' => {
|
||||
'this_one' => subject.instance_variable_get('@replacement'),
|
||||
'that_one' => subject.instance_variable_get('@replacement'),
|
||||
'two' => 'two',
|
||||
'three' => 'three',
|
||||
'four' => subject.instance_variable_get('@replacement'),
|
||||
"\xff" => 'invalid utf8',
|
||||
'six' => {
|
||||
'seven' => 'seven',
|
||||
'eight' => 'eight',
|
||||
'one' => subject.instance_variable_get('@replacement'),
|
||||
},
|
||||
},
|
||||
})
|
||||
'this_one' => subject.instance_variable_get('@replacement'),
|
||||
'that_one' => subject.instance_variable_get('@replacement'),
|
||||
'two' => 'two',
|
||||
'three' => 'three',
|
||||
'four' => subject.instance_variable_get('@replacement'),
|
||||
"\xff" => 'invalid utf8',
|
||||
'five' => {
|
||||
'this_one' => subject.instance_variable_get('@replacement'),
|
||||
'that_one' => subject.instance_variable_get('@replacement'),
|
||||
'two' => 'two',
|
||||
'three' => 'three',
|
||||
'four' => subject.instance_variable_get('@replacement'),
|
||||
"\xff" => 'invalid utf8',
|
||||
'six' => {
|
||||
'seven' => 'seven',
|
||||
'eight' => 'eight',
|
||||
'one' => subject.instance_variable_get('@replacement'),
|
||||
},
|
||||
},
|
||||
})
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -8,33 +8,33 @@ describe GrapeLogging::Loggers::RequestHeaders do
|
|||
|
||||
let(:mock_request_with_unhandled_headers) do
|
||||
OpenStruct.new(env: {
|
||||
HTTP_REFERER: 'http://example.com',
|
||||
HTTP_REFERER: 'http://example.com',
|
||||
"PATH_INFO"=>"/api/v1/users"
|
||||
})
|
||||
})
|
||||
end
|
||||
|
||||
let(:mock_request_with_long_headers) do
|
||||
OpenStruct.new(env: {
|
||||
HTTP_REFERER: 'http://example.com',
|
||||
HTTP_REFERER: 'http://example.com',
|
||||
HTTP_USER_AGENT: "Mozilla/5.0"
|
||||
})
|
||||
})
|
||||
end
|
||||
|
||||
it 'strips HTTP_ from the parameter' do
|
||||
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
|
||||
|
||||
it 'only handle things which start with HTTP_' do
|
||||
expect(subject.parameters(mock_request_with_unhandled_headers, nil)).to eq({
|
||||
headers: {'Referer' => 'http://example.com' }
|
||||
})
|
||||
headers: {'Referer' => 'http://example.com' }
|
||||
})
|
||||
end
|
||||
|
||||
it 'substitutes _ with -' do
|
||||
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
|
||||
|
|
|
|||
|
|
@ -9,8 +9,8 @@ describe GrapeLogging::Loggers::Response do
|
|||
|
||||
it 'returns an array of parsed JSON objects' do
|
||||
expect(subject.parameters(nil, response)).to eq({
|
||||
response: [response.body.first],
|
||||
})
|
||||
response: [response.body.first],
|
||||
})
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -21,8 +21,8 @@ describe GrapeLogging::Loggers::Response do
|
|||
|
||||
it 'just returns the body' do
|
||||
expect(subject.parameters(nil, response)).to eq({
|
||||
response: response.body,
|
||||
})
|
||||
response: response.body,
|
||||
})
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
Loading…
Reference in a new issue