LOC should not count lines with only opening or closing brace

Code style should not have an impact on LOC.

Int32 foo(Int32 x) {
return x+1; }

Should have the same LOC as

Int32 foo(Int32 x) 
{
return x+1; 
}

Our coding style have a huge impact on our LOC.

Regards,

Hey there.

Thanks for the feedback.

We aim and have a relatively standardized way of calculating LOC across multiple programming languages and coding styles.

One could argue that this code snippet:

var template = "{a}{b}-{c}{d}";
var myStuff = template
                .replace("{a}", a)
                .replace("{b}", b)
                .replace("{c}", c)
                .replace("{d}", d);

Should only count as 2 line of code because it can also be styled like this:

var template = "{a}{b}-{c}{d}";
myStuff = template.replace("{a}", a).replace("{b}", b).replace("{c}", c).replace("{d}", d)

Similarly, you could also write the code you shared as

int foo(int x) { return x+1; }

We have the draw the line somewhere – and right now we draw that line at not counting empty lines or comments.

1 Like