Skip to content

Commit

Permalink
Merge pull request pharo-project#14672 from MarcusDenker/use-whichMet…
Browse files Browse the repository at this point in the history
…hodsReferTo

Small refactoring: use #whichMethodsReferTo, not #whichSelectorsReferTo
  • Loading branch information
jecisc authored Sep 16, 2023
2 parents 57f421a + ad45f33 commit 42df80e
Show file tree
Hide file tree
Showing 407 changed files with 7,659 additions and 6,911 deletions.
18 changes: 10 additions & 8 deletions src/GeneralRules/ReAddRemoveDependentsRule.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,26 @@
Check that the number of addDependent: message sends in a class is less than or equal to the number of removeDependent: messages. If there are more addDependent: messages that may signify that some dependents are not being released, which may lead to memory leaks.
"
Class {
#name : #ReAddRemoveDependentsRule,
#superclass : #ReAbstractRule,
#category : #'GeneralRules-Migrated'
#name : 'ReAddRemoveDependentsRule',
#superclass : 'ReAbstractRule',
#category : 'GeneralRules-Migrated',
#package : 'GeneralRules',
#tag : 'Migrated'
}

{ #category : #testing }
{ #category : 'testing' }
ReAddRemoveDependentsRule class >> checksClass [
^ true
]

{ #category : #accessing }
{ #category : 'accessing' }
ReAddRemoveDependentsRule class >> uniqueIdentifierName [
"This number should be unique and should change only when the rule completely change semantics"

^'AddRemoveDependentsRule'
]

{ #category : #running }
{ #category : 'running' }
ReAddRemoveDependentsRule >> basicCheck: aClass [
| methods addSends removeSends |
addSends := 0.
Expand All @@ -33,12 +35,12 @@ ReAddRemoveDependentsRule >> basicCheck: aClass [
^ addSends > removeSends
]

{ #category : #accessing }
{ #category : 'accessing' }
ReAddRemoveDependentsRule >> group [
^ 'Potential Bugs'
]

{ #category : #accessing }
{ #category : 'accessing' }
ReAddRemoveDependentsRule >> name [
^ 'Number of addDependent: messages > removeDependent:'
]
18 changes: 10 additions & 8 deletions src/GeneralRules/ReAllAnyNoneSatisfyRule.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -16,24 +16,26 @@ collection allSatisfy: [ :each | condition ]
]]]
"
Class {
#name : #ReAllAnyNoneSatisfyRule,
#superclass : #ReNodeRewriteRule,
#category : #'GeneralRules-Migrated'
#name : 'ReAllAnyNoneSatisfyRule',
#superclass : 'ReNodeRewriteRule',
#category : 'GeneralRules-Migrated',
#package : 'GeneralRules',
#tag : 'Migrated'
}

{ #category : #accessing }
{ #category : 'accessing' }
ReAllAnyNoneSatisfyRule class >> uniqueIdentifierName [
"This number should be unique and should change only when the rule completely change semantics"

^'AllAnyNoneSatisfyRule'
]

{ #category : #accessing }
{ #category : 'accessing' }
ReAllAnyNoneSatisfyRule >> group [
^ 'Coding Idiom Violation'
]

{ #category : #initialization }
{ #category : 'initialization' }
ReAllAnyNoneSatisfyRule >> initialize [
super initialize.
self
Expand Down Expand Up @@ -93,12 +95,12 @@ ReAllAnyNoneSatisfyRule >> initialize [
`@condition ]'
]

{ #category : #accessing }
{ #category : 'accessing' }
ReAllAnyNoneSatisfyRule >> name [
^ 'Replace with #allSatisfy:, #anySatisfy: or #noneSatisfy:'
]

{ #category : #accessing }
{ #category : 'accessing' }
ReAllAnyNoneSatisfyRule >> rationale [
^ 'Replace ad-hoc implementations (using explicit logic based on do:) of allSatisfy:, anySatisfy: and noneSatisfy: by the adequate calls to #allSatisfy:, #anySatisfy: or #noneSatisfy:. '
]
16 changes: 9 additions & 7 deletions src/GeneralRules/ReAsClassRule.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,20 @@ Do not use methods such as
because they do not take into account an environment. Instead use `self class environment at: #ClassName`
"
Class {
#name : #ReAsClassRule,
#superclass : #ReNodeRewriteRule,
#category : #'GeneralRules-Migrated'
#name : 'ReAsClassRule',
#superclass : 'ReNodeRewriteRule',
#category : 'GeneralRules-Migrated',
#package : 'GeneralRules',
#tag : 'Migrated'
}

{ #category : #accessing }
{ #category : 'accessing' }
ReAsClassRule >> group [

^ 'Design Flaws'
]

{ #category : #initialization }
{ #category : 'initialization' }
ReAsClassRule >> initialize [
super initialize.
self
Expand All @@ -33,13 +35,13 @@ ReAsClassRule >> initialize [
with: 'self class environment at: `@expr ifPresent: `@block'
]

{ #category : #accessing }
{ #category : 'accessing' }
ReAsClassRule >> name [

^ 'Do not use #asClass & similar'
]

{ #category : #accessing }
{ #category : 'accessing' }
ReAsClassRule >> severity [

^ #error
Expand Down
16 changes: 9 additions & 7 deletions src/GeneralRules/ReAsOrderedCollectionNotNeededRule.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,26 @@ A prior conversion to an Array or OrderedCollection is not necessary when adding
"
Class {
#name : #ReAsOrderedCollectionNotNeededRule,
#superclass : #ReNodeRewriteRule,
#category : #'GeneralRules-Migrated'
#name : 'ReAsOrderedCollectionNotNeededRule',
#superclass : 'ReNodeRewriteRule',
#category : 'GeneralRules-Migrated',
#package : 'GeneralRules',
#tag : 'Migrated'
}

{ #category : #accessing }
{ #category : 'accessing' }
ReAsOrderedCollectionNotNeededRule class >> uniqueIdentifierName [
"This number should be unique and should change only when the rule completely change semantics"

^'AsOrderedCollectionNotNeededRule'
]

{ #category : #accessing }
{ #category : 'accessing' }
ReAsOrderedCollectionNotNeededRule >> group [
^ 'Optimization'
]

{ #category : #initialization }
{ #category : 'initialization' }
ReAsOrderedCollectionNotNeededRule >> initialize [
super initialize.
#('addAll:' 'removeAll:' 'includesAll:' 'copyWithoutAll:')
Expand All @@ -32,7 +34,7 @@ ReAsOrderedCollectionNotNeededRule >> initialize [
self replace: baseString , conversionMessage with: baseString ] ]
]

{ #category : #accessing }
{ #category : 'accessing' }
ReAsOrderedCollectionNotNeededRule >> name [
^ '#asOrderedCollection/#asArray not needed'
]
16 changes: 9 additions & 7 deletions src/GeneralRules/ReAssignmentInBlockRule.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,26 @@
Checks ensure:, ifCurtailed:, and showWhile: blocks for assignments or returns that are the last statement in the block. These assignments or returns can be moved outside the block since these messages return the value of the block.
"
Class {
#name : #ReAssignmentInBlockRule,
#superclass : #ReNodeMatchRule,
#category : #'GeneralRules-Migrated'
#name : 'ReAssignmentInBlockRule',
#superclass : 'ReNodeMatchRule',
#category : 'GeneralRules-Migrated',
#package : 'GeneralRules',
#tag : 'Migrated'
}

{ #category : #accessing }
{ #category : 'accessing' }
ReAssignmentInBlockRule class >> uniqueIdentifierName [
"This number should be unique and should change only when the rule completely change semantics"

^'AssignmentInBlockRule'
]

{ #category : #accessing }
{ #category : 'accessing' }
ReAssignmentInBlockRule >> group [
^ 'Coding Idiom Violation'
]

{ #category : #initialization }
{ #category : 'initialization' }
ReAssignmentInBlockRule >> initialize [
super initialize.
self matchesAny: #(
Expand All @@ -31,7 +33,7 @@ ReAssignmentInBlockRule >> initialize [
'[| `@temps | `@.Statements. ^`@object] ifCurtailed: `@block' )
]

{ #category : #accessing }
{ #category : 'accessing' }
ReAssignmentInBlockRule >> name [
^ 'Unnecessary assignment or return in block'
]
18 changes: 10 additions & 8 deletions src/GeneralRules/ReAssignmentInIfTrueRule.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -10,24 +10,26 @@ var := test
ifFalse: [2]
"
Class {
#name : #ReAssignmentInIfTrueRule,
#superclass : #ReNodeRewriteRule,
#category : #'GeneralRules-Migrated'
#name : 'ReAssignmentInIfTrueRule',
#superclass : 'ReNodeRewriteRule',
#category : 'GeneralRules-Migrated',
#package : 'GeneralRules',
#tag : 'Migrated'
}

{ #category : #accessing }
{ #category : 'accessing' }
ReAssignmentInIfTrueRule class >> uniqueIdentifierName [
"This number should be unique and should change only when the rule completely change semantics"

^'AssignmentInIfTrueRule'
]

{ #category : #accessing }
{ #category : 'accessing' }
ReAssignmentInIfTrueRule >> group [
^ 'Optimization'
]

{ #category : #initialization }
{ #category : 'initialization' }
ReAssignmentInIfTrueRule >> initialize [
super initialize.
self
Expand All @@ -37,12 +39,12 @@ ReAssignmentInIfTrueRule >> initialize [
with: '`variable := ``@Boolean ifFalse: [``@true] ifTrue: [``@false]'
]

{ #category : #accessing }
{ #category : 'accessing' }
ReAssignmentInIfTrueRule >> name [
^ 'Move variable assignment outside of single statement ifTrue:ifFalse: blocks'
]

{ #category : #accessing }
{ #category : 'accessing' }
ReAssignmentInIfTrueRule >> rationale [
^ 'Moving assignments outside blocks leads to shorter and more efficient code.'
]
18 changes: 10 additions & 8 deletions src/GeneralRules/ReAssignmentWithoutEffectRule.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -2,35 +2,37 @@
This smell arises when a statement such as x := x is found. This statement has not effect, it can be removed.
"
Class {
#name : #ReAssignmentWithoutEffectRule,
#superclass : #ReNodeRewriteRule,
#category : #'GeneralRules-Migrated'
#name : 'ReAssignmentWithoutEffectRule',
#superclass : 'ReNodeRewriteRule',
#category : 'GeneralRules-Migrated',
#package : 'GeneralRules',
#tag : 'Migrated'
}

{ #category : #accessing }
{ #category : 'accessing' }
ReAssignmentWithoutEffectRule class >> uniqueIdentifierName [
"This number should be unique and should change only when the rule completely change semantics"

^'AssignmentWithoutEffectRule'
]

{ #category : #accessing }
{ #category : 'accessing' }
ReAssignmentWithoutEffectRule >> group [
^ 'Optimization'
]

{ #category : #initialization }
{ #category : 'initialization' }
ReAssignmentWithoutEffectRule >> initialize [
super initialize.
self replace: '`var := `var' with: ''
]

{ #category : #accessing }
{ #category : 'accessing' }
ReAssignmentWithoutEffectRule >> name [
^ 'Assignment has no effect'
]

{ #category : #accessing }
{ #category : 'accessing' }
ReAssignmentWithoutEffectRule >> severity [
^ #information
]
16 changes: 9 additions & 7 deletions src/GeneralRules/ReAtIfAbsentRule.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,26 @@ Replaces at:ifAbsent: by at:ifAbsentPut:. Its leads to shorter and more readable
"
Class {
#name : #ReAtIfAbsentRule,
#superclass : #ReNodeRewriteRule,
#category : #'GeneralRules-Migrated'
#name : 'ReAtIfAbsentRule',
#superclass : 'ReNodeRewriteRule',
#category : 'GeneralRules-Migrated',
#package : 'GeneralRules',
#tag : 'Migrated'
}

{ #category : #accessing }
{ #category : 'accessing' }
ReAtIfAbsentRule class >> uniqueIdentifierName [
"This number should be unique and should change only when the rule completely change semantics"

^'AtIfAbsentRule'
]

{ #category : #accessing }
{ #category : 'accessing' }
ReAtIfAbsentRule >> group [
^ 'Coding Idiom Violation'
]

{ #category : #initialization }
{ #category : 'initialization' }
ReAtIfAbsentRule >> initialize [
super initialize.
self
Expand All @@ -46,7 +48,7 @@ ReAtIfAbsentRule >> initialize [
``@object]'
]

{ #category : #accessing }
{ #category : 'accessing' }
ReAtIfAbsentRule >> name [
^ 'at:ifAbsent: -> at:ifAbsentPut:'
]
Loading

0 comments on commit 42df80e

Please sign in to comment.