diff --git a/src/Glorp-Unit-Tests/GlorpVideoDescriptorSystem.class.st b/src/Glorp-Unit-Tests/GlorpVideoDescriptorSystem.class.st index f6bc7d07..2072cf18 100644 --- a/src/Glorp-Unit-Tests/GlorpVideoDescriptorSystem.class.st +++ b/src/Glorp-Unit-Tests/GlorpVideoDescriptorSystem.class.st @@ -252,46 +252,50 @@ GlorpVideoDescriptorSystem >> exampleCreditStatus3 [ { #category : #examples } GlorpVideoDescriptorSystem >> exampleCustomer1 [ "A customer with only online purchases" + | customer | customer := GlorpVideoCustomer new. customer name: 'Adrian'. - customer dateOfBirth: (Date today subtractDays: (10 * 365)). + customer dateOfBirth: (Date today subtractDays: 10 * 365). customer addOnlinePurchase: self exampleOnlinePurchase1. customer addOnlinePurchase: self exampleOnlinePurchase2. - ^customer. + ^ customer ] { #category : #examples } GlorpVideoDescriptorSystem >> exampleCustomer2 [ "A customer with only inStore purchases" + | customer | customer := GlorpVideoCustomer new. customer name: 'Bob'. - customer dateOfBirth: (Date today subtractDays: (20 * 365)). + customer dateOfBirth: (Date today subtractDays: 20 * 365). customer addInStorePurchase: self exampleInStorePurchase1. - ^customer. + ^ customer ] { #category : #examples } GlorpVideoDescriptorSystem >> exampleCustomer3 [ "A customer with only rentals" + | customer | customer := GlorpVideoCustomer new. customer name: 'Carol'. - customer dateOfBirth: (Date today subtractDays: (30 * 365)). + customer dateOfBirth: (Date today subtractDays: 30 * 365). customer addRental: self exampleInStoreRental1. - ^customer. + ^ customer ] { #category : #examples } GlorpVideoDescriptorSystem >> exampleCustomer4 [ "A customer with only credit" + | customer | customer := GlorpVideoCustomer new. customer name: 'David'. - customer dateOfBirth: (Date today subtractDays: (40 * 365)). + customer dateOfBirth: (Date today subtractDays: 40 * 365). customer creditStatus: self exampleCreditStatus1. - ^customer. + ^ customer ] { #category : #examples } @@ -305,7 +309,7 @@ GlorpVideoDescriptorSystem >> exampleCustomer5 [ customer addInStorePurchase: self exampleInStorePurchase2. customer addInStorePurchase: self exampleInStorePurchase3. customer addRental: self exampleInStoreRental2. - ^customer. + ^ customer ] { #category : #examples } @@ -319,7 +323,7 @@ GlorpVideoDescriptorSystem >> exampleCustomer6 [ customer addInStorePurchase: self exampleInStorePurchase4. customer addInStorePurchase: self exampleInStorePurchase5. customer creditStatus: self exampleCreditStatus2. - ^customer. + ^ customer ] { #category : #examples } @@ -335,7 +339,7 @@ GlorpVideoDescriptorSystem >> exampleCustomer7 [ customer addRental: self exampleInStoreRental3. customer addRental: self exampleInStoreRental4. customer creditStatus: self exampleCreditStatus3. - ^customer. + ^ customer ] { #category : #examples } @@ -347,251 +351,294 @@ GlorpVideoDescriptorSystem >> exampleCustomer8 [ customer name: 'Hieronymous'. customer dateOfBirth: (Date today subtractDays: 80 * 365). customer addInStorePurchase: self exampleInStorePurchase7. - ^customer. + ^ customer ] { #category : #examples } GlorpVideoDescriptorSystem >> exampleInStorePurchase1 [ + | purchase | purchase := GlorpVideoPurchase new. purchase id: 101. purchase title: 'An American in Paris'. purchase price: 1.00. purchase inStore: true. - ^purchase. + ^ purchase ] { #category : #examples } GlorpVideoDescriptorSystem >> exampleInStorePurchase2 [ + | purchase | purchase := GlorpVideoPurchase new. purchase id: 102. purchase title: 'Brazil'. purchase price: 2.00. purchase inStore: true. - ^purchase. + ^ purchase ] { #category : #examples } GlorpVideoDescriptorSystem >> exampleInStorePurchase3 [ + | purchase | purchase := GlorpVideoPurchase new. purchase id: 103. purchase title: 'Cambodia, Swimming To'. purchase price: 3.00. purchase inStore: true. - ^purchase. + ^ purchase ] { #category : #examples } GlorpVideoDescriptorSystem >> exampleInStorePurchase4 [ + | purchase | purchase := GlorpVideoPurchase new. purchase id: 104. purchase title: 'Dogma'. purchase price: 4.00. purchase inStore: true. - ^purchase. + ^ purchase ] { #category : #examples } GlorpVideoDescriptorSystem >> exampleInStorePurchase5 [ + | purchase | purchase := GlorpVideoPurchase new. purchase id: 105. purchase title: 'ET'. purchase price: 5.00. purchase inStore: true. - ^purchase. + ^ purchase ] { #category : #examples } GlorpVideoDescriptorSystem >> exampleInStorePurchase6 [ + | purchase | purchase := GlorpVideoPurchase new. purchase id: 106. purchase title: 'Fargo'. purchase price: 6.00. purchase inStore: true. - ^purchase. + ^ purchase ] { #category : #examples } GlorpVideoDescriptorSystem >> exampleInStorePurchase7 [ + | purchase | purchase := GlorpVideoPurchase new. purchase id: 107. purchase title: 'Glengarry GlenRoss'. purchase price: 7.00. purchase inStore: true. - ^purchase. + ^ purchase ] { #category : #examples } GlorpVideoDescriptorSystem >> exampleInStoreRental1 [ + | rental | rental := GlorpVideoRental new. rental id: 1001. rental title: 'Amelie'. rental price: 21.00. rental dueDate: Date today. - ^rental. + ^ rental ] { #category : #examples } GlorpVideoDescriptorSystem >> exampleInStoreRental2 [ + | rental | rental := GlorpVideoRental new. rental id: 1002. rental title: 'Best in Show'. rental price: 22.00. rental dueDate: Date today. - ^rental. + ^ rental ] { #category : #examples } GlorpVideoDescriptorSystem >> exampleInStoreRental3 [ + | rental | rental := GlorpVideoRental new. rental id: 1003. rental title: 'Charlie Brown Christmas'. rental price: 23.00. rental dueDate: Date today. - ^rental. + ^ rental ] { #category : #examples } GlorpVideoDescriptorSystem >> exampleInStoreRental4 [ + | rental | rental := GlorpVideoRental new. rental id: 1004. rental title: 'Down By Law'. rental price: 24.00. rental dueDate: Date today. - ^rental. + ^ rental ] { #category : #examples } GlorpVideoDescriptorSystem >> exampleOnlinePurchase1 [ + | purchase | purchase := GlorpVideoPurchase new. purchase id: 1. purchase title: 'All About Eve'. purchase price: 1.11. purchase inStore: false. - ^purchase. + ^ purchase ] { #category : #examples } GlorpVideoDescriptorSystem >> exampleOnlinePurchase2 [ + | purchase | purchase := GlorpVideoPurchase new. purchase id: 2. purchase title: 'Butch Cassidy and the Sundance Kid'. purchase price: 2.22. purchase inStore: false. - ^purchase. + ^ purchase ] { #category : #examples } GlorpVideoDescriptorSystem >> exampleOnlinePurchase3 [ + | purchase | purchase := GlorpVideoPurchase new. purchase id: 3. purchase title: 'Cabaret'. purchase price: 3.33. purchase inStore: false. - ^purchase. + ^ purchase ] { #category : #examples } GlorpVideoDescriptorSystem >> exampleStore1 [ "self new exampleStore1" + | example | example := GlorpVideoStore new. example name: 'Als Video'. example id: 1. - example customers: (Array with: self exampleCustomer1 with: self exampleCustomer2 with: self exampleCustomer3 with: self exampleCustomer4), (Array with: self exampleCustomer5 with: self exampleCustomer6 with: self exampleCustomer7). + example customers: (Array + with: self exampleCustomer1 + with: self exampleCustomer2 + with: self exampleCustomer3 + with: self exampleCustomer4) , (Array + with: self exampleCustomer5 + with: self exampleCustomer6 + with: self exampleCustomer7). example computeCollections. - ^example. + ^ example ] { #category : #examples } GlorpVideoDescriptorSystem >> exampleStore2 [ "self new exampleStore2" + | example | example := GlorpVideoStore new. example name: 'Bonzai Video'. example id: 2. example customers: (Array with: self exampleCustomer8). example computeCollections. - ^example. + ^ example ] { #category : #tables } GlorpVideoDescriptorSystem >> tableForVIDEO_CREDIT_STATUS: aTable [ + | customerTable custName custDate storeId | customerTable := self tableNamed: 'VIDEO_CUSTOMER'. - custName := (aTable createFieldNamed: 'CUSTOMERNAME' type: (platform varchar: 50)) - bePrimaryKey. - custDate := (aTable createFieldNamed: 'CUSTOMERBIRTHDATE' type: platform date) bePrimaryKey. - storeId := (aTable createFieldNamed: 'STORE_ID' type: platform int4) bePrimaryKey. - aTable addForeignKeyFrom: custName + custName := (aTable + createFieldNamed: 'CUSTOMERNAME' + type: (platform varchar: 50)) bePrimaryKey. + custDate := (aTable + createFieldNamed: 'CUSTOMERBIRTHDATE' + type: platform date) bePrimaryKey. + storeId := (aTable createFieldNamed: 'STORE_ID' type: platform int4) + bePrimaryKey. + aTable + addForeignKeyFrom: custName to: (customerTable fieldNamed: 'CUSTOMERNAME') from: custDate to: (customerTable fieldNamed: 'BIRTHDATE') from: storeId - to: (customerTable fieldNamed: 'STORE_ID') . - aTable addForeignKeyFrom: storeId to: ((self tableNamed: 'VIDEO_STORE') fieldNamed: 'ID'). + to: (customerTable fieldNamed: 'STORE_ID'). + aTable + addForeignKeyFrom: storeId + to: ((self tableNamed: 'VIDEO_STORE') fieldNamed: 'ID'). - aTable createFieldNamed: 'BALANCE' type: (platform double). + aTable createFieldNamed: 'BALANCE' type: platform double. aTable createFieldNamed: 'DATE_OWING' type: platform date. - aTable createFieldNamed: 'COMMENTS' type: (platform varchar: 50). + aTable createFieldNamed: 'COMMENTS' type: (platform varchar: 50) ] { #category : #tables } GlorpVideoDescriptorSystem >> tableForVIDEO_CUSTOMER: aTable [ "Note: This table is imaginary" + | storeId | aTable isImaginary: true. (aTable createFieldNamed: 'CUSTOMERNAME' type: (platform varchar: 50)) bePrimaryKey. - (aTable createFieldNamed: 'BIRTHDATE' type: platform date) bePrimaryKey. - storeId := (aTable createFieldNamed: 'STORE_ID' type: (platform int4)) bePrimaryKey. - aTable addForeignKeyFrom: storeId + (aTable createFieldNamed: 'BIRTHDATE' type: platform date) + bePrimaryKey. + storeId := (aTable createFieldNamed: 'STORE_ID' type: platform int4) + bePrimaryKey. + aTable + addForeignKeyFrom: storeId to: ((self tableNamed: 'VIDEO_STORE') fieldNamed: 'ID') ] { #category : #tables } GlorpVideoDescriptorSystem >> tableForVIDEO_PURCHASE: aTable [ + | custName custDate customerTable | - (aTable createFieldNamed: 'ID' type: (platform int4)) bePrimaryKey. + (aTable createFieldNamed: 'ID' type: platform int4) bePrimaryKey. customerTable := self tableNamed: 'VIDEO_CUSTOMER'. custName := aTable createFieldNamed: 'CUSTOMERNAME' type: (platform varchar: 50). custDate := aTable createFieldNamed: 'CUSTOMERBIRTHDATE' type: platform date. - aTable addForeignKeyFrom: custName + aTable + addForeignKeyFrom: custName to: (customerTable fieldNamed: 'CUSTOMERNAME') from: custDate to: (customerTable fieldNamed: 'BIRTHDATE'). - aTable createFieldNamed: 'TITLE' type: (platform varchar: 50). - aTable createFieldNamed: 'PRICE' type: (platform double). - aTable createFieldNamed: 'IN_STORE' type: (platform char: 1). + aTable createFieldNamed: 'TITLE' type: (platform varchar: 50). + aTable createFieldNamed: 'PRICE' type: platform double. + aTable createFieldNamed: 'IN_STORE' type: (platform char: 1) ] { #category : #tables } GlorpVideoDescriptorSystem >> tableForVIDEO_PURCHASE_LINK: aTable [ + | storeId purchaseId | - purchaseId := aTable createFieldNamed: 'PURCHASE_ID' type: platform int4. - storeId := aTable createFieldNamed: 'STORE_ID' type: (platform int4). - aTable addForeignKeyFrom: storeId + purchaseId := aTable + createFieldNamed: 'PURCHASE_ID' + type: platform int4. + storeId := aTable createFieldNamed: 'STORE_ID' type: platform int4. + aTable + addForeignKeyFrom: storeId to: ((self tableNamed: 'VIDEO_STORE') fieldNamed: 'ID'). - aTable addForeignKeyFrom: purchaseId - to: ((self tableNamed: 'VIDEO_PURCHASE') fieldNamed: 'ID'). + aTable + addForeignKeyFrom: purchaseId + to: ((self tableNamed: 'VIDEO_PURCHASE') fieldNamed: 'ID') ] { #category : #tables } GlorpVideoDescriptorSystem >> tableForVIDEO_RENTAL: aTable [ + | custName custDate storeId customerTable | (aTable createFieldNamed: 'ID' type: (platform int4)) bePrimaryKey. customerTable := self tableNamed: 'VIDEO_CUSTOMER'. @@ -606,13 +653,14 @@ GlorpVideoDescriptorSystem >> tableForVIDEO_RENTAL: aTable [ to: (customerTable fieldNamed: 'STORE_ID'). aTable addForeignKeyFrom: storeId to: ((self tableNamed: 'VIDEO_STORE') fieldNamed: 'ID'). - aTable createFieldNamed: 'TITLE' type: (platform varchar: 50). + aTable createFieldNamed: 'TITLE' type: (platform varchar: 50). aTable createFieldNamed: 'DUE_DATE' type: platform date. - aTable createFieldNamed: 'PRICE' type: (platform double). + aTable createFieldNamed: 'PRICE' type: (platform double) ] { #category : #tables } GlorpVideoDescriptorSystem >> tableForVIDEO_STORE: aTable [ + (aTable createFieldNamed: 'ID' type: (platform int4)) bePrimaryKey. - aTable createFieldNamed: 'NAME' type: (platform varchar: 20). + aTable createFieldNamed: 'NAME' type: (platform varchar: 20) ] diff --git a/src/Glorp-Unit-Tests/GlorpVideoPurchase.class.st b/src/Glorp-Unit-Tests/GlorpVideoPurchase.class.st index d9425484..d3a1057a 100644 --- a/src/Glorp-Unit-Tests/GlorpVideoPurchase.class.st +++ b/src/Glorp-Unit-Tests/GlorpVideoPurchase.class.st @@ -17,67 +17,81 @@ Class { { #category : #comparing } GlorpVideoPurchase >> <= aVideoPurchase [ - ^self title <= aVideoPurchase title. + + ^ self title <= aVideoPurchase title ] { #category : #testing } GlorpVideoPurchase >> assertEqual: aPurchase [ - self assert: customer name = aPurchase customer name. - self assert: customer dateOfBirth = aPurchase customer dateOfBirth. - self assert: store id = aPurchase videoStore id. - self assert: id = aPurchase id. - self assert: title = aPurchase title. - self assert: (price * 1000) rounded = (aPurchase price * 1000) rounded. - self assert: inStore = aPurchase inStore. + self assert: customer name equals: aPurchase customer name. + self + assert: customer dateOfBirth + equals: aPurchase customer dateOfBirth. + self assert: store id equals: aPurchase videoStore id. + self assert: id equals: aPurchase id. + self assert: title equals: aPurchase title. + self + assert: (price * 1000) rounded + equals: (aPurchase price * 1000) rounded. + self assert: inStore equals: aPurchase inStore ] { #category : #accessing } GlorpVideoPurchase >> customer [ - ^customer + + ^ customer ] { #category : #accessing } GlorpVideoPurchase >> customer: aCustomer [ - customer := aCustomer. + + customer := aCustomer ] { #category : #accessing } GlorpVideoPurchase >> id [ - ^id + + ^ id ] { #category : #accessing } GlorpVideoPurchase >> id: anObject [ + id := anObject ] { #category : #accessing } GlorpVideoPurchase >> inStore [ - ^inStore + + ^ inStore ] { #category : #accessing } GlorpVideoPurchase >> inStore: anObject [ + inStore := anObject ] { #category : #accessing } GlorpVideoPurchase >> price [ - ^price + + ^ price ] { #category : #accessing } GlorpVideoPurchase >> price: anObject [ + price := anObject ] { #category : #printing } GlorpVideoPurchase >> printOn: aStream [ + super printOn: aStream. aStream nextPut: $(. aStream nextPutAll: self title. - aStream nextPut: $). + aStream nextPut: $) ] { #category : #accessing } @@ -88,15 +102,18 @@ GlorpVideoPurchase >> store: aGlorpVideoStore [ { #category : #accessing } GlorpVideoPurchase >> title [ - ^title + + ^ title ] { #category : #accessing } GlorpVideoPurchase >> title: aString [ + title := aString ] { #category : #accessing } GlorpVideoPurchase >> videoStore [ - ^store. + + ^ store ] diff --git a/src/Glorp-Unit-Tests/GlorpVideoRental.class.st b/src/Glorp-Unit-Tests/GlorpVideoRental.class.st index 25d716a3..ab7127a8 100644 --- a/src/Glorp-Unit-Tests/GlorpVideoRental.class.st +++ b/src/Glorp-Unit-Tests/GlorpVideoRental.class.st @@ -23,73 +23,71 @@ GlorpVideoRental >> <= aVideoRental [ { #category : #testing } GlorpVideoRental >> assertEqual: aRental [ - self assert: customer name = aRental customer name. - self assert: customer dateOfBirth = aRental customer dateOfBirth. - self assert: id = aRental id. - self assert: title = aRental title. - self assert: price = aRental price. - self assert: dueDate = aRental dueDate. + self assert: customer name equals: aRental customer name. + self + assert: customer dateOfBirth + equals: aRental customer dateOfBirth. + self assert: id equals: aRental id. + self assert: title equals: aRental title. + self assert: price equals: aRental price. + self assert: dueDate equals: aRental dueDate ] { #category : #accessing } GlorpVideoRental >> customer [ - ^customer. + + ^ customer ] { #category : #accessing } GlorpVideoRental >> customer: aCustomer [ - customer := aCustomer. + + customer := aCustomer ] { #category : #accessing } GlorpVideoRental >> dueDate [ - ^dueDate + + ^ dueDate ] { #category : #accessing } GlorpVideoRental >> dueDate: anObject [ + dueDate := anObject ] { #category : #accessing } GlorpVideoRental >> id [ - ^id + + ^ id ] { #category : #accessing } GlorpVideoRental >> id: anObject [ - id := anObject -] -{ #category : #'initialize-release' } -GlorpVideoRental >> initialize [ - "Initialize a newly created instance. This method must answer the receiver." - - " *** Edit the following to properly initialize instance variables ***" - id := nil. - title := nil. - dueDate := nil. - price := nil. - " *** And replace this comment with additional initialization code *** " - ^self + id := anObject ] { #category : #accessing } GlorpVideoRental >> price [ - ^price + + ^ price ] { #category : #accessing } GlorpVideoRental >> price: anObject [ + price := anObject ] { #category : #printing } GlorpVideoRental >> printOn: aStream [ + super printOn: aStream. aStream nextPut: $(. aStream nextPutAll: self title. - aStream nextPut: $). + aStream nextPut: $) ] { #category : #accessing } @@ -100,10 +98,12 @@ GlorpVideoRental >> store: aGlorpVideoStore [ { #category : #accessing } GlorpVideoRental >> title [ - ^title + + ^ title ] { #category : #accessing } GlorpVideoRental >> title: anObject [ + title := anObject ] diff --git a/src/Glorp-Unit-Tests/GlorpVideoStore.class.st b/src/Glorp-Unit-Tests/GlorpVideoStore.class.st index e616f3b8..fac6cf6e 100644 --- a/src/Glorp-Unit-Tests/GlorpVideoStore.class.st +++ b/src/Glorp-Unit-Tests/GlorpVideoStore.class.st @@ -16,27 +16,31 @@ Class { { #category : #testing } GlorpVideoStore >> assertEqual: aStore [ - self assert: id = aStore id. - self assert: name = aStore name. + + self assert: id equals: aStore id. + self assert: name equals: aStore name. customers assertEqual: aStore customers. - purchases assertEqual: aStore purchases. + purchases assertEqual: aStore purchases ] { #category : #private } GlorpVideoStore >> computeCollections [ + customers do: [:each | each store: self]. purchases := customers inject: #() into: [:sum :each | sum, each purchases]. - purchases do: [:each | each store: self]. + purchases do: [:each | each store: self] ] { #category : #accessing } GlorpVideoStore >> customers [ - ^customers + + ^ customers ] { #category : #accessing } GlorpVideoStore >> customers: anObject [ + customers := anObject ] @@ -60,20 +64,24 @@ GlorpVideoStore >> initialize [ { #category : #'As yet unclassified' } GlorpVideoStore >> name [ - ^name. + + ^ name ] { #category : #'As yet unclassified' } GlorpVideoStore >> name: aString [ - name := aString. + + name := aString ] { #category : #accessing } GlorpVideoStore >> purchases [ - ^purchases + + ^ purchases ] { #category : #accessing } GlorpVideoStore >> purchases: aCollection [ + purchases := aCollection ] diff --git a/src/Glorp-Unit-Tests/ManifestGlorpTests.class.st b/src/Glorp-Unit-Tests/ManifestGlorpTests.class.st index c68f494a..6c75bda5 100644 --- a/src/Glorp-Unit-Tests/ManifestGlorpTests.class.st +++ b/src/Glorp-Unit-Tests/ManifestGlorpTests.class.st @@ -28,6 +28,13 @@ ManifestGlorpTests class >> ruleSentNotImplementedRuleV1FalsePositive [ ^ #(#(#(#RGMethodDefinition #(#GlorpExpressionTest #testTwoLevelMappingExpressionIdentity #false)) #'2023-06-26T17:19:32.656259+02:00') #(#(#RGMethodDefinition #(#GlorpExpressionRebuildingTest #testRebuildDoubleInnerScopeNormallyWithExists #false)) #'2023-06-26T17:23:00.60756+02:00') #(#(#RGMethodDefinition #(#GlorpExpressionRebuildingTest #testRebuildDoubleInnerScopeNormallyWithJoins #false)) #'2023-06-26T17:23:08.036157+02:00') #(#(#RGMethodDefinition #(#GlorpExpressionRebuildingTest #testRebuildInnerScopeForSubquery #false)) #'2023-06-26T17:23:32.681276+02:00') #(#(#RGMethodDefinition #(#GlorpExpressionRebuildingTest #testRebuildInnerScopeNormally #false)) #'2023-06-26T17:23:39.17862+02:00') ) ] +{ #category : #'code-critics' } +ManifestGlorpTests class >> ruleStringConcatenationRuleV1FalsePositive [ + + + ^ #(#(#(#RGMethodDefinition #(#GlorpVideoStore #computeCollections #false)) #'2023-06-26T19:30:25.8836+02:00') ) +] + { #category : #'code-critics' } ManifestGlorpTests class >> ruleUncommonMessageSendRuleV1FalsePositive [