SystemOrganization addCategory: #'Refactoring-Tests-Spelling'! SystemOrganization addCategory: #'Refactoring-Tests-Spelling-Data'! SystemOrganization addCategory: #'Refactoring-Tests-Spelling-Eror'! Object subclass: #RBArgumentVariableNamesSpellingClass instanceVariableNames: '' classVariableNames: '' poolDictionaries: '' category: 'Refactoring-Tests-Spelling-Data'! !RBArgumentVariableNamesSpellingClass commentStamp: 'StanShepherd 1/8/2010 22:26' prior: 0! I have a spelling error in a method variable! !RBArgumentVariableNamesSpellingClass methodsFor: 'intentional-errors' stamp: 'StanShepherd 1/8/2010 21:10'! argumentVariableNamesSpelling: rong ^self! ! Object subclass: #RBClassCategorySpellingClass instanceVariableNames: '' classVariableNames: '' poolDictionaries: '' category: 'Refactoring-Tests-Spelling-Eror'! !RBClassCategorySpellingClass commentStamp: 'StanShepherd 1/9/2010 18:32' prior: 0! I am just here to be in a category with a spelling error! Object subclass: #RBClassCommentsSpellingClass instanceVariableNames: '' classVariableNames: '' poolDictionaries: '' category: 'Refactoring-Tests-Spelling-Data'! !RBClassCommentsSpellingClass commentStamp: 'StanShepherd 1/8/2010 22:12' prior: 0! I intentionally have a ftmch spelling! Object subclass: #RBClassNamesSpellingClassFolt instanceVariableNames: '' classVariableNames: '' poolDictionaries: '' category: 'Refactoring-Tests-Spelling-Data'! !RBClassNamesSpellingClassFolt commentStamp: 'StanShepherd 1/9/2010 13:11' prior: 0! I have a spelling error in my name! Object subclass: #RBClassVariableNamesSpellingClass instanceVariableNames: '' classVariableNames: 'GoodVariable Yelnats' poolDictionaries: '' category: 'Refactoring-Tests-Spelling-Data'! !RBClassVariableNamesSpellingClass commentStamp: 'StanShepherd 1/9/2010 13:12' prior: 0! I have a class variable name spelling error ! Object subclass: #RBCorrectSpellingClass instanceVariableNames: '' classVariableNames: 'GoodVariable' poolDictionaries: 'ChronologyConstants' category: 'Refactoring-Tests-Spelling-Data'! !RBCorrectSpellingClass commentStamp: 'StanShepherd 1/12/2010 13:44' prior: 0! My class comments contain correct spelling. I have correct spelling everywhere. In previous versions, the sequence 'RB' would give a false positive of the letter bee Similarly, WARenderCanvas or 'WARenderCanvas' or YAGNI or 'YAGNI' would be fine, but 'IT' is not OK or 'OK'. Unfortunately, the standard dictionary does not contain re factor ring. Also, we don't want to catch single quote abbreviations, such as 'don't' We do want to allow method' s spelling, but the standard dictionary does not. It does not allow the abbreviation of does not. 'methods'' is OK ! !RBCorrectSpellingClass class methodsFor: 'correct-spelling' stamp: 'StanShepherd 1/9/2010 10:39'! methodCommentsSpellingRuleCheckClassSide "The is the correct spelling" ^self! ! !RBCorrectSpellingClass methodsFor: 'correctly-spelled' stamp: 'StanShepherd 1/8/2010 21:11'! argumentVariableNamesSpelling: right ^self! ! !RBCorrectSpellingClass methodsFor: 'correctly-spelled' stamp: 'StanShepherd 1/9/2010 01:03'! listSomeLiterals (#literalGood = 'this should find no error') ifTrue:[ ^'I am amazed']. ^{#literalGood. 'this should find no error'. }! ! !RBCorrectSpellingClass methodsFor: 'correctly-spelled' stamp: 'StanShepherd 1/9/2010 10:38'! methodCommentsSpellingRuleCheck "Caesar had some jam for tea" ^self! ! !RBCorrectSpellingClass methodsFor: 'correctly-spelled' stamp: 'StanShepherd 1/9/2010 01:52'! temporaryVariableNamesSpelling | rightTemporary | ^self! ! Object subclass: #RBInstanceVariableNamesSpellingClass instanceVariableNames: 'goodVariable drehpehs' classVariableNames: '' poolDictionaries: '' category: 'Refactoring-Tests-Spelling-Data'! !RBInstanceVariableNamesSpellingClass commentStamp: 'StanShepherd 1/9/2010 18:58' prior: 0! I have variable name spelling errors Instance Variables drehpehs goodVariable ! Object subclass: #RBLiteralValuesSpellingClass instanceVariableNames: '' classVariableNames: '' poolDictionaries: '' category: 'Refactoring-Tests-Spelling-Data'! !RBLiteralValuesSpellingClass commentStamp: 'StanShepherd 1/9/2010 13:14' prior: 0! I have literal spelling errors ! !RBLiteralValuesSpellingClass methodsFor: 'intentional-errors' stamp: 'StanShepherd 1/9/2010 01:05'! listSomeLiterals #loteralBad = 'this should find sume errurs' ifTrue: [ ^ 'I am gobsmacked' ]. ^ {#loteral. 'this should find en erur'}! ! Object subclass: #RBMethodCommentsSpellingClass instanceVariableNames: '' classVariableNames: '' poolDictionaries: '' category: 'Refactoring-Tests-Spelling-Data'! !RBMethodCommentsSpellingClass commentStamp: 'StanShepherd 1/9/2010 13:15' prior: 0! I have method comments spelling errors ! !RBMethodCommentsSpellingClass methodsFor: 'intentional-errors' stamp: 'StanShepherd 1/9/2010 10:30'! methodCommentsSpellingRuleCheck "floccinaucinihilipilificashun is a typo for floccinaucinihilipilification. that is likely not in the standard dictionaries either" ^self! ! Object subclass: #RBMethodCommentsSpellingClassSideClass instanceVariableNames: '' classVariableNames: '' poolDictionaries: '' category: 'Refactoring-Tests-Spelling-Data'! !RBMethodCommentsSpellingClassSideClass commentStamp: 'StanShepherd 1/9/2010 13:15' prior: 0! I have method comments spelling errors on my class side ! !RBMethodCommentsSpellingClassSideClass class methodsFor: 'intentional-errors' stamp: 'StanShepherd 1/9/2010 10:49'! methodCommentsSpellingRuleCheckClassSide "teh is a common error. Ftmch is not." ^self! ! Object subclass: #RBMethodProtocolsSpellingClass instanceVariableNames: '' classVariableNames: '' poolDictionaries: '' category: 'Refactoring-Tests-Spelling-Data'! !RBMethodProtocolsSpellingClass commentStamp: 'StanShepherd 1/9/2010 13:16' prior: 0! I have method protocol spelling errors ! !RBMethodProtocolsSpellingClass methodsFor: 'intentionally-missspelt' stamp: 'StanShepherd 1/9/2010 01:57'! methodProtocolsSpellingRuleCheck ^self! ! Object subclass: #RBMethodProtocolsSpellingClassSideClass instanceVariableNames: '' classVariableNames: '' poolDictionaries: '' category: 'Refactoring-Tests-Spelling-Data'! !RBMethodProtocolsSpellingClassSideClass commentStamp: 'StanShepherd 1/9/2010 13:16' prior: 0! I have method protocols spelling errors on my class side ! !RBMethodProtocolsSpellingClassSideClass class methodsFor: 'intentionally-missspeltclass' stamp: 'StanShepherd 1/9/2010 02:02'! methodProtocolsSpellingRuleCheck ^self! ! Object subclass: #RBMethodSelectorsSpellingClass instanceVariableNames: '' classVariableNames: '' poolDictionaries: '' category: 'Refactoring-Tests-Spelling-Data'! !RBMethodSelectorsSpellingClass commentStamp: 'StanShepherd 1/9/2010 13:17' prior: 0! I have method selector spelling errors ! !RBMethodSelectorsSpellingClass methodsFor: 'intentional-errors' stamp: 'StanShepherd 1/9/2010 10:06'! methodSelectorsSpellingBleurghRuleCheck ^self! ! Object subclass: #RBMethodSelectorsSpellingClassSideClass instanceVariableNames: '' classVariableNames: '' poolDictionaries: '' category: 'Refactoring-Tests-Spelling-Data'! !RBMethodSelectorsSpellingClassSideClass commentStamp: 'StanShepherd 1/9/2010 13:17' prior: 0! I have method selector spelling errors on my class side ! !RBMethodSelectorsSpellingClassSideClass class methodsFor: 'intentional-errors' stamp: 'StanShepherd 1/9/2010 10:18'! floccinaucinihilipilificashunMethodSelectorsSpellingRuleCheck ^self! ! !RBMethodSelectorsSpellingClassSideClass class methodsFor: 'intentional-errors' stamp: 'StanShepherd 1/9/2010 10:20'! methodSelectorsFloccinaucinihilipilificashunSpellingRuleCheck ^self! ! Object subclass: #RBPoolDictionaryNameSpellingClass instanceVariableNames: '' classVariableNames: '' poolDictionaries: 'Smalltalk' category: 'Refactoring-Tests-Spelling-Data'! !RBPoolDictionaryNameSpellingClass commentStamp: 'StanShepherd 1/9/2010 13:18' prior: 0! I have pool dictionary spelling errors. The pool variable test should perhaps be renamed? ! Object subclass: #RBTemporaryVariableNamesSpellingClass instanceVariableNames: '' classVariableNames: '' poolDictionaries: '' category: 'Refactoring-Tests-Spelling-Data'! !RBTemporaryVariableNamesSpellingClass commentStamp: 'StanShepherd 1/9/2010 13:19' prior: 0! I have temporary variable spelling errors. ! !RBTemporaryVariableNamesSpellingClass methodsFor: 'intentional-errors' stamp: 'StanShepherd 1/9/2010 01:51'! temporaryVariableNamesSpelling | rongTemporary | ^self! ! Object subclass: #RBTemporaryVariableNamesSpellingClassSideClass instanceVariableNames: '' classVariableNames: '' poolDictionaries: '' category: 'Refactoring-Tests-Spelling-Data'! !RBTemporaryVariableNamesSpellingClassSideClass commentStamp: 'StanShepherd 1/9/2010 13:19' prior: 0! I have temporary variable spelling errors on my class side. ! !RBTemporaryVariableNamesSpellingClassSideClass class methodsFor: 'intentional-errors' stamp: 'StanShepherd 1/9/2010 12:49'! temporaryVariableNamesSpellingClassSide | rongTemporary | ^self! ! RBSpellingRule subclass: #RBPoolDictionaryNamesSpellingRule instanceVariableNames: '' classVariableNames: '' poolDictionaries: '' category: 'Refactoring-Tests-Spelling-Data'! !RBPoolDictionaryNamesSpellingRule methodsFor: 'running' stamp: 'lr 2/24/2009 08:07'! checkClass: aContext (aContext selectedClass isTrait or: [ aContext selectedClass isMeta ]) ifTrue: [ ^ self ]. (self check: aContext selectedClass poolDictionaryNames) do: [ :each | result addSearchString: each; addClass: aContext selectedClass ]! ! !RBPoolDictionaryNamesSpellingRule methodsFor: 'accessing' stamp: 'lr 2/24/2009 07:57'! name ^ 'Pool variable names'! ! !RBPoolDictionaryNamesSpellingRule methodsFor: 'accessing' stamp: 'lr 2/24/2009 07:57'! resultClass ^ ClassEnvironment! ! TestCase subclass: #RBSpellCheckerTest instanceVariableNames: '' classVariableNames: '' poolDictionaries: '' category: 'Refactoring-Tests-Spelling'! TestCase subclass: #RBSpellingRuleTest instanceVariableNames: 'environment packageEnvironment' classVariableNames: '' poolDictionaries: '' category: 'Refactoring-Tests-Spelling'! RBSpellingRuleTest class instanceVariableNames: 'classesRun'! !RBSpellingRuleTest commentStamp: 'StanShepherd 1/8/2010 22:15' prior: 0! For each of the spelling rules, I run the rule. I pass the result to the checking method for that rule class. e.g. RBClassCommentsSpellingRule is checked by #classCommentsSpellingRuleCheck:! RBSpellingRuleTest class instanceVariableNames: 'classesRun'! !RBSpellingRuleTest class methodsFor: 'checking' stamp: 'StanShepherd 1/12/2010 15:03'! addClassRun: aSpellingRuleClass "this list is initialized by the method testAA... for each pass of the test suite" self classesRun add: aSpellingRuleClass ! ! !RBSpellingRuleTest class methodsFor: 'checking' stamp: 'StanShepherd 1/12/2010 14:58'! classesRun ^classesRun ifNil: [classesRun := IdentitySet new] ! ! !RBSpellingRuleTest class methodsFor: 'accessing' stamp: 'StanShepherd 1/12/2010 15:05'! classesRun: anIdentityCollection ^ classesRun := anIdentityCollection ! ! !RBSpellingRuleTest class methodsFor: 'initialize - event' stamp: 'StanShepherd 1/9/2010 12:54'! initialize "Invoke lazy initialization for code critics" super initialize. self history! ! !RBSpellingRuleTest methodsFor: 'checking' stamp: 'StanShepherd 1/9/2010 11:17'! argumentVariableNamesSpellingRuleCheck: aSpellingRuleResult environment := aSpellingRuleResult result. self should: [ environment includesSelector: #argumentVariableNamesSpelling: in: RBArgumentVariableNamesSpellingClass ]; shouldnt: [ environment includesSelector: #argumentVariableNamesSpelling: in: RBCorrectSpellingClass ]! ! !RBSpellingRuleTest methodsFor: 'running' stamp: 'StanShepherd 1/8/2010 22:05'! checkResult: result forClass: aSpellingRuleClass | selector | selector := aSpellingRuleClass name. selector := selector copyFrom: 3 to: selector size. selector := selector, 'Check:'. selector at: 1 put: selector first asLowercase. selector := selector asSymbol. self perform: selector with: result.! ! !RBSpellingRuleTest methodsFor: 'checking' stamp: 'TestRunner 1/20/2010 16:41'! classCategoriesSpellingRuleCheck: aSpellingRuleResult environment := aSpellingRuleResult result. self should: [ environment includesCategory: #'Refactoring-Spelling-Tests-Data-Eror' ] "shouldnt: [ environment includesCategory: #'Refactoring-Tests-Spelling-Data' ] Unfortunately, the standard dictionary does not contain re factor ring"! ! !RBSpellingRuleTest methodsFor: 'checking' stamp: 'StanShepherd 1/12/2010 11:46'! classCommentsSpellingRuleCheck: aSpellingRuleResult environment := aSpellingRuleResult result. self should: [ environment includesClass: RBClassCommentsSpellingClass]; shouldnt: [ environment includesClass: RBCorrectSpellingClass] ! ! !RBSpellingRuleTest methodsFor: 'checking' stamp: 'StanShepherd 1/8/2010 22:29'! classNamesSpellingRuleCheck: aSpellingRuleResult environment := aSpellingRuleResult result. self should: [ environment includesClass: RBClassNamesSpellingClassFolt ]; shouldnt: [ environment includesClass: RBCorrectSpellingClass]! ! !RBSpellingRuleTest methodsFor: 'checking' stamp: 'StanShepherd 1/8/2010 22:36'! classVariableNamesSpellingRuleCheck: aSpellingRuleResult environment := aSpellingRuleResult result. self should: [ environment includesClass: RBClassVariableNamesSpellingClass ]; shouldnt: [ environment includesClass: RBCorrectSpellingClass]! ! !RBSpellingRuleTest methodsFor: 'checking' stamp: 'StanShepherd 1/8/2010 22:39'! instanceVariableNamesSpellingRuleCheck: aSpellingRuleResult environment := aSpellingRuleResult result. self should: [ environment includesClass: RBInstanceVariableNamesSpellingClass ]; shouldnt: [ environment includesClass: RBCorrectSpellingClass]! ! !RBSpellingRuleTest methodsFor: 'checking' stamp: 'StanShepherd 1/9/2010 12:17'! literalValuesSpellingRuleCheck: aSpellingRuleResult environment := aSpellingRuleResult result. self shouldnt: [ environment includesSelector: #listSomeLiterals in: RBCorrectSpellingClass ]; should: [ environment includesSelector: #listSomeLiterals in: RBLiteralValuesSpellingClass ]! ! !RBSpellingRuleTest methodsFor: 'checking' stamp: 'StanShepherd 1/9/2010 12:58'! methodCommentsSpellingRuleCheck: aSpellingRuleResult environment := aSpellingRuleResult result. self shouldnt: [ environment includesSelector: #methodCommentsSpellingRuleCheck in: RBCorrectSpellingClass ]; shouldnt: [ environment includesSelector: #methodCommentsSpellingRuleCheckClassSide in: RBCorrectSpellingClass ]; should: [ environment includesSelector: #methodCommentsSpellingRuleCheck in: RBMethodCommentsSpellingClass ]; should: [ environment includesSelector: #methodCommentsSpellingRuleCheckClassSide in: RBMethodCommentsSpellingClassSideClass class] ! ! !RBSpellingRuleTest methodsFor: 'checking' stamp: 'StanShepherd 1/9/2010 02:09'! methodProtocolsSpellingRuleCheck: aSpellingRuleResult | searchStrings | environment := aSpellingRuleResult result. searchStrings := environment searchStrings. self should: [ searchStrings includes: 'missspelt' ]; should: [ searchStrings includes: 'missspeltclass' ]; shouldnt: [ searchStrings includes: 'correctly' ]! ! !RBSpellingRuleTest methodsFor: 'checking' stamp: 'StanShepherd 1/9/2010 13:04'! methodSelectorsSpellingRuleCheck: aSpellingRuleResult environment := aSpellingRuleResult result. self shouldnt: [ environment includesSelector: #argumentVariableNamesSpelling: in: RBCorrectSpellingClass ]; should: [ environment includesSelector: #methodSelectorsSpellingBleurghRuleCheck in: RBMethodSelectorsSpellingClass ]; should: [ environment includesSelector: #floccinaucinihilipilificashunMethodSelectorsSpellingRuleCheck in: RBMethodSelectorsSpellingClassSideClass class]; should: [ environment includesSelector: #methodSelectorsFloccinaucinihilipilificashunSpellingRuleCheck in: RBMethodSelectorsSpellingClassSideClass class] ! ! !RBSpellingRuleTest methodsFor: 'archive' stamp: 'StanShepherd 1/9/2010 12:23'! oldTestSpelling "I am no longer used, as more granular tests (one per rule) are preferable. I will always fail when a new rule is added. I may be useful for developing new tests for new rules" | result rule rules | rules := RBSpellingRule allSubclasses. (rules copyWithoutAll: {RBLiteralValuesSpellingRule. RBMethodSelectorsSpellingRule. RBMethodCommentsSpellingRule} ) do: [: spellingRuleClass | self runAndcheck: spellingRuleClass]. {RBLiteralValuesSpellingRule. RBMethodSelectorsSpellingRule. RBMethodCommentsSpellingRule} do: [: spellingRuleClassA | self runAndcheck: spellingRuleClassA].! ! !RBSpellingRuleTest methodsFor: 'checking' stamp: 'TestRunner 1/12/2010 09:06'! poolDictionaryNameSpellingRuleCheck: aSpellingRuleResult environment := aSpellingRuleResult result. self should: [ environment includesClass: RBPoolDictionaryNameSpellingClass ]; shouldnt: [ environment includesClass: RBCorrectSpellingClass]! ! !RBSpellingRuleTest methodsFor: 'checking' stamp: 'StanShepherd 1/12/2010 14:19'! poolDictionaryNamesSpellingRuleCheck: aSpellingRuleResult environment := aSpellingRuleResult result. self should: [ environment includesClass: RBPoolDictionaryNameSpellingClass ]; shouldnt: [ environment includesClass: RBCorrectSpellingClass]! ! !RBSpellingRuleTest methodsFor: 'running' stamp: 'StanShepherd 1/12/2010 15:08'! runAndcheck: aSpellingRuleClass | result rule | "keep track of which rules we've run in the class side. Not so elegant, but better than dropping a test without realising" self class addClassRun: aSpellingRuleClass. result := SmalllintChecker runRule: (rule := aSpellingRuleClass new) onEnvironment: packageEnvironment. self checkResult: result forClass: aSpellingRuleClass! ! !RBSpellingRuleTest methodsFor: 'running' stamp: 'lr 1/22/2010 18:44'! setUp environment := BrowserEnvironment new. packageEnvironment := environment forCategories: #(#'Refactoring-Tests-Spelling-Data' #'Refactoring-Tests-Spelling-Eror')! ! !RBSpellingRuleTest methodsFor: 'running' stamp: 'StanShepherd 1/11/2010 22:07'! tearDown environment := nil. packageEnvironment := nil. ! ! !RBSpellingRuleTest methodsFor: 'checking' stamp: 'StanShepherd 1/9/2010 13:07'! temporaryVariableNamesSpellingRuleCheck: aSpellingRuleResult environment := aSpellingRuleResult result. self shouldnt: [ environment includesSelector: #temporaryVariableNamesSpelling in: RBCorrectSpellingClass ]; should: [ environment includesSelector: #temporaryVariableNamesSpelling in: RBTemporaryVariableNamesSpellingClass ]; should: [ environment includesSelector: #temporaryVariableNamesSpellingClassSide in: RBTemporaryVariableNamesSpellingClassSideClass class ] ! ! !RBSpellingRuleTest methodsFor: 'tests' stamp: 'StanShepherd 1/12/2010 14:56'! testAAresetTestCount self class classesRun: IdentitySet new! ! !RBSpellingRuleTest methodsFor: 'tests' stamp: 'StanShepherd 1/9/2010 12:13'! testArgumentVariableNames self runAndcheck: RBArgumentVariableNamesSpellingRule! ! !RBSpellingRuleTest methodsFor: 'tests' stamp: 'StanShepherd 1/9/2010 12:11'! testClassCategories self runAndcheck: RBClassCategoriesSpellingRule! ! !RBSpellingRuleTest methodsFor: 'tests' stamp: 'StanShepherd 1/9/2010 12:14'! testClassComments self runAndcheck: RBClassCommentsSpellingRule! ! !RBSpellingRuleTest methodsFor: 'tests' stamp: 'StanShepherd 1/9/2010 12:09'! testClassNames self runAndcheck: RBClassNamesSpellingRule! ! !RBSpellingRuleTest methodsFor: 'tests' stamp: 'StanShepherd 1/9/2010 12:08'! testClassVariableNames self runAndcheck: RBClassVariableNamesSpellingRule! ! !RBSpellingRuleTest methodsFor: 'tests' stamp: 'StanShepherd 1/9/2010 12:07'! testInstanceVariableNames self runAndcheck: RBInstanceVariableNamesSpellingRule! ! !RBSpellingRuleTest methodsFor: 'tests' stamp: 'StanShepherd 1/9/2010 12:08'! testLiteralValues self runAndcheck: RBLiteralValuesSpellingRule! ! !RBSpellingRuleTest methodsFor: 'tests' stamp: 'StanShepherd 1/9/2010 12:13'! testMethodComments self runAndcheck: RBMethodCommentsSpellingRule! ! !RBSpellingRuleTest methodsFor: 'tests' stamp: 'StanShepherd 1/9/2010 12:10'! testMethodProtocols self runAndcheck: RBMethodProtocolsSpellingRule! ! !RBSpellingRuleTest methodsFor: 'tests' stamp: 'StanShepherd 1/9/2010 12:10'! testMethodSelectors self runAndcheck: RBMethodSelectorsSpellingRule! ! !RBSpellingRuleTest methodsFor: 'tests' stamp: 'StanShepherd 1/12/2010 14:17'! testPoolVariable self runAndcheck: RBPoolDictionaryNamesSpellingRule ! ! !RBSpellingRuleTest methodsFor: 'tests' stamp: 'StanShepherd 1/9/2010 12:09'! testTemporaryVariableNames self runAndcheck: RBTemporaryVariableNamesSpellingRule! ! !RBSpellingRuleTest methodsFor: 'tests' stamp: 'StanShepherd 1/12/2010 15:06'! testZZCheckAllRulesTested self should:[self class classesRun size = 12]! ! RBSpellingRuleTest initialize!