rubocop-rspec_parity 1.2.1 → 1.2.2
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/CHANGELOG.md +4 -0
- data/lib/rubocop/cop/rspec_parity/public_method_has_spec.rb +23 -1
- data/lib/rubocop/rspec_parity/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 7f6cb712ad716f1a6c82659cd5114785bd93f7ed7344fb2ba6317de8bae3d37e
|
|
4
|
+
data.tar.gz: 2588d5b16c636142a361c2d0723d049099e7e1da76ed30b72b0c78b211734fb9
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: a2d8de79c7cf285c21e656b96ac473037aabd21c9d206753d44c863b6844d9393217bdf1850b21646f96996355270467e07d711230702fbbb6ed51b4c3536699
|
|
7
|
+
data.tar.gz: 65836a3ae64470aa713d5c3492fb33b993d137f66f1be2d464104a3ce75a22733dd0a055fd2875f6d7ad24c25b407869d42bfebb9d494c3416a4d7003813d8b8
|
data/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
## [Unreleased]
|
|
2
2
|
|
|
3
|
+
## [1.2.2] - 2026-02-10
|
|
4
|
+
|
|
5
|
+
Added: `PublicMethodHasSpec` now skips class methods marked with `private_class_method` (both inline and post-hoc forms)
|
|
6
|
+
|
|
3
7
|
## [1.2.1] - 2026-02-09
|
|
4
8
|
|
|
5
9
|
Fixed: Detect tested methods correctly for classes nested inside modules (e.g. `Calendar::UserCreator`)
|
|
@@ -36,13 +36,35 @@ module RuboCop
|
|
|
36
36
|
end
|
|
37
37
|
|
|
38
38
|
def on_defs(node)
|
|
39
|
-
return unless checkable_method?(node)
|
|
39
|
+
return unless checkable_method?(node) && public_class_method?(node)
|
|
40
40
|
|
|
41
41
|
check_method_has_spec(node, instance_method: false)
|
|
42
42
|
end
|
|
43
43
|
|
|
44
44
|
private
|
|
45
45
|
|
|
46
|
+
def public_class_method?(node)
|
|
47
|
+
# Inline form: private_class_method def self.method_name
|
|
48
|
+
return false if node.parent&.send_type? && node.parent.method_name == :private_class_method
|
|
49
|
+
|
|
50
|
+
# Post-hoc form: private_class_method :method_name
|
|
51
|
+
class_node = find_class_or_module(node)
|
|
52
|
+
return true unless class_node&.body
|
|
53
|
+
|
|
54
|
+
!private_class_method_declared?(class_node, node.method_name)
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
def private_class_method_declared?(class_node, method_name)
|
|
58
|
+
children = class_node.body.begin_type? ? class_node.body.children : [class_node.body]
|
|
59
|
+
children.any? { |child| private_class_method_call?(child, method_name) }
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
def private_class_method_call?(node, method_name)
|
|
63
|
+
node&.send_type? &&
|
|
64
|
+
node.method_name == :private_class_method &&
|
|
65
|
+
node.arguments.any? { |arg| arg.sym_type? && arg.value == method_name }
|
|
66
|
+
end
|
|
67
|
+
|
|
46
68
|
def checkable_method?(node)
|
|
47
69
|
should_check_file? && !excluded_method?(node.method_name.to_s)
|
|
48
70
|
end
|