Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Additional Default Metric: "Functional Code" #862

Open
Danielku15 opened this issue Oct 21, 2024 · 1 comment
Open

Additional Default Metric: "Functional Code" #862

Danielku15 opened this issue Oct 21, 2024 · 1 comment

Comments

@Danielku15
Copy link

General idea:

While the current metrics are great to get to get a rough insight on the size of your application, I feel an important metric missing, is the number of lines with "functional code". By "functional code" I do not mean "working" code or "code within functions" but rather:

I might be an exception but I think a metric ignoring certain "quasi empty" lines would allow me to judge the size of a software way better than only ignoring blanks.

Lines which contain some sort of meaningful code beyond the syntactic requirements of the language.

The goal is to get an idea on the functional size (and complexity) of the software.

The simplest example would be: Ignore all lines which contain only certain characters like { , } , ;

Depending on how you format your code you have more lines, but not more "complexity". See following 3 pieces of code. They result in completely different LoC reports without necessary meaning "more code".

if ( CanSkip() ) { /* exit fast */ return; }

if ( CanSkip() ) {
   // exit fast
   return;
}

if ( CanSkip() ) 
{
   // exit fast
   return;
}

How should it work?
There should be a list of patterns (per language?) specifying when a line is not counted for this new metric. e.g a pattern like ^[ \t]+[{}]$ would not count lines with only a brace symbol.

If I could choose, I'd like to see this additionally metric additionally by-default right beside metrics like code,blank,comments.

An alternative apporach is to add new CLI options to provide multple patterns to exclude in counting.

@AlDanial
Copy link
Owner

It's an interesting idea but not easily implemented. The challenge isn't adding an ignore filter--that part is relatively simple. The tedious part is extending the metrics type to include "functional code" in addition to the existing categories of code,blank,comments because of the many (too many?) output formats and styles.

I'll keep this issue open since the concept has merit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants