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

Aberta
#1,250 0 comentários 0 reações 0 responsáveis Ver no GitHub

Mantenedores costumam responder em até 1 dia

Ninguém assumiu esta issue ainda.

Avaliação

Dificuldade
4/5
Tempo estimado
3-5 dias
Facilidade para iniciantes
48/100
Tipo de issue
Bug
Clareza
Razoavelmente clara
Status de atividade
Ativa
Stack de tecnologia
java, rust
Domínio
backend, testing-qa

Direção de pesquisa

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.

Escrita pelo modelo de indexação a partir do texto da issue.

Descrição

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.

Linguagem predominante
Rust
Estrelas
469
Forks
74
Merge médio
17h 16min
PRs com merge (30d)
10

Preparar o ambiente

Este projeto não oferece contêiner de desenvolvimento, Dockerfile nem guia de contribuição, então a configuração fica por sua conta: comece pelo README e veja nosso guia da primeira contribuição para os passos gerais.

Primeiros passos

  1. Leia a issue inteira e depois o guia de contribuição do projeto.
  2. Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
  3. Faça um fork do repositório e trabalhe em uma branch.
  4. Abra um pull request que referencie o número da issue.

Mais de mozilla/rust-code-analysis

Todas as issues de mozilla/rust-code-analysis

Issues semelhantes

Mais issues de Rust

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.