betterlint 1.6.0 → 1.7.0
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 +4 -4
- data/config/default.yml +1 -1
- data/lib/rubocop/cop/betterment/unscoped_find.rb +19 -4
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ec284b88f4606e1f10bb1a7e0c26794135b2f605077ac2ef472c9fff8ae1d80f
|
4
|
+
data.tar.gz: 25e9df31ca75903e469dadb172847f992b2bf4005679f76cc15343850697c5c2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 56be31837c8216b387b4ad5baa0fb4362152354bb5b5c71ccd95f2cf49d58da5c3499f6765a3509b8773b585bd6a0df22d4092dbeefb2152011ec095520a2293
|
7
|
+
data.tar.gz: c0b3a8a0fde1eae38420afe105cba2a5f9b3ac9d5704695c45337a6ba78ddcd04b8642ba701d610ea2434fb3814459fc810e9e877839c06bb69194bbfabaa564
|
data/config/default.yml
CHANGED
@@ -21,6 +21,7 @@ module RuboCop
|
|
21
21
|
MSG
|
22
22
|
METHOD_PATTERN = /^find_by_(.+?)(!)?$/
|
23
23
|
FINDS = %i(find find_by find_by! where).freeze
|
24
|
+
GRAPHQL_PATTERN = /\bGraphQL\b/i
|
24
25
|
|
25
26
|
def_node_matcher :custom_scope_find?, <<-PATTERN
|
26
27
|
(send (send (const ... _) ...) {#{FINDS.map(&:inspect).join(' ')}} ...)
|
@@ -30,6 +31,10 @@ module RuboCop
|
|
30
31
|
(send (const ... _) {#{FINDS.map(&:inspect).join(' ')}} ...)
|
31
32
|
PATTERN
|
32
33
|
|
34
|
+
def_node_search :find_graphql_namespace_nodes, <<~PATTERN, name: GRAPHQL_PATTERN
|
35
|
+
(const _ %name)
|
36
|
+
PATTERN
|
37
|
+
|
33
38
|
def initialize(config = nil, options = nil)
|
34
39
|
super(config, options)
|
35
40
|
config = @config.for_cop(self)
|
@@ -44,16 +49,26 @@ module RuboCop
|
|
44
49
|
_, _, *arg_nodes = *node # rubocop:disable InternalAffairs/NodeDestructuring
|
45
50
|
return unless
|
46
51
|
(
|
47
|
-
|
48
|
-
|
49
|
-
|
52
|
+
find?(node) ||
|
53
|
+
custom_scope_find?(node) ||
|
54
|
+
static_method_name(node.method_name)
|
50
55
|
) && !@unauthenticated_models.include?(Utils::Parser.get_root_token(node))
|
51
56
|
|
52
|
-
add_offense(node) if find_param_arg(arg_nodes)
|
57
|
+
add_offense(node) if find_param_arg(arg_nodes) || graphql_file? || graphql_namespace?(node)
|
53
58
|
end
|
54
59
|
|
55
60
|
private
|
56
61
|
|
62
|
+
def graphql_file?
|
63
|
+
processed_source.path&.match?(GRAPHQL_PATTERN)
|
64
|
+
end
|
65
|
+
|
66
|
+
def graphql_namespace?(node)
|
67
|
+
node
|
68
|
+
.each_ancestor(:class, :module)
|
69
|
+
.any? { |ancestor| find_graphql_namespace_nodes(ancestor).any? }
|
70
|
+
end
|
71
|
+
|
57
72
|
def find_param_arg(arg_nodes)
|
58
73
|
return unless arg_nodes
|
59
74
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: betterlint
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.7.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Development
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-12-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rubocop
|
@@ -129,7 +129,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
129
129
|
- !ruby/object:Gem::Version
|
130
130
|
version: '0'
|
131
131
|
requirements: []
|
132
|
-
rubygems_version: 3.4.
|
132
|
+
rubygems_version: 3.4.22
|
133
133
|
signing_key:
|
134
134
|
specification_version: 4
|
135
135
|
summary: Betterment rubocop configuration
|