Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Motivation
Rack::Lint is a middleware that validates applications, requests and responses according to Rack spec. I thought it would be great to have an idea of our compliance with the newest specs. Without any surprises, I've found a few violations but nothing major and most violations were found in specs.
This PR fixes all violations but do not prevent adding new ones. We would have to change a couple of things in the specs to add
Rack::Lint
in the specs but its another discussion.Here what has been fixed:
Body yielded non-string value
nil
Under specific case, Grape might return a body equal to
[nil]
which is not valid according to the linter. Instead of relying on the received bodies, it returns systematically[]
like Rack::Response does. See formatterBody yielded non-string value
:symbol
,exception
When calling
error!
a user might not pass a string message. I've changed a bit the algorithm to make sure it's always astring
. See txt.Rewindable input
According to Rack 3 specs,
input
may not be rewindable. Instead of callingrewind
all the time, I've added anif input.respond_to?(:rewind)
. See formatterBody has not been closed
When cascading, we need to close the body if it can be closed
respond_to?(:close)
See router