numberOfLinesOfCode

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

numberOfLinesOfCode

Nicolas Anquetil

Anne spotted a bug in numberOfLinesOfCode.

In Java, one can easily find classes with numberOfLinesOfCode <
numberOfLinesOfCodewithMoreThanOnecharacter

The reason is that numberOfLinesOfCodewithMoreThanOnecharacter is
defined in SourcedEntity by counting the lines (with more than 1 char)
in the sourceText

numberOfLinesOfCode is the sum of numberOfLinesOfCode of the methods.

This is clearly not right for Java where a class as more code than just
its methods.

But it is not even coherent for Smalltalk where a class' sourceText
includes  the name of the class (at least 1 additional line).
So even in Smalltalk, one finds classes with numberOfLinesOfCode <
numberOfLinesOfCodewithMoreThanOnecharacter
(happens when none of the methods of the class have blank lines e.g.
FamixEntity)


So I propose to unify both methods and compute numberOfLinesOfCode in
SourcedEntity from the sourceText
(and remove FAMIXClass>>numberOfLinesOfCode)


Second, for methods, the same numberOfLinesOfCode has a backward
compatibilty with "exporters that use LOC as a property name"
(in this case, it uses LOC instead of computing the number)

Anybody still having this case?


So I propose to remove FAMIXBehaviouralEntity>>numberOfLinesOfCode


nicolas

--
Nicolas Anquetil -- MCF (HDR)
Project-Team RMod

_______________________________________________
Moose-dev mailing list
[hidden email]
https://www.list.inf.unibe.ch/listinfo/moose-dev
Reply | Threaded
Open this post in threaded view
|

Re: numberOfLinesOfCode

Stephan Eggermont-3
There are many ways to calculate the number of lines of code,
so I don't expect them to be consistent. Computing from the
sourceText is not necessarily any better, especially in the case
of smalltalk. The sourceText of a smalltalk class is not in a form
where a smalltalker would find it easy to predict the #loc, or
where she would find it recognizable as a smalltalk class
(missing package and superclass)

e.g.
Smalltalk::Job
CIV#jobAnnouncer
block
currentValue
min
max
title
children
isRunning
parent
process
  ...

I would either test-drive the different ways of calculating #loc
describing what exactly we mean, and making those different
calculations available, or not touch it.

There are a.o.
- count empty lines
- count empty lines beyond end
- count empty lines before class start
- count license comment
- reduce multiple empty lines to one
- count method separators
- wrap
- word-wrap
- ignore comments
- ignore multi-line comments
- map instance variables from string to separate lines
- package name

Stephan

On 01/01/17 13:18, Nicolas Anquetil wrote:
>
> Anne spotted a bug in numberOfLinesOfCode.
...

> So I propose to remove FAMIXBehaviouralEntity>>numberOfLinesOfCode

_______________________________________________
Moose-dev mailing list
[hidden email]
https://www.list.inf.unibe.ch/listinfo/moose-dev
Reply | Threaded
Open this post in threaded view
|

Re: numberOfLinesOfCode

Nicolas Anquetil
yes there are many ways

but I don't see any reasonable argument for numberOfLinesOfCode to be
inferior to numberOfLinesOfCodWithMorethanOneCharacter

nicolas


On 01/01/2017 16:05, stephan wrote:

> There are many ways to calculate the number of lines of code,
> so I don't expect them to be consistent. Computing from the
> sourceText is not necessarily any better, especially in the case
> of smalltalk. The sourceText of a smalltalk class is not in a form
> where a smalltalker would find it easy to predict the #loc, or
> where she would find it recognizable as a smalltalk class
> (missing package and superclass)
>
> e.g.
> Smalltalk::Job
> CIV#jobAnnouncer
> block
> currentValue
> min
> max
> title
> children
> isRunning
> parent
> process
>  ...
>
> I would either test-drive the different ways of calculating #loc
> describing what exactly we mean, and making those different
> calculations available, or not touch it.
>
> There are a.o.
> - count empty lines
> - count empty lines beyond end
> - count empty lines before class start
> - count license comment
> - reduce multiple empty lines to one
> - count method separators
> - wrap
> - word-wrap
> - ignore comments
> - ignore multi-line comments
> - map instance variables from string to separate lines
> - package name
>
> Stephan
>
> On 01/01/17 13:18, Nicolas Anquetil wrote:
>>
>> Anne spotted a bug in numberOfLinesOfCode.
> ...
>
>> So I propose to remove FAMIXBehaviouralEntity>>numberOfLinesOfCode
>
> _______________________________________________
> Moose-dev mailing list
> [hidden email]
> https://www.list.inf.unibe.ch/listinfo/moose-dev

--
Nicolas Anquetil -- MCF (HDR)
Project-Team RMod

_______________________________________________
Moose-dev mailing list
[hidden email]
https://www.list.inf.unibe.ch/listinfo/moose-dev