On Apr 2, 2013, at 4:54 AM, Hernán Morales Durand <[email protected]> 
wrote:

> Hi Janko. Thanks for your useful package.
> 
> Apparently there is some issue with #linesOfCode. The dummy expression below 
> return 5 instead of 4 in Pharo 1.4 and 2 because is counting the 
> autogenerated 'DoIt' selector.
> 
> (UndefinedObject evaluatorClass new
>       compileNoPattern: '| oc |
> oc := OrderedCollection new: 20.
> oc add: 1.
> oc size'
>       in: UndefinedObject
>       context: nil
>       notifying: nil
>       ifFail: []) generate linesOfCode

Hello, 

I do not think that this is wrong. The doit *does* contain a selector. if 
#linesOfCode would contain a special
case for doits, it would be inconsistent.

E.g. print this:

thisContext method sourceCode

--> 

 'DoIt
        ^ thisContext method sourceCode'

There is a Doit. There is even a return in the that is generated… and the doit 
is actually pretty-printed:



thisContext 
method
linesOfCode

--> 2

So in short: dots are special, there is no need to change #linesOfCode, as 
there is no thinkable change
that would make any sense.

In general, LOC as a metric is not that good. It is better than nothing, but it 
makes more sense to count
e.g. message sends or use more advanced metrics on the AST (not every statement 
adds the same
to complexity, e.g. conditionals versus simple statements).


        Marcus

Reply via email to