feat: add cognitive complexity analysis for Java#296
Conversation
Implements Java support via tree-sitter-java@0.21.0, closing #238. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Adds Java support to the VS Code extension’s cognitive complexity analysis by introducing a Tree-sitter-based Java analyzer, wiring it into the analyzer factory and extension activation, and adding initial Java-focused tests and sample code.
Changes:
- Added
JavaMetricsAnalyzerusingtree-sitter-javato compute method-level cognitive complexity. - Registered the Java analyzer in
MetricsAnalyzerFactoryand enabled activation foronLanguage:java. - Added Java analyzer unit tests and a Java sample file; added
tree-sitter-javadependency.
Reviewed changes
Copilot reviewed 5 out of 6 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| src/metricsAnalyzer/languages/javaAnalyzer.ts | New Tree-sitter Java analyzer for computing cognitive complexity and per-construct detail records. |
| src/metricsAnalyzer/metricsAnalyzerFactory.ts | Registers the Java analyzer under language id java. |
| src/test/metricsAnalyzer/languages/javaAnalyzer.test.ts | Adds unit tests validating Java method detection and complexity increments for common constructs. |
| samples/Test.java | Adds a sample Java file for manual validation in the extension host. |
| package.json | Adds tree-sitter-java dependency and activates extension on Java files; updates keywords. |
| package-lock.json | Locks tree-sitter-java package content, but currently has an inconsistent top-level spec. |
|
@copilot Fix the unit tests. Also add the new Java information to the README. |
Agent-Logs-Url: https://github.com/askpt/code-metrics/sessions/18bc6900-9535-4991-931b-adba3d24a365 Co-authored-by: askpt <2493377+askpt@users.noreply.github.com>
|
@copilot apply changes based on the comments in this thread |
Agent-Logs-Url: https://github.com/askpt/code-metrics/sessions/18bc6900-9535-4991-931b-adba3d24a365 Co-authored-by: askpt <2493377+askpt@users.noreply.github.com>
Implemented in 520569c (with core behavior/test update in c8fca2e). I fixed the Java unit coverage (including if/else and else-if expectations) and updated README language support/details to include Java. Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
Agent-Logs-Url: https://github.com/askpt/code-metrics/sessions/7d5a0198-c37c-4ef4-bd28-38a284c4b2b1 Co-authored-by: askpt <2493377+askpt@users.noreply.github.com>
Applied in e459749. I addressed the actionable item from that review thread by syncing |
|
@copilot the build is still failing in the GitHub actions. Fix it please. |
Agent-Logs-Url: https://github.com/askpt/code-metrics/sessions/fd998b06-a357-411f-a6b5-6358de92823f Co-authored-by: askpt <2493377+askpt@users.noreply.github.com>
Fixed in ac206e2. The CI failure was from |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #296 +/- ##
==========================================
+ Coverage 66.24% 69.54% +3.30%
==========================================
Files 9 10 +1
Lines 2604 3054 +450
Branches 224 287 +63
==========================================
+ Hits 1725 2124 +399
- Misses 878 929 +51
Partials 1 1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Implements Java support via tree-sitter-java@0.21.0, closing #238, #292