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

Compute metrics differently according to parsers #364

Open
Luni-4 opened this issue Nov 18, 2020 · 1 comment
Open

Compute metrics differently according to parsers #364

Luni-4 opened this issue Nov 18, 2020 · 1 comment
Labels
enhancement New feature or request

Comments

@Luni-4
Copy link
Collaborator

Luni-4 commented Nov 18, 2020

Actually metrics are computed equally for each parser through the metrics function contained in spaces.rs file. This approach though doesn't allow to customize parsers.

To overcome the problem above, it would be helpful to split up parsers in two great classes:

  • Metric parsers. They contain a metric function that allows only determined metrics to be computed
  • Non-metric parsers. They do other things, but they do not compute metrics. For now we can consider them like metric parsers but without the methods to compute metrics

Possible structure for the metric parsers

let parser = CppParser::new(...);
// This function sets the list of metrics to be computed for the CppParser.
// Returns an error if the ones specified aren't available for the CppParser
parser.set_metrics(...).unwrap(); 
// Compute the metrics
parser.compute_metrics().unwrap();

Advantages

  • Each parser computes only the metrics related to the structure of its language (i.e. For the HTML language, loc, but not nom because there aren't functions or closures in it)
  • A user can choose the metrics to be computed through the set_metrics function
  • This new design can be useful for other features other than metrics

Disdvantages

  • Refactor lots of code
  • Implementing this new kind of design could introduce further issues
@Luni-4 Luni-4 added the enhancement New feature or request label Nov 18, 2020
@Luni-4
Copy link
Collaborator Author

Luni-4 commented Nov 20, 2020

This new approach needs to take into account also the dump of the chosen metrics in different formats

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

No branches or pull requests

1 participant