fix: resolve bug where workspace projects are silently dropped [IDE-1083]#358
Conversation
…083] The `add` boolean in `getAccessibleTopLevelProjects()` was never reset to `true` at the start of each loop iteration. Once any project was identified as a sub-project (setting `add = false`), all subsequent independent projects were silently dropped from the workspace folders list. This caused only 1 of N projects to be scanned when a workspace contained both parent/child projects and unrelated independent projects. Additionally, diagnostic logging is added at each filtering stage (not accessible, derived, hidden, sub-project) so that future issues with missing workspace projects can be diagnosed from the logs. Co-authored-by: Cursor <cursoragent@cursor.com>
|
/describe |
✅ Snyk checks have passed. No issues have been found so far.
💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse. |
|
PR Description updated to latest commit (9115819) |
| for (IProject project : allProjects) { | ||
| var path = getFullPath(project); | ||
| if (!project.isAccessible()) { | ||
| SnykLogger.logInfo("Project filtered (not accessible): " + project.getName() + " path=" + path); |
Check warning
Code scanning / PMD
The String literal " path=" appears 4 times in this file; the first occurrence is on line 82 Warning
Extract duplicate string literal " path=" to PATH_LOG_PREFIX constant (AvoidDuplicateLiterals) and narrow catch block from Exception to IOException (AvoidCatchingGenericException). Co-authored-by: Cursor <cursoragent@cursor.com>
This comment has been minimized.
This comment has been minimized.
Add logDebug method to SnykLogger (IStatus.OK level) and switch all diagnostic log messages in getAccessibleTopLevelProjects from logInfo to logDebug to avoid noise in production logs. Co-authored-by: Cursor <cursoragent@cursor.com>
This comment has been minimized.
This comment has been minimized.
…1083]" This reverts commit 0549fd1.
PR Reviewer Guide 🔍
|
User description
Description
Fixes IDE-1083 — Eclipse plugin only scans 1 of N projects in a workspace.
Root cause: The
addboolean flag inResourceUtils.getAccessibleTopLevelProjects()was declared outside the outerforloop and never reset totrueat the start of each iteration. Once any project was identified as a sub-project (settingadd = false), all subsequent independent projects were silently dropped from the workspace folders list sent to the language server.Fix: Replace the outer-scoped
boolean addwith a properly scopedboolean isSubProjectdeclared inside each loop iteration.Additional: Diagnostic logging added at each filtering stage (not accessible, derived, hidden, sub-project deduplication) so that future issues with missing workspace projects can be diagnosed from LS logs without requiring customer log exchanges.
Checklist
Test scenarios
testIndependentProjectsAreAllReturnedtestSubProjectIsFilteredOuttestProjectAfterSubProjectIsNotDroppedtestInaccessibleProjectIsFilteredisAccessible() == falseprojects are excludedtestDerivedProjectIsFilteredisDerived() == trueprojects are excludedtestHiddenProjectIsFilteredisHidden() == trueprojects are excludedPR Type
bug_fix, tests
Description
Fixes bug where workspace projects were silently dropped.
Introduces enhanced logging for project filtering.
Adds comprehensive unit tests for project filtering scenarios.
Diagram Walkthrough
flowchart LR A[Existing Project Filtering Logic] --> B(Bug: 'add' flag not reset); B --> C{Subsequent projects dropped}; D[New Logic: 'isSubProject' flag] --> E{Correct project inclusion}; F[Added Logging] --> G(Improved diagnostics); H[New Tests] --> I(Verified fixes and regressions);File Walkthrough
ResourceUtils.java
Refactor project filtering logic and add loggingplugin/src/main/java/io/snyk/eclipse/plugin/utils/ResourceUtils.java
addboolean flag withisSubProjectfor correct scope.getAccessibleTopLevelProjects.ResourceUtilsTest.java
Add comprehensive tests for project filteringtests/src/test/java/io/snyk/eclipse/plugin/utils/ResourceUtilsTest.java
sub-projects, inaccessible, derived, and hidden projects.
not dropped.