-
-
Notifications
You must be signed in to change notification settings - Fork 346
/
RePointRule.class.st
48 lines (36 loc) · 1.04 KB
/
RePointRule.class.st
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
"
This smell arise when a method contains a creation of an instance Point in this way :
Point x: y:
prefer use x@y to create an instance of Point.
"
Class {
#name : 'RePointRule',
#superclass : 'ReNodeBasedRule',
#category : 'General-Rules-Migrated',
#package : 'General-Rules',
#tag : 'Migrated'
}
{ #category : 'manifest' }
RePointRule class >> uniqueIdentifierName [
"This number should be unique and should change only when the rule completely change semantics"
^ 'PointRule'
]
{ #category : 'running' }
RePointRule >> basicCheck: aNode [
aNode isMessage ifFalse: [ ^ false ].
aNode receiver isMessage ifTrue: [ ^ false ].
aNode isSelfSend ifTrue: [ ^ false ].
^ (#( #x:y: ) includes: aNode selector ) and: [ aNode receiver name == Point name ]
]
{ #category : 'accessing' }
RePointRule >> group [
^ 'Optimization'
]
{ #category : 'accessing' }
RePointRule >> name [
^ 'prefer to use x@y instead of Point x: x y: y'
]
{ #category : 'accessing' }
RePointRule >> rationale [
^ 'it''s much faster to use x@y than Point x:x y:y'
]