[Java] NARGS and cognitive metrics appear incorrect for simple methods

Aperta
#1,250 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
48/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Attiva
Stack tecnologico
java, rust

Direzione di ricerca

Start with the Java grammar and metric implementation used by rust-code-analysis-cli, then trace how the CLI's JSON output aggregates NARGS and cognitive values into function-space metrics. Reproduce the supplied MetricsFixture.java example with the documented command and compare the per-method values with the expected counts. Done when the output reports NARGS 1 and cognitive complexity 1 for one, and 0 for both metrics for two, or the JSON field semantics are clarified.

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

Descrizione

Summary

With rust-code-analysis-cli 0.0.25, the Java NARGS and cognitive metrics appear incorrect for a minimal class with a one-parameter method and one if statement.

Reproduction
class MetricsFixture {
  int one(int x) { if (x > 0) return x; return 0; }
  int two() { return 0; }
}

Run:

rust-code-analysis-cli -p MetricsFixture.java --metrics --output-format json --output out
Expected

Based on the documented metric meanings, method one has one argument and cognitive complexity 1; method two has zero arguments and cognitive complexity 0.

Observed

In the function-space metrics, one reports NARGS functions_min/functions_max as 3 and cognitive min/max as 0. two reports NARGS functions_min/functions_max as 2 and cognitive min/max as 0.

This makes the Java NARGS and cognitive values unsuitable for simple per-function measurements. Please clarify whether these JSON fields have different semantics or whether the Java grammar/metric implementation needs correction.

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.