rubocop-nueca 1.2.3 → 1.2.6
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: 6ae060f2f69c576434c27818dc11cb0261f36ff4bea5d2bf8cd7921db648a742
|
4
|
+
data.tar.gz: f1ba128f09eecdde792dc78363f958814c6243cdbdfcb4ee9bfde539e13e399e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ed1840e4b53be4f603c35937e9787ba26c24b9e91450d15d994f3ce06941daa95f9dbf4fd3f0a2b15a748e9942f98d8b6ca641cf59f4e5ef4c2bbef04d1be03f
|
7
|
+
data.tar.gz: 644a0cd75f372919536c623f6ce1580fb40f72631bbf33e7b00efece86d1cad46164838ac7e6dff1caa525add3c4b7bc39e2cb26ee8d2b9c053be790d5a17b03
|
@@ -36,7 +36,8 @@ module RuboCop
|
|
36
36
|
|
37
37
|
def same_type_and_level?(current_route, next_route)
|
38
38
|
current_route[:type] == next_route[:type] &&
|
39
|
-
current_route[:namespace_level] == next_route[:namespace_level]
|
39
|
+
current_route[:namespace_level] == next_route[:namespace_level] &&
|
40
|
+
current_route[:namespace_path] == next_route[:namespace_path]
|
40
41
|
end
|
41
42
|
|
42
43
|
def blank_line_between?(current_route, next_route)
|
@@ -7,7 +7,7 @@ module RuboCop
|
|
7
7
|
ROUTE_CATEGORIES = {
|
8
8
|
simple: [:get, :post, :put, :patch, :delete, :head, :options, :match, :root],
|
9
9
|
resource: [:resource, :resources],
|
10
|
-
namespace: [:namespace, :scope, :concern],
|
10
|
+
namespace: [:namespace, :scope, :concern, :member, :collection],
|
11
11
|
draw: [:draw]
|
12
12
|
}.freeze
|
13
13
|
|
@@ -44,7 +44,7 @@ module RuboCop
|
|
44
44
|
send_node = node.send_node
|
45
45
|
return unless send_node.send_type? && route_method?(send_node)
|
46
46
|
|
47
|
-
add_route_block_if_valid(node)
|
47
|
+
add_route_block_if_valid(node) unless [:member, :collection].include?(send_node.method_name)
|
48
48
|
process_nested_context(node)
|
49
49
|
end
|
50
50
|
|
@@ -67,19 +67,41 @@ module RuboCop
|
|
67
67
|
|
68
68
|
def build_namespace_path(send_node)
|
69
69
|
new_namespace_path = @namespace_path.dup
|
70
|
+
method_name = send_node.method_name
|
70
71
|
|
71
|
-
case
|
72
|
+
case method_name
|
72
73
|
when :namespace
|
73
|
-
|
74
|
-
new_namespace_path << namespace_name if namespace_name
|
74
|
+
add_namespace_to_path(new_namespace_path, send_node)
|
75
75
|
when :scope
|
76
|
-
|
77
|
-
|
76
|
+
add_scope_to_path(new_namespace_path, send_node)
|
77
|
+
when :resources, :resource
|
78
|
+
add_resource_to_path(new_namespace_path, send_node)
|
79
|
+
when :member, :collection
|
80
|
+
add_member_collection_to_path(new_namespace_path, method_name)
|
78
81
|
end
|
79
82
|
|
80
83
|
new_namespace_path
|
81
84
|
end
|
82
85
|
|
86
|
+
def add_namespace_to_path(path, node)
|
87
|
+
namespace_name = extract_namespace_name(node)
|
88
|
+
path << namespace_name if namespace_name
|
89
|
+
end
|
90
|
+
|
91
|
+
def add_scope_to_path(path, node)
|
92
|
+
scope_name = extract_scope_name(node)
|
93
|
+
path << scope_name if scope_name
|
94
|
+
end
|
95
|
+
|
96
|
+
def add_resource_to_path(path, node)
|
97
|
+
resource_name = extract_namespace_name(node)
|
98
|
+
path << resource_name if resource_name
|
99
|
+
end
|
100
|
+
|
101
|
+
def add_member_collection_to_path(path, method_name)
|
102
|
+
path << method_name.to_s
|
103
|
+
end
|
104
|
+
|
83
105
|
def extract_namespace_name(node)
|
84
106
|
first_arg = node.arguments.first
|
85
107
|
return first_arg.value.to_s if first_arg&.sym_type? || first_arg&.str_type?
|
@@ -199,6 +221,7 @@ module RuboCop
|
|
199
221
|
|
200
222
|
def extract_simple_route_name(first_arg)
|
201
223
|
return first_arg.value.to_s if first_arg&.str_type?
|
224
|
+
return first_arg.value.to_s if first_arg&.sym_type?
|
202
225
|
return extract_hash_route_name(first_arg) if first_arg&.hash_type?
|
203
226
|
|
204
227
|
'unknown'
|