Skip to content

🐛 On windows with certain Quarkus applications Java is not found as a language#710

Open
shawn-hurley wants to merge 2 commits into
konveyor:mainfrom
shawn-hurley:bugfix/handle-alizer-not-finding-provider
Open

🐛 On windows with certain Quarkus applications Java is not found as a language#710
shawn-hurley wants to merge 2 commits into
konveyor:mainfrom
shawn-hurley:bugfix/handle-alizer-not-finding-provider

Conversation

@shawn-hurley

@shawn-hurley shawn-hurley commented Feb 6, 2026

Copy link
Copy Markdown
Contributor

This happens because the weight of the Java language falls below the threshold for the reconginzer. Using the components, we can assign our own weights; here, we will assign different weights depending on whether there is a default provider for that language.

Summary by CodeRabbit

  • Bug Fixes

    • Improved component-based language detection for non-file inputs and clearer "Could not determine programming language components" feedback.
    • Language listings now filter out low-weight entries to reduce noise.
    • Stricter provider selection for non-default languages using a validated provider set and higher weight thresholds.
  • Tests

    • Added tests for language-based provider auto-detection, including mappings for non-default languages.

@coderabbitai

coderabbitai Bot commented Feb 6, 2026

Copy link
Copy Markdown
📝 Walkthrough

Walkthrough

Replaces direct language analysis with component-based detection, flattens component Languages into a languages collection, tightens provider selection via a whitelist and weight gates, adjusts list/filter thresholds and error text, and adds tests for non-default language provider mapping.

Changes

Cohort / File(s) Summary
Component Detection & CLI flow
cmd/analyze.go
Replace recognizer.Analyze(...) with recognizer.DetectComponents(...) when input is not a file; flatten component Languages into a languages collection; use maps.Values(languages) for downstream calls; update error message and filter printed languages by Weight > 0.02.
Provider selection logic
cmd/command-context.go
Introduce validProvs whitelist (java, python, go, nodejs, csharp); only auto-select non-JS/TS providers if listed in validProvs with Weight > 0.001 or if Weight > 0.1; retain Java/NodeJS/C# special-casing.
Tests for provider mapping
cmd/command-context_test.go
Add Weight values to test language entries and introduce Test_AnalyzeCommandContext_setProviders_NonDefaultLanguage to verify mapping of non-default languages (e.g., Rust/PHP) to expected provider strings when providers list is empty.

Sequence Diagram(s)

sequenceDiagram
    participant CLI as CLI
    participant Recognizer as Recognizer
    participant ProviderMgr as ProviderManager
    participant Analyzer as Analyzer

    CLI->>Recognizer: DetectComponents(input)
    Recognizer-->>CLI: components (each has Languages)
    CLI->>CLI: flatten component Languages -> languages list
    CLI->>ProviderMgr: setProviders(maps.Values(languages))
    ProviderMgr-->>CLI: foundProviders
    CLI->>Analyzer: run analysis with foundProviders and languages
    Analyzer-->>CLI: analysis results
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Poem

🐇 I sniffed out components, languages in tow,

Flattened their voices to help the flow,
Whitelisted seeds and weights so fair,
Providers found with a careful stare,
A hop, a patch — code tidy, off we go.

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 20.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The PR title directly addresses the main issue: Java language detection on Windows with Quarkus applications, which is the central problem solved by the changeset.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Fix all issues with AI agents
In `@cmd/analyze.go`:
- Around line 188-198: The flattened languages slice produced after
recognizer.DetectComponentsInRoot(analyzeCmd.input) can contain duplicates
across components, which later causes setProviders to create duplicate
foundProviders and invoke setProviderInitInfo/freeport.GetFreePort() multiple
times for the same provider; fix by deduplicating languages immediately after
the flattening loop (or alternatively deduplicate entries in foundProviders at
the end of setProviders) — use the existing variables/functions (the languages
slice, recognizer.DetectComponentsInRoot, setProviders, foundProviders,
setProviderInitInfo, freeport.GetFreePort) to implement a simple map[string]bool
keyed by language identifier to filter out duplicates before proceeding.

In `@cmd/command-context_test.go`:
- Around line 138-146: Update the test in cmd/command-context_test.go to fix
copy-paste mistakes: change the comment above the assertion to describe
Rust/non-default language behavior (not "JavaScript should map to nodejs
provider"), and correct the error message in the failing case to expect the
lowercase provider string used in the assertion (use "rust" consistently) when
checking the result from setProviders(); ensure the format string and passed
want value match (result[0] vs "rust").
🧹 Nitpick comments (2)
cmd/command-context.go (1)

52-58: Duplicated valid provider list.

This validProvs map duplicates the list at cmd/analyze.go:566-572 (validateProviders). Consider extracting a shared set/constant to keep them in sync.

cmd/command-context_test.go (1)

112-147: Consider adding a test case for a non-default language below the 0.1 threshold.

The test verifies that Rust (weight 0.3) passes, but it would be valuable to explicitly assert that PHP (weight 0.03) is not in the result, rather than only checking len(result) == 1. This makes the test more resilient to future changes and documents the gating behavior for non-default languages more explicitly.

🧪 Suggested assertion addition
 	if result[0] != "rust" {
 		t.Errorf("setProviders() returned provider %s for non-default Rust, want %s",
 			result[0], "rust")
 	}
+
+	for _, p := range result {
+		if p == "php" {
+			t.Error("setProviders() should not include php provider (weight 0.03 below 0.1 threshold)")
+		}
+	}

Comment thread cmd/analyze.go Outdated
Comment thread cmd/command-context_test.go Outdated
@codecov

codecov Bot commented Feb 6, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 37.50000% with 15 lines in your changes missing coverage. Please review.
✅ Project coverage is 40.23%. Comparing base (935178d) to head (404f845).
⚠️ Report is 63 commits behind head on main.

Files with missing lines Patch % Lines
cmd/analyze.go 0.00% 15 Missing ⚠️

❌ Your patch check has failed because the patch coverage (37.50%) is below the target coverage (80.00%). You can increase the patch coverage or adjust the target coverage.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #710      +/-   ##
==========================================
+ Coverage   40.19%   40.23%   +0.03%     
==========================================
  Files          38       38              
  Lines        5098     5113      +15     
==========================================
+ Hits         2049     2057       +8     
- Misses       2774     2781       +7     
  Partials      275      275              

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@shawn-hurley
shawn-hurley force-pushed the bugfix/handle-alizer-not-finding-provider branch from afba154 to d9dd729 Compare February 6, 2026 18:59
Signed-off-by: Shawn Hurley <shawn@hurley.page>
@shawn-hurley
shawn-hurley force-pushed the bugfix/handle-alizer-not-finding-provider branch from d9dd729 to 4bf73ff Compare February 6, 2026 20:31

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In `@cmd/analyze.go`:
- Around line 1555-1559: The listLanguages output uses a different weight cutoff
(l.Weight > .02) than setProviders (uses 0.001), causing inconsistency; update
listLanguages to use the same threshold as setProviders (0.001) or, better,
introduce a shared constant (e.g., languageWeightThreshold) used by both
listLanguages and setProviders so both provider selection and --list-languages
output align and avoid hiding default providers like Java/Python/Go.

Comment thread cmd/analyze.go
Comment on lines +1555 to +1559
// This what alizer uses to determine languages today
// This will allow this to continue having the same behavior
if l.Weight > .02 {
fmt.Fprintln(os.Stdout, l.Name)
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

ast-grep --pattern $'func ($_ *analyzeCommand) setProviders($$$) {
  $$$
}'

Repository: konveyor/kantra

Length of output: 41


🏁 Script executed:

rg "setProviders" --type go -B 5 -A 15

Repository: konveyor/kantra

Length of output: 16707


🏁 Script executed:

rg "func \(c \*AnalyzeCommandContext\) setProviders" -A 50 cmd/command-context.go

Repository: konveyor/kantra

Length of output: 1738


🏁 Script executed:

rg "alizer" --type go -i -B 2 -A 2 | head -60

Repository: konveyor/kantra

Length of output: 1501


🏁 Script executed:

rg "0\.02|\.02" --type go -B 3 -A 3

Repository: konveyor/kantra

Length of output: 384


🌐 Web query:

alizer language detection weight threshold 0.02

💡 Result:

I couldn’t find any public documentation or source reference for an “alizer” language detection setting called “weight threshold” with value 0.02. The term “alizer” doesn’t appear to match a known/commonly documented language-detection library or API in the results I checked.

What I did find is that most language detectors expose confidence/probability thresholds (not usually called “weight thresholds”):

  • AssemblyAI: language_confidence_threshold is a configurable cutoff in [0, 1]; the API errors if detected language confidence is below it. This is the closest mainstream concept to what you described (e.g., 0.02 would be an extremely permissive threshold). [1]
  • Nakatani Shuyo / langdetect-derived implementations (e.g., azagniotov’s reimplementation) expose model parameters like convergenceThreshold (default shown as 0.99999)—again, not a “weight threshold 0.02”. [2]

If you tell me which project/package “alizer” refers to (link to repo/docs, or the config file / code snippet where you saw 0.02), I can pinpoint exactly what that threshold does and how it affects detection.

Sources: [1] [2]


🏁 Script executed:

cat go.mod | grep alizer

Repository: konveyor/kantra

Length of output: 92


🏁 Script executed:

rg "0\.001" --type go -B 5 -A 2

Repository: konveyor/kantra

Length of output: 41


🏁 Script executed:

rg "Weight > \." --type go -B 3 -A 1

Repository: konveyor/kantra

Length of output: 885


Alignment issue: listLanguages threshold (0.02) differs from setProviders threshold (0.001 for default providers).

The --list-languages output filters by l.Weight > .02, but setProviders includes default providers (Java, Python, Go, etc.) with l.Weight > .001. This creates a mismatch where Java—or any default provider with weight between 0.001–0.02—would be selected for analysis but not displayed in --list-languages, contradicting the stated goal of preserving alizer's behavior.

Since this filtering controls both user-facing output and provider selection, aligning these thresholds will prevent confusing scenarios where users don't see a language option that analysis actually runs.

🤖 Prompt for AI Agents
In `@cmd/analyze.go` around lines 1555 - 1559, The listLanguages output uses a
different weight cutoff (l.Weight > .02) than setProviders (uses 0.001), causing
inconsistency; update listLanguages to use the same threshold as setProviders
(0.001) or, better, introduce a shared constant (e.g., languageWeightThreshold)
used by both listLanguages and setProviders so both provider selection and
--list-languages output align and avoid hiding default providers like
Java/Python/Go.

Signed-off-by: Shawn Hurley <shawn@hurley.page>
@shawn-hurley
shawn-hurley force-pushed the bugfix/handle-alizer-not-finding-provider branch from 52c97be to 404f845 Compare February 6, 2026 22:05
@shawn-hurley

Copy link
Copy Markdown
Contributor Author

This is not fixing the issue in koncur.

I am going to come back to this once I get the nightly working.

@dymurray dymurray left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me, CodeRabbit's comment about --list-languages not matching behavior is worth investigating but changes to bump weight for default providers makes a ton of sense

@github-actions

Copy link
Copy Markdown

This pull request has been automatically marked as stale because it has not had any activity for 60 days.
It will remain open for visibility and reporting purposes.
Please comment if this PR is still relevant.

@github-actions github-actions Bot added stale and removed stale labels May 12, 2026
@github-actions

Copy link
Copy Markdown

This pull request has been automatically marked as stale because it has not had any activity for 60 days.
It will remain open for visibility and reporting purposes.
Please comment if this PR is still relevant.

@github-actions github-actions Bot added stale and removed stale labels Jul 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants