[Bug] In ClassDescription>>#linesOfCode
Hi, I looked at the implementation of #linesOfCode of ClassDescription. It is actually wrong, a correct version should be: linesOfCode "An approximate measure of lines of code. Includes comments, but excludes blank lines." | lines | lines := self localMethods inject: 0 into: [:sum :each | sum + each linesOfCode]. ^ self isMeta not ifTrue: [lines] ifFalse: [lines + self class linesOfCode] Cheers, Roby
On 15 Nov 2013, at 14:07, Roberto Minelli <roberto.minelli@usi.ch> wrote:
Hi,
I looked at the implementation of #linesOfCode of ClassDescription. It is actually wrong, a correct version should be:
linesOfCode "An approximate measure of lines of code. Includes comments, but excludes blank lines." | lines |
lines := self localMethods inject: 0 into: [:sum :each | sum + each linesOfCode]. ^ self isMeta not ifTrue: [lines] ifFalse: [lines + self class linesOfCode]
indeed! and after fixing, Pharo3 shrinks from 444kLoc to 368KLoc :-) Marcus
On 15 Nov 2013, at 14:18, Marcus Denker <marcus.denker@inria.fr> wrote:
On 15 Nov 2013, at 14:07, Roberto Minelli <roberto.minelli@usi.ch> wrote:
Hi,
I looked at the implementation of #linesOfCode of ClassDescription. It is actually wrong, a correct version should be:
linesOfCode "An approximate measure of lines of code. Includes comments, but excludes blank lines." | lines |
lines := self localMethods inject: 0 into: [:sum :each | sum + each linesOfCode]. ^ self isMeta not ifTrue: [lines] ifFalse: [lines + self class linesOfCode]
indeed!
Hmm⦠not that sure after thinking about it. On the meta side, we just take the linesOfCode of all methods. On the instance side, we take the linesOfCode of all method *and* the ones of the meta. When you call Object linesOfCode this means it takes linesOfCode of Instance Side + linesOfCode of class side of Object which seems ok. Marcus
In fact *after* I wrote the email I actually thought about that. IMHO we need to have a method which gave us only the LOC of the âsideâ we are interested in, i.e., there is no way to access only the LOC of the instance side and for me this is wrong. Something like actualLinesOfCode ^ self localMethods inject: 0 into: [:sum :each | sum + each linesOfCode]. and then linesOfCode "An approximate measure of lines of code. Includes comments, but excludes blank lines." | lines | lines := self actualLinesOfCode ^ self isMeta ifTrue: [lines] ifFalse: [lines + self class linesOfCode] So that one can invoke Object>>#linesOfCode and have the current behavior, or Object>>#actualLinesOfCode and have just the instance side lines of code, and Object class>>#actualLinesOfCode and get only the meta-lines of code. Cheers, R On Nov 15, 2013, at 2:30 PM, Marcus Denker <marcus.denker@inria.fr> wrote:
On 15 Nov 2013, at 14:18, Marcus Denker <marcus.denker@inria.fr> wrote:
On 15 Nov 2013, at 14:07, Roberto Minelli <roberto.minelli@usi.ch> wrote:
Hi,
I looked at the implementation of #linesOfCode of ClassDescription. It is actually wrong, a correct version should be:
linesOfCode "An approximate measure of lines of code. Includes comments, but excludes blank lines." | lines |
lines := self localMethods inject: 0 into: [:sum :each | sum + each linesOfCode]. ^ self isMeta not ifTrue: [lines] ifFalse: [lines + self class linesOfCode]
indeed!
Hmm⦠not that sure after thinking about it.
On the meta side, we just take the linesOfCode of all methods. On the instance side, we take the linesOfCode of all method *and* the ones of the meta.
When you call
Object linesOfCode
this means it takes
linesOfCode of Instance Side + linesOfCode of class side of Object
which seems ok.
Marcus
participants (2)
-
Marcus Denker -
Roberto Minelli