Skip to content

Commit 555efc6

Browse files
authored
Merge pull request #738 from moosetechnology/number-of-comments
Clean #numberOfComments
2 parents 18e6794 + 9554734 commit 555efc6

File tree

7 files changed

+15
-46
lines changed

7 files changed

+15
-46
lines changed

src/Famix-Java-Entities/FamixJavaClass.class.st

-11
Original file line numberDiff line numberDiff line change
@@ -173,17 +173,6 @@ FamixJavaClass >> methodsWithoutSutbsAndConstructors [
173173
each isStub not and: [each isConstructor not]]) asSet
174174
]
175175

176-
{ #category : #accessing }
177-
FamixJavaClass >> numberOfComments [
178-
"Overrides to include method comments in the numberOfComments of the class"
179-
180-
^ self lookUpPropertyNamed: #numberOfComments computedAs: [
181-
self children asArray inject: self comments size into: [ :sum :child |
182-
(child class includesTrait: FamixTWithComments)
183-
ifTrue: [ child numberOfComments + sum ]
184-
ifFalse: [ sum ] ] ]
185-
]
186-
187176
{ #category : #'Famix-Extensions' }
188177
FamixJavaClass >> structuralChildren [
189178
^ (OrderedCollection withAll: self methods), self attributes

src/Famix-Java-Entities/FamixJavaMethod.class.st

-8
Original file line numberDiff line numberDiff line change
@@ -280,14 +280,6 @@ FamixJavaMethod >> numberOfAccesses [
280280
computedAs: [ self accesses size ]
281281
]
282282

283-
{ #category : #accessing }
284-
FamixJavaMethod >> numberOfComments [
285-
<FMProperty: #numberOfComments type: #Number>
286-
<FMComment: 'The number of comment fragments'>
287-
<derived>
288-
^ self lookUpPropertyNamed: #numberOfComments computedAs: [ self comments size ]
289-
]
290-
291283
{ #category : #'Famix-Extensions-private' }
292284
FamixJavaMethod >> numberOfConditionals [
293285
<FMProperty: #numberOfConditionals type: #Number>

src/Famix-Java-Tests/FamixJavaCommentsTest.class.st

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,5 +25,5 @@ FamixJavaCommentsTest >> testClassWithCommentAndMethodsWithComments [
2525
FamixJavaComment new commentedEntity: (FamixJavaMethod new
2626
parentType: javaClass;
2727
yourself).
28-
self assert: javaClass numberOfComments equals: 3 "one in the class, one on each of the 2 methods"
28+
self assert: javaClass numberOfComments equals: 1 "Comments of children are not taken into account."
2929
]

src/Famix-PharoSmalltalk-Entities/FamixStClass.class.st

-11
Original file line numberDiff line numberDiff line change
@@ -173,17 +173,6 @@ FamixStClass >> methodsWithoutSutbsAndConstructors [
173173
^ (self methods select: [ :each | each isStub not and: [ each isConstructor not ] ]) asSet
174174
]
175175

176-
{ #category : #accessing }
177-
FamixStClass >> numberOfComments [
178-
"Overrides to include method comments in the numberOfComments of the class"
179-
180-
^ self lookUpPropertyNamed: #numberOfComments computedAs: [
181-
self children asArray inject: self comments size into: [ :sum :child |
182-
(child class includesTrait: FamixTWithComments)
183-
ifTrue: [ child numberOfComments + sum ]
184-
ifFalse: [ sum ] ] ]
185-
]
186-
187176
{ #category : #metrics }
188177
FamixStClass >> numberOfMessageSends [
189178
<FMProperty: #numberOfMessageSends type: #Number>

src/Famix-PharoSmalltalk-Entities/FamixStMethod.class.st

-8
Original file line numberDiff line numberDiff line change
@@ -244,14 +244,6 @@ FamixStMethod >> numberOfAccesses [
244244
computedAs: [ self accesses size ]
245245
]
246246

247-
{ #category : #'Famix-Extensions-private' }
248-
FamixStMethod >> numberOfComments [
249-
<FMProperty: #numberOfComments type: #Number>
250-
<FMComment: 'The number of comment fragments'>
251-
<derived>
252-
^ self lookUpPropertyNamed: #numberOfComments computedAs: [ self comments size ]
253-
]
254-
255247
{ #category : #'Famix-Extensions-private' }
256248
FamixStMethod >> numberOfConditionals [
257249
<FMProperty: #numberOfConditionals type: #Number>

src/Famix-Traits/FamixTWithComments.trait.st

+3-5
Original file line numberDiff line numberDiff line change
@@ -61,13 +61,11 @@ FamixTWithComments >> hasComments [
6161

6262
{ #category : #accessing }
6363
FamixTWithComments >> numberOfComments [
64+
6465
<FMProperty: #numberOfComments type: #Number>
6566
<derived>
66-
<FMComment: 'The number of comments in the entity'>
67-
^ self
68-
lookUpPropertyNamed: #numberOfComments
69-
computedAs: [ self comments size ]
70-
67+
<FMComment: 'The number of comments in the entity. Does not count comments of children entities (for example, for a class, I will count the comments associated to the class and not the methods or arguments.'>
68+
^ self lookUpPropertyNamed: #numberOfComments computedAs: [ self comments size ]
7169
]
7270

7371
{ #category : #accessing }

src/Moose-SmalltalkImporter-LAN-Tests/LANFamixPropertiesTest.class.st

+11-2
Original file line numberDiff line numberDiff line change
@@ -78,9 +78,10 @@ LANFamixPropertiesTest >> testClassCategories [
7878

7979
{ #category : #testing }
8080
LANFamixPropertiesTest >> testClassComments [
81+
8182
self model allClasses do: [ :each | self assert: each numberOfComments >= 0 ].
82-
self assert: (self nodeClass propertyNamed: #numberOfComments) equals: 11.
83-
self assert: self nodeClass numberOfComments equals: 11
83+
self assert: (self nodeClass propertyNamed: #numberOfComments) equals: 0.
84+
self assert: self nodeClass numberOfComments equals: 0
8485
]
8586

8687
{ #category : #testing }
@@ -158,6 +159,14 @@ LANFamixPropertiesTest >> testMethodAccesses [
158159
self assert: (self model entityNamed: #'Smalltalk::LANInterface.originator()') numberOfAccesses equals: 3
159160
]
160161

162+
{ #category : #testing }
163+
LANFamixPropertiesTest >> testMethodComments [
164+
165+
self model allMethods do: [ :each | self assert: each numberOfComments >= 0 ].
166+
self assert: (self lanInterfaceOriginateMethod propertyNamed: #numberOfComments) equals: 6.
167+
self assert: self lanInterfaceOriginateMethod numberOfComments equals: 6
168+
]
169+
161170
{ #category : #testing }
162171
LANFamixPropertiesTest >> testMethodHierarchyNesting [
163172
self assert: (self lanInterfaceOriginateMethod propertyNamed: #hierarchyNestingLevel) equals: 1.

0 commit comments

Comments
 (0)