WARNING: THIS SITE IS A MIRROR OF GITHUB.COM / IT CANNOT LOGIN OR REGISTER ACCOUNTS / THE CONTENTS ARE PROVIDED AS-IS / THIS SITE ASSUMES NO RESPONSIBILITY FOR ANY DISPLAYED CONTENT OR LINKS / IF YOU FOUND SOMETHING MAY NOT GOOD FOR EVERYONE, CONTACT ADMIN AT ilovescratch@foxmail.com
Skip to content

Conversation

@tsanders-rh
Copy link
Contributor

@tsanders-rh tsanders-rh commented Dec 6, 2025

Summary

Fixes the nodejs provider's GetDocumentUris() method counting files twice during provider preparation when both InitConfig.Location and ProviderSpecificConfig["workspaceFolders"] are set to the same directory.

Changes

  • Added deduplication check in symbol_cache_helper.go to skip workspace folders that duplicate the primaryPath
  • Ensures each directory is only scanned once by FileSearcher

Impact

  • Provider preparation now shows accurate file counts (e.g., 802 files instead of 1604)
  • Eliminates duplicate file processing during symbol cache operations
  • Improves performance during the preparation phase
  • Fixes confusing progress reporting for users

Testing

  • Code compiles successfully
  • Logic verified against existing deduplication in service_client.go (lines 75-80)
  • Handles edge cases: empty primaryPath, multiple workspace folders

Fixes #1035

Summary by CodeRabbit

  • Bug Fixes
    • Fixed duplicate file entries appearing in search results when working with multiple workspace folders, eliminating redundant search results.

✏️ Tip: You can customize this high-level summary in your review settings.

…eFolders overlap

The nodejs provider's GetDocumentUris() method was counting files twice during
provider preparation when both InitConfig.Location and workspaceFolders were
set to the same directory. This caused incorrect progress reporting and
performance degradation.

Added a deduplication check to skip workspace folders that duplicate the
primaryPath, ensuring each directory is only scanned once by FileSearcher.

Fixes konveyor#1035

Signed-off-by: tsanders <[email protected]>
@coderabbitai
Copy link

coderabbitai bot commented Dec 6, 2025

Walkthrough

Fixed a duplicate file counting issue in the nodejs provider's GetDocumentUris method. When both InitConfig.Location and workspaceFolders configuration point to the same directory, the method now skips adding the duplicate path to AdditionalPaths, eliminating redundant file traversal.

Changes

Cohort / File(s) Summary
Nodejs symbol cache deduplication
external-providers/generic-external-provider/pkg/server_configurations/nodejs/symbol_cache_helper.go
Added conditional check in GetDocumentUris to skip workspace folders that match the primary path, preventing duplicate file counting when Location and workspaceFolders are set to the same directory.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~5 minutes

  • Single-file change with a straightforward deduplication guard clause
  • Clear, self-explanatory logic addition
  • No structural or control-flow modifications

Suggested reviewers

  • shawn-hurley
  • pranavgaikwad

Poem

🐰 A path so clear, yet counted twice before,
Now skip the dupe, and search no more!
One primaryPath, one truth to find,
No double-scanning clutters the mind. ✨

Pre-merge checks and finishing touches

✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main bug fix: preventing duplicate file counting when nodejs provider's Location and workspaceFolders point to the same directory.
Linked Issues check ✅ Passed The PR implements the recommended Option 1 fix from issue #1035 by adding deduplication logic to skip workspace folders that equal primaryPath, directly addressing the stated objectives.
Out of Scope Changes check ✅ Passed All changes are scoped to the nodejs symbol cache helper file and directly address the duplicate file counting bug without introducing unrelated modifications.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ 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.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
external-providers/generic-external-provider/pkg/server_configurations/nodejs/symbol_cache_helper.go (1)

44-47: Deduplication guard correctly fixes double-counting; consider path normalization for robustness

The new check cleanly prevents adding a workspace folder that is exactly equal to primaryPath, which addresses the reported double-counting when Location and workspaceFolders point to the same directory while preserving the existing behavior when primaryPath starts empty.

If you want this to be a bit more robust against minor path spelling differences (e.g., "/repo" vs "/repo/"), you could normalize both sides before comparison:

-        // Skip workspace folders that duplicate primaryPath to avoid counting files twice
-        if path == primaryPath {
+        // Skip workspace folders that duplicate primaryPath (after normalization) to avoid counting files twice
+        if filepath.Clean(path) == filepath.Clean(primaryPath) {
             continue
         }

This keeps the core behavior but avoids surprises from equivalent paths with different string forms, while still treating additionalPaths as already‑vetted workspaces without changing exclude patterns on them. Based on learnings, this remains consistent with only applying exclusion patterns to primaryPath.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 08bd294 and 8ad8f18.

📒 Files selected for processing (1)
  • external-providers/generic-external-provider/pkg/server_configurations/nodejs/symbol_cache_helper.go (1 hunks)
🧰 Additional context used
🧠 Learnings (2)
📓 Common learnings
Learnt from: pranavgaikwad
Repo: konveyor/analyzer-lsp PR: 975
File: external-providers/generic-external-provider/pkg/server_configurations/nodejs/symbol_cache_helper.go:29-78
Timestamp: 2025-11-21T14:12:52.228Z
Learning: In the analyzer-lsp codebase, additional workspace folders (additionalPaths) used in FileSearcher are already vetted and scoped, so they do not require additional exclusion patterns for directories like node_modules, .git, dist, etc. Only the primary path needs these exclusions.
📚 Learning: 2025-11-21T14:12:52.228Z
Learnt from: pranavgaikwad
Repo: konveyor/analyzer-lsp PR: 975
File: external-providers/generic-external-provider/pkg/server_configurations/nodejs/symbol_cache_helper.go:29-78
Timestamp: 2025-11-21T14:12:52.228Z
Learning: In the analyzer-lsp codebase, additional workspace folders (additionalPaths) used in FileSearcher are already vetted and scoped, so they do not require additional exclusion patterns for directories like node_modules, .git, dist, etc. Only the primary path needs these exclusions.

Applied to files:

  • external-providers/generic-external-provider/pkg/server_configurations/nodejs/symbol_cache_helper.go
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (12)
  • GitHub Check: build-all-providers (c-sharp, c-sharp-provider, Dockerfile, konveyor/c-sharp-analyzer-provider, f...
  • GitHub Check: build-all-providers (java, java-provider, external-providers/java-external-provider/Dockerfile, J...
  • GitHub Check: build-all-providers (yq, yq-provider, external-providers/yq-external-provider/Dockerfile, true)
  • GitHub Check: build-all-providers (generic, generic-provider, external-providers/generic-external-provider/Dock...
  • GitHub Check: benchmark (windows-latest, windows)
  • GitHub Check: benchmark (macos-latest, mac)
  • GitHub Check: benchmark (ubuntu-latest, linux)
  • GitHub Check: test (macos-latest, darwin, arm64)
  • GitHub Check: test (windows-latest, windows, amd64)
  • GitHub Check: test (ubuntu-latest, linux, amd64)
  • GitHub Check: test (ubuntu-latest, linux, arm64)
  • GitHub Check: test (macos-latest, darwin, amd64)

@shawn-hurley shawn-hurley merged commit 2a75387 into konveyor:main Dec 6, 2025
33 checks passed
@tsanders-rh tsanders-rh deleted the 1035-nodejs-duplicate-file-count branch December 6, 2025 10:59
tsanders-rh added a commit to tsanders-rh/kantra that referenced this pull request Dec 6, 2025
Removes the nodejs provider workaround that set Location to empty string
to avoid duplicate file counting. This workaround is no longer needed as
the root cause has been fixed in analyzer-lsp#1036.

Changes:
- Update analyzer-lsp to version with deduplication fix (2a753870572f)
- Remove nodejs-specific Location="" workaround
- Simplify provider configuration logic
- Update comments to reference merged fix

Fixes: konveyor/analyzer-lsp#1035
Related: konveyor/analyzer-lsp#1036
Signed-off-by: tsanders <[email protected]>
tsanders-rh added a commit to tsanders-rh/kantra that referenced this pull request Dec 6, 2025
Removes the nodejs provider workaround that set Location to empty string
to avoid duplicate file counting. This workaround is no longer needed as
the root cause has been fixed in analyzer-lsp#1036.

Changes:
- Remove nodejs-specific Location="" workaround
- Simplify provider configuration logic
- Update comments to reference merged fix

Fixes: konveyor/analyzer-lsp#1035
Related: konveyor/analyzer-lsp#1036
Signed-off-by: tsanders <[email protected]>
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.

Nodejs provider: GetDocumentUris counts files twice when Location and workspaceFolders are both set

2 participants