Compute metrics differently according to parsers

Aperta
#364 1 commento 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
5/5
Tempo stimato
Più di una settimana
Idoneità per principianti
25/100
Tipo di issue
Refactoring
Chiarezza
Abbastanza chiara
Stato di attività
Ferma
Stack tecnologico
rust
Ambito
backend

Direzione di ricerca

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.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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
Lingua principale
Rust
Stelle
469
Fork
74
Merge medio
17h 16m
PR unite (30g)
10

Preparare l'ambiente

Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di mozilla/rust-code-analysis

Tutte le issue di mozilla/rust-code-analysis

Issue simili

Altre issue su Rust

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.