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

Đang mở
#1,250 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức phù hợp với người mới
48/100
Loại issue
Lỗi
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
java, rust
Lĩnh vực
backend, testing-qa

Hướng nghiên cứu

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.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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.

Ngôn ngữ chính
Rust
Star
469
Fork
74
Merge trung bình
17 giờ 16 phút
Pull request đã merge (30 ngày)
10

Chuẩn bị môi trường

Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của mozilla/rust-code-analysis

Tất cả issue của mozilla/rust-code-analysis

Issue tương tự

Thêm issue về Rust

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.