Compute metrics differently according to parsers

Offen
#364 1 Kommentar 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Maintainer antworten meist innerhalb von 1 Tag

Dieses Issue hat noch niemand übernommen.

Bewertung

Schwierigkeit
5/5
Geschätzter Aufwand
Über eine Woche
Anfängerfreundlichkeit
25/100
Issue-Typ
Refactoring
Klarheit
Größtenteils klar
Aktivitätsstatus
Veraltet
Tech-Stack
rust
Bereich
backend

Rechercherichtung

Start with the metrics function in spaces.rs and trace how parsers currently compute and expose metrics. Then inspect the parser implementations, including CppParser, to determine how metrics are selected and where parser-specific behavior belongs. Done means metric parsers can select supported metrics and compute them, while non-metric parsers do not expose metric computation; this broad refactor needs design work and tests across parsers.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Beschreibung

enhancement

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
Vorherrschende Sprache
Rust
Sterne
469
Forks
74
Ø Merge
17 Std. 16 Min.
Gemergte PRs (30 T.)
10

Entwicklungsumgebung

Dieses Projekt bietet weder Dev-Container noch Dockerfile noch Beitragsleitfaden – die Einrichtung liegt bei Ihnen. Beginnen Sie mit der README; die allgemeinen Schritte stehen in unserem Leitfaden für den ersten Beitrag.

Erste Schritte

  1. Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
  3. Forken Sie das Repository und arbeiten Sie in einem Branch.
  4. Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.

Mehr aus mozilla/rust-code-analysis

Alle Issues in mozilla/rust-code-analysis

Ähnliche Issues

Weitere Issues zu Rust

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.