Skip to content

Commit

Permalink
add a rule to discourage the usage of World/ActiveWorld
Browse files Browse the repository at this point in the history
  • Loading branch information
estebanlm committed Jun 17, 2019
1 parent adf47e5 commit 55baca1
Showing 1 changed file with 43 additions and 0 deletions.
43 changes: 43 additions & 0 deletions src/GeneralRules/RBUsesWorldGlobalRule.class.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
"
The direct use of the global variables World and ActiveWorld is incorrect.
Use ""self currentWorld"" instead.
"
Class {
#name : #RBUsesWorldGlobalRule,
#superclass : #ReNodeBasedRule,
#category : #'GeneralRules-Migrated'
}

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

^'UsesWorldGlobalRule'
]

{ #category : #running }
RBUsesWorldGlobalRule >> check: aNode forCritiquesDo: aCriticBlock [

(aNode isVariable
and: [ aNode isGlobal
and: [ #(#World #ActiveWorld) includes: aNode name ] ])
ifFalse: [ ^ self ].

aCriticBlock cull: (self critiqueFor: aNode)
]

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

{ #category : #accessing }
RBUsesWorldGlobalRule >> name [
^ 'Uses World/ActiveWorld directly'
]

{ #category : #accessing }
RBUsesWorldGlobalRule >> severity [

^ #warning
]

0 comments on commit 55baca1

Please sign in to comment.