rubocop-grape 0.4.2 → 0.4.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0a10e156b9a117d1d9bd4eb1e3d0c559268669f410d80c786d5c4b38ca79d508
|
4
|
+
data.tar.gz: '0287d909c47e61e540fcc98edf2303b97f43ebad7a6fc244fa14444661dbc77f'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f01ca9109f953bc9f7f74bebad5a468004fb9db4b738b4d9e01ef0d9265325159e4d6397d16ca35453b3ae5784df27523e7ceea01413de9f030358b4101d9f4e
|
7
|
+
data.tar.gz: e1acec347d818fe04be34f01a012ebd7961730091b00cc370aa720e6097a783eb59b5de54bb2aada39f2f21d7b393b1e26e696d56298ce762ba43243fff3d3a3
|
data/config/default.yml
CHANGED
@@ -0,0 +1,34 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RuboCop
|
4
|
+
module Cop
|
5
|
+
module Grape
|
6
|
+
#
|
7
|
+
# @example
|
8
|
+
#
|
9
|
+
# # bad
|
10
|
+
# get ':id' do
|
11
|
+
# end
|
12
|
+
#
|
13
|
+
# # good
|
14
|
+
# route_param :id, type: Integer do
|
15
|
+
# get do
|
16
|
+
# end
|
17
|
+
# end
|
18
|
+
#
|
19
|
+
class RouteParamGrouping < Base
|
20
|
+
include EndpointHelper
|
21
|
+
|
22
|
+
MSG = 'Use route_param for route parameter'
|
23
|
+
|
24
|
+
def on_block(node)
|
25
|
+
return unless (method_send_node = http_method_node?(node))
|
26
|
+
return unless (first_argument_node = method_send_node.arguments.first)
|
27
|
+
return unless first_argument_node.value.match?(/:\w/)
|
28
|
+
|
29
|
+
add_offense(first_argument_node)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -7,7 +7,7 @@ module RuboCop
|
|
7
7
|
extend NodePattern::Macros
|
8
8
|
|
9
9
|
def_node_matcher :http_method_node?, <<~PATTERN
|
10
|
-
(block (send _ {:get :post :put :patch :delete} ...) ...)
|
10
|
+
(block $(send _ {:get :post :put :patch :delete} ...) ...)
|
11
11
|
PATTERN
|
12
12
|
|
13
13
|
def_node_matcher :params_node?, <<~PATTERN
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rubocop-grape
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Akito Hikasa
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-04-
|
11
|
+
date: 2024-04-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rubocop
|
@@ -49,6 +49,7 @@ files:
|
|
49
49
|
- lib/rubocop/cop/grape/ivar.rb
|
50
50
|
- lib/rubocop/cop/grape/params_position.rb
|
51
51
|
- lib/rubocop/cop/grape/present_with.rb
|
52
|
+
- lib/rubocop/cop/grape/route_param_grouping.rb
|
52
53
|
- lib/rubocop/cop/grape/route_param_type.rb
|
53
54
|
- lib/rubocop/cop/grape_cops.rb
|
54
55
|
- lib/rubocop/cop/mixin/endpoint_helper.rb
|