rubocop-fourshark 0.8.0 → 0.8.1

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: a3715ce918bf2499ae19801f42db4966430bc7a2ae33aae165bc7676865bdfc3
4
- data.tar.gz: 48d1eac2b33b6971b80463057f859d4f2cbc5efa5d03d298484a9819cb1c1989
3
+ metadata.gz: 31d77a73abb724b68a4c2d187cc780899067d2ef82564e50bcce0d6b09dbffeb
4
+ data.tar.gz: fd2eda214bf001b848e18be1f68df32463d70272be3f7ce999ac7cb3b1be8f8f
5
5
  SHA512:
6
- metadata.gz: 2cb23a767a11947a89a3792c32cb9a3da0e888c83ebd377447b71e9ec21c4643a3105bf361d445fdd1d942b3f92894e68989efcceed7ba4946077f882cdb36b4
7
- data.tar.gz: c9f15b6c4a0a3340ead5387783a0585423c44a3e299143910c145d3bf086d15924a2d0e93a87213ff2da8f059c6cd897fd05a7f04fe9d6ff29b0517e9d00885b
6
+ metadata.gz: 61aabc197c8224de85d39c9f150cb0fb1b73916a8882fd35cb3241b4b5ca330eb44f4098a12eff4fc934b918ea2ccf75a81bd150c1eac96193678ef620ae734c
7
+ data.tar.gz: b0b7426b78afa3a99f028eb84b4dd78479c153d219997d55611e7e1ab3544ddfe99ead0b323306c24220c9806715ddf413b1ace76bdb19df8ccad9bb43391562
data/CHANGELOG.md CHANGED
@@ -1,3 +1,9 @@
1
+ ## [0.8.1] - 2026-08-06
2
+
3
+ ### Fixed
4
+
5
+ - `Style/DisallowDelegate` — a method answering about its own class is no longer flagged
6
+
1
7
  ## [0.8.0] - 2026-08-05
2
8
 
3
9
  ### Changed
@@ -17,6 +17,11 @@ module RuboCop
17
17
  # the forwarder by hand changes what `grep` finds, not what the class
18
18
  # claims to be responsible for.
19
19
  #
20
+ # `self.class` is not a collaborator — it is the object's own class. An
21
+ # instance method that composes its own attributes into a same-named class
22
+ # method answers for a domain it owns, so it is not delegation and is not
23
+ # flagged.
24
+ #
20
25
  # @example
21
26
  # # bad
22
27
  # delegate :name, to: :commission
@@ -29,6 +34,11 @@ module RuboCop
29
34
  # # good — the caller navigates
30
35
  # statement.commission.name
31
36
  #
37
+ # # good — the object answers about itself, not for a collaborator
38
+ # def lock_key
39
+ # self.class.lock_key(company_id: company_id)
40
+ # end
41
+ #
32
42
  class DisallowDelegate < ::RuboCop::Cop::Base
33
43
  MACRO_MSG = 'Do not use automatic delegation. Delete the forwarder and let the caller navigate.'
34
44
  FORWARDER_MSG = 'Do not forward a collaborator\'s message. Delete the forwarder and let the caller navigate.'
@@ -53,9 +63,18 @@ module RuboCop
53
63
  return false if body.nil?
54
64
  return false unless body.send_type?
55
65
  return false if body.receiver.nil?
66
+ return false if own_class?(body.receiver)
56
67
 
57
68
  body.method?(method_name)
58
69
  end
70
+
71
+ def own_class?(receiver)
72
+ return false unless receiver.send_type?
73
+ return false unless receiver.method?(:class)
74
+ return false if receiver.receiver.nil?
75
+
76
+ receiver.receiver.self_type?
77
+ end
59
78
  end
60
79
  end
61
80
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module RuboCop
4
4
  module Fourshark
5
- VERSION = '0.8.0'
5
+ VERSION = '0.8.1'
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rubocop-fourshark
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.0
4
+ version: 0.8.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Paulo Ribeiro