New feature : linting#2557
Conversation
Add spec All specs are now linted
|
Should we call it But thinking about it, maybe we need something more generic that allows one to inject middleware here, including potentially the ability to remove |
Add `yaml-dev` in Dockerfile
The middleware stack lacks a |
dblock
left a comment
There was a problem hiding this comment.
Please document this in the README if you want it merged.
That said, also consider not merging this and doing a configurable middleware implementation instead.
There was a problem hiding this comment.
Pull Request Overview
This PR introduces a new linting feature into the Grape framework, allowing endpoints to be linted by default or via a per-endpoint configuration. Key changes include:
- Enabling the global lint configuration in spec_helper and lib/grape.
- Incorporating Rack::Lint middleware in the endpoint stack when linting is enabled.
- Adding a new DSL method lint! to allow per-endpoint lint configuration.
Reviewed Changes
Copilot reviewed 6 out of 7 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| spec/spec_helper.rb | Enables linting globally by setting Grape.config.lint to true. |
| spec/integration/rails/mounting_spec.rb | Modifies Rails app instantiation and wraps the app with Rack::Lint. |
| spec/grape/api_spec.rb | Adds tests for the new .lint! behavior and Rack::Lint error handling. |
| lib/grape/endpoint.rb | Inserts Rack::Lint middleware conditionally and defines a lint? method. |
| lib/grape/dsl/routing.rb | Introduces lint! in the DSL for endpoint-specific lint enabling. |
| lib/grape.rb | Sets the default lint configuration to false. |
Files not reviewed (1)
- docker/Dockerfile: Language not supported
I like the insert_before Grape::Middleware::Error, Rack::LintI think the |
5d45776 to
fad6b2e
Compare
Fix typo in UPGRADING.md
fad6b2e to
ed493d0
Compare
dblock
left a comment
There was a problem hiding this comment.
I don't think we should be switching a default value in Grape globally in tests, that negates the default. Any strong feelings?
* Add linting feature through Grape.config and `lint_api!` method Add spec All specs are now linted * Remove error message for Lint::Error * Add ruby 3.1 to 3.2 to spec integrations Add `yaml-dev` in Dockerfile * Rename `lint_api!` to `lint!` * Revert test.yml * Add README.md and CHANGELOG.md Fix typo in UPGRADING.md * Fix CHANGELOG * Use `lint!` in rails spec * Fix api_spec lint with ensure --------- Co-authored-by: Daniel (dB.) Doubrovkine <dblock@dblock.org>
This PR adds a linting feature that can activated through
Grape.config.lint = trueorlint!in aGrape::Api.Suggested in this comment.
By design, Grape's CI has
Grape.config.lint = true, so all specs calling an endpoint are linted.