diff --git a/src/Refactoring-Core-Tests/ManifestRefactoringCoreTests.class.st b/src/Refactoring-Core-Tests/ManifestRefactoringCoreTests.class.st new file mode 100644 index 00000000000..8c424296080 --- /dev/null +++ b/src/Refactoring-Core-Tests/ManifestRefactoringCoreTests.class.st @@ -0,0 +1,10 @@ +" +Please describe the package using the class comment of the included manifest class. The manifest class also includes other additional metadata for the package. These meta data are used by other tools such as the SmalllintManifestChecker and the critics Browser +" +Class { + #name : 'ManifestRefactoringCoreTests', + #superclass : 'PackageManifest', + #category : 'Refactoring-Core-Tests-Manifest', + #package : 'Refactoring-Core-Tests', + #tag : 'Manifest' +} diff --git a/src/Refactoring-Core-Tests/RBClassTest.class.st b/src/Refactoring-Core-Tests/RBClassTest.class.st index 19bab66d3c4..c7959979ff7 100644 --- a/src/Refactoring-Core-Tests/RBClassTest.class.st +++ b/src/Refactoring-Core-Tests/RBClassTest.class.st @@ -161,6 +161,35 @@ RBClassTest >> testHierarchy [ self assert: (meta withAllSuperclasses includes: objectClass) ] +{ #category : 'tests - definition' } +RBClassTest >> testHierarchyDefinesClassVariable [ + + | rootClass middleClass lastLeafClass | + + rootClass := rbNamespace classNamed: #RBHierarchyForClassVariable. + middleClass := rbNamespace classNamed: #RBHierarchySubclassAForClassVariable. + lastLeafClass := rbNamespace classNamed: #RBHierarchySubclassBForClassVariable. + + self deny: (rootClass hierarchyDefinesClassVariable: #ClassVariable1). + self assert: (rootClass hierarchyDefinesClassVariable: #ClassVarB). + + self deny: (middleClass hierarchyDefinesClassVariable: #ClassVariable1). + self assert: (middleClass hierarchyDefinesClassVariable: #ClassVarA). + self assert: (middleClass hierarchyDefinesClassVariable: #ClassVarB). + + self deny: (lastLeafClass hierarchyDefinesClassVariable: #ClassVariable1). + self assert: (lastLeafClass hierarchyDefinesClassVariable: #ClassVarA). +] + +{ #category : 'tests - definition' } +RBClassTest >> testHierarchyDefinesPoolDictionary [ + + self deny: (abstractTransformationClass definesPoolDictionary: #OpcodePool). + self assert: (newClass definesPoolDictionary: #TextConstants). + self deny: (refactoringClass definesPoolDictionary: #OpcodePool). + self assert: ((RBNamespace new classNamed: #Text) definesPoolDictionary: #TextConstants) +] + { #category : 'tests - navigation' } RBClassTest >> testIsEmptyClass [ @@ -233,6 +262,26 @@ RBClassTest >> testObjectIsNotAbstract [ self deny: objectClass classSide isAbstract ] +{ #category : 'tests - definition' } +RBClassTest >> testSuperclassRedefines [ + + | rootClass leafClass | + + rootClass := rbNamespace classNamed: #RBEquivalentMethodRootHolder. + leafClass := rbNamespace classNamed: #RBEquivalentMethodSubclassHolder. + self + assert: (leafClass superclassRedefines: #someNumber) + description: 'It test that superclass already defines the existing superimplementor'. + + self + deny: (leafClass superclassRedefines: #anotherMethod:) + description: 'It test that superclass does not define a defined subimplementor'. + + self + assert: (leafClass superclassRedefines: #yourself) + description: 'It test that a non-direct superclass defined the method' +] + { #category : 'tests - defining methods' } RBClassTest >> testWhichClassIncludesSelectorDefinedInTheClass [ diff --git a/src/Refactoring-DataForTesting/ManifestRefactoringDataForTesting.class.st b/src/Refactoring-DataForTesting/ManifestRefactoringDataForTesting.class.st index 5ef36a1bde2..c65ee69ace0 100644 --- a/src/Refactoring-DataForTesting/ManifestRefactoringDataForTesting.class.st +++ b/src/Refactoring-DataForTesting/ManifestRefactoringDataForTesting.class.st @@ -9,6 +9,34 @@ Class { #tag : 'Manifest' } +{ #category : 'code-critics' } +ManifestRefactoringDataForTesting class >> ruleClassNotReferencedRuleV1FalsePositive [ + + + ^ #(#(#(#RGClassDefinition #(#RBHierarchySubclassBForClassVariable)) #'2024-07-18T12:39:47.723158+02:00') #(#(#RGClassDefinition #(#MyClassNonEmptyLeafUnused)) #'2024-07-18T12:40:19.70241+02:00') #(#(#RGClassDefinition #(#RBDummyCompositeLintRuleTest)) #'2024-07-18T12:40:19.702201+02:00') #(#(#RGClassDefinition #(#RBClassUsingSharedPoolForTestData)) #'2024-07-18T12:40:19.701335+02:00') #(#(#RGClassDefinition #(#RBBasicDummyLintRuleTest)) #'2024-07-18T12:40:19.702472+02:00') #(#(#RGClassDefinition #(#RBTransformationRuleTestData2)) #'2024-07-18T12:40:19.701755+02:00') ) +] + +{ #category : 'code-critics' } +ManifestRefactoringDataForTesting class >> ruleEquivalentSuperclassMethodsRuleV1FalsePositive [ + + + ^ #(#(#(#RGMethodDefinition #(#MySubAccessingSuperclassState #accessingSharedVariable #false)) #'2024-07-18T12:38:46.533561+02:00') #(#(#RGMethodDefinition #(#RBTransformationDummyRuleTest1 #openEditor #false)) #'2024-07-18T12:38:46.533586+02:00') #(#(#RGMethodDefinition #(#MySubAccessingSuperclassState #accessing #false)) #'2024-07-18T12:38:46.533614+02:00') #(#(#RGMethodDefinition #(#RBSharedPoolForTestData1 #msg4 #false)) #'2024-07-18T12:38:46.532822+02:00') #(#(#RGMethodDefinition #(#RBEquivalentMethodSubclassHolder #yourself #false)) #'2024-07-18T12:38:46.533594+02:00') #(#(#RGMethodDefinition #(#RBSubclassOfClassToRename #equallyDefinedInSubclass #false)) #'2024-07-18T12:38:46.533603+02:00') #(#(#RGMethodDefinition #(#RBSharedPoolForTestData2 #msg4 #false)) #'2024-07-18T12:38:46.533433+02:00') ) +] + +{ #category : 'code-critics' } +ManifestRefactoringDataForTesting class >> ruleExcessiveArgumentsRuleV1FalsePositive [ + + + ^ #(#(#(#RGMethodDefinition #(#RBBasicLintRuleTestData #method:with:lots:of:arguments: #false)) #'2024-07-18T12:40:39.143779+02:00') #(#(#RGMethodDefinition #(#RBBasicDummyLintRuleTest #method:with:lots:of:arguments: #false)) #'2024-07-18T12:40:39.143696+02:00') ) +] + +{ #category : 'code-critics' } +ManifestRefactoringDataForTesting class >> ruleExcessiveMethodsRuleV1FalsePositive [ + + + ^ #(#(#(#RGClassDefinition #(#RBClassDataForRefactoringTest)) #'2024-07-18T12:41:02.656436+02:00') #(#(#RGMetaclassDefinition #(#'RBBasicDummyLintRuleTest class' #RBBasicDummyLintRuleTest)) #'2024-07-18T12:41:02.656083+02:00') ) +] + { #category : 'code-critics' } ManifestRefactoringDataForTesting class >> ruleNoUnusedInstanceVariableRuleV1FalsePositive [ @@ -16,9 +44,30 @@ ManifestRefactoringDataForTesting class >> ruleNoUnusedInstanceVariableRuleV1Fal ^ #(#(#(#RGClassDefinition #(#ReClassForGeneratingEqualAndHash)) #'2024-07-05T12:05:01.988597+02:00') #(#(#RGClassDefinition #(#ReClassForGeneratingEqualAndHashExistingImplementors)) #'2024-07-05T12:07:30.662537+02:00') ) ] +{ #category : 'code-critics' } +ManifestRefactoringDataForTesting class >> ruleReClassVariableNeitherReadNorWrittenRuleV1FalsePositive [ + + + ^ #(#(#(#RGClassDefinition #(#RBHierarchySubclassAForClassVariable)) #'2024-07-18T12:50:23.92547+02:00') #(#(#RGClassDefinition #(#RBHierarchySubclassBForClassVariable)) #'2024-07-18T12:50:42.673173+02:00') #(#(#RGMetaclassDefinition #(#'RBHierarchySubclassBForClassVariable class' #RBHierarchySubclassBForClassVariable)) #'2024-07-18T14:51:42.347867+02:00') #(#(#RGMetaclassDefinition #(#'RBHierarchySubclassAForClassVariable class' #RBHierarchySubclassAForClassVariable)) #'2024-07-18T14:51:42.347564+02:00') ) +] + { #category : 'code-critics' } ManifestRefactoringDataForTesting class >> ruleReIvarNeitherReadNorWrittenRuleV1FalsePositive [ ^ #(#(#(#RGClassDefinition #(#ReClassForGeneratingPrintOn)) #'2024-06-20T19:43:13.245998+02:00') #(#(#RGClassDefinition #(#ReClassForGeneratingEqualAndHashExistingImplementors)) #'2024-06-20T19:43:13.245838+02:00') #(#(#RGClassDefinition #(#ReClassForGeneratingEqualAndHash)) #'2024-06-20T19:43:13.245672+02:00') ) ] + +{ #category : 'code-critics' } +ManifestRefactoringDataForTesting class >> ruleRefersToClassRuleV1FalsePositive [ + + + ^ #(#(#(#RGMethodDefinition #(#'RBBasicLintRuleTestData class' #modifiesCollection #true)) #'2024-07-18T12:42:35.357229+02:00') #(#(#RGMethodDefinition #(#RBClassDataForRefactoringTest #refersToClass #false)) #'2024-07-18T12:42:35.357361+02:00') ) +] + +{ #category : 'code-critics' } +ManifestRefactoringDataForTesting class >> ruleSendsDifferentSuperRuleV1FalsePositive [ + + + ^ #(#(#(#RGMethodDefinition #(#RBEquivalentMethodSubclassHolder #methodToExtractFromWithSuperAndSimilarMethodInSuper #false)) #'2024-07-18T12:41:57.585437+02:00') #(#(#RGMethodDefinition #(#RBEquivalentMethodRootHolder #methodWithSuper #false)) #'2024-07-18T12:41:57.585423+02:00') #(#(#RGMethodDefinition #(#RBEquivalentMethodSubclassHolder #methodWithSuperSend #false)) #'2024-07-18T12:41:57.585283+02:00') #(#(#RGMethodDefinition #(#RBEquivalentMethodSubclassHolder #methodToExtractFrom #false)) #'2024-07-18T12:41:57.585158+02:00') #(#(#RGMethodDefinition #(#RBClassDataForRefactoringTest #sendsDifferentSuper #false)) #'2024-07-18T12:41:57.585447+02:00') #(#(#RGMethodDefinition #(#RBSubclassOfClassToRename #justSuperSendInSubclassBroken #false)) #'2024-07-18T12:41:57.585456+02:00') ) +] diff --git a/src/Refactoring-DataForTesting/MyClassARoot.class.st b/src/Refactoring-DataForTesting/MyClassARoot.class.st index adb84abc0d5..97a14f01378 100644 --- a/src/Refactoring-DataForTesting/MyClassARoot.class.st +++ b/src/Refactoring-DataForTesting/MyClassARoot.class.st @@ -25,13 +25,13 @@ MyClassARoot class >> accessingFromClassSide [ { #category : 'accessing' } MyClassARoot >> accessing [ - ^ instVarName1 + ^ instVarName1 ] { #category : 'accessing' } MyClassARoot >> accessingSharedVariable [ - ^ Shared1 + ^ Shared1 ] { #category : 'initialization' } diff --git a/src/Refactoring-DataForTesting/MySubAccessingSuperclassState.class.st b/src/Refactoring-DataForTesting/MySubAccessingSuperclassState.class.st index 40bd3b8ec0d..e30ce7c45fe 100644 --- a/src/Refactoring-DataForTesting/MySubAccessingSuperclassState.class.st +++ b/src/Refactoring-DataForTesting/MySubAccessingSuperclassState.class.st @@ -21,19 +21,19 @@ MySubAccessingSuperclassState class >> sharedOnlyInClassSideSubclass [ { #category : 'accessing' } MySubAccessingSuperclassState >> accessing [ - ^ instVarName1 + ^ instVarName1 ] { #category : 'accessing' } MySubAccessingSuperclassState >> accessing2InSub [ - ^ instVarName1 + ^ instVarName1 ] { #category : 'accessing' } MySubAccessingSuperclassState >> accessingSharedVariable [ - ^ Shared1 + ^ Shared1 ] { #category : 'accessing' } @@ -45,5 +45,5 @@ MySubAccessingSuperclassState >> accessingSharedVariable2 [ { #category : 'actions' } MySubAccessingSuperclassState >> writing [ - instVarName1 := 42 + instVarName1 := 42 ] diff --git a/src/Refactoring-DataForTesting/RBBasicLintRuleTestData.class.st b/src/Refactoring-DataForTesting/RBBasicLintRuleTestData.class.st index 7191ce05f8c..7383486c120 100644 --- a/src/Refactoring-DataForTesting/RBBasicLintRuleTestData.class.st +++ b/src/Refactoring-DataForTesting/RBBasicLintRuleTestData.class.st @@ -328,7 +328,7 @@ RBBasicLintRuleTestData >> newResultClass: aClass [ { #category : 'accessing' } RBBasicLintRuleTestData >> onlyReferenceToSomeDemoMethod [ - ^ self onlyReferenceToSomeDemoMethod + ^ self onlyReferenceToSomeDemoMethod ] { #category : 'accessing' } diff --git a/src/Refactoring-DataForTesting/RBClassDataForRefactoringTest.class.st b/src/Refactoring-DataForTesting/RBClassDataForRefactoringTest.class.st index 730a2209bc9..a47cdfd720a 100644 --- a/src/Refactoring-DataForTesting/RBClassDataForRefactoringTest.class.st +++ b/src/Refactoring-DataForTesting/RBClassDataForRefactoringTest.class.st @@ -67,7 +67,7 @@ RBClassDataForRefactoringTest >> called: anObject on1: aBlock [ { #category : 'inline' } RBClassDataForRefactoringTest >> called: anObject on: aBlock [ - + anObject printString traceCr; cr. aBlock value ] diff --git a/src/Refactoring-DataForTesting/RBEquivalentMethodSubclassHolder.class.st b/src/Refactoring-DataForTesting/RBEquivalentMethodSubclassHolder.class.st index 83183f0629a..cd86c9cf31e 100644 --- a/src/Refactoring-DataForTesting/RBEquivalentMethodSubclassHolder.class.st +++ b/src/Refactoring-DataForTesting/RBEquivalentMethodSubclassHolder.class.st @@ -45,3 +45,9 @@ RBEquivalentMethodSubclassHolder >> someNumber [ ^ 1 ] + +{ #category : 'accessing' } +RBEquivalentMethodSubclassHolder >> yourself [ + + ^ self +] diff --git a/src/Refactoring-DataForTesting/RBHierarchyForClassVariable.class.st b/src/Refactoring-DataForTesting/RBHierarchyForClassVariable.class.st new file mode 100644 index 00000000000..f56eb20cafb --- /dev/null +++ b/src/Refactoring-DataForTesting/RBHierarchyForClassVariable.class.st @@ -0,0 +1,7 @@ +Class { + #name : 'RBHierarchyForClassVariable', + #superclass : 'Object', + #category : 'Refactoring-DataForTesting-MiniHierarchy', + #package : 'Refactoring-DataForTesting', + #tag : 'MiniHierarchy' +} diff --git a/src/Refactoring-DataForTesting/RBHierarchySubclassAForClassVariable.class.st b/src/Refactoring-DataForTesting/RBHierarchySubclassAForClassVariable.class.st new file mode 100644 index 00000000000..8a9057e09e0 --- /dev/null +++ b/src/Refactoring-DataForTesting/RBHierarchySubclassAForClassVariable.class.st @@ -0,0 +1,17 @@ +Class { + #name : 'RBHierarchySubclassAForClassVariable', + #superclass : 'RBHierarchyForClassVariable', + #classVars : [ + 'ClassVarA' + ], + #category : 'Refactoring-DataForTesting-MiniHierarchy', + #package : 'Refactoring-DataForTesting', + #tag : 'MiniHierarchy' +} + +{ #category : 'initialization' } +RBHierarchySubclassAForClassVariable >> initialize [ + + super initialize. + +] diff --git a/src/Refactoring-DataForTesting/RBHierarchySubclassBForClassVariable.class.st b/src/Refactoring-DataForTesting/RBHierarchySubclassBForClassVariable.class.st new file mode 100644 index 00000000000..b54d330464f --- /dev/null +++ b/src/Refactoring-DataForTesting/RBHierarchySubclassBForClassVariable.class.st @@ -0,0 +1,18 @@ +Class { + #name : 'RBHierarchySubclassBForClassVariable', + #superclass : 'RBHierarchySubclassAForClassVariable', + #classVars : [ + 'ClassVarB' + ], + #category : 'Refactoring-DataForTesting-MiniHierarchy', + #package : 'Refactoring-DataForTesting', + #tag : 'MiniHierarchy' +} + +{ #category : 'initialization' } +RBHierarchySubclassBForClassVariable >> initialize [ + + + super initialize. + +] diff --git a/src/Refactoring-DataForTesting/RBSharedPoolForTestData1.class.st b/src/Refactoring-DataForTesting/RBSharedPoolForTestData1.class.st index c6879e62fab..5f6222533b4 100644 --- a/src/Refactoring-DataForTesting/RBSharedPoolForTestData1.class.st +++ b/src/Refactoring-DataForTesting/RBSharedPoolForTestData1.class.st @@ -6,7 +6,7 @@ Class { #tag : 'ForSharedPool' } -{ #category : 'tests perform' } +{ #category : 'tests - perform' } RBSharedPoolForTestData1 >> msg4 [ ^ Var1 diff --git a/src/Refactoring-DataForTesting/RBSubclassOfClassToRename.class.st b/src/Refactoring-DataForTesting/RBSubclassOfClassToRename.class.st index de9750e6c1b..3a5e835aedb 100644 --- a/src/Refactoring-DataForTesting/RBSubclassOfClassToRename.class.st +++ b/src/Refactoring-DataForTesting/RBSubclassOfClassToRename.class.st @@ -39,8 +39,6 @@ RBSubclassOfClassToRename >> justSuperSendInSubclassBroken [ { #category : 'accessing' } RBSubclassOfClassToRename >> methodThatIsNotUsedForSure [ - - ] { #category : 'accessing' } @@ -48,7 +46,7 @@ RBSubclassOfClassToRename >> name [ ^rewriteRule1 ] -{ #category : 'accessing' } +{ #category : 'printing' } RBSubclassOfClassToRename >> printOn: aStream [ "just for the test"