Skip to content

Commit

Permalink
Two more Slime rules ported
Browse files Browse the repository at this point in the history
  • Loading branch information
jbrichau committed Jan 7, 2024
1 parent 18a37b0 commit e34bcc2
Show file tree
Hide file tree
Showing 16 changed files with 69 additions and 7 deletions.
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
accessing
group

^ 'Grease Portability'
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
initialization
initialize

super initialize.
self matchesAny: #(
'`@receiver canPerform: `@selector'
'`@receiver canUnderstand: `@selector' )
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
accessing
name

^ 'Sends #canPerform: or #canUnderstand:'
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
accessing
rationale

^ '#canPerform: or #canUnderstand: are not portable.'
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"commentStamp" : "",
"super" : "GRReSlimeParseTreeLintRule",
"category" : "Grease-Pharo110-Slime",
"classinstvars" : [ ],
"pools" : [ ],
"classvars" : [ ],
"instvars" : [ ],
"name" : "GRUsesCanPerformOrUnderstandRule",
"type" : "normal"
}
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
hooks
afterCheck: aNode mappings: mappingDict

^ aNode methodNode selector = #hash
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
accessing
group

^ 'Grease Portability'
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
initialization
initialize

super initialize.
self matches: '`@receiver class hash'
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
accessing
name

^ 'Uses its class for hash'
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
accessing
rationale

^ 'The hash of an object should not depend on the hash of its class as some Smalltalk have non-constant class hashes.'
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"commentStamp" : "",
"super" : "GRReSlimeParseTreeLintRule",
"category" : "Grease-Pharo110-Slime",
"classinstvars" : [ ],
"pools" : [ ],
"classvars" : [ ],
"instvars" : [ ],
"name" : "GRUsesClassForHashRule",
"type" : "normal"
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ testEmptyStatements
self
assertRule: ReMultiplePeriodsTerminatingStatementRule
matches: { class>>#emptyStatement1 . class>>#emptyStatement2 . class>>#emptyStatement3 . class>>#emptyStatement4 }
ignoring: (Array with: GRUnnecessaryLastPeriodRule)
ignoring: (Array with: ReUnnecessaryLastPeriodRule)
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
tests-parsetree
testUsesCanPerformOrUnderstand
<expectedFailure>

| class |
class := self defineSubClassOf: #GRObject.
self
Expand All @@ -16,5 +16,5 @@ testUsesCanPerformOrUnderstand
Object respondsTo: #new'
in: class.
self
runRule: GRUsesCanPerformOrUnderstandRule
selectors: #(invalid1 invalid2)
assertRule: GRUsesCanPerformOrUnderstandRule
matches: { class>>#invalid1 . class>>#invalid2 }
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
tests-parsetree
testUsesClassForHash
<expectedFailure>

| class |
class := self defineSubClassOf: #GRObject.
self
Expand All @@ -12,5 +12,5 @@ testUsesClassForHash
^ super hash bitXor: self class hash'
in: class.
self
runRule: GRUsesClassForHashRule
selectors: #(hash)
assertRule: GRUsesClassForHashRule
matches: { class>>#hash }

0 comments on commit e34bcc2

Please sign in to comment.