Class: RuboCop::Cop::Boxt::ApiPathFormat
- Inherits:
-
RuboCop::Cop::Base
- Object
- RuboCop::Cop::Base
- RuboCop::Cop::Boxt::ApiPathFormat
- Defined in:
- lib/rubocop/cop/boxt/api_path_format.rb
Overview
Clients expect to interface with our API using kebab-case.
This cop ensures that our API paths are formatted using the correct case.
Underscores are acceptable in path variables (e.g. “/path/:path_id/update”)
API style guide: github.com/boxt/boxt-docs/blob/main/coding-styles/api.md#camel-cased-endpoints
Constant Summary collapse
- MSG =
"Use kebab-case for the API path"
Instance Method Summary collapse
Instance Method Details
#on_send(node) ⇒ Object
37 38 39 40 41 42 43 44 45 |
# File 'lib/rubocop/cop/boxt/api_path_format.rb', line 37 def on_send(node) path_defining_method_with_string_path(node) do |path| add_offense(node) if path_name_does_not_follow_kebab_case?(path) end namespace_with_symbol(node) do |path| add_offense(node) if path.to_s.include?("_") end end |