AutoFix RuboCop Layout/SpaceBeforeBlockBraces

This commit is contained in:
Pieter Oliver 2025-06-30 12:37:45 +01:00
parent 1b9aedf01e
commit f5a1cdb6f9
5 changed files with 6 additions and 18 deletions

View file

@ -29,18 +29,6 @@ Gemspec/RequiredRubyVersion:
Exclude: Exclude:
- 'grape_logging.gemspec' - 'grape_logging.gemspec'
# Offense count: 6
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: EnforcedStyle, EnforcedStyleForEmptyBraces.
# SupportedStyles: space, no_space
# SupportedStylesForEmptyBraces: space, no_space
Layout/SpaceBeforeBlockBraces:
Exclude:
- 'lib/grape_logging/formatters/rails.rb'
- 'lib/grape_logging/loggers/filter_parameters.rb'
- 'lib/grape_logging/loggers/response.rb'
- 'spec/lib/grape_logging/middleware/request_logger_spec.rb'
# Offense count: 2 # Offense count: 2
# This cop supports safe autocorrection (--autocorrect). # This cop supports safe autocorrection (--autocorrect).
Layout/SpaceBeforeComma: Layout/SpaceBeforeComma:

View file

@ -23,7 +23,7 @@ module GrapeLogging
[ [
"#{exception.message} (#{exception.class})", "#{exception.message} (#{exception.class})",
backtrace_array.join("\n") backtrace_array.join("\n")
].reject{|line| line == ""}.join("\n") ].reject {|line| line == ""}.join("\n")
end end
def format_hash(hash) def format_hash(hash)

View file

@ -30,8 +30,8 @@ module GrapeLogging
def clean_parameters(parameters) def clean_parameters(parameters)
original_encoding_map = build_encoding_map(parameters) original_encoding_map = build_encoding_map(parameters)
params = transform_key_encoding(parameters, Hash.new{ |h, _| [Encoding::ASCII_8BIT, h] }) params = transform_key_encoding(parameters, Hash.new { |h, _| [Encoding::ASCII_8BIT, h] })
cleaned_params = parameter_filter.filter(params).reject{ |key, _value| @exceptions.include?(key) } cleaned_params = parameter_filter.filter(params).reject { |key, _value| @exceptions.include?(key) }
transform_key_encoding(cleaned_params, original_encoding_map) transform_key_encoding(cleaned_params, original_encoding_map)
end end

View file

@ -14,7 +14,7 @@ module GrapeLogging
if response.respond_to?(:body) if response.respond_to?(:body)
# Rack responses # Rack responses
begin begin
response.body.map{ |body| JSON.parse(body.to_s) } response.body.map { |body| JSON.parse(body.to_s) }
rescue # No reason to have "=> e" here when we don't use it.. rescue # No reason to have "=> e" here when we don't use it..
response.body response.body
end end

View file

@ -3,7 +3,7 @@ require 'rack'
describe GrapeLogging::Middleware::RequestLogger do describe GrapeLogging::Middleware::RequestLogger do
let(:subject) { request.send(request_method, path) } let(:subject) { request.send(request_method, path) }
let(:app) { proc{ [status, {} , ['response body']] } } let(:app) { proc { [status, {} , ['response body']] } }
let(:stack) { described_class.new app, options } let(:stack) { described_class.new app, options }
let(:request) { Rack::MockRequest.new(stack) } let(:request) { Rack::MockRequest.new(stack) }
let(:options) { {include: [], logger: logger} } let(:options) { {include: [], logger: logger} }
@ -49,7 +49,7 @@ describe GrapeLogging::Middleware::RequestLogger do
end end
context 'with a nil response' do context 'with a nil response' do
let(:app) { proc{ [500, {} , nil] } } let(:app) { proc { [500, {} , nil] } }
it 'should log "fail" instead of a status' do it 'should log "fail" instead of a status' do
expect(Rack::MockResponse).to receive(:new) { nil } expect(Rack::MockResponse).to receive(:new) { nil }
expect(logger).to receive('info') do |arguments| expect(logger).to receive('info') do |arguments|